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,23 +6,29 @@
import { useState } from "react";
import { useTranslation } from "react-i18next";
import { FeatherPlus } from "@subframe/core";
import { FeatherBell, FeatherPlus } from "@subframe/core";
import type { HrSickLeaveOfficeVM, HrSickLeaveOwnVM, HrSickLeaveRow } 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 { Tabs } from "~/ui/components/Tabs";
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 HrSickTab = "own" | "office";
export type HrSickActions = {
onReport: (input: { startDate: string; expectedReturnDate: string }) => void;
onReportFor: (input: { employeeUserId: string; startDate: string }) => void;
onAttach: (reportId: string, certificateFileId: string) => void;
onReport: (values: InternalFormValues) => void;
onReportFor: (values: InternalFormValues) => void;
onAttach: (reportId: string, certificate: File) => void;
onRevealCertificate: (reportId: string) => void;
onClose: (reportId: string, returnDate: string) => void;
};
@@ -32,6 +38,8 @@ export type HrSickPageProps = {
canManage: boolean;
ownVm: HrSickLeaveOwnVM;
officeVm: HrSickLeaveOfficeVM;
ownFormDefinition: FormDefinition;
officeFormDefinition: FormDefinition;
tabHref: (tab: HrSickTab) => string;
submitting: boolean;
actions: HrSickActions;
@@ -48,187 +56,177 @@ function readDate(el: HTMLElement | null, name: string): string {
return el?.querySelector<HTMLInputElement>(`input[name='${name}']`)?.value ?? "";
}
export function HrSickPage({ tab, canManage, ownVm, officeVm, tabHref, submitting, actions }: HrSickPageProps) {
export function HrSickPage({ tab, canManage, ownVm, officeVm, ownFormDefinition, officeFormDefinition, tabHref, submitting, actions }: HrSickPageProps) {
const { t } = useTranslation();
const [dialog, setDialog] = useState<DialogState>(null);
const [text, setText] = useState("");
const [certificate, setCertificate] = useState<File | null>(null);
const tabs: HrSickTab[] = canManage ? ["own", "office"] : ["own"];
const ownRows = ownVm.data?.rows ?? [];
const officeRows = officeVm.data?.rows ?? [];
return (
<div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.hr.sick">
<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.sick.title")}</span>
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">{t("hr.sick.subtitle")}</span>
<PageShell uiId="ui.hr.sick">
<PageHeader
icon={<FeatherBell className={PAGE_HEADER_ICON_CLASS} />}
title={t("hr.sick.title")}
subtitle={t("hr.sick.subtitle")}
actions={
tab === "own" ? (
<Button icon={<FeatherPlus />} onClick={() => setDialog({ type: "report" })} data-ui-id="ui.hr.sick.report">
{t("hr.sick.action.report")}
</Button>
) : (
<Button icon={<FeatherPlus />} onClick={() => setDialog({ type: "reportFor" })} data-ui-id="ui.hr.sick.reportFor">
{t("hr.sick.action.reportFor")}
</Button>
)
}
/>
<PageBody>
<div data-ui-id="ui.hr.sick.tabs">
<Tabs>
{tabs.map((entry) => (
<AppLink key={entry} href={tabHref(entry)} className="contents no-underline">
<Tabs.Item active={tab === entry}>{t(`hr.sick.tab.${entry}`)}</Tabs.Item>
</AppLink>
))}
</Tabs>
</div>
{tab === "own" ? (
<Button icon={<FeatherPlus />} onClick={() => setDialog({ type: "report" })} data-ui-id="ui.hr.sick.report">
{t("hr.sick.action.report")}
</Button>
) : (
<Button icon={<FeatherPlus />} onClick={() => setDialog({ type: "reportFor" })} data-ui-id="ui.hr.sick.reportFor">
{t("hr.sick.action.reportFor")}
</Button>
)}
</div>
ownRows.length === 0 ? (
<div data-ui-id="ui.hr.sick.own.empty">
<EmptyState title={t("hr.sick.own.empty.headline")} body={t("hr.sick.own.empty.body")} />
</div>
) : (
<div className="flex w-full flex-col gap-3" data-ui-id="ui.hr.sick.own.list">
{ownRows.map((row) => (
<SickCard
key={row.id}
row={row}
submitting={submitting}
onReveal={() => actions.onRevealCertificate(row.id)}
onAttach={() => setDialog({ type: "attach", reportId: row.id })}
onClose={() => setDialog({ type: "close", reportId: row.id })}
/>
))}
</div>
)
) : null}
<div data-ui-id="ui.hr.sick.tabs">
<Tabs>
{tabs.map((entry) => (
<a key={entry} href={tabHref(entry)} className="contents no-underline">
<Tabs.Item active={tab === entry}>{t(`hr.sick.tab.${entry}`)}</Tabs.Item>
</a>
))}
</Tabs>
</div>
{tab === "own" ? (
ownRows.length === 0 ? (
<div data-ui-id="ui.hr.sick.own.empty">
<EmptyState title={t("hr.sick.own.empty.headline")} body={t("hr.sick.own.empty.body")} />
</div>
) : (
<div className="flex w-full flex-col gap-3" data-ui-id="ui.hr.sick.own.list">
{ownRows.map((row) => (
<SickCard
key={row.id}
row={row}
submitting={submitting}
onReveal={() => actions.onRevealCertificate(row.id)}
onAttach={() => { setText(""); setDialog({ type: "attach", reportId: row.id }); }}
onClose={() => setDialog({ type: "close", reportId: row.id })}
/>
))}
</div>
)
) : null}
{tab === "office" ? (
officeRows.length === 0 ? (
<div data-ui-id="ui.hr.sick.office.empty">
<EmptyState title={t("hr.sick.office.empty.headline")} body={t("hr.sick.office.empty.body")} />
</div>
) : (
<div className="flex w-full flex-col gap-2" data-ui-id="ui.hr.sick.office.list">
{officeRows.map((row) => (
<Card key={row.id} data-row-id={row.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">{row.employeeLabel}</span>
<div className="flex items-center gap-2">
<span className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-tertiary">{row.startDateIso}</span>
<BadgeFeedback farbe="subtle-neutral" size="small">
{t(row.statusLabelKey)}
</BadgeFeedback>
{tab === "office" ? (
officeRows.length === 0 ? (
<div data-ui-id="ui.hr.sick.office.empty">
<EmptyState title={t("hr.sick.office.empty.headline")} body={t("hr.sick.office.empty.body")} />
</div>
) : (
<div className="flex w-full flex-col gap-2" data-ui-id="ui.hr.sick.office.list">
{officeRows.map((row) => (
<Card key={row.id} data-row-id={row.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">{row.employeeLabel}</span>
<div className="flex items-center gap-2">
<span className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-tertiary">{row.startDateIso}</span>
<BadgeFeedback farbe="subtle-neutral" size="small">
{t(row.statusLabelKey)}
</BadgeFeedback>
</div>
</div>
</div>
</Card>
))}
</div>
)
) : null}
</Card>
))}
</div>
)
) : null}
{/* Report dialog (own or office) */}
<Dialog open={dialog?.type === "report" || dialog?.type === "reportFor"} onOpenChange={(open) => !open && setDialog(null)}>
<Dialog.Content className="w-full max-w-[560px] p-4" data-ui-id="ui.hr.sick.reportDialog">
<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 === "reportFor" ? t("hr.sick.action.reportFor") : t("hr.sick.action.report")}
</span>
<div className="flex w-full flex-col gap-4">
{dialog?.type === "reportFor" ? (
<TextInput label={t("hr.sick.field.employee")} showLabel fillContainer>
<TextInput.Input value={text} onChange={(e) => setText(e.target.value)} />
</TextInput>
) : null}
<div className="flex flex-wrap gap-4">
<DateField label={t("hr.sick.field.start")} name="startDate" />
{dialog?.type === "report" ? <DateField label={t("hr.sick.field.expectedReturn")} name="expectedReturnDate" /> : null}
{/* Report dialog (own or office) */}
<Dialog open={dialog?.type === "report" || dialog?.type === "reportFor"} onOpenChange={(open) => !open && setDialog(null)}>
<Dialog.Content className="w-full max-w-[560px] p-4" data-ui-id="ui.hr.sick.reportDialog">
<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 === "reportFor" ? t("hr.sick.action.reportFor") : t("hr.sick.action.report")}
</span>
<InternalFormRenderer
definition={
dialog?.type === "reportFor"
? officeFormDefinition
: ownFormDefinition
}
submitting={submitting}
uiId="ui.hr.sick.m05"
onCancel={() => setDialog(null)}
onSubmit={(values) => {
if (dialog?.type === "reportFor") actions.onReportFor(values);
else actions.onReport(values);
setDialog(null);
}}
/>
</div>
</Dialog.Content>
</Dialog>
{/* Attach certificate dialog */}
<Dialog open={dialog?.type === "attach"} onOpenChange={(open) => !open && setDialog(null)}>
<Dialog.Content className="w-full max-w-[560px] p-4" data-ui-id="ui.hr.sick.attachDialog">
<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.sick.action.attachCertificate")}</span>
<label className="flex w-full flex-col gap-2 text-body-small-medium-0 text-text-neutral-secondary">
{t("hr.sick.field.certificateFileId")}
<input
type="file"
accept=".pdf,image/*"
onChange={(event) => setCertificate(event.target.files?.[0] ?? null)}
data-ui-id="ui.hr.sick.attachDialog.file"
/>
</label>
<div className="flex justify-end gap-2">
<Button variant="neutral" onClick={() => setDialog(null)}>
{t("hr.action.cancel")}
</Button>
<Button
loading={submitting}
disabled={!certificate}
onClick={() => {
if (dialog?.type === "attach" && certificate) actions.onAttach(dialog.reportId, certificate);
setCertificate(null);
setDialog(null);
}}
>
{t("hr.action.confirm")}
</Button>
</div>
</div>
<div className="flex justify-end gap-2">
<Button variant="neutral" onClick={() => setDialog(null)}>
{t("hr.action.cancel")}
</Button>
<Button
loading={submitting}
onClick={(event) => {
const el = (event.currentTarget as HTMLElement).closest("[data-ui-id='ui.hr.sick.reportDialog']");
const start = readDate(el as HTMLElement, "startDate");
if (!start) return;
if (dialog?.type === "reportFor") {
if (!text.trim()) return;
actions.onReportFor({ employeeUserId: text, startDate: start });
} else {
actions.onReport({ startDate: start, expectedReturnDate: readDate(el as HTMLElement, "expectedReturnDate") });
}
setDialog(null);
}}
data-ui-id="ui.hr.sick.reportDialog.submit"
>
{t("hr.action.confirm")}
</Button>
</div>
</div>
</Dialog.Content>
</Dialog>
</Dialog.Content>
</Dialog>
{/* Attach certificate dialog */}
<Dialog open={dialog?.type === "attach"} onOpenChange={(open) => !open && setDialog(null)}>
<Dialog.Content className="w-full max-w-[560px] p-4" data-ui-id="ui.hr.sick.attachDialog">
<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.sick.action.attachCertificate")}</span>
<TextInput label={t("hr.sick.field.certificateFileId")} showLabel fillContainer>
<TextInput.Input value={text} onChange={(e) => setText(e.target.value)} />
</TextInput>
<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 === "attach") actions.onAttach(dialog.reportId, text);
setDialog(null);
}}
>
{t("hr.action.confirm")}
</Button>
{/* Close dialog */}
<Dialog open={dialog?.type === "close"} onOpenChange={(open) => !open && setDialog(null)}>
<Dialog.Content className="w-full max-w-[560px] p-4" data-ui-id="ui.hr.sick.closeDialog">
<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.sick.action.close")}</span>
<DateField label={t("hr.sick.field.returnDate")} name="returnDate" />
<div className="flex justify-end gap-2">
<Button variant="neutral" onClick={() => setDialog(null)}>
{t("hr.action.cancel")}
</Button>
<Button
loading={submitting}
onClick={(event) => {
const el = (event.currentTarget as HTMLElement).closest("[data-ui-id='ui.hr.sick.closeDialog']");
const ret = readDate(el as HTMLElement, "returnDate");
if (!ret || dialog?.type !== "close") return;
actions.onClose(dialog.reportId, ret);
setDialog(null);
}}
>
{t("hr.action.confirm")}
</Button>
</div>
</div>
</div>
</Dialog.Content>
</Dialog>
{/* Close dialog */}
<Dialog open={dialog?.type === "close"} onOpenChange={(open) => !open && setDialog(null)}>
<Dialog.Content className="w-full max-w-[560px] p-4" data-ui-id="ui.hr.sick.closeDialog">
<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.sick.action.close")}</span>
<DateField label={t("hr.sick.field.returnDate")} name="returnDate" />
<div className="flex justify-end gap-2">
<Button variant="neutral" onClick={() => setDialog(null)}>
{t("hr.action.cancel")}
</Button>
<Button
loading={submitting}
onClick={(event) => {
const el = (event.currentTarget as HTMLElement).closest("[data-ui-id='ui.hr.sick.closeDialog']");
const ret = readDate(el as HTMLElement, "returnDate");
if (!ret || dialog?.type !== "close") return;
actions.onClose(dialog.reportId, ret);
setDialog(null);
}}
>
{t("hr.action.confirm")}
</Button>
</div>
</div>
</Dialog.Content>
</Dialog>
</div>
</Dialog.Content>
</Dialog>
</PageBody>
</PageShell>
);
}