// AK-P17b Interim-UI (AD-28) — sick-leave screen composed from ~/ui (D-HR "Krank", // archetype A2 + A4). Pure presentational: URL-driven tabs (own / office). The AU // certificate is sensitive — never rendered; a reveal action decrypts + opens it // on demand (route owns the fetch/open). Report / attach / close run through // injected actions. Final Subframe optics = tracked design-nachzug. import { useState } from "react"; import { useTranslation } from "react-i18next"; import { FeatherPlus } from "@subframe/core"; import type { HrSickLeaveOfficeVM, HrSickLeaveOwnVM, HrSickLeaveRow } from "@hivegrid/view-models"; import { BadgeFeedback } from "~/ui/components/BadgeFeedback"; import { Button } from "~/ui/components/Button"; import { Card } from "~/ui/components/Card"; import { Dialog } from "~/ui/components/Dialog"; import { EmptyState } from "~/ui/components/EmptyState"; import { Tabs } from "~/ui/components/Tabs"; import { TextInput } from "~/ui/components/TextInput"; import { DateField } from "~/components/screens/tasks/DateField"; export type HrSickTab = "own" | "office"; export type HrSickActions = { onReport: (input: { startDate: string; expectedReturnDate: string }) => void; onReportFor: (input: { employeeUserId: string; startDate: string }) => void; onAttach: (reportId: string, certificateFileId: string) => void; onRevealCertificate: (reportId: string) => void; onClose: (reportId: string, returnDate: string) => void; }; export type HrSickPageProps = { tab: HrSickTab; canManage: boolean; ownVm: HrSickLeaveOwnVM; officeVm: HrSickLeaveOfficeVM; tabHref: (tab: HrSickTab) => string; submitting: boolean; actions: HrSickActions; }; type DialogState = | { type: "report" } | { type: "reportFor" } | { type: "attach"; reportId: string } | { type: "close"; reportId: string } | null; function readDate(el: HTMLElement | null, name: string): string { return el?.querySelector(`input[name='${name}']`)?.value ?? ""; } export function HrSickPage({ tab, canManage, ownVm, officeVm, tabHref, submitting, actions }: HrSickPageProps) { const { t } = useTranslation(); const [dialog, setDialog] = useState(null); const [text, setText] = useState(""); const tabs: HrSickTab[] = canManage ? ["own", "office"] : ["own"]; const ownRows = ownVm.data?.rows ?? []; const officeRows = officeVm.data?.rows ?? []; return (
{t("hr.sick.title")} {t("hr.sick.subtitle")}
{tab === "own" ? ( ) : ( )}
{tabs.map((entry) => ( {t(`hr.sick.tab.${entry}`)} ))}
{tab === "own" ? ( ownRows.length === 0 ? (
) : (
{ownRows.map((row) => ( actions.onRevealCertificate(row.id)} onAttach={() => { setText(""); setDialog({ type: "attach", reportId: row.id }); }} onClose={() => setDialog({ type: "close", reportId: row.id })} /> ))}
) ) : null} {tab === "office" ? ( officeRows.length === 0 ? (
) : (
{officeRows.map((row) => (
{row.employeeLabel}
{row.startDateIso} {t(row.statusLabelKey)}
))}
) ) : null} {/* Report dialog (own or office) */} !open && setDialog(null)}>
{dialog?.type === "reportFor" ? t("hr.sick.action.reportFor") : t("hr.sick.action.report")}
{dialog?.type === "reportFor" ? ( setText(e.target.value)} /> ) : null}
{dialog?.type === "report" ? : null}
{/* Attach certificate dialog */} !open && setDialog(null)}>
{t("hr.sick.action.attachCertificate")} setText(e.target.value)} />
{/* Close dialog */} !open && setDialog(null)}>
{t("hr.sick.action.close")}
); } function SickCard({ row, submitting, onReveal, onAttach, onClose, }: { row: HrSickLeaveRow; submitting: boolean; onReveal: () => void; onAttach: () => void; onClose: () => void; }) { const { t } = useTranslation(); return (
{row.startDateIso} {row.returnDateIso ? ` – ${row.returnDateIso}` : ""} {row.hasCertificate ? t("hr.sick.certificate.present") : t("hr.sick.certificate.missing")}
{t(row.statusLabelKey)} {row.hasCertificate ? ( ) : ( )} {row.canClose ? ( ) : null}
); }