@tmllak-erp/hr 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/HrStatusBadge.d.ts +9 -0
- package/dist/components/HrStatusBadge.js +9 -0
- package/dist/components/HrStatusBadge.js.map +1 -0
- package/dist/components/attendance/Attendance.d.ts +84 -0
- package/dist/components/attendance/Attendance.js +92 -0
- package/dist/components/attendance/Attendance.js.map +1 -0
- package/dist/components/attendance/attendance.css +95 -0
- package/dist/components/employee/Employee.d.ts +61 -0
- package/dist/components/employee/Employee.js +26 -0
- package/dist/components/employee/Employee.js.map +1 -0
- package/dist/components/employee/employee.css +147 -0
- package/dist/components/filters/Filters.d.ts +37 -0
- package/dist/components/filters/Filters.js +20 -0
- package/dist/components/filters/Filters.js.map +1 -0
- package/dist/components/filters/filters.css +16 -0
- package/dist/components/portal/Portal.d.ts +82 -0
- package/dist/components/portal/Portal.js +50 -0
- package/dist/components/portal/Portal.js.map +1 -0
- package/dist/components/portal/portal.css +292 -0
- package/dist/components/recruitment/Recruitment.d.ts +68 -0
- package/dist/components/recruitment/Recruitment.js +88 -0
- package/dist/components/recruitment/Recruitment.js.map +1 -0
- package/dist/components/recruitment/recruitment.css +131 -0
- package/dist/components/templates/TaskTemplateImport.d.ts +38 -0
- package/dist/components/templates/TaskTemplateImport.js +41 -0
- package/dist/components/templates/TaskTemplateImport.js.map +1 -0
- package/dist/components/templates/templates.css +59 -0
- package/dist/components/tickets/Tickets.d.ts +36 -0
- package/dist/components/tickets/Tickets.js +20 -0
- package/dist/components/tickets/Tickets.js.map +1 -0
- package/dist/components/tickets/tickets.css +79 -0
- package/dist/copy.d.ts +129 -0
- package/dist/copy.en.d.ts +126 -0
- package/dist/copy.en.js +100 -0
- package/dist/copy.en.js.map +1 -0
- package/dist/copy.js +71 -0
- package/dist/copy.js.map +1 -0
- package/dist/feedback.d.ts +2313 -0
- package/dist/feedback.js +7 -0
- package/dist/feedback.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/messages.d.ts +1250 -0
- package/dist/messages.js +568 -0
- package/dist/messages.js.map +1 -0
- package/dist/navigation.d.ts +19 -0
- package/dist/navigation.js +124 -0
- package/dist/navigation.js.map +1 -0
- package/dist/statuses.d.ts +35 -0
- package/dist/statuses.js +120 -0
- package/dist/statuses.js.map +1 -0
- package/package.json +47 -6
- package/README.md +0 -3
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type HrStatus, type HrStatusSet } from '../statuses.js';
|
|
2
|
+
export interface HrStatusBadgeProps<S extends HrStatusSet> {
|
|
3
|
+
set: S;
|
|
4
|
+
status: HrStatus<S>;
|
|
5
|
+
size?: 'sm' | 'md';
|
|
6
|
+
className?: string;
|
|
7
|
+
}
|
|
8
|
+
/** Status badge for any HR vocabulary, e.g. `<HrStatusBadge set="leave" status="pending" />`. */
|
|
9
|
+
export declare function HrStatusBadge<S extends HrStatusSet>({ set, status, size, className }: HrStatusBadgeProps<S>): import("react").JSX.Element;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { StatusBadge } from '@tmllak-erp/ui';
|
|
3
|
+
import { hrStatus } from '../statuses.js';
|
|
4
|
+
/** Status badge for any HR vocabulary, e.g. `<HrStatusBadge set="leave" status="pending" />`. */
|
|
5
|
+
export function HrStatusBadge({ set, status, size = 'sm', className }) {
|
|
6
|
+
const { label, tone } = hrStatus(set, status);
|
|
7
|
+
return _jsx(StatusBadge, { tone: tone, label: label, size: size, className: className });
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=HrStatusBadge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HrStatusBadge.js","sourceRoot":"","sources":["../../src/components/HrStatusBadge.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAmC,MAAM,aAAa,CAAC;AASxE,iGAAiG;AACjG,MAAM,UAAU,aAAa,CAAwB,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,GAAG,IAAI,EAAE,SAAS,EAAyB;IACjH,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IAC9C,OAAO,KAAC,WAAW,IAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,GAAI,CAAC;AACrF,CAAC","sourcesContent":["import { StatusBadge } from '@tmllak-erp/ui';\r\nimport { hrStatus, type HrStatus, type HrStatusSet } from '../statuses';\r\n\r\nexport interface HrStatusBadgeProps<S extends HrStatusSet> {\r\n set: S;\r\n status: HrStatus<S>;\r\n size?: 'sm' | 'md';\r\n className?: string;\r\n}\r\n\r\n/** Status badge for any HR vocabulary, e.g. `<HrStatusBadge set=\"leave\" status=\"pending\" />`. */\r\nexport function HrStatusBadge<S extends HrStatusSet>({ set, status, size = 'sm', className }: HrStatusBadgeProps<S>) {\r\n const { label, tone } = hrStatus(set, status);\r\n return <StatusBadge tone={tone} label={label} size={size} className={className} />;\r\n}\r\n"]}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { type WeekStart } from '@tmllak-erp/ui';
|
|
2
|
+
import { type ReactNode } from 'react';
|
|
3
|
+
import { type AttendanceStatus } from '../../statuses.js';
|
|
4
|
+
import './attendance.css';
|
|
5
|
+
/** Times may be given as dates or as «08:05» strings from the device feed. */
|
|
6
|
+
type Punch = Date | string;
|
|
7
|
+
export interface AttendanceRecord {
|
|
8
|
+
date: Date;
|
|
9
|
+
status: AttendanceStatus;
|
|
10
|
+
checkIn?: Punch;
|
|
11
|
+
checkOut?: Punch;
|
|
12
|
+
/** e.g. holiday name or leave type. */
|
|
13
|
+
note?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface AttendanceDayCellProps {
|
|
16
|
+
status: AttendanceStatus;
|
|
17
|
+
checkIn?: Punch;
|
|
18
|
+
checkOut?: Punch;
|
|
19
|
+
note?: string;
|
|
20
|
+
/** Hide the times (narrow calendars). */
|
|
21
|
+
compact?: boolean;
|
|
22
|
+
className?: string;
|
|
23
|
+
}
|
|
24
|
+
/** One attendance day (Figma «خلية يوم الحضور», 8 types): status word, icon and punch times. */
|
|
25
|
+
export declare function AttendanceDayCell({ status, checkIn, checkOut, note, compact, className }: AttendanceDayCellProps): import("react").JSX.Element;
|
|
26
|
+
export interface AttendanceCalendarProps {
|
|
27
|
+
records: readonly AttendanceRecord[];
|
|
28
|
+
month?: Date;
|
|
29
|
+
defaultMonth?: Date;
|
|
30
|
+
onMonthChange?: (month: Date) => void;
|
|
31
|
+
onDaySelect?: (date: Date, record: AttendanceRecord | undefined) => void;
|
|
32
|
+
selected?: Date | null;
|
|
33
|
+
/** Weekdays shown as «عطلة أسبوعية» when there is no record (default Friday and Saturday). */
|
|
34
|
+
weekendDays?: readonly number[];
|
|
35
|
+
weekStartsOn?: WeekStart;
|
|
36
|
+
today?: Date;
|
|
37
|
+
headerActions?: ReactNode;
|
|
38
|
+
className?: string;
|
|
39
|
+
}
|
|
40
|
+
/** Monthly attendance (Figma «تقويم الحضور»): CalendarGrid with attendance cells and a month summary. */
|
|
41
|
+
export declare function AttendanceCalendar({ records, month, defaultMonth, onMonthChange, onDaySelect, selected, weekendDays, weekStartsOn, today, headerActions, className, }: AttendanceCalendarProps): import("react").JSX.Element;
|
|
42
|
+
export interface AttendanceTodayChartProps {
|
|
43
|
+
present: number;
|
|
44
|
+
late: number;
|
|
45
|
+
absent: number;
|
|
46
|
+
onLeave: number;
|
|
47
|
+
title?: string;
|
|
48
|
+
className?: string;
|
|
49
|
+
}
|
|
50
|
+
/** Today's attendance split (Figma «حضور اليوم»), on the shared DonutChart. */
|
|
51
|
+
export declare function AttendanceTodayChart({ present, late, absent, onLeave, title, className }: AttendanceTodayChartProps): import("react").JSX.Element;
|
|
52
|
+
export interface WeeklyAttendanceDay {
|
|
53
|
+
/** Day label, e.g. «الأحد». */
|
|
54
|
+
label: string;
|
|
55
|
+
present: number;
|
|
56
|
+
late: number;
|
|
57
|
+
absent: number;
|
|
58
|
+
}
|
|
59
|
+
export interface WeeklyAttendanceChartProps {
|
|
60
|
+
days: readonly WeeklyAttendanceDay[];
|
|
61
|
+
title?: string;
|
|
62
|
+
actions?: ReactNode;
|
|
63
|
+
className?: string;
|
|
64
|
+
}
|
|
65
|
+
/** Present / late / absent per weekday as stacked bars (Figma «الحضور الأسبوعي»). */
|
|
66
|
+
export declare function WeeklyAttendanceChart({ days, title, actions, className }: WeeklyAttendanceChartProps): import("react").JSX.Element;
|
|
67
|
+
export type ReportPeriod = 6 | 12;
|
|
68
|
+
export interface PeriodBarsChartProps {
|
|
69
|
+
title: string;
|
|
70
|
+
/** Up to 12 months, oldest first; the chart shows the last 6 or 12. */
|
|
71
|
+
months: readonly {
|
|
72
|
+
label: string;
|
|
73
|
+
value: number;
|
|
74
|
+
}[];
|
|
75
|
+
period?: ReportPeriod;
|
|
76
|
+
defaultPeriod?: ReportPeriod;
|
|
77
|
+
onPeriodChange?: (period: ReportPeriod) => void;
|
|
78
|
+
formatValue?: (value: number) => string;
|
|
79
|
+
seriesLabel?: string;
|
|
80
|
+
className?: string;
|
|
81
|
+
}
|
|
82
|
+
/** Monthly bars with the 6/12-month switch (Figma «مبدّل الفترة»), e.g. overtime or absence hours. */
|
|
83
|
+
export declare function PeriodBarsChart({ title, months, period, defaultPeriod, onPeriodChange, formatValue, seriesLabel, className }: PeriodBarsChartProps): import("react").JSX.Element;
|
|
84
|
+
export {};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { formatNumber, formatTime } from '@tmllak-erp/formatters';
|
|
4
|
+
import { UI_COPY } from '@tmllak-erp/messages';
|
|
5
|
+
import { BarChart, CalendarGrid, DonutChart, SegmentedControl, isSameMonth, monthMatrix, toneClassName, } from '@tmllak-erp/ui';
|
|
6
|
+
import { CalendarOff, CheckCircle2, Clock, Coffee, Fingerprint, LogOut, PartyPopper, Plane, XCircle } from 'lucide-react';
|
|
7
|
+
import { useState } from 'react';
|
|
8
|
+
import { HR_COPY } from '../../copy.js';
|
|
9
|
+
import { HR_STATUSES, hrStatus } from '../../statuses.js';
|
|
10
|
+
import './attendance.css';
|
|
11
|
+
const ICONS = {
|
|
12
|
+
present: CheckCircle2,
|
|
13
|
+
late: Clock,
|
|
14
|
+
earlyLeave: LogOut,
|
|
15
|
+
missingPunch: Fingerprint,
|
|
16
|
+
absent: XCircle,
|
|
17
|
+
leave: Plane,
|
|
18
|
+
weekend: Coffee,
|
|
19
|
+
holiday: PartyPopper,
|
|
20
|
+
};
|
|
21
|
+
const punch = (p) => (p === undefined ? undefined : typeof p === 'string' ? p : formatTime(p));
|
|
22
|
+
/** One attendance day (Figma «خلية يوم الحضور», 8 types): status word, icon and punch times. */
|
|
23
|
+
export function AttendanceDayCell({ status, checkIn, checkOut, note, compact, className }) {
|
|
24
|
+
const { label, tone } = hrStatus('attendance', status);
|
|
25
|
+
const inTime = punch(checkIn);
|
|
26
|
+
const outTime = punch(checkOut);
|
|
27
|
+
const details = [inTime && `${HR_COPY.attendance.checkIn} ${inTime}`, outTime && `${HR_COPY.attendance.checkOut} ${outTime}`, note].filter(Boolean).join(' · ');
|
|
28
|
+
const Icon = ICONS[status];
|
|
29
|
+
return (_jsxs("span", { className: ['erp-hr-day', `erp-hr-day--${status}`, toneClassName(tone), compact && 'is-compact', className].filter(Boolean).join(' '), title: details || label, "data-status": status, children: [_jsxs("span", { className: "erp-hr-day__status", children: [_jsx(Icon, { "aria-hidden": "true", className: "erp-hr-day__icon", strokeWidth: 1.75 }), _jsx("span", { className: "erp-hr-day__label", children: label })] }), !compact && (inTime || outTime) && (_jsxs("span", { className: "erp-hr-day__times erp-numeric", dir: "ltr", children: [inTime ?? '--:--', " \u2013 ", outTime ?? '--:--'] })), !compact && note && _jsx("span", { className: "erp-hr-day__note", children: note }), compact && details && _jsx("span", { className: "erp-visually-hidden", children: details })] }));
|
|
30
|
+
}
|
|
31
|
+
const dayKey = (d) => `${d.getFullYear()}-${d.getMonth()}-${d.getDate()}`;
|
|
32
|
+
/** Monthly attendance (Figma «تقويم الحضور»): CalendarGrid with attendance cells and a month summary. */
|
|
33
|
+
export function AttendanceCalendar({ records, month, defaultMonth, onMonthChange, onDaySelect, selected, weekendDays = [5, 6], weekStartsOn = 0, today, headerActions, className, }) {
|
|
34
|
+
const [internalMonth, setInternalMonth] = useState(defaultMonth ?? today ?? new Date());
|
|
35
|
+
const visibleMonth = month ?? internalMonth;
|
|
36
|
+
const byDay = new Map(records.map((r) => [dayKey(r.date), r]));
|
|
37
|
+
const statusOf = (d) => byDay.get(dayKey(d)) ?? (weekendDays.includes(d.getDay()) ? { date: d, status: 'weekend' } : undefined);
|
|
38
|
+
const counts = new Map();
|
|
39
|
+
for (const day of monthMatrix(visibleMonth, weekStartsOn).flat()) {
|
|
40
|
+
if (!isSameMonth(day, visibleMonth))
|
|
41
|
+
continue;
|
|
42
|
+
const status = byDay.get(dayKey(day))?.status;
|
|
43
|
+
if (status)
|
|
44
|
+
counts.set(status, (counts.get(status) ?? 0) + 1);
|
|
45
|
+
}
|
|
46
|
+
return (_jsxs("div", { className: ['erp-hr-attendance', className].filter(Boolean).join(' '), children: [_jsx(CalendarGrid, { label: HR_COPY.attendance.calendar, month: visibleMonth, onMonthChange: (m) => {
|
|
47
|
+
setInternalMonth(m);
|
|
48
|
+
onMonthChange?.(m);
|
|
49
|
+
}, selected: selected, onSelect: (d) => onDaySelect?.(d, byDay.get(dayKey(d))), weekStartsOn: weekStartsOn, today: today, headerActions: headerActions, renderDay: (date, { inMonth }) => {
|
|
50
|
+
const record = inMonth ? statusOf(date) : undefined;
|
|
51
|
+
return record ? _jsx(AttendanceDayCell, { status: record.status, checkIn: record.checkIn, checkOut: record.checkOut, note: record.note }) : null;
|
|
52
|
+
} }), _jsx("section", { className: "erp-hr-attendance__summary", "aria-label": HR_COPY.attendance.summary, children: _jsxs("ul", { children: [Object.keys(HR_STATUSES.attendance)
|
|
53
|
+
.filter((s) => counts.has(s))
|
|
54
|
+
.map((s) => {
|
|
55
|
+
const { label, tone } = hrStatus('attendance', s);
|
|
56
|
+
const Icon = ICONS[s];
|
|
57
|
+
return (_jsxs("li", { className: ['erp-hr-attendance__count', toneClassName(tone)].join(' '), children: [_jsx(Icon, { "aria-hidden": "true", className: "erp-hr-day__icon", strokeWidth: 1.75 }), label, _jsx("strong", { className: "erp-numeric", children: formatNumber(counts.get(s)) })] }, s));
|
|
58
|
+
}), counts.size === 0 && (_jsxs("li", { className: "erp-hr-attendance__count", children: [_jsx(CalendarOff, { "aria-hidden": "true", className: "erp-hr-day__icon", strokeWidth: 1.75 }), HR_COPY.attendance.noRecord] }))] }) })] }));
|
|
59
|
+
}
|
|
60
|
+
/** Today's attendance split (Figma «حضور اليوم»), on the shared DonutChart. */
|
|
61
|
+
export function AttendanceTodayChart({ present, late, absent, onLeave, title = HR_COPY.attendance.today, className }) {
|
|
62
|
+
return (_jsx(DonutChart, { title: title, className: className, centerLabel: HR_COPY.attendance.employees, segments: [
|
|
63
|
+
{ id: 'present', label: hrStatus('attendance', 'present').label, value: present, tone: 'positive' },
|
|
64
|
+
{ id: 'late', label: hrStatus('attendance', 'late').label, value: late, tone: 'warning' },
|
|
65
|
+
{ id: 'absent', label: hrStatus('attendance', 'absent').label, value: absent, tone: 'negative' },
|
|
66
|
+
{ id: 'leave', label: HR_COPY.attendance.onLeave, value: onLeave, tone: 'neutral' },
|
|
67
|
+
] }));
|
|
68
|
+
}
|
|
69
|
+
/** Present / late / absent per weekday as stacked bars (Figma «الحضور الأسبوعي»). */
|
|
70
|
+
export function WeeklyAttendanceChart({ days, title = HR_COPY.attendance.weekly, actions, className }) {
|
|
71
|
+
const series = [
|
|
72
|
+
{ id: 'present', tone: 'positive' },
|
|
73
|
+
{ id: 'late', tone: 'warning' },
|
|
74
|
+
{ id: 'absent', tone: 'negative' },
|
|
75
|
+
];
|
|
76
|
+
return (_jsx(BarChart, { title: title, actions: actions, className: className, stacked: true, categories: days.map((d) => d.label), series: series.map((s) => ({ id: s.id, label: hrStatus('attendance', s.id).label, tone: s.tone, values: days.map((d) => d[s.id]) })) }));
|
|
77
|
+
}
|
|
78
|
+
/** Monthly bars with the 6/12-month switch (Figma «مبدّل الفترة»), e.g. overtime or absence hours. */
|
|
79
|
+
export function PeriodBarsChart({ title, months, period, defaultPeriod = 6, onPeriodChange, formatValue, seriesLabel = UI_COPY.chart.total, className }) {
|
|
80
|
+
const [internal, setInternal] = useState(defaultPeriod);
|
|
81
|
+
const current = period ?? internal;
|
|
82
|
+
const shown = months.slice(-current);
|
|
83
|
+
return (_jsx(BarChart, { title: title, className: className, formatValue: formatValue, showLegend: false, actions: _jsx(SegmentedControl, { label: HR_COPY.period.label, size: "sm", value: String(current), onChange: (v) => {
|
|
84
|
+
const next = Number(v);
|
|
85
|
+
setInternal(next);
|
|
86
|
+
onPeriodChange?.(next);
|
|
87
|
+
}, options: [
|
|
88
|
+
{ value: '6', label: HR_COPY.period.six },
|
|
89
|
+
{ value: '12', label: HR_COPY.period.twelve },
|
|
90
|
+
] }), categories: shown.map((m) => m.label), series: [{ id: 'value', label: seriesLabel, values: shown.map((m) => m.value) }] }));
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=Attendance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Attendance.js","sourceRoot":"","sources":["../../../src/components/attendance/Attendance.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;A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C,EACD,OAAO,EAAE;gBACP,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,EAAE;gBACzC,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE;aAC9C,GACD,EAEJ,UAAU,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,EACrC,MAAM,EAAE,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,GAChF,CACH,CAAC;AACJ,CAAC","sourcesContent":["'use client';\r\n\r\nimport { formatNumber, formatTime } from '@tmllak-erp/formatters';\r\nimport { UI_COPY } from '@tmllak-erp/messages';\r\nimport {\r\n BarChart,\r\n CalendarGrid,\r\n DonutChart,\r\n SegmentedControl,\r\n isSameMonth,\r\n monthMatrix,\r\n toneClassName,\r\n type ChartTone,\r\n type WeekStart,\r\n} from '@tmllak-erp/ui';\r\nimport { CalendarOff, CheckCircle2, Clock, Coffee, Fingerprint, LogOut, PartyPopper, Plane, XCircle, type LucideIcon } from 'lucide-react';\r\nimport { useState, type ReactNode } from 'react';\r\nimport { HR_COPY } from '../../copy';\r\nimport { HR_STATUSES, hrStatus, type AttendanceStatus } from '../../statuses';\r\nimport './attendance.css';\r\n\r\nconst ICONS: Record<AttendanceStatus, LucideIcon> = {\r\n present: CheckCircle2,\r\n late: Clock,\r\n earlyLeave: LogOut,\r\n missingPunch: Fingerprint,\r\n absent: XCircle,\r\n leave: Plane,\r\n weekend: Coffee,\r\n holiday: PartyPopper,\r\n};\r\n\r\n/** Times may be given as dates or as «08:05» strings from the device feed. */\r\ntype Punch = Date | string;\r\nconst punch = (p: Punch | undefined) => (p === undefined ? undefined : typeof p === 'string' ? p : formatTime(p));\r\n\r\nexport interface AttendanceRecord {\r\n date: Date;\r\n status: AttendanceStatus;\r\n checkIn?: Punch;\r\n checkOut?: Punch;\r\n /** e.g. holiday name or leave type. */\r\n note?: string;\r\n}\r\n\r\nexport interface AttendanceDayCellProps {\r\n status: AttendanceStatus;\r\n checkIn?: Punch;\r\n checkOut?: Punch;\r\n note?: string;\r\n /** Hide the times (narrow calendars). */\r\n compact?: boolean;\r\n className?: string;\r\n}\r\n\r\n/** One attendance day (Figma «خلية يوم الحضور», 8 types): status word, icon and punch times. */\r\nexport function AttendanceDayCell({ status, checkIn, checkOut, note, compact, className }: AttendanceDayCellProps) {\r\n const { label, tone } = hrStatus('attendance', status);\r\n const inTime = punch(checkIn);\r\n const outTime = punch(checkOut);\r\n const details = [inTime && `${HR_COPY.attendance.checkIn} ${inTime}`, outTime && `${HR_COPY.attendance.checkOut} ${outTime}`, note].filter(Boolean).join(' · ');\r\n const Icon = ICONS[status];\r\n return (\r\n <span className={['erp-hr-day', `erp-hr-day--${status}`, toneClassName(tone), compact && 'is-compact', className].filter(Boolean).join(' ')} title={details || label} data-status={status}>\r\n <span className=\"erp-hr-day__status\">\r\n <Icon aria-hidden=\"true\" className=\"erp-hr-day__icon\" strokeWidth={1.75} />\r\n <span className=\"erp-hr-day__label\">{label}</span>\r\n </span>\r\n {!compact && (inTime || outTime) && (\r\n <span className=\"erp-hr-day__times erp-numeric\" dir=\"ltr\">\r\n {inTime ?? '--:--'} – {outTime ?? '--:--'}\r\n </span>\r\n )}\r\n {!compact && note && <span className=\"erp-hr-day__note\">{note}</span>}\r\n {compact && details && <span className=\"erp-visually-hidden\">{details}</span>}\r\n </span>\r\n );\r\n}\r\n\r\nconst dayKey = (d: Date) => `${d.getFullYear()}-${d.getMonth()}-${d.getDate()}`;\r\n\r\nexport interface AttendanceCalendarProps {\r\n records: readonly AttendanceRecord[];\r\n month?: Date;\r\n defaultMonth?: Date;\r\n onMonthChange?: (month: Date) => void;\r\n onDaySelect?: (date: Date, record: AttendanceRecord | undefined) => void;\r\n selected?: Date | null;\r\n /** Weekdays shown as «عطلة أسبوعية» when there is no record (default Friday and Saturday). */\r\n weekendDays?: readonly number[];\r\n weekStartsOn?: WeekStart;\r\n today?: Date;\r\n headerActions?: ReactNode;\r\n className?: string;\r\n}\r\n\r\n/** Monthly attendance (Figma «تقويم الحضور»): CalendarGrid with attendance cells and a month summary. */\r\nexport function AttendanceCalendar({\r\n records,\r\n month,\r\n defaultMonth,\r\n onMonthChange,\r\n onDaySelect,\r\n selected,\r\n weekendDays = [5, 6],\r\n weekStartsOn = 0,\r\n today,\r\n headerActions,\r\n className,\r\n}: AttendanceCalendarProps) {\r\n const [internalMonth, setInternalMonth] = useState(defaultMonth ?? today ?? new Date());\r\n const visibleMonth = month ?? internalMonth;\r\n const byDay = new Map(records.map((r) => [dayKey(r.date), r]));\r\n const statusOf = (d: Date): AttendanceRecord | undefined => byDay.get(dayKey(d)) ?? (weekendDays.includes(d.getDay()) ? { date: d, status: 'weekend' } : undefined);\r\n\r\n const counts = new Map<AttendanceStatus, number>();\r\n for (const day of monthMatrix(visibleMonth, weekStartsOn).flat()) {\r\n if (!isSameMonth(day, visibleMonth)) continue;\r\n const status = byDay.get(dayKey(day))?.status;\r\n if (status) counts.set(status, (counts.get(status) ?? 0) + 1);\r\n }\r\n\r\n return (\r\n <div className={['erp-hr-attendance', className].filter(Boolean).join(' ')}>\r\n <CalendarGrid\r\n label={HR_COPY.attendance.calendar}\r\n month={visibleMonth}\r\n onMonthChange={(m) => {\r\n setInternalMonth(m);\r\n onMonthChange?.(m);\r\n }}\r\n selected={selected}\r\n onSelect={(d) => onDaySelect?.(d, byDay.get(dayKey(d)))}\r\n weekStartsOn={weekStartsOn}\r\n today={today}\r\n headerActions={headerActions}\r\n renderDay={(date, { inMonth }) => {\r\n const record = inMonth ? statusOf(date) : undefined;\r\n return record ? <AttendanceDayCell status={record.status} checkIn={record.checkIn} checkOut={record.checkOut} note={record.note} /> : null;\r\n }}\r\n />\r\n <section className=\"erp-hr-attendance__summary\" aria-label={HR_COPY.attendance.summary}>\r\n <ul>\r\n {(Object.keys(HR_STATUSES.attendance) as AttendanceStatus[])\r\n .filter((s) => counts.has(s))\r\n .map((s) => {\r\n const { label, tone } = hrStatus('attendance', s);\r\n const Icon = ICONS[s];\r\n return (\r\n <li key={s} className={['erp-hr-attendance__count', toneClassName(tone)].join(' ')}>\r\n <Icon aria-hidden=\"true\" className=\"erp-hr-day__icon\" strokeWidth={1.75} />\r\n {label}\r\n <strong className=\"erp-numeric\">{formatNumber(counts.get(s)!)}</strong>\r\n </li>\r\n );\r\n })}\r\n {counts.size === 0 && (\r\n <li className=\"erp-hr-attendance__count\">\r\n <CalendarOff aria-hidden=\"true\" className=\"erp-hr-day__icon\" strokeWidth={1.75} />\r\n {HR_COPY.attendance.noRecord}\r\n </li>\r\n )}\r\n </ul>\r\n </section>\r\n </div>\r\n );\r\n}\r\n\r\nexport interface AttendanceTodayChartProps {\r\n present: number;\r\n late: number;\r\n absent: number;\r\n onLeave: number;\r\n title?: string;\r\n className?: string;\r\n}\r\n\r\n/** Today's attendance split (Figma «حضور اليوم»), on the shared DonutChart. */\r\nexport function AttendanceTodayChart({ present, late, absent, onLeave, title = HR_COPY.attendance.today, className }: AttendanceTodayChartProps) {\r\n return (\r\n <DonutChart\r\n title={title}\r\n className={className}\r\n centerLabel={HR_COPY.attendance.employees}\r\n segments={[\r\n { id: 'present', label: hrStatus('attendance', 'present').label, value: present, tone: 'positive' },\r\n { id: 'late', label: hrStatus('attendance', 'late').label, value: late, tone: 'warning' },\r\n { id: 'absent', label: hrStatus('attendance', 'absent').label, value: absent, tone: 'negative' },\r\n { id: 'leave', label: HR_COPY.attendance.onLeave, value: onLeave, tone: 'neutral' },\r\n ]}\r\n />\r\n );\r\n}\r\n\r\nexport interface WeeklyAttendanceDay {\r\n /** Day label, e.g. «الأحد». */\r\n label: string;\r\n present: number;\r\n late: number;\r\n absent: number;\r\n}\r\n\r\nexport interface WeeklyAttendanceChartProps {\r\n days: readonly WeeklyAttendanceDay[];\r\n title?: string;\r\n actions?: ReactNode;\r\n className?: string;\r\n}\r\n\r\n/** Present / late / absent per weekday as stacked bars (Figma «الحضور الأسبوعي»). */\r\nexport function WeeklyAttendanceChart({ days, title = HR_COPY.attendance.weekly, actions, className }: WeeklyAttendanceChartProps) {\r\n const series: { id: keyof Omit<WeeklyAttendanceDay, 'label'>; tone: ChartTone }[] = [\r\n { id: 'present', tone: 'positive' },\r\n { id: 'late', tone: 'warning' },\r\n { id: 'absent', tone: 'negative' },\r\n ];\r\n return (\r\n <BarChart\r\n title={title}\r\n actions={actions}\r\n className={className}\r\n stacked\r\n categories={days.map((d) => d.label)}\r\n series={series.map((s) => ({ id: s.id, label: hrStatus('attendance', s.id).label, tone: s.tone, values: days.map((d) => d[s.id]) }))}\r\n />\r\n );\r\n}\r\n\r\nexport type ReportPeriod = 6 | 12;\r\n\r\nexport interface PeriodBarsChartProps {\r\n title: string;\r\n /** Up to 12 months, oldest first; the chart shows the last 6 or 12. */\r\n months: readonly { label: string; value: number }[];\r\n period?: ReportPeriod;\r\n defaultPeriod?: ReportPeriod;\r\n onPeriodChange?: (period: ReportPeriod) => void;\r\n formatValue?: (value: number) => string;\r\n seriesLabel?: string;\r\n className?: string;\r\n}\r\n\r\n/** Monthly bars with the 6/12-month switch (Figma «مبدّل الفترة»), e.g. overtime or absence hours. */\r\nexport function PeriodBarsChart({ title, months, period, defaultPeriod = 6, onPeriodChange, formatValue, seriesLabel = UI_COPY.chart.total, className }: PeriodBarsChartProps) {\r\n const [internal, setInternal] = useState<ReportPeriod>(defaultPeriod);\r\n const current = period ?? internal;\r\n const shown = months.slice(-current);\r\n return (\r\n <BarChart\r\n title={title}\r\n className={className}\r\n formatValue={formatValue}\r\n showLegend={false}\r\n actions={\r\n <SegmentedControl\r\n label={HR_COPY.period.label}\r\n size=\"sm\"\r\n value={String(current)}\r\n onChange={(v) => {\r\n const next = Number(v) as ReportPeriod;\r\n setInternal(next);\r\n onPeriodChange?.(next);\r\n }}\r\n options={[\r\n { value: '6', label: HR_COPY.period.six },\r\n { value: '12', label: HR_COPY.period.twelve },\r\n ]}\r\n />\r\n }\r\n categories={shown.map((m) => m.label)}\r\n series={[{ id: 'value', label: seriesLabel, values: shown.map((m) => m.value) }]}\r\n />\r\n );\r\n}\r\n"]}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
.erp-hr-day {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
gap: var(--erp-space-0-5);
|
|
5
|
+
min-inline-size: 0;
|
|
6
|
+
padding: var(--erp-space-1) var(--erp-space-1-5);
|
|
7
|
+
border-inline-start: 3px solid var(--erp-badge-dot);
|
|
8
|
+
border-radius: var(--erp-radius-xs);
|
|
9
|
+
background: var(--erp-badge-bg);
|
|
10
|
+
color: var(--erp-badge-fg);
|
|
11
|
+
font-family: var(--erp-font-family-base);
|
|
12
|
+
transition: box-shadow var(--erp-duration-fast) var(--erp-easing-standard);
|
|
13
|
+
}
|
|
14
|
+
.erp-hr-day:hover {
|
|
15
|
+
box-shadow: var(--erp-shadow-sm);
|
|
16
|
+
}
|
|
17
|
+
.erp-hr-day--weekend,
|
|
18
|
+
.erp-hr-day--holiday {
|
|
19
|
+
border-inline-start-style: dashed;
|
|
20
|
+
}
|
|
21
|
+
.erp-hr-day__status {
|
|
22
|
+
display: flex;
|
|
23
|
+
align-items: center;
|
|
24
|
+
gap: var(--erp-space-1);
|
|
25
|
+
min-inline-size: 0;
|
|
26
|
+
font-size: var(--erp-font-size-micro);
|
|
27
|
+
line-height: var(--erp-line-height-micro);
|
|
28
|
+
font-weight: var(--erp-font-weight-semibold);
|
|
29
|
+
}
|
|
30
|
+
.erp-hr-day__icon {
|
|
31
|
+
flex: none;
|
|
32
|
+
inline-size: var(--erp-space-3);
|
|
33
|
+
block-size: var(--erp-space-3);
|
|
34
|
+
}
|
|
35
|
+
.erp-hr-day__label {
|
|
36
|
+
overflow: hidden;
|
|
37
|
+
text-overflow: ellipsis;
|
|
38
|
+
white-space: nowrap;
|
|
39
|
+
}
|
|
40
|
+
.erp-hr-day__times,
|
|
41
|
+
.erp-hr-day__note {
|
|
42
|
+
overflow: hidden;
|
|
43
|
+
color: var(--erp-color-text-secondary);
|
|
44
|
+
font-size: var(--erp-font-size-micro);
|
|
45
|
+
line-height: var(--erp-line-height-micro);
|
|
46
|
+
text-overflow: ellipsis;
|
|
47
|
+
white-space: nowrap;
|
|
48
|
+
}
|
|
49
|
+
.erp-hr-day.is-compact {
|
|
50
|
+
padding: var(--erp-space-0-5) var(--erp-space-1);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.erp-hr-attendance {
|
|
54
|
+
display: flex;
|
|
55
|
+
flex-direction: column;
|
|
56
|
+
gap: var(--erp-space-3);
|
|
57
|
+
min-inline-size: 0;
|
|
58
|
+
}
|
|
59
|
+
.erp-hr-attendance__summary ul {
|
|
60
|
+
display: flex;
|
|
61
|
+
flex-wrap: wrap;
|
|
62
|
+
gap: var(--erp-space-2);
|
|
63
|
+
margin: 0;
|
|
64
|
+
padding: 0;
|
|
65
|
+
list-style: none;
|
|
66
|
+
}
|
|
67
|
+
.erp-hr-attendance__count {
|
|
68
|
+
display: inline-flex;
|
|
69
|
+
align-items: center;
|
|
70
|
+
gap: var(--erp-space-1-5);
|
|
71
|
+
padding: var(--erp-space-1) var(--erp-space-3);
|
|
72
|
+
border-radius: var(--erp-radius-full);
|
|
73
|
+
background: var(--erp-badge-bg, var(--erp-color-bg-subtle));
|
|
74
|
+
color: var(--erp-badge-fg, var(--erp-color-text-secondary));
|
|
75
|
+
font-family: var(--erp-font-family-base);
|
|
76
|
+
font-size: var(--erp-font-size-caption);
|
|
77
|
+
line-height: var(--erp-line-height-caption);
|
|
78
|
+
}
|
|
79
|
+
@media (max-width: 600px) {
|
|
80
|
+
.erp-hr-day__times,
|
|
81
|
+
.erp-hr-day__note {
|
|
82
|
+
display: none;
|
|
83
|
+
}
|
|
84
|
+
/* Narrow cells keep only the icon visible; the status word stays available to screen readers. */
|
|
85
|
+
.erp-hr-day__label {
|
|
86
|
+
position: absolute;
|
|
87
|
+
inline-size: 1px;
|
|
88
|
+
block-size: 1px;
|
|
89
|
+
overflow: hidden;
|
|
90
|
+
clip: rect(0 0 0 0);
|
|
91
|
+
}
|
|
92
|
+
.erp-hr-day__status {
|
|
93
|
+
justify-content: center;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { type Presence } from '@tmllak-erp/ui';
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
|
+
import type { HrStatus } from '../../statuses.js';
|
|
4
|
+
import './employee.css';
|
|
5
|
+
export interface EmployeeSummary {
|
|
6
|
+
name: string;
|
|
7
|
+
src?: string;
|
|
8
|
+
jobTitle: string;
|
|
9
|
+
employeeNumber: string;
|
|
10
|
+
department: string;
|
|
11
|
+
branch?: string;
|
|
12
|
+
status: HrStatus<'employee'>;
|
|
13
|
+
manager?: string;
|
|
14
|
+
email?: string;
|
|
15
|
+
phone?: string;
|
|
16
|
+
joinedAt?: Date;
|
|
17
|
+
}
|
|
18
|
+
export interface ProfileField {
|
|
19
|
+
label: string;
|
|
20
|
+
value: ReactNode;
|
|
21
|
+
/** Latin values (IBAN, email, ID numbers) are displayed left-to-right. */
|
|
22
|
+
ltr?: boolean;
|
|
23
|
+
/** Span the full row (addresses, notes). */
|
|
24
|
+
wide?: boolean;
|
|
25
|
+
}
|
|
26
|
+
export interface ProfileSection {
|
|
27
|
+
id: string;
|
|
28
|
+
title: string;
|
|
29
|
+
fields?: readonly ProfileField[];
|
|
30
|
+
/** Custom content (tables, document lists) instead of or after the fields. */
|
|
31
|
+
content?: ReactNode;
|
|
32
|
+
/** Section controls, e.g. «تعديل». */
|
|
33
|
+
actions?: ReactNode;
|
|
34
|
+
}
|
|
35
|
+
export interface EmployeeProfileProps {
|
|
36
|
+
employee: EmployeeSummary;
|
|
37
|
+
sections: readonly ProfileSection[];
|
|
38
|
+
/** Header controls: «تعديل البيانات»، «طلب استكمال»… */
|
|
39
|
+
actions?: ReactNode;
|
|
40
|
+
/** Share of required data that is filled (0–1). */
|
|
41
|
+
completion?: number;
|
|
42
|
+
/** `tabs` for the admin record, `stacked` for «حسابي - الملف الكامل». */
|
|
43
|
+
layout?: 'tabs' | 'stacked';
|
|
44
|
+
className?: string;
|
|
45
|
+
}
|
|
46
|
+
/** Employee record (Figma «ملف الموظف» / «حسابي - الملف الكامل»): identity header and data sections. */
|
|
47
|
+
export declare function EmployeeProfile({ employee, sections, actions, completion, layout, className }: EmployeeProfileProps): import("react").JSX.Element;
|
|
48
|
+
export interface TeamMemberCardProps {
|
|
49
|
+
name: string;
|
|
50
|
+
src?: string;
|
|
51
|
+
jobTitle: string;
|
|
52
|
+
presence?: Presence;
|
|
53
|
+
leader?: boolean;
|
|
54
|
+
email?: string;
|
|
55
|
+
phone?: string;
|
|
56
|
+
/** Extra content, e.g. «في إجازة حتى 12 نوفمبر». */
|
|
57
|
+
note?: ReactNode;
|
|
58
|
+
className?: string;
|
|
59
|
+
}
|
|
60
|
+
/** Colleague card in «فريقي» (Figma «تفاعل/بطاقة عضو»). */
|
|
61
|
+
export declare function TeamMemberCard({ name, src, jobTitle, presence, leader, email, phone, note, className }: TeamMemberCardProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { formatDate, formatPercent } from '@tmllak-erp/formatters';
|
|
4
|
+
import { fillCopy } from '@tmllak-erp/messages';
|
|
5
|
+
import { Avatar, Card, Icon, IconButton, PresenceIndicator, ProgressBar, Tabs } from '@tmllak-erp/ui';
|
|
6
|
+
import { Crown, Mail, Phone } from 'lucide-react';
|
|
7
|
+
import { HR_COPY } from '../../copy.js';
|
|
8
|
+
import { HrStatusBadge } from '../HrStatusBadge.js';
|
|
9
|
+
import './employee.css';
|
|
10
|
+
function FieldGrid({ fields }) {
|
|
11
|
+
return (_jsx("dl", { className: "erp-hr-fields", children: fields.map((f) => (_jsxs("div", { className: f.wide ? 'erp-hr-fields__item erp-hr-fields__item--wide' : 'erp-hr-fields__item', children: [_jsx("dt", { children: f.label }), _jsx("dd", { dir: f.ltr ? 'ltr' : undefined, className: f.ltr ? 'erp-ltr erp-numeric' : undefined, children: f.value ?? '—' })] }, f.label))) }));
|
|
12
|
+
}
|
|
13
|
+
/** Employee record (Figma «ملف الموظف» / «حسابي - الملف الكامل»): identity header and data sections. */
|
|
14
|
+
export function EmployeeProfile({ employee, sections, actions, completion, layout = 'tabs', className }) {
|
|
15
|
+
const sectionBody = (s) => (_jsxs(_Fragment, { children: [s.fields && _jsx(FieldGrid, { fields: s.fields }), s.content] }));
|
|
16
|
+
return (_jsxs("div", { className: ['erp-hr-profile', className].filter(Boolean).join(' '), children: [_jsxs(Card, { className: "erp-hr-profile__header", children: [_jsxs("div", { className: "erp-hr-profile__identity", children: [_jsx(Avatar, { name: employee.name, src: employee.src, size: "xl", decorative: true }), _jsxs("div", { className: "erp-hr-profile__titles", children: [_jsx("h2", { className: "erp-hr-profile__name", children: employee.name }), _jsxs("p", { className: "erp-hr-profile__job", children: [employee.jobTitle, " \u00B7 ", employee.department, employee.branch && ` · ${employee.branch}`] }), _jsxs("div", { className: "erp-hr-profile__badges", children: [_jsx(HrStatusBadge, { set: "employee", status: employee.status }), _jsxs("span", { className: "erp-hr-profile__number", children: [_jsxs("span", { className: "erp-visually-hidden", children: [HR_COPY.profile.number, ": "] }), _jsx("bdi", { className: "erp-numeric", children: employee.employeeNumber })] })] })] }), actions && _jsx("div", { className: "erp-hr-profile__actions", children: actions })] }), _jsxs("dl", { className: "erp-hr-profile__facts", children: [employee.manager && (_jsxs("div", { children: [_jsx("dt", { children: HR_COPY.profile.manager }), _jsx("dd", { children: employee.manager })] })), employee.joinedAt && (_jsxs("div", { children: [_jsx("dt", { children: HR_COPY.profile.joined }), _jsx("dd", { className: "erp-numeric", children: formatDate(employee.joinedAt) })] })), employee.email && (_jsxs("div", { children: [_jsx("dt", { children: HR_COPY.profile.email }), _jsx("dd", { children: _jsx("a", { href: `mailto:${employee.email}`, dir: "ltr", className: "erp-ltr", children: employee.email }) })] })), employee.phone && (_jsxs("div", { children: [_jsx("dt", { children: HR_COPY.profile.phone }), _jsx("dd", { children: _jsx("a", { href: `tel:${employee.phone.replace(/\s/g, '')}`, dir: "ltr", className: "erp-ltr erp-numeric", children: employee.phone }) })] }))] }), completion !== undefined && (_jsx(ProgressBar, { className: "erp-hr-profile__completion", label: HR_COPY.profile.completion, value: completion * 100, showLabel: true, showValue: true, tone: "auto", valueText: formatPercent(completion) }))] }), layout === 'tabs' ? (_jsx(Tabs, { label: HR_COPY.profile.sections, items: sections.map((s) => ({
|
|
17
|
+
id: s.id,
|
|
18
|
+
label: s.title,
|
|
19
|
+
content: (_jsx(Card, { title: s.title, headingLevel: 3, actions: s.actions, children: sectionBody(s) })),
|
|
20
|
+
})) })) : (sections.map((s) => (_jsx(Card, { title: s.title, headingLevel: 3, actions: s.actions, children: sectionBody(s) }, s.id))))] }));
|
|
21
|
+
}
|
|
22
|
+
/** Colleague card in «فريقي» (Figma «تفاعل/بطاقة عضو»). */
|
|
23
|
+
export function TeamMemberCard({ name, src, jobTitle, presence, leader, email, phone, note, className }) {
|
|
24
|
+
return (_jsxs("article", { className: ['erp-hr-member', className].filter(Boolean).join(' '), "aria-label": name, children: [_jsx(Avatar, { name: name, src: src, size: "lg", presence: presence, decorative: true }), _jsxs("div", { className: "erp-hr-member__body", children: [_jsxs("h3", { className: "erp-hr-member__name", children: [name, leader && (_jsxs("span", { className: "erp-hr-member__leader", children: [_jsx(Icon, { icon: Crown, size: "xs" }), HR_COPY.team.leader] }))] }), _jsx("p", { className: "erp-hr-member__job", children: jobTitle }), presence && _jsx(PresenceIndicator, { presence: presence }), note && _jsx("p", { className: "erp-hr-member__note", children: note })] }), (email || phone) && (_jsxs("div", { className: "erp-hr-member__actions", children: [email && _jsx(IconButton, { icon: Mail, size: "sm", variant: "secondary", label: fillCopy(HR_COPY.team.message, { name }), onClick: () => window.open(`mailto:${email}`) }), phone && _jsx(IconButton, { icon: Phone, size: "sm", variant: "secondary", label: fillCopy(HR_COPY.team.call, { name }), onClick: () => window.open(`tel:${phone.replace(/\s/g, '')}`) })] }))] }));
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=Employee.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Employee.js","sourceRoot":"","sources":["../../../src/components/employee/Employee.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,iBAAiB,EAAE,WAAW,EAAE,IAAI,EAAiB,MAAM,gBAAgB,CAAC;AACrH,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAElD,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,gBAAgB,CAAC;AA+CxB,SAAS,SAAS,CAAC,EAAE,MAAM,EAAuC;IAChE,OAAO,CACL,aAAI,SAAS,EAAC,eAAe,YAC1B,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CACjB,eAAmB,SAAS,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,+CAA+C,CAAC,CAAC,CAAC,qBAAqB,aAC5G,uBAAK,CAAC,CAAC,KAAK,GAAM,EAClB,aAAI,GAAG,EAAE,CAAC,CAAC,GAAG,CAAC,CA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,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,CAAC,GAAI,IAC5K,CACP,IACO,CACX,CAAC;AACJ,CAAC","sourcesContent":["'use client';\r\n\r\nimport { formatDate, formatPercent } from '@tmllak-erp/formatters';\r\nimport { fillCopy } from '@tmllak-erp/messages';\r\nimport { Avatar, Card, Icon, IconButton, PresenceIndicator, ProgressBar, Tabs, type Presence } from '@tmllak-erp/ui';\r\nimport { Crown, Mail, Phone } from 'lucide-react';\r\nimport type { ReactNode } from 'react';\r\nimport { HR_COPY } from '../../copy';\r\nimport type { HrStatus } from '../../statuses';\r\nimport { HrStatusBadge } from '../HrStatusBadge';\r\nimport './employee.css';\r\n\r\nexport interface EmployeeSummary {\r\n name: string;\r\n src?: string;\r\n jobTitle: string;\r\n employeeNumber: string;\r\n department: string;\r\n branch?: string;\r\n status: HrStatus<'employee'>;\r\n manager?: string;\r\n email?: string;\r\n phone?: string;\r\n joinedAt?: Date;\r\n}\r\n\r\nexport interface ProfileField {\r\n label: string;\r\n value: ReactNode;\r\n /** Latin values (IBAN, email, ID numbers) are displayed left-to-right. */\r\n ltr?: boolean;\r\n /** Span the full row (addresses, notes). */\r\n wide?: boolean;\r\n}\r\n\r\nexport interface ProfileSection {\r\n id: string;\r\n title: string;\r\n fields?: readonly ProfileField[];\r\n /** Custom content (tables, document lists) instead of or after the fields. */\r\n content?: ReactNode;\r\n /** Section controls, e.g. «تعديل». */\r\n actions?: ReactNode;\r\n}\r\n\r\nexport interface EmployeeProfileProps {\r\n employee: EmployeeSummary;\r\n sections: readonly ProfileSection[];\r\n /** Header controls: «تعديل البيانات»، «طلب استكمال»… */\r\n actions?: ReactNode;\r\n /** Share of required data that is filled (0–1). */\r\n completion?: number;\r\n /** `tabs` for the admin record, `stacked` for «حسابي - الملف الكامل». */\r\n layout?: 'tabs' | 'stacked';\r\n className?: string;\r\n}\r\n\r\nfunction FieldGrid({ fields }: { fields: readonly ProfileField[] }) {\r\n return (\r\n <dl className=\"erp-hr-fields\">\r\n {fields.map((f) => (\r\n <div key={f.label} className={f.wide ? 'erp-hr-fields__item erp-hr-fields__item--wide' : 'erp-hr-fields__item'}>\r\n <dt>{f.label}</dt>\r\n <dd dir={f.ltr ? 'ltr' : undefined} className={f.ltr ? 'erp-ltr erp-numeric' : undefined}>\r\n {f.value ?? '—'}\r\n </dd>\r\n </div>\r\n ))}\r\n </dl>\r\n );\r\n}\r\n\r\n/** Employee record (Figma «ملف الموظف» / «حسابي - الملف الكامل»): identity header and data sections. */\r\nexport function EmployeeProfile({ employee, sections, actions, completion, layout = 'tabs', className }: EmployeeProfileProps) {\r\n const sectionBody = (s: ProfileSection) => (\r\n <>\r\n {s.fields && <FieldGrid fields={s.fields} />}\r\n {s.content}\r\n </>\r\n );\r\n return (\r\n <div className={['erp-hr-profile', className].filter(Boolean).join(' ')}>\r\n <Card className=\"erp-hr-profile__header\">\r\n <div className=\"erp-hr-profile__identity\">\r\n <Avatar name={employee.name} src={employee.src} size=\"xl\" decorative />\r\n <div className=\"erp-hr-profile__titles\">\r\n <h2 className=\"erp-hr-profile__name\">{employee.name}</h2>\r\n <p className=\"erp-hr-profile__job\">\r\n {employee.jobTitle} · {employee.department}\r\n {employee.branch && ` · ${employee.branch}`}\r\n </p>\r\n <div className=\"erp-hr-profile__badges\">\r\n <HrStatusBadge set=\"employee\" status={employee.status} />\r\n <span className=\"erp-hr-profile__number\">\r\n <span className=\"erp-visually-hidden\">{HR_COPY.profile.number}: </span>\r\n <bdi className=\"erp-numeric\">{employee.employeeNumber}</bdi>\r\n </span>\r\n </div>\r\n </div>\r\n {actions && <div className=\"erp-hr-profile__actions\">{actions}</div>}\r\n </div>\r\n <dl className=\"erp-hr-profile__facts\">\r\n {employee.manager && (\r\n <div>\r\n <dt>{HR_COPY.profile.manager}</dt>\r\n <dd>{employee.manager}</dd>\r\n </div>\r\n )}\r\n {employee.joinedAt && (\r\n <div>\r\n <dt>{HR_COPY.profile.joined}</dt>\r\n <dd className=\"erp-numeric\">{formatDate(employee.joinedAt)}</dd>\r\n </div>\r\n )}\r\n {employee.email && (\r\n <div>\r\n <dt>{HR_COPY.profile.email}</dt>\r\n <dd>\r\n <a href={`mailto:${employee.email}`} dir=\"ltr\" className=\"erp-ltr\">\r\n {employee.email}\r\n </a>\r\n </dd>\r\n </div>\r\n )}\r\n {employee.phone && (\r\n <div>\r\n <dt>{HR_COPY.profile.phone}</dt>\r\n <dd>\r\n <a href={`tel:${employee.phone.replace(/\\s/g, '')}`} dir=\"ltr\" className=\"erp-ltr erp-numeric\">\r\n {employee.phone}\r\n </a>\r\n </dd>\r\n </div>\r\n )}\r\n </dl>\r\n {completion !== undefined && (\r\n <ProgressBar className=\"erp-hr-profile__completion\" label={HR_COPY.profile.completion} value={completion * 100} showLabel showValue tone=\"auto\" valueText={formatPercent(completion)} />\r\n )}\r\n </Card>\r\n {layout === 'tabs' ? (\r\n <Tabs\r\n label={HR_COPY.profile.sections}\r\n items={sections.map((s) => ({\r\n id: s.id,\r\n label: s.title,\r\n content: (\r\n <Card title={s.title} headingLevel={3} actions={s.actions}>\r\n {sectionBody(s)}\r\n </Card>\r\n ),\r\n }))}\r\n />\r\n ) : (\r\n sections.map((s) => (\r\n <Card key={s.id} title={s.title} headingLevel={3} actions={s.actions}>\r\n {sectionBody(s)}\r\n </Card>\r\n ))\r\n )}\r\n </div>\r\n );\r\n}\r\n\r\nexport interface TeamMemberCardProps {\r\n name: string;\r\n src?: string;\r\n jobTitle: string;\r\n presence?: Presence;\r\n leader?: boolean;\r\n email?: string;\r\n phone?: string;\r\n /** Extra content, e.g. «في إجازة حتى 12 نوفمبر». */\r\n note?: ReactNode;\r\n className?: string;\r\n}\r\n\r\n/** Colleague card in «فريقي» (Figma «تفاعل/بطاقة عضو»). */\r\nexport function TeamMemberCard({ name, src, jobTitle, presence, leader, email, phone, note, className }: TeamMemberCardProps) {\r\n return (\r\n <article className={['erp-hr-member', className].filter(Boolean).join(' ')} aria-label={name}>\r\n <Avatar name={name} src={src} size=\"lg\" presence={presence} decorative />\r\n <div className=\"erp-hr-member__body\">\r\n <h3 className=\"erp-hr-member__name\">\r\n {name}\r\n {leader && (\r\n <span className=\"erp-hr-member__leader\">\r\n <Icon icon={Crown} size=\"xs\" />\r\n {HR_COPY.team.leader}\r\n </span>\r\n )}\r\n </h3>\r\n <p className=\"erp-hr-member__job\">{jobTitle}</p>\r\n {presence && <PresenceIndicator presence={presence} />}\r\n {note && <p className=\"erp-hr-member__note\">{note}</p>}\r\n </div>\r\n {(email || phone) && (\r\n <div className=\"erp-hr-member__actions\">\r\n {email && <IconButton icon={Mail} size=\"sm\" variant=\"secondary\" label={fillCopy(HR_COPY.team.message, { name })} onClick={() => window.open(`mailto:${email}`)} />}\r\n {phone && <IconButton icon={Phone} size=\"sm\" variant=\"secondary\" label={fillCopy(HR_COPY.team.call, { name })} onClick={() => window.open(`tel:${phone.replace(/\\s/g, '')}`)} />}\r\n </div>\r\n )}\r\n </article>\r\n );\r\n}\r\n"]}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
.erp-hr-profile {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
gap: var(--erp-space-4);
|
|
5
|
+
min-inline-size: 0;
|
|
6
|
+
font-family: var(--erp-font-family-base);
|
|
7
|
+
}
|
|
8
|
+
.erp-hr-profile__header {
|
|
9
|
+
gap: var(--erp-space-5);
|
|
10
|
+
}
|
|
11
|
+
.erp-hr-profile__identity {
|
|
12
|
+
display: flex;
|
|
13
|
+
flex-wrap: wrap;
|
|
14
|
+
align-items: center;
|
|
15
|
+
gap: var(--erp-space-4);
|
|
16
|
+
}
|
|
17
|
+
.erp-hr-profile__titles {
|
|
18
|
+
flex: 1;
|
|
19
|
+
min-inline-size: 0;
|
|
20
|
+
}
|
|
21
|
+
.erp-hr-profile__name {
|
|
22
|
+
margin: 0;
|
|
23
|
+
font-size: var(--erp-font-size-h2);
|
|
24
|
+
line-height: var(--erp-line-height-h2);
|
|
25
|
+
font-weight: var(--erp-font-weight-bold);
|
|
26
|
+
}
|
|
27
|
+
.erp-hr-profile__job {
|
|
28
|
+
margin: var(--erp-space-0-5) 0 var(--erp-space-2);
|
|
29
|
+
color: var(--erp-color-text-secondary);
|
|
30
|
+
font-size: var(--erp-font-size-body-sm);
|
|
31
|
+
line-height: var(--erp-line-height-body-sm);
|
|
32
|
+
}
|
|
33
|
+
.erp-hr-profile__badges,
|
|
34
|
+
.erp-hr-profile__actions {
|
|
35
|
+
display: flex;
|
|
36
|
+
flex-wrap: wrap;
|
|
37
|
+
align-items: center;
|
|
38
|
+
gap: var(--erp-space-2);
|
|
39
|
+
}
|
|
40
|
+
.erp-hr-profile__number {
|
|
41
|
+
padding: 0 var(--erp-space-2);
|
|
42
|
+
border-radius: var(--erp-radius-full);
|
|
43
|
+
background: var(--erp-color-bg-subtle);
|
|
44
|
+
color: var(--erp-color-text-secondary);
|
|
45
|
+
font-size: var(--erp-font-size-caption);
|
|
46
|
+
line-height: var(--erp-line-height-caption);
|
|
47
|
+
}
|
|
48
|
+
.erp-hr-profile__facts {
|
|
49
|
+
display: grid;
|
|
50
|
+
grid-template-columns: repeat(auto-fit, minmax(var(--erp-width-sidebar-collapsed), 1fr));
|
|
51
|
+
gap: var(--erp-space-3) var(--erp-space-6);
|
|
52
|
+
margin: 0;
|
|
53
|
+
padding-block-start: var(--erp-space-4);
|
|
54
|
+
border-block-start: 1px solid var(--erp-color-border-default);
|
|
55
|
+
}
|
|
56
|
+
.erp-hr-profile__facts dt,
|
|
57
|
+
.erp-hr-fields dt {
|
|
58
|
+
color: var(--erp-color-text-secondary);
|
|
59
|
+
font-size: var(--erp-font-size-caption);
|
|
60
|
+
line-height: var(--erp-line-height-caption);
|
|
61
|
+
}
|
|
62
|
+
.erp-hr-profile__facts dd,
|
|
63
|
+
.erp-hr-fields dd {
|
|
64
|
+
margin: 0;
|
|
65
|
+
font-size: var(--erp-font-size-body-sm);
|
|
66
|
+
line-height: var(--erp-line-height-body-sm);
|
|
67
|
+
font-weight: var(--erp-font-weight-medium);
|
|
68
|
+
overflow-wrap: anywhere;
|
|
69
|
+
}
|
|
70
|
+
.erp-hr-profile__facts a {
|
|
71
|
+
color: var(--erp-color-brand-text);
|
|
72
|
+
}
|
|
73
|
+
.erp-hr-fields {
|
|
74
|
+
display: grid;
|
|
75
|
+
grid-template-columns: repeat(3, minmax(0, 1fr));
|
|
76
|
+
gap: var(--erp-space-4) var(--erp-space-6);
|
|
77
|
+
margin: 0;
|
|
78
|
+
}
|
|
79
|
+
.erp-hr-fields__item--wide {
|
|
80
|
+
grid-column: 1 / -1;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.erp-hr-member {
|
|
84
|
+
display: flex;
|
|
85
|
+
align-items: flex-start;
|
|
86
|
+
gap: var(--erp-space-3);
|
|
87
|
+
padding: var(--erp-card-padding);
|
|
88
|
+
border: 1px solid var(--erp-color-border-default);
|
|
89
|
+
border-radius: var(--erp-radius-lg);
|
|
90
|
+
background: var(--erp-color-bg-surface);
|
|
91
|
+
box-shadow: var(--erp-shadow-card);
|
|
92
|
+
font-family: var(--erp-font-family-base);
|
|
93
|
+
color: var(--erp-color-text-primary);
|
|
94
|
+
}
|
|
95
|
+
.erp-hr-member:hover {
|
|
96
|
+
border-color: var(--erp-color-brand-default);
|
|
97
|
+
}
|
|
98
|
+
.erp-hr-member__body {
|
|
99
|
+
display: flex;
|
|
100
|
+
flex: 1;
|
|
101
|
+
flex-direction: column;
|
|
102
|
+
gap: var(--erp-space-1);
|
|
103
|
+
min-inline-size: 0;
|
|
104
|
+
}
|
|
105
|
+
.erp-hr-member__name {
|
|
106
|
+
display: flex;
|
|
107
|
+
flex-wrap: wrap;
|
|
108
|
+
align-items: center;
|
|
109
|
+
gap: var(--erp-space-2);
|
|
110
|
+
margin: 0;
|
|
111
|
+
font-size: var(--erp-font-size-body);
|
|
112
|
+
line-height: var(--erp-line-height-body);
|
|
113
|
+
font-weight: var(--erp-font-weight-bold);
|
|
114
|
+
}
|
|
115
|
+
.erp-hr-member__leader {
|
|
116
|
+
display: inline-flex;
|
|
117
|
+
align-items: center;
|
|
118
|
+
gap: var(--erp-space-1);
|
|
119
|
+
padding: 0 var(--erp-space-2);
|
|
120
|
+
border-radius: var(--erp-radius-full);
|
|
121
|
+
background: var(--erp-color-brand-subtle);
|
|
122
|
+
color: var(--erp-color-brand-text);
|
|
123
|
+
font-size: var(--erp-font-size-micro);
|
|
124
|
+
line-height: var(--erp-line-height-micro);
|
|
125
|
+
font-weight: var(--erp-font-weight-semibold);
|
|
126
|
+
}
|
|
127
|
+
.erp-hr-member__job,
|
|
128
|
+
.erp-hr-member__note {
|
|
129
|
+
margin: 0;
|
|
130
|
+
color: var(--erp-color-text-secondary);
|
|
131
|
+
font-size: var(--erp-font-size-caption);
|
|
132
|
+
line-height: var(--erp-line-height-caption);
|
|
133
|
+
}
|
|
134
|
+
.erp-hr-member__actions {
|
|
135
|
+
display: flex;
|
|
136
|
+
gap: var(--erp-space-1);
|
|
137
|
+
}
|
|
138
|
+
@media (max-width: 600px) {
|
|
139
|
+
.erp-hr-fields {
|
|
140
|
+
grid-template-columns: minmax(0, 1fr);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
@media (min-width: 601px) and (max-width: 1024px) {
|
|
144
|
+
.erp-hr-fields {
|
|
145
|
+
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
146
|
+
}
|
|
147
|
+
}
|