// AK-P17b Interim-UI (AD-28) — generic HR requests composed from ~/ui (D-HR // "Anträge", archetype A2 + A4/A5). Pure presentational: URL-driven tabs (own / // approvals); new (from optional template) + clarify via real Dialogs; other // actions injected (route owns the fetcher). Final Subframe optics = design-nachzug. import { useState } from "react"; import { useTranslation } from "react-i18next"; import { FeatherClipboard, FeatherPlus } from "@subframe/core"; import type { HrRequestApproverVM, HrRequestKind, HrRequestOwnVM } from "@hivegrid/view-models"; import type { FormDefinition } from "@hivegrid/form-widget"; import { PAGE_HEADER_ICON_CLASS, PageBody, PageHeader, PageShell } from "../shared/PageShell"; 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 { AppLink } from "~/components/app/AppLink"; import { InternalFormRenderer, type InternalFormValues, } from "~/modules/forms/internal/InternalFormRenderer"; export type HrRequestsTab = "own" | "approvals"; export type HrRequestTemplateOption = { id: string; title: string; requestKind: HrRequestKind; definition: FormDefinition }; export type HrRequestsActions = { onSubmit: (input: { templateId: string; values: InternalFormValues }) => void; onWithdraw: (requestId: string) => void; onApprove: (requestId: string) => void; onReject: (requestId: string) => void; onClarify: (requestId: string, question: string) => void; }; export type HrRequestsPageProps = { tab: HrRequestsTab; canApprove: boolean; ownVm: HrRequestOwnVM; approverVm: HrRequestApproverVM; templates: readonly HrRequestTemplateOption[]; defaultFormDefinition: FormDefinition; tabHref: (tab: HrRequestsTab) => string; submitting: boolean; actions: HrRequestsActions; }; const NO_TEMPLATE = "__none__"; export function HrRequestsPage({ tab, canApprove, ownVm, approverVm, templates, defaultFormDefinition, tabHref, submitting, actions }: HrRequestsPageProps) { const { t } = useTranslation(); const [newOpen, setNewOpen] = useState(false); const [clarifyFor, setClarifyFor] = useState(null); const [text, setText] = useState(""); const [templateId, setTemplateId] = useState(NO_TEMPLATE); const tabs: HrRequestsTab[] = canApprove ? ["own", "approvals"] : ["own"]; const ownRows = ownVm.data?.rows ?? []; const approverRows = approverVm.data?.rows ?? []; const selectedTemplate = templateId === NO_TEMPLATE ? null : templates.find((template) => template.id === templateId) ?? null; const activeDefinition = selectedTemplate?.definition ?? defaultFormDefinition; return ( } title={t("hr.requests.title")} subtitle={t("hr.requests.subtitle")} actions={ tab === "own" ? ( ) : undefined } />
{tabs.map((entry) => ( {t(`hr.requests.tab.${entry}`)} ))}
{tab === "own" ? ( ownRows.length === 0 ? (
) : (
{ownRows.map((row) => (
{row.title} {t(row.kindLabelKey)}
{t(row.statusLabelKey)} {row.canWithdraw ? ( ) : null}
))}
) ) : null} {tab === "approvals" ? ( approverRows.length === 0 ? (
) : (
{approverRows.map((row) => (
{row.title} {row.employeeLabel} · {t(row.kindLabelKey)}
))}
) ) : null} {/* New request dialog */}
{t("hr.requests.action.new")}
setNewOpen(false)} onSubmit={(values) => { actions.onSubmit({ templateId: selectedTemplate?.id ?? "", values, }); setNewOpen(false); setTemplateId(NO_TEMPLATE); }} />
{/* Clarify dialog */} !open && setClarifyFor(null)}>
{t("hr.requests.action.clarify")}
); }