@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.
Files changed (54) hide show
  1. package/dist/components/HrStatusBadge.d.ts +9 -0
  2. package/dist/components/HrStatusBadge.js +9 -0
  3. package/dist/components/HrStatusBadge.js.map +1 -0
  4. package/dist/components/attendance/Attendance.d.ts +84 -0
  5. package/dist/components/attendance/Attendance.js +92 -0
  6. package/dist/components/attendance/Attendance.js.map +1 -0
  7. package/dist/components/attendance/attendance.css +95 -0
  8. package/dist/components/employee/Employee.d.ts +61 -0
  9. package/dist/components/employee/Employee.js +26 -0
  10. package/dist/components/employee/Employee.js.map +1 -0
  11. package/dist/components/employee/employee.css +147 -0
  12. package/dist/components/filters/Filters.d.ts +37 -0
  13. package/dist/components/filters/Filters.js +20 -0
  14. package/dist/components/filters/Filters.js.map +1 -0
  15. package/dist/components/filters/filters.css +16 -0
  16. package/dist/components/portal/Portal.d.ts +82 -0
  17. package/dist/components/portal/Portal.js +50 -0
  18. package/dist/components/portal/Portal.js.map +1 -0
  19. package/dist/components/portal/portal.css +292 -0
  20. package/dist/components/recruitment/Recruitment.d.ts +68 -0
  21. package/dist/components/recruitment/Recruitment.js +88 -0
  22. package/dist/components/recruitment/Recruitment.js.map +1 -0
  23. package/dist/components/recruitment/recruitment.css +131 -0
  24. package/dist/components/templates/TaskTemplateImport.d.ts +38 -0
  25. package/dist/components/templates/TaskTemplateImport.js +41 -0
  26. package/dist/components/templates/TaskTemplateImport.js.map +1 -0
  27. package/dist/components/templates/templates.css +59 -0
  28. package/dist/components/tickets/Tickets.d.ts +36 -0
  29. package/dist/components/tickets/Tickets.js +20 -0
  30. package/dist/components/tickets/Tickets.js.map +1 -0
  31. package/dist/components/tickets/tickets.css +79 -0
  32. package/dist/copy.d.ts +129 -0
  33. package/dist/copy.en.d.ts +126 -0
  34. package/dist/copy.en.js +100 -0
  35. package/dist/copy.en.js.map +1 -0
  36. package/dist/copy.js +71 -0
  37. package/dist/copy.js.map +1 -0
  38. package/dist/feedback.d.ts +2313 -0
  39. package/dist/feedback.js +7 -0
  40. package/dist/feedback.js.map +1 -0
  41. package/dist/index.d.ts +13 -0
  42. package/dist/index.js +14 -0
  43. package/dist/index.js.map +1 -0
  44. package/dist/messages.d.ts +1250 -0
  45. package/dist/messages.js +568 -0
  46. package/dist/messages.js.map +1 -0
  47. package/dist/navigation.d.ts +19 -0
  48. package/dist/navigation.js +124 -0
  49. package/dist/navigation.js.map +1 -0
  50. package/dist/statuses.d.ts +35 -0
  51. package/dist/statuses.js +120 -0
  52. package/dist/statuses.js.map +1 -0
  53. package/package.json +47 -6
  54. package/README.md +0 -3
@@ -0,0 +1,88 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { formatDate, formatNumber } from '@tmllak-erp/formatters';
4
+ import { fillCopy } from '@tmllak-erp/messages';
5
+ import { Avatar, Button, Card, KanbanBoard, Select, Textarea, directionOf, useErp } from '@tmllak-erp/ui';
6
+ import { Minus, Star, ThumbsDown, ThumbsUp, Trophy } from 'lucide-react';
7
+ import { useId, useMemo, useRef, useState } from 'react';
8
+ import { HR_COPY } from '../../copy.js';
9
+ import { HR_STATUSES } from '../../statuses.js';
10
+ import './recruitment.css';
11
+ /** Star rating (Figma «تقييم بالنجوم»): a radio group with RTL-aware arrows, or a read-only image. */
12
+ export function StarRating({ value, onChange, max = 5, label = HR_COPY.rating.label, readOnly, size = 'md', className }) {
13
+ const [hover, setHover] = useState(null);
14
+ const groupRef = useRef(null);
15
+ const shown = hover ?? value;
16
+ const stars = Array.from({ length: max }, (_, i) => i + 1);
17
+ const classes = ['erp-hr-stars', `erp-hr-stars--${size}`, readOnly && 'is-readonly', className].filter(Boolean).join(' ');
18
+ if (readOnly || !onChange) {
19
+ return (_jsx("span", { className: classes, role: "img", "aria-label": `${label}: ${fillCopy(HR_COPY.rating.value, { value: formatNumber(value, { maximumFractionDigits: 1 }), max: formatNumber(max) })}`, children: stars.map((n) => (_jsx(Star, { "aria-hidden": "true", className: n <= Math.round(value) ? 'erp-hr-stars__star is-filled' : 'erp-hr-stars__star', strokeWidth: 1.75 }, n))) }));
20
+ }
21
+ const focusStar = (n) => groupRef.current?.querySelector(`[data-value="${n}"]`)?.focus();
22
+ const onKeyDown = (event, n) => {
23
+ const rtl = directionOf(groupRef.current) === 'rtl';
24
+ const forward = event.key === 'ArrowUp' || event.key === (rtl ? 'ArrowLeft' : 'ArrowRight');
25
+ const backward = event.key === 'ArrowDown' || event.key === (rtl ? 'ArrowRight' : 'ArrowLeft');
26
+ let next = null;
27
+ if (forward)
28
+ next = n === max ? 1 : n + 1;
29
+ else if (backward)
30
+ next = n === 1 ? max : n - 1;
31
+ else if (event.key === 'Home')
32
+ next = 1;
33
+ else if (event.key === 'End')
34
+ next = max;
35
+ if (next === null)
36
+ return;
37
+ event.preventDefault();
38
+ onChange(next);
39
+ focusStar(next);
40
+ };
41
+ const tabStop = value > 0 ? value : 1;
42
+ return (_jsx("div", { ref: groupRef, role: "radiogroup", "aria-label": label, className: classes, onPointerLeave: () => setHover(null), children: stars.map((n) => (_jsx("button", { type: "button", role: "radio", "aria-checked": n === value, "aria-label": fillCopy(HR_COPY.rating.star, { value: formatNumber(n), max: formatNumber(max) }), tabIndex: n === tabStop ? 0 : -1, "data-value": n, className: "erp-hr-stars__button", onClick: () => onChange(n), onKeyDown: (e) => onKeyDown(e, n), onPointerEnter: () => setHover(n), children: _jsx(Star, { "aria-hidden": "true", className: n <= shown ? 'erp-hr-stars__star is-filled' : 'erp-hr-stars__star', strokeWidth: 1.75 }) }, n))) }));
43
+ }
44
+ /** Interviewer's recommendation (Figma «توصية المقابلة»). */
45
+ export function InterviewRecommendationSelect({ value, onChange, label = HR_COPY.recommendation.label, error, required, className }) {
46
+ const { locale } = useErp();
47
+ const options = useMemo(() => {
48
+ const copy = HR_COPY.recommendation;
49
+ return [
50
+ { value: 'strongHire', label: copy.strongHire, icon: Trophy },
51
+ { value: 'hire', label: copy.hire, icon: ThumbsUp },
52
+ { value: 'neutral', label: copy.neutral, icon: Minus },
53
+ { value: 'noHire', label: copy.noHire, icon: ThumbsDown },
54
+ ];
55
+ // HR_COPY follows the active language, so the options are rebuilt when `locale` changes.
56
+ // eslint-disable-next-line react-hooks/exhaustive-deps
57
+ }, [locale]);
58
+ return _jsx(Select, { label: label, options: options, value: value, onChange: onChange, error: error, required: required, className: className });
59
+ }
60
+ /** Interview evaluation section: a star rating per criterion, the average, notes and a recommendation. */
61
+ export function CandidateEvaluation({ candidateName, criteria, value, onChange, onSubmit, readOnly, className }) {
62
+ const errorId = useId();
63
+ const [error, setError] = useState(false);
64
+ const [saving, setSaving] = useState(false);
65
+ const scored = criteria.filter((c) => (value.scores[c.id] ?? 0) > 0);
66
+ const average = scored.length ? scored.reduce((s, c) => s + value.scores[c.id], 0) / scored.length : 0;
67
+ const update = (patch) => onChange?.({ ...value, ...patch });
68
+ const submit = async () => {
69
+ if (scored.length < criteria.length || !value.recommendation) {
70
+ setError(true);
71
+ return;
72
+ }
73
+ setError(false);
74
+ setSaving(true);
75
+ try {
76
+ await onSubmit?.(value);
77
+ }
78
+ finally {
79
+ setSaving(false);
80
+ }
81
+ };
82
+ return (_jsxs(Card, { className: ['erp-hr-evaluation', className].filter(Boolean).join(' '), title: HR_COPY.evaluation.title, subtitle: candidateName, actions: _jsxs("span", { className: "erp-hr-evaluation__average", children: [HR_COPY.evaluation.average, _jsx("strong", { className: "erp-numeric", children: formatNumber(average, { maximumFractionDigits: 1, minimumFractionDigits: 1 }) }), _jsx(StarRating, { value: average, readOnly: true, size: "sm" })] }), children: [_jsx("ul", { className: "erp-hr-evaluation__criteria", children: criteria.map((c) => (_jsxs("li", { className: "erp-hr-evaluation__criterion", children: [_jsxs("div", { children: [_jsx("p", { className: "erp-hr-evaluation__label", children: c.label }), c.description && _jsx("p", { className: "erp-hr-evaluation__description", children: c.description })] }), _jsx(StarRating, { label: c.label, value: value.scores[c.id] ?? 0, readOnly: readOnly, onChange: readOnly ? undefined : (n) => update({ scores: { ...value.scores, [c.id]: n } }) })] }, c.id))) }), readOnly ? (value.notes && _jsx("p", { className: "erp-hr-evaluation__notes", children: value.notes })) : (_jsxs("div", { className: "erp-hr-evaluation__form", children: [_jsx(InterviewRecommendationSelect, { value: value.recommendation, onChange: (recommendation) => update({ recommendation }), required: true }), _jsx(Textarea, { label: HR_COPY.evaluation.notes, value: value.notes, maxLength: 1000, onChange: (e) => update({ notes: e.target.value }) }), error && (_jsx("p", { id: errorId, role: "alert", className: "erp-hr-evaluation__error", children: HR_COPY.evaluation.incomplete })), onSubmit && (_jsx(Button, { variant: "primary", loading: saving, onClick: submit, "aria-describedby": error ? errorId : undefined, className: "erp-hr-evaluation__submit", children: HR_COPY.evaluation.submit }))] }))] }));
83
+ }
84
+ /** Candidates by recruitment stage on the shared KanbanBoard, with drag, keyboard and «نقل إلى» moves. */
85
+ export function RecruitmentPipeline({ candidates, stages = Object.keys(HR_STATUSES.recruitment), onMove, onOpen, className }) {
86
+ return (_jsx(KanbanBoard, { label: HR_COPY.pipeline.label, className: className, columns: stages.map((s) => ({ id: s, title: HR_STATUSES.recruitment[s].label, tone: HR_STATUSES.recruitment[s].tone })), items: candidates, getItemId: (c) => c.id, getColumnId: (c) => c.stage, getItemLabel: (c) => c.name, onMove: (move) => onMove(move.itemId, move.to, move), renderCard: (c) => (_jsxs("div", { className: "erp-hr-candidate", children: [_jsx(Avatar, { name: c.name, src: c.src, size: "sm", decorative: true }), _jsxs("div", { className: "erp-hr-candidate__body", children: [_jsx("p", { className: "erp-hr-candidate__name", children: onOpen ? (_jsx("button", { type: "button", className: "erp-hr-candidate__open", onClick: () => onOpen(c), "aria-label": fillCopy(HR_COPY.pipeline.open, { name: c.name }), children: c.name })) : (c.name) }), _jsx("p", { className: "erp-hr-candidate__job", children: c.jobTitle }), _jsx("p", { className: "erp-hr-candidate__date erp-numeric", children: fillCopy(HR_COPY.pipeline.applied, { date: formatDate(c.appliedAt) }) }), c.rating !== undefined && _jsx(StarRating, { value: c.rating, readOnly: true, size: "sm" })] })] })) }));
87
+ }
88
+ //# sourceMappingURL=Recruitment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Recruitment.js","sourceRoot":"","sources":["../../../src/components/recruitment/Recruitment.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAmB,MAAM,gBAAgB,CAAC;AAC3H,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACzE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAsB,MAAM,OAAO,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,WAAW,EAAiB,MAAM,gBAAgB,CAAC;AAC5D,OAAO,mBAAmB,CAAC;AAgB3B,sGAAsG;AACtG,MAAM,UAAU,UAAU,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,GAAG,CAAC,EAAE,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,GAAG,IAAI,EAAE,SAAS,EAAmB;IACtI,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAgB,IAAI,CAAC,CAAC;IACxD,MAAM,QAAQ,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAC9C,MAAM,KAAK,GAAG,KAAK,IAAI,KAAK,CAAC;IAC7B,MAAM,KAAK,GA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messages';\r\nimport { Avatar, Button, Card, KanbanBoard, Select, Textarea, directionOf, useErp, type KanbanMove } from '@tmllak-erp/ui';\r\nimport { Minus, Star, ThumbsDown, ThumbsUp, Trophy } from 'lucide-react';\r\nimport { useId, useMemo, useRef, useState, type KeyboardEvent } from 'react';\r\nimport { HR_COPY } from '../../copy';\r\nimport { HR_STATUSES, type HrStatus } from '../../statuses';\r\nimport './recruitment.css';\r\n\r\n/* ---------------------------------------------------------------- StarRating */\r\n\r\nexport interface StarRatingProps {\r\n /** 0 means not rated yet. */\r\n value: number;\r\n onChange?: (value: number) => void;\r\n max?: number;\r\n /** Accessible name, e.g. the criterion «المهارات التقنية». */\r\n label?: string;\r\n readOnly?: boolean;\r\n size?: 'sm' | 'md';\r\n className?: string;\r\n}\r\n\r\n/** Star rating (Figma «تقييم بالنجوم»): a radio group with RTL-aware arrows, or a read-only image. */\r\nexport function StarRating({ value, onChange, max = 5, label = HR_COPY.rating.label, readOnly, size = 'md', className }: StarRatingProps) {\r\n const [hover, setHover] = useState<number | null>(null);\r\n const groupRef = useRef<HTMLDivElement>(null);\r\n const shown = hover ?? value;\r\n const stars = Array.from({ length: max }, (_, i) => i + 1);\r\n const classes = ['erp-hr-stars', `erp-hr-stars--${size}`, readOnly && 'is-readonly', className].filter(Boolean).join(' ');\r\n\r\n if (readOnly || !onChange) {\r\n return (\r\n <span className={classes} role=\"img\" aria-label={`${label}: ${fillCopy(HR_COPY.rating.value, { value: formatNumber(value, { maximumFractionDigits: 1 }), max: formatNumber(max) })}`}>\r\n {stars.map((n) => (\r\n <Star key={n} aria-hidden=\"true\" className={n <= Math.round(value) ? 'erp-hr-stars__star is-filled' : 'erp-hr-stars__star'} strokeWidth={1.75} />\r\n ))}\r\n </span>\r\n );\r\n }\r\n\r\n const focusStar = (n: number) => groupRef.current?.querySelector<HTMLElement>(`[data-value=\"${n}\"]`)?.focus();\r\n const onKeyDown = (event: KeyboardEvent<HTMLButtonElement>, n: number) => {\r\n const rtl = directionOf(groupRef.current) === 'rtl';\r\n const forward = event.key === 'ArrowUp' || event.key === (rtl ? 'ArrowLeft' : 'ArrowRight');\r\n const backward = event.key === 'ArrowDown' || event.key === (rtl ? 'ArrowRight' : 'ArrowLeft');\r\n let next: number | null = null;\r\n if (forward) next = n === max ? 1 : n + 1;\r\n else if (backward) next = n === 1 ? max : n - 1;\r\n else if (event.key === 'Home') next = 1;\r\n else if (event.key === 'End') next = max;\r\n if (next === null) return;\r\n event.preventDefault();\r\n onChange(next);\r\n focusStar(next);\r\n };\r\n const tabStop = value > 0 ? value : 1;\r\n\r\n return (\r\n <div ref={groupRef} role=\"radiogroup\" aria-label={label} className={classes} onPointerLeave={() => setHover(null)}>\r\n {stars.map((n) => (\r\n <button\r\n key={n}\r\n type=\"button\"\r\n role=\"radio\"\r\n aria-checked={n === value}\r\n aria-label={fillCopy(HR_COPY.rating.star, { value: formatNumber(n), max: formatNumber(max) })}\r\n tabIndex={n === tabStop ? 0 : -1}\r\n data-value={n}\r\n className=\"erp-hr-stars__button\"\r\n onClick={() => onChange(n)}\r\n onKeyDown={(e) => onKeyDown(e, n)}\r\n onPointerEnter={() => setHover(n)}\r\n >\r\n <Star aria-hidden=\"true\" className={n <= shown ? 'erp-hr-stars__star is-filled' : 'erp-hr-stars__star'} strokeWidth={1.75} />\r\n </button>\r\n ))}\r\n </div>\r\n );\r\n}\r\n\r\n/* ---------------------------------------------------------------- InterviewRecommendationSelect */\r\n\r\nexport type InterviewRecommendation = 'strongHire' | 'hire' | 'neutral' | 'noHire';\r\n\r\nexport interface InterviewRecommendationSelectProps {\r\n value: InterviewRecommendation | null;\r\n onChange: (value: InterviewRecommendation) => void;\r\n label?: string;\r\n error?: string;\r\n required?: boolean;\r\n className?: string;\r\n}\r\n\r\n/** Interviewer's recommendation (Figma «توصية المقابلة»). */\r\nexport function InterviewRecommendationSelect({ value, onChange, label = HR_COPY.recommendation.label, error, required, className }: InterviewRecommendationSelectProps) {\r\n const { locale } = useErp();\r\n const options = useMemo(() => {\r\n const copy = HR_COPY.recommendation;\r\n return [\r\n { value: 'strongHire' as const, label: copy.strongHire, icon: Trophy },\r\n { value: 'hire' as const, label: copy.hire, icon: ThumbsUp },\r\n { value: 'neutral' as const, label: copy.neutral, icon: Minus },\r\n { value: 'noHire' as const, label: copy.noHire, icon: ThumbsDown },\r\n ];\r\n // HR_COPY follows the active language, so the options are rebuilt when `locale` changes.\r\n // eslint-disable-next-line react-hooks/exhaustive-deps\r\n }, [locale]);\r\n return <Select<InterviewRecommendation> label={label} options={options} value={value} onChange={onChange} error={error} required={required} className={className} />;\r\n}\r\n\r\n/* ---------------------------------------------------------------- CandidateEvaluation */\r\n\r\nexport interface EvaluationCriterion {\r\n id: string;\r\n label: string;\r\n description?: string;\r\n}\r\n\r\nexport interface CandidateEvaluationValue {\r\n scores: Record<string, number>;\r\n notes: string;\r\n recommendation: InterviewRecommendation | null;\r\n}\r\n\r\nexport interface CandidateEvaluationProps {\r\n candidateName: string;\r\n criteria: readonly EvaluationCriterion[];\r\n value: CandidateEvaluationValue;\r\n onChange?: (value: CandidateEvaluationValue) => void;\r\n onSubmit?: (value: CandidateEvaluationValue) => void | Promise<void>;\r\n readOnly?: boolean;\r\n className?: string;\r\n}\r\n\r\n/** Interview evaluation section: a star rating per criterion, the average, notes and a recommendation. */\r\nexport function CandidateEvaluation({ candidateName, criteria, value, onChange, onSubmit, readOnly, className }: CandidateEvaluationProps) {\r\n const errorId = useId();\r\n const [error, setError] = useState(false);\r\n const [saving, setSaving] = useState(false);\r\n const scored = criteria.filter((c) => (value.scores[c.id] ?? 0) > 0);\r\n const average = scored.length ? scored.reduce((s, c) => s + value.scores[c.id]!, 0) / scored.length : 0;\r\n const update = (patch: Partial<CandidateEvaluationValue>) => onChange?.({ ...value, ...patch });\r\n\r\n const submit = async () => {\r\n if (scored.length < criteria.length || !value.recommendation) {\r\n setError(true);\r\n return;\r\n }\r\n setError(false);\r\n setSaving(true);\r\n try {\r\n await onSubmit?.(value);\r\n } finally {\r\n setSaving(false);\r\n }\r\n };\r\n\r\n return (\r\n <Card\r\n className={['erp-hr-evaluation', className].filter(Boolean).join(' ')}\r\n title={HR_COPY.evaluation.title}\r\n subtitle={candidateName}\r\n actions={\r\n <span className=\"erp-hr-evaluation__average\">\r\n {HR_COPY.evaluation.average}\r\n <strong className=\"erp-numeric\">{formatNumber(average, { maximumFractionDigits: 1, minimumFractionDigits: 1 })}</strong>\r\n <StarRating value={average} readOnly size=\"sm\" />\r\n </span>\r\n }\r\n >\r\n <ul className=\"erp-hr-evaluation__criteria\">\r\n {criteria.map((c) => (\r\n <li key={c.id} className=\"erp-hr-evaluation__criterion\">\r\n <div>\r\n <p className=\"erp-hr-evaluation__label\">{c.label}</p>\r\n {c.description && <p className=\"erp-hr-evaluation__description\">{c.description}</p>}\r\n </div>\r\n <StarRating label={c.label} value={value.scores[c.id] ?? 0} readOnly={readOnly} onChange={readOnly ? undefined : (n) => update({ scores: { ...value.scores, [c.id]: n } })} />\r\n </li>\r\n ))}\r\n </ul>\r\n {readOnly ? (\r\n value.notes && <p className=\"erp-hr-evaluation__notes\">{value.notes}</p>\r\n ) : (\r\n <div className=\"erp-hr-evaluation__form\">\r\n <InterviewRecommendationSelect value={value.recommendation} onChange={(recommendation) => update({ recommendation })} required />\r\n <Textarea label={HR_COPY.evaluation.notes} value={value.notes} maxLength={1000} onChange={(e) => update({ notes: e.target.value })} />\r\n {error && (\r\n <p id={errorId} role=\"alert\" className=\"erp-hr-evaluation__error\">\r\n {HR_COPY.evaluation.incomplete}\r\n </p>\r\n )}\r\n {onSubmit && (\r\n <Button variant=\"primary\" loading={saving} onClick={submit} aria-describedby={error ? errorId : undefined} className=\"erp-hr-evaluation__submit\">\r\n {HR_COPY.evaluation.submit}\r\n </Button>\r\n )}\r\n </div>\r\n )}\r\n </Card>\r\n );\r\n}\r\n\r\n/* ---------------------------------------------------------------- RecruitmentPipeline */\r\n\r\nexport type RecruitmentStage = HrStatus<'recruitment'>;\r\n\r\nexport interface PipelineCandidate {\r\n id: string;\r\n name: string;\r\n src?: string;\r\n jobTitle: string;\r\n stage: RecruitmentStage;\r\n appliedAt: Date;\r\n rating?: number;\r\n}\r\n\r\nexport interface RecruitmentPipelineProps {\r\n candidates: readonly PipelineCandidate[];\r\n /** Stages shown as columns, in order (default: all recruitment stages). */\r\n stages?: readonly RecruitmentStage[];\r\n onMove: (candidateId: string, stage: RecruitmentStage, move: KanbanMove) => void;\r\n onOpen?: (candidate: PipelineCandidate) => void;\r\n className?: string;\r\n}\r\n\r\n/** Candidates by recruitment stage on the shared KanbanBoard, with drag, keyboard and «نقل إلى» moves. */\r\nexport function RecruitmentPipeline({ candidates, stages = Object.keys(HR_STATUSES.recruitment) as RecruitmentStage[], onMove, onOpen, className }: RecruitmentPipelineProps) {\r\n return (\r\n <KanbanBoard\r\n label={HR_COPY.pipeline.label}\r\n className={className}\r\n columns={stages.map((s) => ({ id: s, title: HR_STATUSES.recruitment[s].label, tone: HR_STATUSES.recruitment[s].tone }))}\r\n items={candidates}\r\n getItemId={(c) => c.id}\r\n getColumnId={(c) => c.stage}\r\n getItemLabel={(c) => c.name}\r\n onMove={(move) => onMove(move.itemId, move.to as RecruitmentStage, move)}\r\n renderCard={(c) => (\r\n <div className=\"erp-hr-candidate\">\r\n <Avatar name={c.name} src={c.src} size=\"sm\" decorative />\r\n <div className=\"erp-hr-candidate__body\">\r\n <p className=\"erp-hr-candidate__name\">\r\n {onOpen ? (\r\n <button type=\"button\" className=\"erp-hr-candidate__open\" onClick={() => onOpen(c)} aria-label={fillCopy(HR_COPY.pipeline.open, { name: c.name })}>\r\n {c.name}\r\n </button>\r\n ) : (\r\n c.name\r\n )}\r\n </p>\r\n <p className=\"erp-hr-candidate__job\">{c.jobTitle}</p>\r\n <p className=\"erp-hr-candidate__date erp-numeric\">{fillCopy(HR_COPY.pipeline.applied, { date: formatDate(c.appliedAt) })}</p>\r\n {c.rating !== undefined && <StarRating value={c.rating} readOnly size=\"sm\" />}\r\n </div>\r\n </div>\r\n )}\r\n />\r\n );\r\n}\r\n"]}
@@ -0,0 +1,131 @@
1
+ .erp-hr-stars {
2
+ --erp-hr-star: var(--erp-space-6);
3
+ display: inline-flex;
4
+ align-items: center;
5
+ gap: var(--erp-space-0-5);
6
+ }
7
+ .erp-hr-stars--sm {
8
+ --erp-hr-star: var(--erp-space-4);
9
+ }
10
+ .erp-hr-stars__button {
11
+ display: grid;
12
+ place-items: center;
13
+ margin: 0;
14
+ padding: var(--erp-space-0-5);
15
+ border: 0;
16
+ border-radius: var(--erp-radius-xs);
17
+ background: none;
18
+ cursor: pointer;
19
+ }
20
+ .erp-hr-stars__button:focus-visible {
21
+ outline: 2px solid var(--erp-color-focus-ring);
22
+ outline-offset: 1px;
23
+ }
24
+ .erp-hr-stars__star {
25
+ inline-size: var(--erp-hr-star);
26
+ block-size: var(--erp-hr-star);
27
+ color: var(--erp-color-text-disabled);
28
+ fill: none;
29
+ transition: color var(--erp-duration-fast) var(--erp-easing-standard);
30
+ }
31
+ .erp-hr-stars__star.is-filled {
32
+ color: var(--erp-status-warning-dot);
33
+ fill: currentColor;
34
+ }
35
+
36
+ .erp-hr-evaluation__average {
37
+ display: inline-flex;
38
+ align-items: center;
39
+ gap: var(--erp-space-2);
40
+ color: var(--erp-color-text-secondary);
41
+ font-size: var(--erp-font-size-caption);
42
+ }
43
+ .erp-hr-evaluation__average strong {
44
+ color: var(--erp-color-text-primary);
45
+ font-size: var(--erp-font-size-h3);
46
+ }
47
+ .erp-hr-evaluation__criteria {
48
+ display: flex;
49
+ flex-direction: column;
50
+ margin: 0;
51
+ padding: 0;
52
+ list-style: none;
53
+ }
54
+ .erp-hr-evaluation__criterion {
55
+ display: flex;
56
+ flex-wrap: wrap;
57
+ align-items: center;
58
+ justify-content: space-between;
59
+ gap: var(--erp-space-2) var(--erp-space-4);
60
+ padding-block: var(--erp-space-3);
61
+ border-block-end: 1px solid var(--erp-color-border-default);
62
+ }
63
+ .erp-hr-evaluation__label {
64
+ margin: 0;
65
+ font-size: var(--erp-font-size-body-sm);
66
+ font-weight: var(--erp-font-weight-semibold);
67
+ }
68
+ .erp-hr-evaluation__description,
69
+ .erp-hr-evaluation__notes {
70
+ margin: var(--erp-space-0-5) 0 0;
71
+ color: var(--erp-color-text-secondary);
72
+ font-size: var(--erp-font-size-caption);
73
+ line-height: var(--erp-line-height-caption);
74
+ }
75
+ .erp-hr-evaluation__form {
76
+ display: flex;
77
+ flex-direction: column;
78
+ gap: var(--erp-space-4);
79
+ margin-block-start: var(--erp-space-4);
80
+ }
81
+ .erp-hr-evaluation__error {
82
+ margin: 0;
83
+ color: var(--erp-status-danger-fg);
84
+ font-size: var(--erp-font-size-caption);
85
+ }
86
+ .erp-hr-evaluation__submit {
87
+ align-self: flex-end;
88
+ }
89
+
90
+ .erp-hr-candidate {
91
+ display: flex;
92
+ align-items: flex-start;
93
+ gap: var(--erp-space-2);
94
+ font-family: var(--erp-font-family-base);
95
+ }
96
+ .erp-hr-candidate__body {
97
+ display: flex;
98
+ flex-direction: column;
99
+ gap: var(--erp-space-0-5);
100
+ min-inline-size: 0;
101
+ }
102
+ .erp-hr-candidate__name {
103
+ margin: 0;
104
+ font-size: var(--erp-font-size-body-sm);
105
+ font-weight: var(--erp-font-weight-bold);
106
+ }
107
+ .erp-hr-candidate__open {
108
+ margin: 0;
109
+ padding: 0;
110
+ border: 0;
111
+ background: none;
112
+ color: inherit;
113
+ font: inherit;
114
+ text-align: start;
115
+ cursor: pointer;
116
+ }
117
+ .erp-hr-candidate__open:hover {
118
+ color: var(--erp-color-brand-text);
119
+ text-decoration: underline;
120
+ }
121
+ .erp-hr-candidate__open:focus-visible {
122
+ outline: 2px solid var(--erp-color-focus-ring);
123
+ outline-offset: 2px;
124
+ }
125
+ .erp-hr-candidate__job,
126
+ .erp-hr-candidate__date {
127
+ margin: 0;
128
+ color: var(--erp-color-text-secondary);
129
+ font-size: var(--erp-font-size-caption);
130
+ line-height: var(--erp-line-height-caption);
131
+ }
@@ -0,0 +1,38 @@
1
+ import './templates.css';
2
+ export interface TemplateTask {
3
+ id: string;
4
+ title: string;
5
+ /** Due date relative to the start date, in days. */
6
+ offsetDays: number;
7
+ /** Default owner, e.g. «تقنية المعلومات». */
8
+ owner?: string;
9
+ }
10
+ export interface TaskTemplate {
11
+ id: string;
12
+ name: string;
13
+ description?: string;
14
+ tasks: readonly TemplateTask[];
15
+ }
16
+ export interface TaskTemplateImportResult {
17
+ templateIds: string[];
18
+ startDate: Date;
19
+ tasks: {
20
+ templateId: string;
21
+ task: TemplateTask;
22
+ dueDate: Date;
23
+ }[];
24
+ }
25
+ export interface TaskTemplateImportProps {
26
+ open: boolean;
27
+ onClose: () => void;
28
+ templates: readonly TaskTemplate[];
29
+ onImport: (result: TaskTemplateImportResult) => void | Promise<unknown>;
30
+ /** Context in the dialog title, e.g. the new employee's name. */
31
+ description?: string;
32
+ defaultStartDate?: Date;
33
+ }
34
+ /**
35
+ * Imports onboarding/offboarding checklists from templates (Figma «استيراد قالب مهام»):
36
+ * pick templates and a start date, preview the computed due dates, then import.
37
+ */
38
+ export declare function TaskTemplateImport({ open, onClose, templates, onImport, description, defaultStartDate }: TaskTemplateImportProps): import("react").JSX.Element;
@@ -0,0 +1,41 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { formatDate, formatNumber } from '@tmllak-erp/formatters';
4
+ import { fillCopy } from '@tmllak-erp/messages';
5
+ import { addDays, Checkbox, DatePicker, FormDialog, FormGridFull, startOfDay } from '@tmllak-erp/ui';
6
+ import { useEffect, useId, useState } from 'react';
7
+ import { HR_COPY } from '../../copy.js';
8
+ import './templates.css';
9
+ /**
10
+ * Imports onboarding/offboarding checklists from templates (Figma «استيراد قالب مهام»):
11
+ * pick templates and a start date, preview the computed due dates, then import.
12
+ */
13
+ export function TaskTemplateImport({ open, onClose, templates, onImport, description = HR_COPY.templates.description, defaultStartDate }) {
14
+ const headingId = useId();
15
+ const [selected, setSelected] = useState([]);
16
+ const [startDate, setStartDate] = useState(defaultStartDate ?? startOfDay(new Date()));
17
+ const [error, setError] = useState();
18
+ useEffect(() => {
19
+ if (open) {
20
+ setSelected([]);
21
+ setError(undefined);
22
+ }
23
+ }, [open]);
24
+ const start = startDate ?? startOfDay(new Date());
25
+ const planned = templates
26
+ .filter((t) => selected.includes(t.id))
27
+ .flatMap((t) => t.tasks.map((task) => ({ templateId: t.id, task, dueDate: addDays(start, task.offsetDays) })))
28
+ .sort((a, b) => a.dueDate.getTime() - b.dueDate.getTime());
29
+ return (_jsxs(FormDialog, { open: open, onClose: onClose, title: HR_COPY.templates.title, description: description, columns: 1, submitLabel: fillCopy(HR_COPY.templates.submit, { count: formatNumber(planned.length) }), onSubmit: async () => {
30
+ if (selected.length === 0) {
31
+ setError(HR_COPY.templates.pickOne);
32
+ return;
33
+ }
34
+ await onImport({ templateIds: selected, startDate: start, tasks: planned });
35
+ onClose();
36
+ }, children: [_jsx(FormGridFull, { children: _jsxs("fieldset", { className: "erp-hr-templates__list", "aria-describedby": error ? `${headingId}-error` : undefined, children: [_jsx("legend", { className: "erp-hr-templates__legend", children: HR_COPY.templates.templates }), templates.map((t) => (_jsx(Checkbox, { label: t.name, description: [t.description, fillCopy(HR_COPY.templates.taskCount, { count: formatNumber(t.tasks.length) })].filter(Boolean).join(' · '), checked: selected.includes(t.id), onChange: (e) => {
37
+ setError(undefined);
38
+ setSelected(e.target.checked ? [...selected, t.id] : selected.filter((id) => id !== t.id));
39
+ } }, t.id))), error && (_jsx("p", { id: `${headingId}-error`, role: "alert", className: "erp-hr-templates__error", children: error }))] }) }), _jsx(FormGridFull, { children: _jsx(DatePicker, { label: HR_COPY.templates.start, value: startDate, onChange: setStartDate, required: true }) }), _jsx(FormGridFull, { children: _jsxs("section", { "aria-labelledby": headingId, className: "erp-hr-templates__preview", children: [_jsx("h3", { id: headingId, className: "erp-hr-templates__legend", children: HR_COPY.templates.preview }), planned.length === 0 ? (_jsx("p", { className: "erp-hr-templates__empty", children: HR_COPY.templates.empty })) : (_jsx("ol", { className: "erp-hr-templates__tasks", children: planned.map(({ templateId, task, dueDate }) => (_jsxs("li", { children: [_jsx("span", { className: "erp-hr-templates__title", children: task.title }), task.owner && _jsx("span", { className: "erp-hr-templates__owner", children: task.owner }), _jsx("span", { className: "erp-hr-templates__due erp-numeric", children: fillCopy(HR_COPY.templates.due, { date: formatDate(dueDate) }) })] }, `${templateId}-${task.id}`))) }))] }) })] }));
40
+ }
41
+ //# sourceMappingURL=TaskTemplateImport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TaskTemplateImport.js","sourceRoot":"","sources":["../../../src/components/templates/TaskTemplateImport.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACrG,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,iBAAiB,CAAC;AAkCzB;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW,GAAG,OAAO,CAAC,SAAS,CAAC,WAAW,EAAE,gBAAgB,EAA2B;IAC/J,MAAM,SAAS,GAAG,KAAK,EAAE,CAAC;IAC1B,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAW,EAAE,CAAC,CAAC;IACvD,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAc,gBAAgB,IAAI,UAAU,CAAC,IAAI,IAAI,EAAE,CAAC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J,CAAC","sourcesContent":["'use client';\r\n\r\nimport { formatDate, formatNumber } from '@tmllak-erp/formatters';\r\nimport { fillCopy } from '@tmllak-erp/messages';\r\nimport { addDays, Checkbox, DatePicker, FormDialog, FormGridFull, startOfDay } from '@tmllak-erp/ui';\r\nimport { useEffect, useId, useState } from 'react';\r\nimport { HR_COPY } from '../../copy';\r\nimport './templates.css';\r\n\r\nexport interface TemplateTask {\r\n id: string;\r\n title: string;\r\n /** Due date relative to the start date, in days. */\r\n offsetDays: number;\r\n /** Default owner, e.g. «تقنية المعلومات». */\r\n owner?: string;\r\n}\r\n\r\nexport interface TaskTemplate {\r\n id: string;\r\n name: string;\r\n description?: string;\r\n tasks: readonly TemplateTask[];\r\n}\r\n\r\nexport interface TaskTemplateImportResult {\r\n templateIds: string[];\r\n startDate: Date;\r\n tasks: { templateId: string; task: TemplateTask; dueDate: Date }[];\r\n}\r\n\r\nexport interface TaskTemplateImportProps {\r\n open: boolean;\r\n onClose: () => void;\r\n templates: readonly TaskTemplate[];\r\n onImport: (result: TaskTemplateImportResult) => void | Promise<unknown>;\r\n /** Context in the dialog title, e.g. the new employee's name. */\r\n description?: string;\r\n defaultStartDate?: Date;\r\n}\r\n\r\n/**\r\n * Imports onboarding/offboarding checklists from templates (Figma «استيراد قالب مهام»):\r\n * pick templates and a start date, preview the computed due dates, then import.\r\n */\r\nexport function TaskTemplateImport({ open, onClose, templates, onImport, description = HR_COPY.templates.description, defaultStartDate }: TaskTemplateImportProps) {\r\n const headingId = useId();\r\n const [selected, setSelected] = useState<string[]>([]);\r\n const [startDate, setStartDate] = useState<Date | null>(defaultStartDate ?? startOfDay(new Date()));\r\n const [error, setError] = useState<string | undefined>();\r\n\r\n useEffect(() => {\r\n if (open) {\r\n setSelected([]);\r\n setError(undefined);\r\n }\r\n }, [open]);\r\n\r\n const start = startDate ?? startOfDay(new Date());\r\n const planned = templates\r\n .filter((t) => selected.includes(t.id))\r\n .flatMap((t) => t.tasks.map((task) => ({ templateId: t.id, task, dueDate: addDays(start, task.offsetDays) })))\r\n .sort((a, b) => a.dueDate.getTime() - b.dueDate.getTime());\r\n\r\n return (\r\n <FormDialog\r\n open={open}\r\n onClose={onClose}\r\n title={HR_COPY.templates.title}\r\n description={description}\r\n columns={1}\r\n submitLabel={fillCopy(HR_COPY.templates.submit, { count: formatNumber(planned.length) })}\r\n onSubmit={async () => {\r\n if (selected.length === 0) {\r\n setError(HR_COPY.templates.pickOne);\r\n return;\r\n }\r\n await onImport({ templateIds: selected, startDate: start, tasks: planned });\r\n onClose();\r\n }}\r\n >\r\n <FormGridFull>\r\n <fieldset className=\"erp-hr-templates__list\" aria-describedby={error ? `${headingId}-error` : undefined}>\r\n <legend className=\"erp-hr-templates__legend\">{HR_COPY.templates.templates}</legend>\r\n {templates.map((t) => (\r\n <Checkbox\r\n key={t.id}\r\n label={t.name}\r\n description={[t.description, fillCopy(HR_COPY.templates.taskCount, { count: formatNumber(t.tasks.length) })].filter(Boolean).join(' · ')}\r\n checked={selected.includes(t.id)}\r\n onChange={(e) => {\r\n setError(undefined);\r\n setSelected(e.target.checked ? [...selected, t.id] : selected.filter((id) => id !== t.id));\r\n }}\r\n />\r\n ))}\r\n {error && (\r\n <p id={`${headingId}-error`} role=\"alert\" className=\"erp-hr-templates__error\">\r\n {error}\r\n </p>\r\n )}\r\n </fieldset>\r\n </FormGridFull>\r\n <FormGridFull>\r\n <DatePicker label={HR_COPY.templates.start} value={startDate} onChange={setStartDate} required />\r\n </FormGridFull>\r\n <FormGridFull>\r\n <section aria-labelledby={headingId} className=\"erp-hr-templates__preview\">\r\n <h3 id={headingId} className=\"erp-hr-templates__legend\">\r\n {HR_COPY.templates.preview}\r\n </h3>\r\n {planned.length === 0 ? (\r\n <p className=\"erp-hr-templates__empty\">{HR_COPY.templates.empty}</p>\r\n ) : (\r\n <ol className=\"erp-hr-templates__tasks\">\r\n {planned.map(({ templateId, task, dueDate }) => (\r\n <li key={`${templateId}-${task.id}`}>\r\n <span className=\"erp-hr-templates__title\">{task.title}</span>\r\n {task.owner && <span className=\"erp-hr-templates__owner\">{task.owner}</span>}\r\n <span className=\"erp-hr-templates__due erp-numeric\">{fillCopy(HR_COPY.templates.due, { date: formatDate(dueDate) })}</span>\r\n </li>\r\n ))}\r\n </ol>\r\n )}\r\n </section>\r\n </FormGridFull>\r\n </FormDialog>\r\n );\r\n}\r\n"]}
@@ -0,0 +1,59 @@
1
+ .erp-hr-templates__list {
2
+ display: flex;
3
+ flex-direction: column;
4
+ gap: var(--erp-space-3);
5
+ margin: 0;
6
+ padding: 0;
7
+ border: 0;
8
+ }
9
+ .erp-hr-templates__legend {
10
+ margin: 0 0 var(--erp-space-2);
11
+ padding: 0;
12
+ font-size: var(--erp-font-size-body-sm);
13
+ line-height: var(--erp-line-height-body-sm);
14
+ font-weight: var(--erp-font-weight-semibold);
15
+ }
16
+ .erp-hr-templates__error {
17
+ margin: 0;
18
+ color: var(--erp-status-danger-fg);
19
+ font-size: var(--erp-font-size-caption);
20
+ }
21
+ .erp-hr-templates__preview {
22
+ padding: var(--erp-space-3);
23
+ border-radius: var(--erp-radius-md);
24
+ background: var(--erp-color-bg-subtle);
25
+ }
26
+ .erp-hr-templates__empty {
27
+ margin: 0;
28
+ color: var(--erp-color-text-secondary);
29
+ font-size: var(--erp-font-size-caption);
30
+ }
31
+ .erp-hr-templates__tasks {
32
+ display: flex;
33
+ flex-direction: column;
34
+ gap: var(--erp-space-2);
35
+ max-block-size: 30vh;
36
+ margin: 0;
37
+ padding: 0;
38
+ overflow-y: auto;
39
+ list-style: none;
40
+ }
41
+ .erp-hr-templates__tasks li {
42
+ display: flex;
43
+ flex-wrap: wrap;
44
+ align-items: center;
45
+ gap: var(--erp-space-1) var(--erp-space-3);
46
+ padding: var(--erp-space-2) var(--erp-space-3);
47
+ border-radius: var(--erp-radius-sm);
48
+ background: var(--erp-color-bg-surface);
49
+ font-size: var(--erp-font-size-caption);
50
+ line-height: var(--erp-line-height-caption);
51
+ }
52
+ .erp-hr-templates__title {
53
+ flex: 1;
54
+ font-weight: var(--erp-font-weight-semibold);
55
+ }
56
+ .erp-hr-templates__owner,
57
+ .erp-hr-templates__due {
58
+ color: var(--erp-color-text-secondary);
59
+ }
@@ -0,0 +1,36 @@
1
+ import { type ConversationMessage } from '@tmllak-erp/ui';
2
+ import type { ReactNode } from 'react';
3
+ import type { HrStatus } from '../../statuses.js';
4
+ import './tickets.css';
5
+ export type TicketStatus = HrStatus<'ticket'>;
6
+ export interface HrTicket {
7
+ id: string;
8
+ subject: string;
9
+ reference: string;
10
+ category: string;
11
+ status: TicketStatus;
12
+ updatedAt: Date;
13
+ /** A reply the user has not read yet. */
14
+ unread?: boolean;
15
+ }
16
+ export interface TicketListProps {
17
+ tickets: readonly HrTicket[];
18
+ selectedId?: string;
19
+ onSelect: (ticket: HrTicket) => void;
20
+ now?: Date;
21
+ label?: string;
22
+ className?: string;
23
+ }
24
+ /** HR ticket inbox (Figma «التذاكر»): subject, reference, category, status and last update. */
25
+ export declare function TicketList({ tickets, selectedId, onSelect, now, label, className }: TicketListProps): import("react").JSX.Element;
26
+ export interface TicketDetailsProps {
27
+ ticket: HrTicket;
28
+ messages: readonly ConversationMessage[];
29
+ onSend?: (text: string) => void | Promise<void>;
30
+ onEscalate?: () => void;
31
+ /** Extra facts, e.g. the assigned specialist. */
32
+ aside?: ReactNode;
33
+ className?: string;
34
+ }
35
+ /** Ticket conversation (Figma «تفاصيل التذكرة») on the shared ConversationThread; closed tickets lock the reply box. */
36
+ export declare function TicketDetails({ ticket, messages, onSend, onEscalate, aside, className }: TicketDetailsProps): import("react").JSX.Element;
@@ -0,0 +1,20 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { formatDateTime, formatRelativeTime } from '@tmllak-erp/formatters';
4
+ import { Button, Card, ConversationThread, EmptyState, NewIndicator } from '@tmllak-erp/ui';
5
+ import { ArrowUpCircle, LifeBuoy } from 'lucide-react';
6
+ import { HR_COPY } from '../../copy.js';
7
+ import { HrStatusBadge } from '../HrStatusBadge.js';
8
+ import './tickets.css';
9
+ /** HR ticket inbox (Figma «التذاكر»): subject, reference, category, status and last update. */
10
+ export function TicketList({ tickets, selectedId, onSelect, now, label = HR_COPY.tickets.list, className }) {
11
+ if (tickets.length === 0)
12
+ return _jsx(EmptyState, { icon: LifeBuoy, title: HR_COPY.tickets.empty, size: "compact" });
13
+ return (_jsx("ul", { className: ['erp-hr-tickets', className].filter(Boolean).join(' '), "aria-label": label, children: tickets.map((t) => (_jsx("li", { children: _jsxs("button", { type: "button", className: ['erp-hr-ticket', t.id === selectedId && 'is-selected', t.unread && 'is-unread'].filter(Boolean).join(' '), "aria-current": t.id === selectedId || undefined, onClick: () => onSelect(t), children: [_jsxs("span", { className: "erp-hr-ticket__top", children: [_jsx("span", { className: "erp-hr-ticket__subject", children: t.subject }), t.unread && _jsx(NewIndicator, { label: HR_COPY.tickets.unread })] }), _jsxs("span", { className: "erp-hr-ticket__meta", children: [_jsx("bdi", { className: "erp-numeric", children: t.reference }), " \u00B7 ", t.category] }), _jsxs("span", { className: "erp-hr-ticket__bottom", children: [_jsx(HrStatusBadge, { set: "ticket", status: t.status }), _jsx("time", { className: "erp-hr-ticket__time erp-numeric", dateTime: t.updatedAt.toISOString(), title: formatDateTime(t.updatedAt), children: formatRelativeTime(t.updatedAt, now) })] })] }) }, t.id))) }));
14
+ }
15
+ /** Ticket conversation (Figma «تفاصيل التذكرة») on the shared ConversationThread; closed tickets lock the reply box. */
16
+ export function TicketDetails({ ticket, messages, onSend, onEscalate, aside, className }) {
17
+ const closed = ticket.status === 'closed' || ticket.status === 'resolved';
18
+ return (_jsx(Card, { className: ['erp-hr-ticket-details', className].filter(Boolean).join(' '), title: ticket.subject, headingLevel: 2, subtitle: _jsxs(_Fragment, { children: [_jsx("bdi", { className: "erp-numeric", children: ticket.reference }), " \u00B7 ", ticket.category] }), actions: _jsxs(_Fragment, { children: [_jsx(HrStatusBadge, { set: "ticket", status: ticket.status, size: "md" }), onEscalate && !closed && ticket.status !== 'escalated' && (_jsx(Button, { size: "sm", variant: "secondary", startIcon: ArrowUpCircle, onClick: onEscalate, children: HR_COPY.tickets.escalate }))] }), children: _jsxs("div", { className: "erp-hr-ticket-details__layout", children: [_jsx(ConversationThread, { label: HR_COPY.tickets.details, messages: messages, onSend: closed ? undefined : onSend, composerSlot: closed ? _jsx("p", { className: "erp-hr-ticket-details__closed", children: HR_COPY.tickets.closed }) : undefined }), aside && _jsx("aside", { className: "erp-hr-ticket-details__aside", children: aside })] }) }));
19
+ }
20
+ //# sourceMappingURL=Tickets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tickets.js","sourceRoot":"","sources":["../../../src/components/tickets/Tickets.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5E,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,kBAAkB,EAAE,UAAU,EAAE,YAAY,EAA4B,MAAM,gBAAgB,CAAC;AACtH,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAEvD,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,eAAe,CAAC;AAwBvB,+FAA+F;AAC/F,MAAM,UAAU,UAAU,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,EAAE,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,SAAS,EAAmB;IACzH,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,KAAC,UAAU,IAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,EAAC,SAAS,GAAG,CAAC;IAC7G,OAAO,CACL,aAAI,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C,SAAS,GAC5G,EACD,KAAK,IAAI,gBAAO,SAAS,EAAC,8BAA8B,YAAE,KAAK,GAAS,IACrE,GACD,CACR,CAAC;AACJ,CAAC","sourcesContent":["'use client';\r\n\r\nimport { formatDateTime, formatRelativeTime } from '@tmllak-erp/formatters';\r\nimport { Button, Card, ConversationThread, EmptyState, NewIndicator, type ConversationMessage } from '@tmllak-erp/ui';\r\nimport { ArrowUpCircle, LifeBuoy } 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 './tickets.css';\r\n\r\nexport type TicketStatus = HrStatus<'ticket'>;\r\n\r\nexport interface HrTicket {\r\n id: string;\r\n subject: string;\r\n reference: string;\r\n category: string;\r\n status: TicketStatus;\r\n updatedAt: Date;\r\n /** A reply the user has not read yet. */\r\n unread?: boolean;\r\n}\r\n\r\nexport interface TicketListProps {\r\n tickets: readonly HrTicket[];\r\n selectedId?: string;\r\n onSelect: (ticket: HrTicket) => void;\r\n now?: Date;\r\n label?: string;\r\n className?: string;\r\n}\r\n\r\n/** HR ticket inbox (Figma «التذاكر»): subject, reference, category, status and last update. */\r\nexport function TicketList({ tickets, selectedId, onSelect, now, label = HR_COPY.tickets.list, className }: TicketListProps) {\r\n if (tickets.length === 0) return <EmptyState icon={LifeBuoy} title={HR_COPY.tickets.empty} size=\"compact\" />;\r\n return (\r\n <ul className={['erp-hr-tickets', className].filter(Boolean).join(' ')} aria-label={label}>\r\n {tickets.map((t) => (\r\n <li key={t.id}>\r\n <button type=\"button\" className={['erp-hr-ticket', t.id === selectedId && 'is-selected', t.unread && 'is-unread'].filter(Boolean).join(' ')} aria-current={t.id === selectedId || undefined} onClick={() => onSelect(t)}>\r\n <span className=\"erp-hr-ticket__top\">\r\n <span className=\"erp-hr-ticket__subject\">{t.subject}</span>\r\n {t.unread && <NewIndicator label={HR_COPY.tickets.unread} />}\r\n </span>\r\n <span className=\"erp-hr-ticket__meta\">\r\n <bdi className=\"erp-numeric\">{t.reference}</bdi> · {t.category}\r\n </span>\r\n <span className=\"erp-hr-ticket__bottom\">\r\n <HrStatusBadge set=\"ticket\" status={t.status} />\r\n <time className=\"erp-hr-ticket__time erp-numeric\" dateTime={t.updatedAt.toISOString()} title={formatDateTime(t.updatedAt)}>\r\n {formatRelativeTime(t.updatedAt, now)}\r\n </time>\r\n </span>\r\n </button>\r\n </li>\r\n ))}\r\n </ul>\r\n );\r\n}\r\n\r\nexport interface TicketDetailsProps {\r\n ticket: HrTicket;\r\n messages: readonly ConversationMessage[];\r\n onSend?: (text: string) => void | Promise<void>;\r\n onEscalate?: () => void;\r\n /** Extra facts, e.g. the assigned specialist. */\r\n aside?: ReactNode;\r\n className?: string;\r\n}\r\n\r\n/** Ticket conversation (Figma «تفاصيل التذكرة») on the shared ConversationThread; closed tickets lock the reply box. */\r\nexport function TicketDetails({ ticket, messages, onSend, onEscalate, aside, className }: TicketDetailsProps) {\r\n const closed = ticket.status === 'closed' || ticket.status === 'resolved';\r\n return (\r\n <Card\r\n className={['erp-hr-ticket-details', className].filter(Boolean).join(' ')}\r\n title={ticket.subject}\r\n headingLevel={2}\r\n subtitle={\r\n <>\r\n <bdi className=\"erp-numeric\">{ticket.reference}</bdi> · {ticket.category}\r\n </>\r\n }\r\n actions={\r\n <>\r\n <HrStatusBadge set=\"ticket\" status={ticket.status} size=\"md\" />\r\n {onEscalate && !closed && ticket.status !== 'escalated' && (\r\n <Button size=\"sm\" variant=\"secondary\" startIcon={ArrowUpCircle} onClick={onEscalate}>\r\n {HR_COPY.tickets.escalate}\r\n </Button>\r\n )}\r\n </>\r\n }\r\n >\r\n <div className=\"erp-hr-ticket-details__layout\">\r\n <ConversationThread\r\n label={HR_COPY.tickets.details}\r\n messages={messages}\r\n onSend={closed ? undefined : onSend}\r\n composerSlot={closed ? <p className=\"erp-hr-ticket-details__closed\">{HR_COPY.tickets.closed}</p> : undefined}\r\n />\r\n {aside && <aside className=\"erp-hr-ticket-details__aside\">{aside}</aside>}\r\n </div>\r\n </Card>\r\n );\r\n}\r\n"]}
@@ -0,0 +1,79 @@
1
+ .erp-hr-tickets {
2
+ display: flex;
3
+ flex-direction: column;
4
+ gap: var(--erp-space-1);
5
+ margin: 0;
6
+ padding: 0;
7
+ list-style: none;
8
+ font-family: var(--erp-font-family-base);
9
+ }
10
+ .erp-hr-ticket {
11
+ display: flex;
12
+ flex-direction: column;
13
+ gap: var(--erp-space-1);
14
+ inline-size: 100%;
15
+ margin: 0;
16
+ padding: var(--erp-space-3);
17
+ border: 1px solid transparent;
18
+ border-radius: var(--erp-radius-md);
19
+ background: none;
20
+ color: var(--erp-color-text-primary);
21
+ font: inherit;
22
+ text-align: start;
23
+ cursor: pointer;
24
+ }
25
+ .erp-hr-ticket:hover {
26
+ background: var(--erp-color-bg-subtle);
27
+ }
28
+ .erp-hr-ticket.is-selected {
29
+ border-color: var(--erp-color-brand-default);
30
+ background: var(--erp-color-brand-subtle);
31
+ }
32
+ .erp-hr-ticket:focus-visible {
33
+ outline: 2px solid var(--erp-color-focus-ring);
34
+ outline-offset: 1px;
35
+ }
36
+ .erp-hr-ticket__top,
37
+ .erp-hr-ticket__bottom {
38
+ display: flex;
39
+ align-items: center;
40
+ justify-content: space-between;
41
+ gap: var(--erp-space-2);
42
+ }
43
+ .erp-hr-ticket__subject {
44
+ font-size: var(--erp-font-size-body-sm);
45
+ line-height: var(--erp-line-height-body-sm);
46
+ font-weight: var(--erp-font-weight-semibold);
47
+ }
48
+ .erp-hr-ticket.is-unread .erp-hr-ticket__subject {
49
+ font-weight: var(--erp-font-weight-bold);
50
+ }
51
+ .erp-hr-ticket__meta,
52
+ .erp-hr-ticket__time {
53
+ color: var(--erp-color-text-secondary);
54
+ font-size: var(--erp-font-size-caption);
55
+ line-height: var(--erp-line-height-caption);
56
+ }
57
+ .erp-hr-ticket-details__layout {
58
+ display: grid;
59
+ grid-template-columns: minmax(0, 1fr) auto;
60
+ gap: var(--erp-space-4);
61
+ }
62
+ .erp-hr-ticket-details__aside {
63
+ inline-size: var(--erp-width-sidebar);
64
+ }
65
+ .erp-hr-ticket-details__closed {
66
+ margin: 0;
67
+ padding: var(--erp-space-3) var(--erp-space-4);
68
+ border-block-start: 1px solid var(--erp-color-border-default);
69
+ color: var(--erp-color-text-secondary);
70
+ font-size: var(--erp-font-size-caption);
71
+ }
72
+ @media (max-width: 1024px) {
73
+ .erp-hr-ticket-details__layout {
74
+ grid-template-columns: minmax(0, 1fr);
75
+ }
76
+ .erp-hr-ticket-details__aside {
77
+ inline-size: auto;
78
+ }
79
+ }