Update hivegrid-cloud reference to latest main

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
davidandClaude Fable 5 committed 2026-07-08 16:15:37 +02:00
1 parent e98d38e716
commit 7b21524c86
3781 files changed
+373484 -225607

No files matched your search

@@ -0,0 +1,330 @@
// 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<DialogState>(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 (
<div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.hr.leave">
<div className="flex flex-wrap items-start justify-between gap-4">
<div className="flex flex-col gap-0">
<span className="text-heading-2 font-heading-2 text-text-neutral-primary">{t("hr.leave.title")}</span>
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">
{t("hr.leave.subtitle")}
</span>
</div>
{tab === "own" && ownVm.data?.canCreate ? (
<Button icon={<FeatherPlus />} onClick={() => setDialog({ type: "new" })} data-ui-id="ui.hr.leave.new">
{t("hr.leave.action.new")}
</Button>
) : null}
</div>
<div data-ui-id="ui.hr.leave.tabs">
<Tabs>
{tabs.map((entry) => (
<a key={entry} href={tabHref(entry)} className="contents no-underline">
<Tabs.Item active={tab === entry}>{t(`hr.leave.tab.${entry === "approvals" ? "approvals" : entry}`)}</Tabs.Item>
</a>
))}
</Tabs>
</div>
{tab === "own" ? (
<OwnList vm={ownVm} submitting={submitting} onWithdraw={actions.onWithdraw} onReply={(id) => { setText(""); setDialog({ type: "reply", requestId: id }); }} />
) : null}
{tab === "approvals" ? (
<ApproverList
vm={approverVm}
submitting={submitting}
onApprove={actions.onApprove}
onReject={actions.onReject}
onClarify={(id) => { setText(""); setDialog({ type: "clarify", requestId: id }); }}
/>
) : null}
{tab === "team" ? <TeamList team={team} /> : null}
{/* New request dialog */}
<Dialog open={dialog?.type === "new"} onOpenChange={(open) => !open && setDialog(null)}>
<Dialog.Content className="w-full max-w-[560px] p-4" data-ui-id="ui.hr.leave.newDialog">
<div className="flex w-full flex-col gap-6 p-2">
<span className="text-heading-3 font-heading-3 text-text-neutral-primary">{t("hr.leave.action.new")}</span>
<div className="flex w-full flex-col gap-4">
<Select
label={t("hr.leave.field.kind")}
showLabel
value={form.requestKind}
onValueChange={(value: string) => setForm((s) => ({ ...s, requestKind: value as HrVacationRequestKind }))}
>
{kinds.map((kind) => (
<Select.Item key={kind} value={kind}>
{t(`hr.leave.kind.${kind}`)}
</Select.Item>
))}
</Select>
<div className="flex flex-wrap gap-4">
<DateField label={t("hr.leave.field.start")} name="startDate" />
<DateField label={t("hr.leave.field.end")} name="endDate" />
</div>
<TextInput label={t("hr.leave.field.approver")} showLabel fillContainer>
<TextInput.Input value={form.approverUserId} onChange={(e) => setForm((s) => ({ ...s, approverUserId: e.target.value }))} />
</TextInput>
<TextInput label={t("hr.leave.field.note")} showLabel fillContainer>
<TextInput.Input value={form.note} onChange={(e) => setForm((s) => ({ ...s, note: e.target.value }))} />
</TextInput>
</div>
<div className="flex justify-end gap-2">
<Button variant="neutral" onClick={() => setDialog(null)}>
{t("hr.action.cancel")}
</Button>
<NewRequestSubmit form={form} submitting={submitting} onSubmit={actions.onSubmit} onDone={() => setDialog(null)} />
</div>
</div>
</Dialog.Content>
</Dialog>
{/* Reply / clarify text dialog */}
<Dialog open={dialog?.type === "reply" || dialog?.type === "clarify"} onOpenChange={(open) => !open && setDialog(null)}>
<Dialog.Content className="w-full max-w-[560px] p-4" data-ui-id="ui.hr.leave.textDialog">
<div className="flex w-full flex-col gap-6 p-2">
<span className="text-heading-3 font-heading-3 text-text-neutral-primary">
{dialog?.type === "reply" ? t("hr.leave.action.reply") : t("hr.leave.action.clarify")}
</span>
<TextArea label={dialog?.type === "reply" ? t("hr.leave.field.reply") : t("hr.leave.field.question")} showLabel className="w-full">
<TextArea.Input value={text} onChange={(e) => setText(e.target.value)} />
</TextArea>
<div className="flex justify-end gap-2">
<Button variant="neutral" onClick={() => setDialog(null)}>
{t("hr.action.cancel")}
</Button>
<Button
loading={submitting}
disabled={text.trim().length === 0}
onClick={() => {
if (dialog?.type === "reply") actions.onReply(dialog.requestId, text);
if (dialog?.type === "clarify") actions.onClarify(dialog.requestId, text);
setDialog(null);
}}
>
{t("hr.action.confirm")}
</Button>
</div>
</div>
</Dialog.Content>
</Dialog>
</div>
);
}
// 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 (
<Button
loading={submitting}
onClick={(event) => {
const dialogEl = (event.currentTarget as HTMLElement).closest("[data-ui-id='ui.hr.leave.newDialog']");
const start = dialogEl?.querySelector<HTMLInputElement>("input[name='startDate']")?.value ?? "";
const end = dialogEl?.querySelector<HTMLInputElement>("input[name='endDate']")?.value ?? "";
if (!start || !end) return;
onSubmit({ requestKind: form.requestKind, approverUserId: form.approverUserId, startDate: start, endDate: end, note: form.note });
onDone();
}}
data-ui-id="ui.hr.leave.newDialog.submit"
>
{t("hr.leave.action.submit")}
</Button>
);
}
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 (
<div data-ui-id="ui.hr.leave.own.empty">
<EmptyState title={t("hr.leave.own.empty.headline")} body={t("hr.leave.own.empty.body")} />
</div>
);
}
return (
<div className="flex w-full flex-col gap-3" data-ui-id="ui.hr.leave.own.list">
{rows.map((row) => (
<Card key={row.id} data-row-id={row.id}>
<div className="flex w-full items-center justify-between gap-4">
<div className="flex flex-col gap-1">
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">{t(row.kindLabelKey)}</span>
<span className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-tertiary">
{row.startDateIso} – {row.endDateIso}
</span>
</div>
<div className="flex items-center gap-2">
<BadgeFeedback farbe="subtle-neutral" size="small">
{t(row.statusLabelKey)}
</BadgeFeedback>
{row.canReply ? (
<Button variant="tertiary" size="small" onClick={() => onReply(row.id)}>
{t("hr.leave.action.reply")}
</Button>
) : null}
{row.canWithdraw ? (
<Button variant="tertiary" size="small" loading={submitting} onClick={() => onWithdraw(row.id)}>
{t("hr.leave.action.withdraw")}
</Button>
) : null}
</div>
</div>
</Card>
))}
</div>
);
}
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 (
<div data-ui-id="ui.hr.leave.approvals.empty">
<EmptyState title={t("hr.leave.approver.empty.headline")} body={t("hr.leave.approver.empty.body")} />
</div>
);
}
return (
<div className="flex w-full flex-col gap-3" data-ui-id="ui.hr.leave.approvals.list">
{rows.map((row) => (
<Card key={row.id} data-row-id={row.id} data-conflict={row.hasConflict}>
<div className="flex w-full flex-col gap-3">
<div className="flex w-full items-center justify-between gap-4">
<div className="flex flex-col gap-1">
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">{row.employeeLabel}</span>
<span className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-tertiary">
{t(row.kindLabelKey)} · {row.startDateIso} – {row.endDateIso}
</span>
</div>
<div className="flex items-center gap-2">
<Button variant="tertiary" size="small" onClick={() => onClarify(row.id)}>
{t("hr.leave.action.clarify")}
</Button>
<Button variant="destructive" size="small" loading={submitting} onClick={() => onReject(row.id)}>
{t("hr.leave.action.reject")}
</Button>
<Button size="small" loading={submitting} onClick={() => onApprove(row.id)}>
{t("hr.leave.action.approve")}
</Button>
</div>
</div>
{row.hasConflict ? (
<Alert variant="warning" title={t(conflictHintKey, { count: row.conflictCount })} data-ui-id="ui.hr.leave.conflict" />
) : null}
</div>
</Card>
))}
</div>
);
}
function TeamList({ team }: { team: readonly HrLeaveTeamAbsence[] }) {
const { t } = useTranslation();
if (team.length === 0) {
return (
<div data-ui-id="ui.hr.leave.team.empty">
<EmptyState title={t("hr.leave.team.empty.headline")} body={t("hr.leave.team.empty.body")} />
</div>
);
}
return (
<div className="flex w-full flex-col gap-2" data-ui-id="ui.hr.leave.team.list">
{team.map((entry) => (
<Card key={`${entry.source}-${entry.id}`}>
<div className="flex w-full items-center justify-between gap-4">
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">{entry.employeeLabel}</span>
<span className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-tertiary">
{t(`hr.leave.absence.${entry.source}`)} · {entry.startIso} – {entry.endIso}
</span>
</div>
</Card>
))}
</div>
);
}