Refresh HiveGrid Cloud reference snapshot

This commit is contained in:
david committed 2026-08-03 15:31:14 +02:00
1 parent 5e99e14772
commit 7f88026f79
5955 files changed
+1177325 -188362

No files matched your search

@@ -6,25 +6,29 @@
import { useState } from "react";
import { useTranslation } from "react-i18next";
import { FeatherPlus } from "@subframe/core";
import type { HrLeaveApproverVM, HrLeaveOwnVM, HrVacationRequestKind } from "@hivegrid/view-models";
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 { 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";
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: (input: { requestKind: string; approverUserId: string; startDate: string; endDate: string; note: string }) => void;
onSubmit: (values: InternalFormValues) => void;
onWithdraw: (requestId: string) => void;
onReply: (requestId: string, reply: string) => void;
onApprove: (requestId: string) => void;
@@ -38,7 +42,7 @@ export type HrLeavePageProps = {
ownVm: HrLeaveOwnVM;
approverVm: HrLeaveApproverVM;
team: readonly HrLeaveTeamAbsence[];
kinds: readonly HrVacationRequestKind[];
formDefinition: FormDefinition;
tabHref: (tab: HrLeaveTab) => string;
submitting: boolean;
actions: HrLeaveActions;
@@ -50,156 +54,104 @@ type DialogState =
| { type: "clarify"; requestId: string }
| null;
export function HrLeavePage({ tab, canApprove, ownVm, approverVm, team, kinds, tabHref, submitting, actions }: HrLeavePageProps) {
export function HrLeavePage({ tab, canApprove, ownVm, approverVm, team, formDefinition, 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>
<PageShell uiId="ui.hr.leave">
<PageHeader
icon={<FeatherCalendar className={PAGE_HEADER_ICON_CLASS} />}
title={t("hr.leave.title")}
subtitle={t("hr.leave.subtitle")}
actions={
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>
) : undefined
}
/>
<PageBody>
<div data-ui-id="ui.hr.leave.tabs">
<Tabs>
{tabs.map((entry) => (
<AppLink key={entry} href={tabHref(entry)} className="contents no-underline">
<Tabs.Item active={tab === entry}>{t(`hr.leave.tab.${entry === "approvals" ? "approvals" : entry}`)}</Tabs.Item>
</AppLink>
))}
</Tabs>
</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>
{tab === "own" ? (
<OwnList vm={ownVm} submitting={submitting} onWithdraw={actions.onWithdraw} onReply={(id) => { setText(""); setDialog({ type: "reply", requestId: id }); }} />
) : 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 === "approvals" ? (
<ApproverList
vm={approverVm}
submitting={submitting}
onApprove={actions.onApprove}
onReject={actions.onReject}
onClarify={(id) => { setText(""); setDialog({ type: "clarify", requestId: id }); }}
/>
) : null}
{tab === "own" ? (
<OwnList vm={ownVm} submitting={submitting} onWithdraw={actions.onWithdraw} onReply={(id) => { setText(""); setDialog({ type: "reply", requestId: id }); }} />
) : null}
{tab === "team" ? <TeamList team={team} /> : 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);
{/* 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>
<InternalFormRenderer
definition={formDefinition}
submitting={submitting}
uiId="ui.hr.leave.m05"
onCancel={() => setDialog(null)}
onSubmit={(values) => {
actions.onSubmit(values);
setDialog(null);
}}
>
{t("hr.action.confirm")}
</Button>
/>
</div>
</div>
</Dialog.Content>
</Dialog>
</div>
);
}
</Dialog.Content>
</Dialog>
// 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>
{/* 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>
</PageBody>
</PageShell>
);
}