// 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 { FeatherCalendar, FeatherPlus } from "@subframe/core"; import type { HrLeaveApproverVM, HrLeaveOwnVM } from "@hivegrid/view-models"; import type { FormDefinition } from "@hivegrid/form-widget"; import { PAGE_HEADER_ICON_CLASS, PageBody, PageHeader, PageShell } from "../shared/PageShell"; 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 { Tabs } from "~/ui/components/Tabs"; import { TextArea } from "~/ui/components/TextArea"; import { AppLink } from "~/components/app/AppLink"; import { InternalFormRenderer, type InternalFormValues, } from "~/modules/forms/internal/InternalFormRenderer"; 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: (values: InternalFormValues) => 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[]; formDefinition: FormDefinition; 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, formDefinition, tabHref, submitting, actions }: HrLeavePageProps) { const { t } = useTranslation(); const [dialog, setDialog] = useState(null); const [text, setText] = useState(""); const tabs: HrLeaveTab[] = canApprove ? ["own", "approvals", "team"] : ["own", "team"]; return ( } title={t("hr.leave.title")} subtitle={t("hr.leave.subtitle")} actions={ tab === "own" && ownVm.data?.canCreate ? ( ) : undefined } />
{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")} setDialog(null)} onSubmit={(values) => { actions.onSubmit(values); setDialog(null); }} />
{/* Reply / clarify text dialog */} !open && setDialog(null)}>
{dialog?.type === "reply" ? t("hr.leave.action.reply") : t("hr.leave.action.clarify")}
); } 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}
))}
); }