Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
+186
-173
@@ -9,8 +9,10 @@
|
||||
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { FeatherUpload } from "@subframe/core";
|
||||
import { AppLink } from "~/components/app/AppLink";
|
||||
import { FeatherFileText, FeatherUpload } from "@subframe/core";
|
||||
import type { HrDocumentKind, HrDocumentListVM } from "@hivegrid/view-models";
|
||||
import { PAGE_HEADER_ICON_CLASS, PageBody, PageHeader, PageShell, PageToolbar } from "../shared/PageShell";
|
||||
import { Alert } from "~/ui/components/Alert";
|
||||
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
@@ -19,6 +21,7 @@ import { EmptyState } from "~/ui/components/EmptyState";
|
||||
import { Select } from "~/ui/components/Select";
|
||||
import { Table } from "~/ui/components/Table";
|
||||
import { TextInput } from "~/ui/components/TextInput";
|
||||
import { APP_TIME_ZONE } from "~/locale/format";
|
||||
|
||||
/** Injected upload state (owned by the route, which posts the file multipart). */
|
||||
export type HrDocumentUploadState = {
|
||||
@@ -71,11 +74,20 @@ export function HrMyDocumentsPage({ vm, submitting, upload, actions }: HrMyDocum
|
||||
}, [upload.status, uploadOpen]);
|
||||
|
||||
if (vm.status !== "ready" || !vm.data) {
|
||||
return <div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.hr.documents" />;
|
||||
return (
|
||||
<PageShell uiId="ui.hr.documents">
|
||||
<PageHeader
|
||||
icon={<FeatherFileText className={PAGE_HEADER_ICON_CLASS} />}
|
||||
title={t("hr.documents.title")}
|
||||
subtitle={t("hr.documents.subtitle")}
|
||||
/>
|
||||
<PageBody>{null}</PageBody>
|
||||
</PageShell>
|
||||
);
|
||||
}
|
||||
|
||||
const { rows, canUpload, emptyHeadlineKey, emptyBodyKey } = vm.data;
|
||||
const dateFormatter = new Intl.DateTimeFormat(i18n.language, { dateStyle: "medium" });
|
||||
const dateFormatter = new Intl.DateTimeFormat(i18n.language, { timeZone: APP_TIME_ZONE, dateStyle: "medium" });
|
||||
const visible = rows.filter((row) => (kind ? row.documentKind === kind : true));
|
||||
const busy = upload.status === "uploading";
|
||||
|
||||
@@ -85,181 +97,182 @@ export function HrMyDocumentsPage({ vm, submitting, upload, actions }: HrMyDocum
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.hr.documents">
|
||||
<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.documents.title")}</span>
|
||||
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">
|
||||
{t("hr.documents.subtitle")}
|
||||
</span>
|
||||
</div>
|
||||
{canUpload ? (
|
||||
<Button
|
||||
icon={<FeatherUpload />}
|
||||
onClick={() => {
|
||||
actions.onResetUpload();
|
||||
setUploadOpen(true);
|
||||
}}
|
||||
data-ui-id="ui.hr.documents.upload"
|
||||
>
|
||||
{t("hr.documents.upload.button")}
|
||||
</Button>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
<PageShell uiId="ui.hr.documents">
|
||||
<PageHeader
|
||||
icon={<FeatherFileText className={PAGE_HEADER_ICON_CLASS} />}
|
||||
title={t("hr.documents.title")}
|
||||
subtitle={t("hr.documents.subtitle")}
|
||||
actions={
|
||||
canUpload ? (
|
||||
<Button
|
||||
icon={<FeatherUpload />}
|
||||
onClick={() => {
|
||||
actions.onResetUpload();
|
||||
setUploadOpen(true);
|
||||
}}
|
||||
data-ui-id="ui.hr.documents.upload"
|
||||
>
|
||||
{t("hr.documents.upload.button")}
|
||||
</Button>
|
||||
) : undefined
|
||||
}
|
||||
/>
|
||||
{/* --- Filter bar: full-bleed page chrome, same strip as the other list
|
||||
screens. Still only shown when there is something to filter. --- */}
|
||||
{rows.length > 0 ? (
|
||||
<div className="flex flex-wrap items-end gap-4" data-ui-id="ui.hr.documents.filter">
|
||||
<Select
|
||||
className="max-w-[240px]"
|
||||
label={t("hr.documents.filter.kind")}
|
||||
showLabel
|
||||
value={kind ?? FILTER_ALL}
|
||||
onValueChange={(value: string) => setKind(value === FILTER_ALL ? null : (value as HrDocumentKind))}
|
||||
>
|
||||
<Select.Item value={FILTER_ALL}>{t("hr.documents.filter.all")}</Select.Item>
|
||||
{KINDS.map((entry) => (
|
||||
<Select.Item key={entry} value={entry}>
|
||||
{t(`hr.document.kind.${entry}`)}
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
</div>
|
||||
<PageToolbar uiId="ui.hr.documents.filter">
|
||||
<Select
|
||||
className="max-w-[240px]"
|
||||
label={t("hr.documents.filter.kind")}
|
||||
showLabel
|
||||
value={kind ?? FILTER_ALL}
|
||||
onValueChange={(value: string) => setKind(value === FILTER_ALL ? null : (value as HrDocumentKind))}
|
||||
>
|
||||
<Select.Item value={FILTER_ALL}>{t("hr.documents.filter.all")}</Select.Item>
|
||||
{KINDS.map((entry) => (
|
||||
<Select.Item key={entry} value={entry}>
|
||||
{t(`hr.document.kind.${entry}`)}
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
</PageToolbar>
|
||||
) : null}
|
||||
<PageBody>
|
||||
{rows.length === 0 ? (
|
||||
<div data-ui-id="ui.hr.documents.empty">
|
||||
<EmptyState title={t(emptyHeadlineKey)} body={t(emptyBodyKey)} />
|
||||
</div>
|
||||
) : visible.length === 0 ? (
|
||||
<EmptyState variant="no-results" title={t("hr.documents.noMatches")} body={t(emptyBodyKey)} />
|
||||
) : (
|
||||
<div className="w-full overflow-x-auto">
|
||||
<Table
|
||||
data-ui-id="ui.hr.documents.table"
|
||||
header={
|
||||
<Table.HeaderRow>
|
||||
<Table.HeaderCell>{t("hr.documents.column.title")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("hr.documents.column.kind")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("hr.documents.column.date")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("hr.documents.column.validity")}</Table.HeaderCell>
|
||||
<Table.HeaderCell> </Table.HeaderCell>
|
||||
</Table.HeaderRow>
|
||||
}
|
||||
>
|
||||
{visible.map((row) => (
|
||||
<Table.Row key={row.id} data-row-id={row.id} data-readonly={row.readOnly}>
|
||||
<Table.Cell>
|
||||
<div className="flex items-center gap-2">
|
||||
<AppLink href={row.fileHref} className="text-body-default-medium-0 font-body-default-medium-0 text-text-feedback-link-default">
|
||||
{row.title}
|
||||
</AppLink>
|
||||
{row.readOnly ? (
|
||||
<BadgeFeedback farbe="subtle-neutral" size="small">
|
||||
{t("hr.documents.status.readOnly")}
|
||||
</BadgeFeedback>
|
||||
) : null}
|
||||
</div>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<span className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary">{t(row.kindKey)}</span>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<span className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary">
|
||||
{dateFormatter.format(new Date(row.createdAtIso))}
|
||||
</span>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
{row.validUntilIso ? (
|
||||
row.isExpired ? (
|
||||
<BadgeFeedback farbe="subtle-negative" size="small">
|
||||
{t("hr.documents.status.expired")}
|
||||
</BadgeFeedback>
|
||||
) : (
|
||||
<span className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary">
|
||||
{dateFormatter.format(new Date(row.validUntilIso))}
|
||||
</span>
|
||||
)
|
||||
) : (
|
||||
<span className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-tertiary">—</span>
|
||||
)}
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
{!row.readOnly ? (
|
||||
<div className="flex justify-end">
|
||||
<Button variant="tertiary" size="small" loading={submitting} onClick={() => actions.onArchive(row.id)}>
|
||||
{t("hr.documents.action.archive")}
|
||||
</Button>
|
||||
</div>
|
||||
) : null}
|
||||
</Table.Cell>
|
||||
</Table.Row>
|
||||
))}
|
||||
</Table>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{rows.length === 0 ? (
|
||||
<div data-ui-id="ui.hr.documents.empty">
|
||||
<EmptyState title={t(emptyHeadlineKey)} body={t(emptyBodyKey)} />
|
||||
</div>
|
||||
) : visible.length === 0 ? (
|
||||
<EmptyState variant="no-results" title={t("hr.documents.noMatches")} body={t(emptyBodyKey)} />
|
||||
) : (
|
||||
<div className="w-full overflow-x-auto">
|
||||
<Table
|
||||
data-ui-id="ui.hr.documents.table"
|
||||
header={
|
||||
<Table.HeaderRow>
|
||||
<Table.HeaderCell>{t("hr.documents.column.title")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("hr.documents.column.kind")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("hr.documents.column.date")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("hr.documents.column.validity")}</Table.HeaderCell>
|
||||
<Table.HeaderCell> </Table.HeaderCell>
|
||||
</Table.HeaderRow>
|
||||
}
|
||||
>
|
||||
{visible.map((row) => (
|
||||
<Table.Row key={row.id} data-row-id={row.id} data-readonly={row.readOnly}>
|
||||
<Table.Cell>
|
||||
<div className="flex items-center gap-2">
|
||||
<a href={row.fileHref} className="text-body-default-medium-0 font-body-default-medium-0 text-text-feedback-link-default">
|
||||
{row.title}
|
||||
</a>
|
||||
{row.readOnly ? (
|
||||
<BadgeFeedback farbe="subtle-neutral" size="small">
|
||||
{t("hr.documents.status.readOnly")}
|
||||
</BadgeFeedback>
|
||||
{/* Upload dialog (self-service). The route drives the chunked upload + link. */}
|
||||
<Dialog open={uploadOpen} onOpenChange={(next) => { if (!busy) setUploadOpen(next); }}>
|
||||
<Dialog.Content className="w-full max-w-[560px] p-4" data-ui-id="ui.hr.documents.uploadDialog">
|
||||
<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.documents.upload.dialog.title")}</span>
|
||||
<div className="flex w-full flex-col gap-4">
|
||||
<TextInput label={t("hr.documents.upload.field.title")} showLabel fillContainer>
|
||||
<TextInput.Input value={form.title} onChange={(e) => setForm((s) => ({ ...s, title: e.target.value }))} data-ui-id="ui.hr.documents.upload.title" />
|
||||
</TextInput>
|
||||
<Select
|
||||
label={t("hr.documents.upload.field.kind")}
|
||||
showLabel
|
||||
value={form.documentKind}
|
||||
onValueChange={(value: string) => setForm((s) => ({ ...s, documentKind: value as HrDocumentKind }))}
|
||||
>
|
||||
{KINDS.map((entry) => (
|
||||
<Select.Item key={entry} value={entry}>
|
||||
{t(`hr.document.kind.${entry}`)}
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
<label className="flex flex-col gap-1">
|
||||
<span className="text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-tertiary">{t("hr.documents.upload.field.validUntil")}</span>
|
||||
<input
|
||||
type="date"
|
||||
value={form.validUntil}
|
||||
onChange={(e) => setForm((s) => ({ ...s, validUntil: e.target.value }))}
|
||||
className="h-9 rounded-[4px] border border-solid border-border-default bg-transparent px-3 text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-primary outline-none"
|
||||
/>
|
||||
</label>
|
||||
<label className="flex flex-col gap-1">
|
||||
<span className="text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-tertiary">{t("hr.documents.upload.field.file")}</span>
|
||||
<input
|
||||
ref={fileInputRef}
|
||||
type="file"
|
||||
onChange={(e) => setFile(e.target.files?.[0] ?? null)}
|
||||
className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary file:mr-3 file:rounded-[4px] file:border file:border-solid file:border-border-default file:bg-transparent file:px-3 file:py-1.5 file:text-text-neutral-primary"
|
||||
data-ui-id="ui.hr.documents.upload.file"
|
||||
/>
|
||||
</label>
|
||||
|
||||
{upload.status !== "idle" ? (
|
||||
<div className="flex flex-col gap-2" data-ui-id="ui.hr.documents.upload.progress" data-status={upload.status}>
|
||||
{upload.status === "error" ? (
|
||||
<Alert variant="error" textSize="small" description={t(upload.errorKey ?? "hr.documents.upload.error.generic")} notDismissible />
|
||||
) : upload.status === "uploading" ? (
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary">{t("hr.documents.upload.status.uploading")}</span>
|
||||
) : null}
|
||||
</div>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<span className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary">{t(row.kindKey)}</span>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<span className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary">
|
||||
{dateFormatter.format(new Date(row.createdAtIso))}
|
||||
</span>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
{row.validUntilIso ? (
|
||||
row.isExpired ? (
|
||||
<BadgeFeedback farbe="subtle-negative" size="small">
|
||||
{t("hr.documents.status.expired")}
|
||||
</BadgeFeedback>
|
||||
) : (
|
||||
<span className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary">
|
||||
{dateFormatter.format(new Date(row.validUntilIso))}
|
||||
</span>
|
||||
)
|
||||
) : (
|
||||
<span className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-tertiary">—</span>
|
||||
)}
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
{!row.readOnly ? (
|
||||
<div className="flex justify-end">
|
||||
<Button variant="tertiary" size="small" loading={submitting} onClick={() => actions.onArchive(row.id)}>
|
||||
{t("hr.documents.action.archive")}
|
||||
</Button>
|
||||
</div>
|
||||
) : null}
|
||||
</Table.Cell>
|
||||
</Table.Row>
|
||||
))}
|
||||
</Table>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Upload dialog (self-service). The route drives the chunked upload + link. */}
|
||||
<Dialog open={uploadOpen} onOpenChange={(next) => { if (!busy) setUploadOpen(next); }}>
|
||||
<Dialog.Content className="w-full max-w-[560px] p-4" data-ui-id="ui.hr.documents.uploadDialog">
|
||||
<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.documents.upload.dialog.title")}</span>
|
||||
<div className="flex w-full flex-col gap-4">
|
||||
<TextInput label={t("hr.documents.upload.field.title")} showLabel fillContainer>
|
||||
<TextInput.Input value={form.title} onChange={(e) => setForm((s) => ({ ...s, title: e.target.value }))} data-ui-id="ui.hr.documents.upload.title" />
|
||||
</TextInput>
|
||||
<Select
|
||||
label={t("hr.documents.upload.field.kind")}
|
||||
showLabel
|
||||
value={form.documentKind}
|
||||
onValueChange={(value: string) => setForm((s) => ({ ...s, documentKind: value as HrDocumentKind }))}
|
||||
>
|
||||
{KINDS.map((entry) => (
|
||||
<Select.Item key={entry} value={entry}>
|
||||
{t(`hr.document.kind.${entry}`)}
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
<label className="flex flex-col gap-1">
|
||||
<span className="text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-tertiary">{t("hr.documents.upload.field.validUntil")}</span>
|
||||
<input
|
||||
type="date"
|
||||
value={form.validUntil}
|
||||
onChange={(e) => setForm((s) => ({ ...s, validUntil: e.target.value }))}
|
||||
className="h-9 rounded-[4px] border border-solid border-border-default bg-transparent px-3 text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-primary outline-none"
|
||||
/>
|
||||
</label>
|
||||
<label className="flex flex-col gap-1">
|
||||
<span className="text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-tertiary">{t("hr.documents.upload.field.file")}</span>
|
||||
<input
|
||||
ref={fileInputRef}
|
||||
type="file"
|
||||
onChange={(e) => setFile(e.target.files?.[0] ?? null)}
|
||||
className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary file:mr-3 file:rounded-[4px] file:border file:border-solid file:border-border-default file:bg-transparent file:px-3 file:py-1.5 file:text-text-neutral-primary"
|
||||
data-ui-id="ui.hr.documents.upload.file"
|
||||
/>
|
||||
</label>
|
||||
|
||||
{upload.status !== "idle" ? (
|
||||
<div className="flex flex-col gap-2" data-ui-id="ui.hr.documents.upload.progress" data-status={upload.status}>
|
||||
{upload.status === "error" ? (
|
||||
<Alert variant="error" textSize="small" description={t(upload.errorKey ?? "hr.documents.upload.error.generic")} notDismissible />
|
||||
) : upload.status === "uploading" ? (
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary">{t("hr.documents.upload.status.uploading")}</span>
|
||||
) : null}
|
||||
</div>
|
||||
) : null}
|
||||
) : null}
|
||||
</div>
|
||||
<div className="flex justify-end gap-2">
|
||||
<Button variant="neutral" disabled={busy} onClick={() => setUploadOpen(false)}>
|
||||
{t("hr.action.cancel")}
|
||||
</Button>
|
||||
<Button loading={busy} disabled={!file || form.title.trim().length === 0} onClick={submitUpload} data-ui-id="ui.hr.documents.upload.submit">
|
||||
{t("hr.documents.upload.submit")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex justify-end gap-2">
|
||||
<Button variant="neutral" disabled={busy} onClick={() => setUploadOpen(false)}>
|
||||
{t("hr.action.cancel")}
|
||||
</Button>
|
||||
<Button loading={busy} disabled={!file || form.title.trim().length === 0} onClick={submitUpload} data-ui-id="ui.hr.documents.upload.submit">
|
||||
{t("hr.documents.upload.submit")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Dialog.Content>
|
||||
</Dialog>
|
||||
</div>
|
||||
</Dialog.Content>
|
||||
</Dialog>
|
||||
</PageBody>
|
||||
</PageShell>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user