// AK-P17b Interim-UI (AD-28) — leave/vacation screen composed from ~/ui (D-HR // "Urlaub", archetype A2 + A4/A5). Pure presentational: URL-driven tabs (own / // approvals / team); new request + reply + clarify run through injected actions // (route owns the fetcher). Overlap conflicts surface as an inline warning. Final // Subframe optics = tracked design-nachzug. import { useState } from "react"; import { useTranslation } from "react-i18next"; import { FeatherPlus } from "@subframe/core"; import type { HrLeaveApproverVM, HrLeaveOwnVM, HrVacationRequestKind } from "@hivegrid/view-models"; import { Alert } from "~/ui/components/Alert"; 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 { Select } from "~/ui/components/Select"; import { Tabs } from "~/ui/components/Tabs"; import { TextArea } from "~/ui/components/TextArea"; import { TextInput } from "~/ui/components/TextInput"; import { DateField } from "~/components/screens/tasks/DateField"; export type HrLeaveTab = "own" | "approvals" | "team"; export type HrLeaveTeamAbsence = { id: string; employeeLabel: string; source: string; kind: string; startIso: string; endIso: string }; export type HrLeaveActions = { onSubmit: (input: { requestKind: string; approverUserId: string; startDate: string; endDate: string; note: string }) => void; onWithdraw: (requestId: string) => void; onReply: (requestId: string, reply: string) => void; onApprove: (requestId: string) => void; onReject: (requestId: string) => void; onClarify: (requestId: string, question: string) => void; }; export type HrLeavePageProps = { tab: HrLeaveTab; canApprove: boolean; ownVm: HrLeaveOwnVM; approverVm: HrLeaveApproverVM; team: readonly HrLeaveTeamAbsence[]; kinds: readonly HrVacationRequestKind[]; tabHref: (tab: HrLeaveTab) => string; submitting: boolean; actions: HrLeaveActions; }; type DialogState = | { type: "new" } | { type: "reply"; requestId: string } | { type: "clarify"; requestId: string } | null; export function HrLeavePage({ tab, canApprove, ownVm, approverVm, team, kinds, tabHref, submitting, actions }: HrLeavePageProps) { const { t } = useTranslation(); const [dialog, setDialog] = useState(null); const [form, setForm] = useState({ requestKind: kinds[0] ?? "vacation", approverUserId: "", startDate: "", endDate: "", note: "" }); const [text, setText] = useState(""); const tabs: HrLeaveTab[] = canApprove ? ["own", "approvals", "team"] : ["own", "team"]; return (
{t("hr.leave.title")} {t("hr.leave.subtitle")}
{tab === "own" && ownVm.data?.canCreate ? ( ) : null}
{tabs.map((entry) => ( {t(`hr.leave.tab.${entry === "approvals" ? "approvals" : entry}`)} ))}
{tab === "own" ? ( { setText(""); setDialog({ type: "reply", requestId: id }); }} /> ) : null} {tab === "approvals" ? ( { setText(""); setDialog({ type: "clarify", requestId: id }); }} /> ) : null} {tab === "team" ? : null} {/* New request dialog */} !open && setDialog(null)}>
{t("hr.leave.action.new")}
setForm((s) => ({ ...s, approverUserId: e.target.value }))} /> setForm((s) => ({ ...s, note: e.target.value }))} />
setDialog(null)} />
{/* Reply / clarify text dialog */} !open && setDialog(null)}>
{dialog?.type === "reply" ? t("hr.leave.action.reply") : t("hr.leave.action.clarify")}
); } // The DateField uses native inputs (uncontrolled); read them from the dialog DOM on submit. function NewRequestSubmit({ form, submitting, onSubmit, onDone, }: { form: { requestKind: string; approverUserId: string; note: string; startDate: string; endDate: string }; submitting: boolean; onSubmit: HrLeaveActions["onSubmit"]; onDone: () => void; }) { const { t } = useTranslation(); return ( ); } function OwnList({ vm, submitting, onWithdraw, onReply }: { vm: HrLeaveOwnVM; submitting: boolean; onWithdraw: (id: string) => void; onReply: (id: string) => void }) { const { t } = useTranslation(); if (vm.status !== "ready" || !vm.data) return null; const { rows } = vm.data; if (rows.length === 0) { return (
); } return (
{rows.map((row) => (
{t(row.kindLabelKey)} {row.startDateIso} – {row.endDateIso}
{t(row.statusLabelKey)} {row.canReply ? ( ) : null} {row.canWithdraw ? ( ) : null}
))}
); } function ApproverList({ vm, submitting, onApprove, onReject, onClarify, }: { vm: HrLeaveApproverVM; submitting: boolean; onApprove: (id: string) => void; onReject: (id: string) => void; onClarify: (id: string) => void; }) { const { t } = useTranslation(); if (vm.status !== "ready" || !vm.data) return null; const { rows, conflictHintKey } = vm.data; if (rows.length === 0) { return (
); } return (
{rows.map((row) => (
{row.employeeLabel} {t(row.kindLabelKey)} · {row.startDateIso} – {row.endDateIso}
{row.hasConflict ? ( ) : null}
))}
); } function TeamList({ team }: { team: readonly HrLeaveTeamAbsence[] }) { const { t } = useTranslation(); if (team.length === 0) { return (
); } return (
{team.map((entry) => (
{entry.employeeLabel} {t(`hr.leave.absence.${entry.source}`)} · {entry.startIso} – {entry.endIso}
))}
); }