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,161 @@
// AK-P17b Interim-UI (AD-28) — announcements editor (admin) composed from ~/ui
// (D-HR "Ankündigungen verwalten", archetype A2 + A4/A5). Pure presentational:
// create (audience, ack, pin, schedule/expiry) via a real Dialog; archive via the
// injected action. Final Subframe optics = tracked design-nachzug.
import { type MouseEvent, useState } from "react";
import { useTranslation } from "react-i18next";
import { FeatherPin, FeatherPlus } from "@subframe/core";
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
import { Button } from "~/ui/components/Button";
import { Card } from "~/ui/components/Card";
import { Checkbox } from "~/ui/components/Checkbox";
import { Dialog } from "~/ui/components/Dialog";
import { EmptyState } from "~/ui/components/EmptyState";
import { Select } from "~/ui/components/Select";
import { TextArea } from "~/ui/components/TextArea";
import { TextInput } from "~/ui/components/TextInput";
import { DateField } from "~/components/screens/tasks/DateField";
export type AdminAnnouncementRow = {
id: string;
title: string;
audienceKind: string;
requiresAck: boolean;
pinned: boolean;
publishedIso: string | null;
};
export type HrAdminAnnouncementsActions = {
onCreate: (input: {
title: string;
body: string;
audienceKind: string;
audienceRef: string;
requiresAck: boolean;
pinned: boolean;
publishAt: string;
expiresAt: string;
}) => void;
onArchive: (announcementId: string) => void;
};
export type HrAdminAnnouncementsPageProps = {
rows: readonly AdminAnnouncementRow[];
audiences: readonly string[];
submitting: boolean;
actions: HrAdminAnnouncementsActions;
};
const EMPTY = { title: "", body: "", audienceRef: "", requiresAck: false, pinned: false };
export function HrAdminAnnouncementsPage({ rows, audiences, submitting, actions }: HrAdminAnnouncementsPageProps) {
const { t } = useTranslation();
const [open, setOpen] = useState(false);
const [form, setForm] = useState({ ...EMPTY, audienceKind: audiences[0] ?? "all" });
function submit(event: MouseEvent<HTMLButtonElement>) {
const el = (event.currentTarget as HTMLElement).closest("[data-ui-id='ui.hr.admin.announcements.new']");
const publishAt = el?.querySelector<HTMLInputElement>("input[name='publishAt']")?.value ?? "";
const expiresAt = el?.querySelector<HTMLInputElement>("input[name='expiresAt']")?.value ?? "";
if (!form.title.trim() || !form.body.trim()) return;
actions.onCreate({ ...form, publishAt, expiresAt });
setOpen(false);
setForm({ ...EMPTY, audienceKind: audiences[0] ?? "all" });
}
return (
<div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.hr.admin.announcements">
<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.announcements.admin.title")}</span>
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">
{t("hr.announcements.admin.subtitle")}
</span>
</div>
<Button icon={<FeatherPlus />} onClick={() => setOpen(true)} data-ui-id="ui.hr.admin.announcements.newBtn">
{t("hr.announcements.action.create")}
</Button>
</div>
{rows.length === 0 ? (
<div data-ui-id="ui.hr.admin.announcements.empty">
<EmptyState title={t("hr.announcements.admin.empty.headline")} body={t("hr.announcements.admin.empty.body")} />
</div>
) : (
<div className="flex w-full flex-col gap-2" data-ui-id="ui.hr.admin.announcements.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 items-center gap-2">
{row.pinned ? <FeatherPin className="text-body-default-regular-0 font-body-default-regular-0 text-icon-neutral-tertiary" /> : null}
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">{row.title}</span>
<BadgeFeedback farbe="subtle-neutral" size="small">
{t(`hr.audience.${row.audienceKind}`)}
</BadgeFeedback>
{row.requiresAck ? (
<BadgeFeedback farbe="subtle-warning" size="small">
{t("hr.announcements.ackRequired")}
</BadgeFeedback>
) : null}
</div>
<Button variant="tertiary" size="small" loading={submitting} onClick={() => actions.onArchive(row.id)}>
{t("hr.announcements.action.archive")}
</Button>
</div>
</Card>
))}
</div>
)}
<Dialog open={open} onOpenChange={setOpen}>
<Dialog.Content className="w-full max-w-[720px] p-4" data-ui-id="ui.hr.admin.announcements.new">
<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.announcements.action.create")}</span>
<div className="flex w-full flex-col gap-4">
<TextInput label={t("hr.announcements.field.title")} showLabel fillContainer>
<TextInput.Input value={form.title} onChange={(e) => setForm((s) => ({ ...s, title: e.target.value }))} />
</TextInput>
<TextArea label={t("hr.announcements.field.body")} showLabel className="w-full">
<TextArea.Input value={form.body} onChange={(e) => setForm((s) => ({ ...s, body: e.target.value }))} />
</TextArea>
<div className="flex flex-wrap gap-4">
<Select
label={t("hr.announcements.field.audience")}
showLabel
value={form.audienceKind}
onValueChange={(value: string) => setForm((s) => ({ ...s, audienceKind: value }))}
>
{audiences.map((a) => (
<Select.Item key={a} value={a}>
{t(`hr.audience.${a}`)}
</Select.Item>
))}
</Select>
<TextInput label={t("hr.announcements.field.audienceRef")} showLabel>
<TextInput.Input value={form.audienceRef} onChange={(e) => setForm((s) => ({ ...s, audienceRef: e.target.value }))} />
</TextInput>
</div>
<div className="flex flex-wrap gap-4">
<DateField label={t("hr.announcements.field.publishAt")} name="publishAt" />
<DateField label={t("hr.announcements.field.expiresAt")} name="expiresAt" />
</div>
<div className="flex flex-wrap gap-4">
<Checkbox label={t("hr.announcements.field.requiresAck")} checked={form.requiresAck} onCheckedChange={(c: boolean) => setForm((s) => ({ ...s, requiresAck: c }))} />
<Checkbox label={t("hr.announcements.field.pin")} checked={form.pinned} onCheckedChange={(c: boolean) => setForm((s) => ({ ...s, pinned: c }))} />
</div>
</div>
<div className="flex justify-end gap-2">
<Button variant="neutral" onClick={() => setOpen(false)}>
{t("hr.action.cancel")}
</Button>
<Button loading={submitting} disabled={!form.title.trim() || !form.body.trim()} onClick={submit} data-ui-id="ui.hr.admin.announcements.new.submit">
{t("hr.announcements.action.create")}
</Button>
</div>
</div>
</Dialog.Content>
</Dialog>
</div>
);
}
@@ -0,0 +1,94 @@
// AK-P17a Interim-UI (AD-28) — tenant-wide password-safe ADMIN view composed from
// ~/ui (D-HR "Passwort-Safe-Verwaltung", archetype A2/A6). Pure presentational:
// lists ALL tenant vaults with entry/access counts for oversight but NEVER grants
// content access (no secret values reachable here). Archive runs through the
// injected action. Final Subframe optics = tracked design-nachzug.
import { useTranslation } from "react-i18next";
import type { AdminVaultListVM } from "@hivegrid/view-models";
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
import { Button } from "~/ui/components/Button";
import { EmptyState } from "~/ui/components/EmptyState";
import { Table } from "~/ui/components/Table";
export type HrAdminPasswordSafeActions = {
onArchiveVault: (vaultId: string) => void;
};
export type HrAdminPasswordSafePageProps = {
vm: AdminVaultListVM;
submitting: boolean;
actions: HrAdminPasswordSafeActions;
};
export function HrAdminPasswordSafePage({ vm, submitting, actions }: HrAdminPasswordSafePageProps) {
const { t } = useTranslation();
if (vm.status !== "ready" || !vm.data) {
return <div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.hr.admin.passwordSafe" />;
}
const { rows, emptyHeadlineKey, emptyBodyKey } = vm.data;
return (
<div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.hr.admin.passwordSafe">
<div className="flex flex-col gap-0">
<span className="text-heading-2 font-heading-2 text-text-neutral-primary">{t("hr.admin.passwordSafe.title")}</span>
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">
{t("hr.admin.passwordSafe.subtitle")}
</span>
</div>
{rows.length === 0 ? (
<div data-ui-id="ui.hr.admin.passwordSafe.empty">
<EmptyState title={t(emptyHeadlineKey)} body={t(emptyBodyKey)} />
</div>
) : (
<div className="w-full overflow-x-auto">
<Table
data-ui-id="ui.hr.admin.passwordSafe.table"
header={
<Table.HeaderRow>
<Table.HeaderCell>{t("hr.admin.passwordSafe.column.name")}</Table.HeaderCell>
<Table.HeaderCell>{t("hr.admin.passwordSafe.column.entries")}</Table.HeaderCell>
<Table.HeaderCell>{t("hr.admin.passwordSafe.column.access")}</Table.HeaderCell>
<Table.HeaderCell>{t("hr.admin.passwordSafe.column.status")}</Table.HeaderCell>
<Table.HeaderCell> </Table.HeaderCell>
</Table.HeaderRow>
}
>
{rows.map((row) => (
<Table.Row key={row.id} data-row-id={row.id} data-archived={row.archived}>
<Table.Cell>
<a href={row.detailHref} className="text-body-default-medium-0 font-body-default-medium-0 text-text-feedback-link-default">
{row.name}
</a>
</Table.Cell>
<Table.Cell>
<span className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary">{row.entryCount}</span>
</Table.Cell>
<Table.Cell>
<span className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary">{row.accessCount}</span>
</Table.Cell>
<Table.Cell>
<BadgeFeedback farbe={row.archived ? "subtle-neutral" : "subtle-positive"} size="small">
{row.archived ? t("hr.admin.passwordSafe.status.archived") : t("hr.admin.passwordSafe.status.active")}
</BadgeFeedback>
</Table.Cell>
<Table.Cell>
{!row.archived ? (
<div className="flex justify-end">
<Button variant="tertiary" size="small" loading={submitting} onClick={() => actions.onArchiveVault(row.id)}>
{t("hr.admin.passwordSafe.action.archive")}
</Button>
</div>
) : null}
</Table.Cell>
</Table.Row>
))}
</Table>
</div>
)}
</div>
);
}
@@ -0,0 +1,168 @@
// AK-P17b Interim-UI (AD-28) — payslip administration composed from ~/ui (D-HR
// "Lohnabrechnungen verwalten", archetype A2 + A4). Pure presentational: bulk
// auto-match preview (hard/soft/none confidence) with a per-row confirm, plus the
// existing-payslips list. Match/confirm run through injected actions (route owns
// the fetcher). Final Subframe optics = tracked design-nachzug.
import { useState } from "react";
import { useTranslation } from "react-i18next";
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
import { Button } from "~/ui/components/Button";
import { Card } from "~/ui/components/Card";
import { EmptyState } from "~/ui/components/EmptyState";
import { Table } from "~/ui/components/Table";
import { TextArea } from "~/ui/components/TextArea";
import { TextInput } from "~/ui/components/TextInput";
export type PayslipPreviewRow = {
fileId: string;
fileName: string;
confidence: string;
confidenceKey: string;
confidenceTone: string;
employeeUserId: string | null;
employeeLabel: string | null;
};
export type PayslipAdminRow = { id: string; employeeLabel: string; periodLabel: string; isRead: boolean };
export type HrAdminPayslipsActions = {
onMatch: (input: { periodYear: string; periodMonth: string; files: string }) => void;
onConfirm: (input: { fileId: string; employeeUserId: string; periodYear: string; periodMonth: string }) => void;
};
export type HrAdminPayslipsPageProps = {
rows: readonly PayslipAdminRow[];
preview: readonly PayslipPreviewRow[];
period: { year: string; month: string };
submitting: boolean;
actions: HrAdminPayslipsActions;
};
function toneFarbe(tone: string): "subtle-positive" | "subtle-warning" | "subtle-neutral" {
if (tone === "success") return "subtle-positive";
if (tone === "warning") return "subtle-warning";
return "subtle-neutral";
}
export function HrAdminPayslipsPage({ rows, preview, period, submitting, actions }: HrAdminPayslipsPageProps) {
const { t } = useTranslation();
const [year, setYear] = useState("");
const [month, setMonth] = useState("");
const [files, setFiles] = useState("");
const [assignees, setAssignees] = useState<Record<string, string>>({});
return (
<div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.hr.admin.payslips">
<div className="flex flex-col gap-0">
<span className="text-heading-2 font-heading-2 text-text-neutral-primary">{t("hr.payslips.admin.title")}</span>
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">{t("hr.payslips.admin.subtitle")}</span>
</div>
{/* Bulk auto-match */}
<Card>
<div className="flex w-full flex-col gap-4" data-ui-id="ui.hr.admin.payslips.match">
<div className="flex flex-wrap gap-4">
<TextInput label={t("hr.payslips.field.year")} showLabel>
<TextInput.Input type="number" value={year} onChange={(e) => setYear(e.target.value)} />
</TextInput>
<TextInput label={t("hr.payslips.field.month")} showLabel>
<TextInput.Input type="number" value={month} onChange={(e) => setMonth(e.target.value)} />
</TextInput>
</div>
<TextArea label={t("hr.payslips.field.filesHint")} showLabel className="w-full">
<TextArea.Input value={files} onChange={(e) => setFiles(e.target.value)} />
</TextArea>
<div className="flex justify-end">
<Button
variant="secondary"
loading={submitting}
disabled={!year.trim() || !month.trim() || !files.trim()}
onClick={() => actions.onMatch({ periodYear: year, periodMonth: month, files })}
data-ui-id="ui.hr.admin.payslips.match.submit"
>
{t("hr.payslips.action.match")}
</Button>
</div>
</div>
</Card>
{preview.length > 0 ? (
<div className="flex w-full flex-col gap-3" data-ui-id="ui.hr.admin.payslips.preview">
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">{t("hr.payslips.match.title")}</span>
{preview.map((row) => (
<Card key={row.fileId} data-row-id={row.fileId} data-confidence={row.confidence}>
<div className="flex w-full flex-col gap-3">
<div className="flex items-center justify-between gap-3">
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">{row.fileName}</span>
<BadgeFeedback farbe={toneFarbe(row.confidenceTone)} size="small">
{t(row.confidenceKey)}
</BadgeFeedback>
</div>
<div className="flex items-end gap-2">
<TextInput label={t("hr.payslips.field.employee")} showLabel fillContainer className="max-w-none">
<TextInput.Input
value={assignees[row.fileId] ?? row.employeeUserId ?? ""}
onChange={(e) => setAssignees((s) => ({ ...s, [row.fileId]: e.target.value }))}
/>
</TextInput>
<Button
loading={submitting}
onClick={() =>
actions.onConfirm({
fileId: row.fileId,
employeeUserId: assignees[row.fileId] ?? row.employeeUserId ?? "",
periodYear: period.year,
periodMonth: period.month,
})
}
>
{t("hr.payslips.action.assign")}
</Button>
</div>
</div>
</Card>
))}
</div>
) : null}
<div className="flex w-full flex-col gap-2">
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">{t("hr.payslips.admin.existing")}</span>
{rows.length === 0 ? (
<div data-ui-id="ui.hr.admin.payslips.empty">
<EmptyState title={t("hr.payslips.admin.empty.headline")} body={t("hr.payslips.admin.empty.body")} />
</div>
) : (
<div className="w-full overflow-x-auto">
<Table
data-ui-id="ui.hr.admin.payslips.list"
header={
<Table.HeaderRow>
<Table.HeaderCell>{t("hr.payslips.column.employee")}</Table.HeaderCell>
<Table.HeaderCell>{t("hr.payslips.column.period")}</Table.HeaderCell>
<Table.HeaderCell>{t("hr.payslips.column.status")}</Table.HeaderCell>
</Table.HeaderRow>
}
>
{rows.map((row) => (
<Table.Row key={row.id} data-row-id={row.id}>
<Table.Cell>
<span className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-primary">{row.employeeLabel}</span>
</Table.Cell>
<Table.Cell>
<span className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary">{row.periodLabel}</span>
</Table.Cell>
<Table.Cell>
<BadgeFeedback farbe={row.isRead ? "subtle-positive" : "subtle-warning"} size="small">
{row.isRead ? t("hr.payslips.read") : t("hr.payslips.unread")}
</BadgeFeedback>
</Table.Cell>
</Table.Row>
))}
</Table>
</div>
)}
</div>
</div>
);
}
@@ -0,0 +1,125 @@
// AK-P17b Interim-UI (AD-28) — request-template editor (admin) composed from ~/ui
// (D-HR "Antragsvorlagen", archetype A2 + A5). Pure presentational: create via a
// real Dialog; activate/archive via injected actions. Final Subframe optics =
// tracked design-nachzug.
import { useState } from "react";
import { useTranslation } from "react-i18next";
import { FeatherPlus } from "@subframe/core";
import type { HrRequestKind, HrRequestTemplateListVM } from "@hivegrid/view-models";
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 { TextInput } from "~/ui/components/TextInput";
export type HrAdminRequestTemplatesActions = {
onCreate: (input: { requestKind: string; defaultApproverUserId: string; title: string; description: string }) => void;
onToggle: (templateId: string, isActive: boolean) => void;
onArchive: (templateId: string) => void;
};
export type HrAdminRequestTemplatesPageProps = {
vm: HrRequestTemplateListVM;
kinds: readonly HrRequestKind[];
submitting: boolean;
actions: HrAdminRequestTemplatesActions;
};
export function HrAdminRequestTemplatesPage({ vm, kinds, submitting, actions }: HrAdminRequestTemplatesPageProps) {
const { t } = useTranslation();
const [open, setOpen] = useState(false);
const [form, setForm] = useState({ requestKind: kinds[0] ?? "expense", defaultApproverUserId: "", title: "", description: "" });
const rows = vm.data?.rows ?? [];
function submit() {
if (!form.title.trim()) return;
actions.onCreate(form);
setOpen(false);
setForm({ requestKind: kinds[0] ?? "expense", defaultApproverUserId: "", title: "", description: "" });
}
return (
<div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.hr.admin.requestTemplates">
<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.requests.templates.title")}</span>
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">{t("hr.requests.templates.subtitle")}</span>
</div>
<Button icon={<FeatherPlus />} onClick={() => setOpen(true)} data-ui-id="ui.hr.admin.requestTemplates.newBtn">
{t("hr.requests.templates.action.create")}
</Button>
</div>
{rows.length === 0 ? (
<div data-ui-id="ui.hr.admin.requestTemplates.empty">
<EmptyState title={t("hr.requests.templates.empty.headline")} body={t("hr.requests.templates.empty.body")} />
</div>
) : (
<div className="flex w-full flex-col gap-2" data-ui-id="ui.hr.admin.requestTemplates.list">
{rows.map((row) => (
<Card key={row.id} data-row-id={row.id} data-active={row.isActive}>
<div className="flex w-full items-center justify-between gap-4">
<div className="flex items-center gap-2">
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">{row.title}</span>
<BadgeFeedback farbe="subtle-neutral" size="small">
{t(row.kindLabelKey)}
</BadgeFeedback>
{!row.isActive ? (
<BadgeFeedback farbe="subtle-warning" size="small">
{t("hr.requests.templates.inactive")}
</BadgeFeedback>
) : null}
</div>
<div className="flex items-center gap-2">
<Button variant="tertiary" size="small" loading={submitting} onClick={() => actions.onToggle(row.id, !row.isActive)}>
{row.isActive ? t("hr.requests.templates.action.deactivate") : t("hr.requests.templates.action.activate")}
</Button>
<Button variant="tertiary" size="small" loading={submitting} onClick={() => actions.onArchive(row.id)}>
{t("hr.requests.templates.action.archive")}
</Button>
</div>
</div>
</Card>
))}
</div>
)}
<Dialog open={open} onOpenChange={setOpen}>
<Dialog.Content className="w-full max-w-[560px] p-4" data-ui-id="ui.hr.admin.requestTemplates.new">
<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.requests.templates.action.create")}</span>
<div className="flex w-full flex-col gap-4">
<Select label={t("hr.requests.field.kind")} showLabel value={form.requestKind} onValueChange={(v: string) => setForm((s) => ({ ...s, requestKind: v as HrRequestKind }))}>
{kinds.map((kind) => (
<Select.Item key={kind} value={kind}>
{t(`hr.requests.kind.${kind}`)}
</Select.Item>
))}
</Select>
<TextInput label={t("hr.requests.field.title")} showLabel fillContainer>
<TextInput.Input value={form.title} onChange={(e) => setForm((s) => ({ ...s, title: e.target.value }))} />
</TextInput>
<TextInput label={t("hr.requests.field.description")} showLabel fillContainer>
<TextInput.Input value={form.description} onChange={(e) => setForm((s) => ({ ...s, description: e.target.value }))} />
</TextInput>
<TextInput label={t("hr.requests.field.approver")} showLabel fillContainer>
<TextInput.Input value={form.defaultApproverUserId} onChange={(e) => setForm((s) => ({ ...s, defaultApproverUserId: e.target.value }))} />
</TextInput>
</div>
<div className="flex justify-end gap-2">
<Button variant="neutral" onClick={() => setOpen(false)}>
{t("hr.action.cancel")}
</Button>
<Button loading={submitting} disabled={!form.title.trim()} onClick={submit} data-ui-id="ui.hr.admin.requestTemplates.new.submit">
{t("hr.requests.templates.action.create")}
</Button>
</div>
</div>
</Dialog.Content>
</Dialog>
</div>
);
}
@@ -0,0 +1,170 @@
// AK-P17b Interim-UI (AD-28) — upload-reminder editor (admin) composed from ~/ui
// (D-HR "Upload-Erinnerungen", archetype A2 + A5). Pure presentational: create via
// a real Dialog; pause/resume/archive via injected actions (dispatch runs in the
// worker cron). Final Subframe optics = tracked design-nachzug.
import { type MouseEvent, useState } from "react";
import { useTranslation } from "react-i18next";
import { FeatherPlus } from "@subframe/core";
import type { HrReminderCadenceKind, HrReminderListVM } from "@hivegrid/view-models";
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
import { Button } from "~/ui/components/Button";
import { Card } from "~/ui/components/Card";
import { Checkbox } from "~/ui/components/Checkbox";
import { Dialog } from "~/ui/components/Dialog";
import { EmptyState } from "~/ui/components/EmptyState";
import { Select } from "~/ui/components/Select";
import { TextInput } from "~/ui/components/TextInput";
import { DateField } from "~/components/screens/tasks/DateField";
export type HrAdminUploadRemindersActions = {
onCreate: (input: {
title: string;
documentKind: string;
cadenceKind: string;
intervalMonths: string;
audienceKind: string;
dueAt: string;
mandatory: boolean;
escalate: boolean;
}) => void;
onSetStatus: (reminderId: string, status: "active" | "paused") => void;
onArchive: (reminderId: string) => void;
};
export type HrAdminUploadRemindersPageProps = {
vm: HrReminderListVM;
cadences: readonly HrReminderCadenceKind[];
documentKinds: readonly string[];
audiences: readonly string[];
submitting: boolean;
actions: HrAdminUploadRemindersActions;
};
const EMPTY = { title: "", intervalMonths: "", mandatory: false, escalate: false };
export function HrAdminUploadRemindersPage({ vm, cadences, documentKinds, audiences, submitting, actions }: HrAdminUploadRemindersPageProps) {
const { t } = useTranslation();
const [open, setOpen] = useState(false);
const [form, setForm] = useState({ ...EMPTY, documentKind: documentKinds[0] ?? "other", cadenceKind: cadences[0] ?? "once", audienceKind: audiences[0] ?? "all" });
const rows = vm.data?.rows ?? [];
function reset() {
setForm({ ...EMPTY, documentKind: documentKinds[0] ?? "other", cadenceKind: cadences[0] ?? "once", audienceKind: audiences[0] ?? "all" });
}
function submit(event: MouseEvent<HTMLButtonElement>) {
const el = (event.currentTarget as HTMLElement).closest("[data-ui-id='ui.hr.admin.uploadReminders.new']");
const dueAt = el?.querySelector<HTMLInputElement>("input[name='dueAt']")?.value ?? "";
if (!form.title.trim()) return;
actions.onCreate({ ...form, dueAt });
setOpen(false);
reset();
}
return (
<div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.hr.admin.uploadReminders">
<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.reminders.title")}</span>
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">{t("hr.reminders.subtitle")}</span>
</div>
<Button icon={<FeatherPlus />} onClick={() => setOpen(true)} data-ui-id="ui.hr.admin.uploadReminders.newBtn">
{t("hr.reminders.action.create")}
</Button>
</div>
{rows.length === 0 ? (
<div data-ui-id="ui.hr.admin.uploadReminders.empty">
<EmptyState title={t("hr.reminders.empty.headline")} body={t("hr.reminders.empty.body")} />
</div>
) : (
<div className="flex w-full flex-col gap-2" data-ui-id="ui.hr.admin.uploadReminders.list">
{rows.map((row) => (
<Card key={row.id} data-row-id={row.id} data-status={row.status}>
<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.title}</span>
<span className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-tertiary">
{t(row.cadenceLabelKey)} · {t("hr.reminders.pending", { count: row.pendingCount })}
</span>
</div>
<div className="flex items-center gap-2">
<BadgeFeedback farbe={row.status === "active" ? "subtle-positive" : "subtle-neutral"} size="small">
{t(row.statusLabelKey)}
</BadgeFeedback>
{row.status === "active" ? (
<Button variant="tertiary" size="small" loading={submitting} onClick={() => actions.onSetStatus(row.id, "paused")}>
{t("hr.reminders.action.pause")}
</Button>
) : (
<Button variant="tertiary" size="small" loading={submitting} onClick={() => actions.onSetStatus(row.id, "active")}>
{t("hr.reminders.action.resume")}
</Button>
)}
<Button variant="tertiary" size="small" loading={submitting} onClick={() => actions.onArchive(row.id)}>
{t("hr.reminders.action.archive")}
</Button>
</div>
</div>
</Card>
))}
</div>
)}
<Dialog open={open} onOpenChange={setOpen}>
<Dialog.Content className="w-full max-w-[720px] p-4" data-ui-id="ui.hr.admin.uploadReminders.new">
<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.reminders.action.create")}</span>
<div className="flex w-full flex-col gap-4">
<TextInput label={t("hr.reminders.field.title")} showLabel fillContainer>
<TextInput.Input value={form.title} onChange={(e) => setForm((s) => ({ ...s, title: e.target.value }))} />
</TextInput>
<div className="flex flex-wrap gap-4">
<Select label={t("hr.reminders.field.documentKind")} showLabel value={form.documentKind} onValueChange={(v: string) => setForm((s) => ({ ...s, documentKind: v }))}>
{documentKinds.map((k) => (
<Select.Item key={k} value={k}>
{t(`hr.document.kind.${k}`)}
</Select.Item>
))}
</Select>
<Select label={t("hr.reminders.field.cadence")} showLabel value={form.cadenceKind} onValueChange={(v: string) => setForm((s) => ({ ...s, cadenceKind: v as HrReminderCadenceKind }))}>
{cadences.map((c) => (
<Select.Item key={c} value={c}>
{t(`hr.reminders.cadence.${c}`)}
</Select.Item>
))}
</Select>
<Select label={t("hr.reminders.field.audience")} showLabel value={form.audienceKind} onValueChange={(v: string) => setForm((s) => ({ ...s, audienceKind: v }))}>
{audiences.map((a) => (
<Select.Item key={a} value={a}>
{t(`hr.audience.${a}`)}
</Select.Item>
))}
</Select>
</div>
<div className="flex flex-wrap gap-4">
<TextInput label={t("hr.reminders.field.interval")} showLabel>
<TextInput.Input type="number" value={form.intervalMonths} onChange={(e) => setForm((s) => ({ ...s, intervalMonths: e.target.value }))} />
</TextInput>
<DateField label={t("hr.reminders.field.due")} name="dueAt" />
</div>
<div className="flex flex-wrap gap-4">
<Checkbox label={t("hr.reminders.field.mandatory")} checked={form.mandatory} onCheckedChange={(c: boolean) => setForm((s) => ({ ...s, mandatory: c }))} />
<Checkbox label={t("hr.reminders.field.escalate")} checked={form.escalate} onCheckedChange={(c: boolean) => setForm((s) => ({ ...s, escalate: c }))} />
</div>
</div>
<div className="flex justify-end gap-2">
<Button variant="neutral" onClick={() => setOpen(false)}>
{t("hr.action.cancel")}
</Button>
<Button loading={submitting} disabled={!form.title.trim()} onClick={submit} data-ui-id="ui.hr.admin.uploadReminders.new.submit">
{t("hr.reminders.action.create")}
</Button>
</div>
</div>
</Dialog.Content>
</Dialog>
</div>
);
}
@@ -0,0 +1,146 @@
// AK-P17b Interim-UI (AD-28) — announcement detail composed from ~/ui (D-HR
// "Ankündigung Detail", archetype A3). Pure presentational: markdown body,
// reaction toggles, single-level comments, acknowledgement, and a manager
// read-receipt table. Actions run through injected callbacks (route owns the
// fetcher). Final Subframe optics = tracked design-nachzug.
import { useState } from "react";
import { useTranslation } from "react-i18next";
import type { HrAnnouncementDetailVM } from "@hivegrid/view-models";
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
import { Button } from "~/ui/components/Button";
import { Card } from "~/ui/components/Card";
import { Table } from "~/ui/components/Table";
import { TextInput } from "~/ui/components/TextInput";
const REACTIONS = ["👍", "❤️", "🎉", "👀"] as const;
export type HrAnnouncementDetailActions = {
onAck: () => void;
onReact: (reaction: string) => void;
onComment: (body: string) => void;
};
export type HrAnnouncementDetailPageProps = {
vm: HrAnnouncementDetailVM;
submitting: boolean;
actions: HrAnnouncementDetailActions;
};
export function HrAnnouncementDetailPage({ vm, submitting, actions }: HrAnnouncementDetailPageProps) {
const { t } = useTranslation();
const [comment, setComment] = useState("");
const data = vm.data;
if (vm.status !== "ready" || !data) {
return <div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.hr.announcement.detail" />;
}
return (
<div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.hr.announcement.detail" data-row-id={data.id}>
<div className="flex flex-col gap-0">
<span className="text-heading-2 font-heading-2 text-text-neutral-primary">{data.title}</span>
<span className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-tertiary">{data.authorLabel}</span>
</div>
<Card>
<span className="whitespace-pre-wrap text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-primary">
{data.bodyMarkdown}
</span>
</Card>
{data.requiresAcknowledgement ? (
<div data-ui-id="ui.hr.announcement.ack">
{data.isAcknowledged ? (
<BadgeFeedback farbe="subtle-positive" size="small">
{t("hr.announcements.acknowledged")}
</BadgeFeedback>
) : (
<Button loading={submitting} onClick={() => actions.onAck()}>
{t("hr.announcements.action.acknowledge")}
</Button>
)}
</div>
) : null}
<div className="flex flex-wrap items-center gap-2" data-ui-id="ui.hr.announcement.reactions">
{REACTIONS.map((emoji) => {
const group = data.reactions.find((r) => r.reaction === emoji);
return (
<Button
key={emoji}
variant={group?.mine ? "secondary" : "tertiary"}
size="small"
onClick={() => actions.onReact(emoji)}
>
{`${emoji} ${group?.count ?? 0}`}
</Button>
);
})}
</div>
<div className="flex w-full flex-col gap-3" data-ui-id="ui.hr.announcement.comments">
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">{t("hr.announcements.comments.title")}</span>
{data.comments.length === 0 ? (
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">{t(data.commentEmptyKey)}</span>
) : (
data.comments.map((c) => (
<Card key={c.id} data-row-id={c.id}>
<div className="flex w-full flex-col gap-1">
<span className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-tertiary">{c.authorLabel}</span>
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-primary">{c.body}</span>
</div>
</Card>
))
)}
<div className="flex items-end gap-2">
<TextInput label={t("hr.announcements.comments.add")} showLabel fillContainer className="max-w-none">
<TextInput.Input value={comment} onChange={(e) => setComment(e.target.value)} placeholder={t("hr.announcements.comments.placeholder")} />
</TextInput>
<Button
loading={submitting}
disabled={comment.trim().length === 0}
onClick={() => {
actions.onComment(comment);
setComment("");
}}
>
{t("hr.announcements.comments.add")}
</Button>
</div>
</div>
{data.canManage && data.readReceipts.length > 0 ? (
<div className="flex w-full flex-col gap-2" data-ui-id="ui.hr.announcement.receipts">
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">{t("hr.announcements.receipts.title")}</span>
<div className="w-full overflow-x-auto">
<Table
header={
<Table.HeaderRow>
<Table.HeaderCell>{t("hr.announcements.receipts.user")}</Table.HeaderCell>
<Table.HeaderCell>{t("hr.announcements.receipts.acknowledged")}</Table.HeaderCell>
</Table.HeaderRow>
}
>
{data.readReceipts.map((receipt) => (
<Table.Row key={receipt.userLabel}>
<Table.Cell>
<span className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary">{receipt.userLabel}</span>
</Table.Cell>
<Table.Cell>
{receipt.acknowledged ? (
<BadgeFeedback farbe="subtle-positive" size="small">
{t("hr.announcements.acknowledged")}
</BadgeFeedback>
) : (
<span className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-tertiary">—</span>
)}
</Table.Cell>
</Table.Row>
))}
</Table>
</div>
</div>
) : null}
</div>
);
}
@@ -0,0 +1,80 @@
// AK-P17b Interim-UI (AD-28) — announcements feed composed from ~/ui (D-HR
// "Ankündigungen", archetype A2). Pure presentational: pinned first, URL-driven
// unread filter. Final Subframe optics = tracked design-nachzug.
import { useTranslation } from "react-i18next";
import { FeatherPin } from "@subframe/core";
import type { HrAnnouncementFeedVM } from "@hivegrid/view-models";
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
import { Card } from "~/ui/components/Card";
import { EmptyState } from "~/ui/components/EmptyState";
import { LinkButton } from "~/ui/components/LinkButton";
import { Tabs } from "~/ui/components/Tabs";
export type HrAnnouncementsFeedPageProps = { vm: HrAnnouncementFeedVM };
export function HrAnnouncementsFeedPage({ vm }: HrAnnouncementsFeedPageProps) {
const { t } = useTranslation();
const data = vm.data;
if (vm.status !== "ready" || !data) {
return <div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.hr.announcements" />;
}
return (
<div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.hr.announcements">
<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.announcements.title")}</span>
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">
{t("hr.announcements.subtitle")}
</span>
</div>
{data.canManage ? (
<a href={data.manageHref} className="contents no-underline" data-ui-id="ui.hr.announcements.manage">
<LinkButton variant="subtle">{t("hr.announcements.action.manage")}</LinkButton>
</a>
) : null}
</div>
<div data-ui-id="ui.hr.announcements.filter">
<Tabs>
<a href="?" className="contents no-underline">
<Tabs.Item active={!data.unreadOnly}>{t("hr.announcements.filter.all")}</Tabs.Item>
</a>
<a href="?unread=1" className="contents no-underline">
<Tabs.Item active={data.unreadOnly}>{t("hr.announcements.filter.unread")}</Tabs.Item>
</a>
</Tabs>
</div>
{data.rows.length === 0 ? (
<div data-ui-id="ui.hr.announcements.empty">
<EmptyState title={t("hr.announcements.empty.headline")} body={t("hr.announcements.empty.body")} />
</div>
) : (
<div className="flex w-full flex-col gap-3" data-ui-id="ui.hr.announcements.list">
{data.rows.map((row) => (
<a key={row.id} href={row.detailHref} className="no-underline" data-row-id={row.id} data-pinned={row.pinned} data-read={row.isRead}>
<Card>
<div className="flex w-full flex-col gap-1">
<div className="flex items-center justify-between gap-3">
<div className="flex items-center gap-2">
{row.pinned ? <FeatherPin className="text-body-default-regular-0 font-body-default-regular-0 text-icon-neutral-tertiary" /> : null}
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">{row.title}</span>
</div>
{row.requiresAcknowledgement && !row.isAcknowledged ? (
<BadgeFeedback farbe="subtle-warning" size="small">
{t("hr.announcements.ackRequired")}
</BadgeFeedback>
) : null}
</div>
<span className="line-clamp-2 text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">{row.snippet}</span>
</div>
</Card>
</a>
))}
</div>
)}
</div>
);
}
@@ -0,0 +1,51 @@
import { vi, describe, it, expect } from "vitest";
import "@testing-library/jest-dom";
import { render, fireEvent } from "@testing-library/react";
import { HrDirectoryDetailPage, type HrDirectoryDetailPageProps } from "./HrDirectoryDetailPage";
vi.mock("react-i18next", () => ({
useTranslation: () => ({ t: (str: string) => str, i18n: { language: "de" } }),
}));
function props(overrides: Partial<HrDirectoryDetailPageProps> = {}): HrDirectoryDetailPageProps {
return {
backHref: "..",
name: "Ada Lovelace",
email: "ada@acme.test",
position: "Engineer",
team: "Core",
isSelf: true,
canRevealEmergency: true,
canEditEmergency: true,
hasEmergencyContact: false,
revealedContact: null,
revealing: false,
saving: false,
savingEmergency: false,
actions: { onSaveProfile: vi.fn(), onRevealEmergency: vi.fn(), onSetEmergency: vi.fn() },
...overrides,
};
}
describe("HrDirectoryDetailPage (interim-UI, emergency-contact editing)", () => {
it("lets an editor set a new emergency contact via the dialog", () => {
const onSetEmergency = vi.fn();
const { container } = render(<HrDirectoryDetailPage {...props({ actions: { onSaveProfile: vi.fn(), onRevealEmergency: vi.fn(), onSetEmergency } })} />);
// With no contact on file the edit control offers "add".
fireEvent.click(container.querySelector('[data-ui-id="ui.hr.directory.detail.emergency.edit"]') as HTMLElement);
// Dialog content is portalled to document.body.
fireEvent.change(document.querySelector('[data-ui-id="ui.hr.directory.detail.emergency.dialog.name"]') as HTMLInputElement, { target: { value: " Tom Davis " } });
fireEvent.change(document.querySelector('[data-ui-id="ui.hr.directory.detail.emergency.dialog.phone"]') as HTMLInputElement, { target: { value: "+49 172 8899001" } });
fireEvent.change(document.querySelector('[data-ui-id="ui.hr.directory.detail.emergency.dialog.relation"]') as HTMLInputElement, { target: { value: "Ehepartner" } });
fireEvent.click(document.querySelector('[data-ui-id="ui.hr.directory.detail.emergency.dialog.submit"]') as HTMLElement);
expect(onSetEmergency).toHaveBeenCalledWith({ name: "Tom Davis", phone: "+49 172 8899001", relation: "Ehepartner" });
});
it("hides the emergency card entirely when the viewer can neither reveal nor edit", () => {
const { container } = render(<HrDirectoryDetailPage {...props({ isSelf: false, canRevealEmergency: false, canEditEmergency: false })} />);
expect(container.querySelector('[data-ui-id="ui.hr.directory.detail.emergency"]')).not.toBeInTheDocument();
});
});
@@ -0,0 +1,218 @@
// AK-P17a Interim-UI (AD-28) — employee detail screen composed from ~/ui (D-HR
// "MA-Detail", archetype A3). Pure presentational: master data, inline self-edit
// of the self-editable fields (position/team), and an ON-DEMAND emergency-contact
// reveal (self or hr.read_all only, audited server-side). The route owns the
// fetchers and injects callbacks + revealed data; this screen never fetches.
// Final Subframe optics = tracked design-nachzug.
import { useState } from "react";
import { useTranslation } from "react-i18next";
import { Breadcrumbs } from "~/ui/components/Breadcrumbs";
import { Button } from "~/ui/components/Button";
import { Card } from "~/ui/components/Card";
import { Dialog } from "~/ui/components/Dialog";
import { TextInput } from "~/ui/components/TextInput";
/** Decrypted emergency-contact triple (mirrors the server EmergencyContact). */
export type RevealedEmergencyContact = { name: string; phone: string; relation: string };
export type HrDirectoryDetailActions = {
/** POSTs intent=update-own-profile with the self-editable fields. */
onSaveProfile: (input: { position: string; team: string }) => void;
/** POSTs intent=reveal-emergency (audited). */
onRevealEmergency: () => void;
/** POSTs intent=set-emergency; stores the envelope-encrypted contact. */
onSetEmergency: (input: RevealedEmergencyContact) => void;
};
export type HrDirectoryDetailPageProps = {
backHref: string;
name: string;
email: string;
position: string | null;
team: string | null;
isSelf: boolean;
canRevealEmergency: boolean;
/** Self or HR with hr.write — may create/overwrite the emergency contact. */
canEditEmergency: boolean;
hasEmergencyContact: boolean;
/** Populated once the reveal fetcher returns; null before reveal. */
revealedContact: RevealedEmergencyContact | null;
revealing: boolean;
saving: boolean;
savingEmergency: boolean;
actions: HrDirectoryDetailActions;
};
function DataRow({ label, value }: { label: string; value: string }) {
return (
<div className="flex flex-col gap-0">
<span className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-tertiary">{label}</span>
<span className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-primary">{value}</span>
</div>
);
}
export function HrDirectoryDetailPage({
backHref,
name,
email,
position,
team,
isSelf,
canRevealEmergency,
canEditEmergency,
hasEmergencyContact,
revealedContact,
revealing,
saving,
savingEmergency,
actions,
}: HrDirectoryDetailPageProps) {
const { t } = useTranslation();
const [positionDraft, setPositionDraft] = useState(position ?? "");
const [teamDraft, setTeamDraft] = useState(team ?? "");
const [emergencyOpen, setEmergencyOpen] = useState(false);
const [emergencyDraft, setEmergencyDraft] = useState<RevealedEmergencyContact>({ name: "", phone: "", relation: "" });
function openEmergencyDialog() {
// Prefill from the revealed contact if the viewer has already revealed it;
// otherwise start blank (we never auto-decrypt just to edit).
setEmergencyDraft(revealedContact ?? { name: "", phone: "", relation: "" });
setEmergencyOpen(true);
}
function submitEmergency() {
actions.onSetEmergency({ name: emergencyDraft.name.trim(), phone: emergencyDraft.phone.trim(), relation: emergencyDraft.relation.trim() });
setEmergencyOpen(false);
}
return (
<div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.hr.directory.detail">
<Breadcrumbs>
<a href={backHref} className="contents no-underline" data-ui-id="ui.hr.directory.detail.back">
<Breadcrumbs.Item>{t("hr.directory.detail.back")}</Breadcrumbs.Item>
</a>
<Breadcrumbs.Divider />
<Breadcrumbs.Item active>{name}</Breadcrumbs.Item>
</Breadcrumbs>
<div className="flex flex-col gap-0">
<span className="text-heading-2 font-heading-2 text-text-neutral-primary">{name}</span>
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">
{email || "—"}
</span>
</div>
{/* Master data — self-editable fields become inputs for the employee. */}
<Card>
{isSelf ? (
<div className="flex w-full flex-col gap-4" data-ui-id="ui.hr.directory.detail.edit">
<TextInput label={t("hr.directory.column.position")} showLabel fillContainer>
<TextInput.Input
value={positionDraft}
onChange={(event) => setPositionDraft(event.target.value)}
data-ui-id="ui.hr.directory.detail.position"
/>
</TextInput>
<TextInput label={t("hr.directory.column.team")} showLabel fillContainer>
<TextInput.Input
value={teamDraft}
onChange={(event) => setTeamDraft(event.target.value)}
data-ui-id="ui.hr.directory.detail.team"
/>
</TextInput>
<div className="flex justify-end">
<Button
loading={saving}
onClick={() => actions.onSaveProfile({ position: positionDraft, team: teamDraft })}
data-ui-id="ui.hr.directory.detail.save"
>
{t("hr.directory.detail.save")}
</Button>
</div>
</div>
) : (
<div className="flex w-full flex-col gap-4">
<DataRow label={t("hr.directory.column.position")} value={position ?? "—"} />
<DataRow label={t("hr.directory.column.team")} value={team ?? "—"} />
<DataRow label={t("hr.directory.detail.email")} value={email || "—"} />
</div>
)}
</Card>
{/* Emergency contact — never shown automatically, revealed on demand.
Editable by self or HR (hr.write) via the dialog. */}
{canRevealEmergency || canEditEmergency ? (
<Card data-ui-id="ui.hr.directory.detail.emergency">
<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">
{t("hr.directory.detail.emergencyContact")}
</span>
{canEditEmergency ? (
<Button variant="secondary" size="small" onClick={openEmergencyDialog} data-ui-id="ui.hr.directory.detail.emergency.edit">
{hasEmergencyContact ? t("hr.directory.detail.emergency.edit") : t("hr.directory.detail.emergency.add")}
</Button>
) : null}
</div>
{!hasEmergencyContact ? (
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">
{t("hr.directory.detail.noEmergencyContact")}
</span>
) : !canRevealEmergency ? (
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">
{t("hr.directory.detail.emergency.stored")}
</span>
) : revealedContact ? (
<div className="flex w-full flex-col gap-4" data-ui-id="ui.hr.directory.detail.emergency.revealed">
<DataRow label={t("hr.directory.detail.emergency.name")} value={revealedContact.name} />
<DataRow label={t("hr.directory.detail.emergency.phone")} value={revealedContact.phone} />
<DataRow label={t("hr.directory.detail.emergency.relation")} value={revealedContact.relation} />
</div>
) : (
<Button
variant="secondary"
loading={revealing}
onClick={() => actions.onRevealEmergency()}
data-ui-id="ui.hr.directory.detail.emergency.reveal"
>
{t("hr.directory.detail.reveal")}
</Button>
)}
</Card>
) : null}
{/* Set / overwrite emergency contact (self or HR with hr.write). */}
<Dialog open={emergencyOpen} onOpenChange={(next) => { if (!savingEmergency) setEmergencyOpen(next); }}>
<Dialog.Content className="w-full max-w-[560px] p-4" data-ui-id="ui.hr.directory.detail.emergency.dialog">
<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.directory.detail.emergency.dialogTitle")}</span>
<div className="flex w-full flex-col gap-4">
<TextInput label={t("hr.directory.detail.emergency.name")} showLabel fillContainer>
<TextInput.Input value={emergencyDraft.name} onChange={(e) => setEmergencyDraft((s) => ({ ...s, name: e.target.value }))} data-ui-id="ui.hr.directory.detail.emergency.dialog.name" />
</TextInput>
<TextInput label={t("hr.directory.detail.emergency.phone")} showLabel fillContainer>
<TextInput.Input value={emergencyDraft.phone} onChange={(e) => setEmergencyDraft((s) => ({ ...s, phone: e.target.value }))} data-ui-id="ui.hr.directory.detail.emergency.dialog.phone" />
</TextInput>
<TextInput label={t("hr.directory.detail.emergency.relation")} showLabel fillContainer>
<TextInput.Input value={emergencyDraft.relation} onChange={(e) => setEmergencyDraft((s) => ({ ...s, relation: e.target.value }))} data-ui-id="ui.hr.directory.detail.emergency.dialog.relation" />
</TextInput>
</div>
<div className="flex justify-end gap-2">
<Button variant="neutral" disabled={savingEmergency} onClick={() => setEmergencyOpen(false)}>
{t("hr.action.cancel")}
</Button>
<Button
loading={savingEmergency}
disabled={emergencyDraft.name.trim().length === 0 || emergencyDraft.phone.trim().length === 0}
onClick={submitEmergency}
data-ui-id="ui.hr.directory.detail.emergency.dialog.submit"
>
{t("hr.directory.detail.emergency.save")}
</Button>
</div>
</div>
</Dialog.Content>
</Dialog>
</div>
);
}
@@ -0,0 +1,42 @@
import { vi, describe, it, expect } from "vitest";
import "@testing-library/jest-dom";
import { render } from "@testing-library/react";
import { BrowserRouter as Router } from "react-router";
import { buildHrDirectoryVM } from "@hivegrid/view-models";
import { HrDirectoryPage } from "./HrDirectoryPage";
vi.mock("react-i18next", () => ({
useTranslation: () => ({ t: (str: string) => str, i18n: { language: "de" } }),
}));
describe("HrDirectoryPage (interim-UI)", () => {
it("renders directory rows (non-sensitive fields only) from the VM", () => {
const vm = buildHrDirectoryVM({
canManage: true,
rows: [
{ userId: "u1", name: "Ada Lovelace", email: "ada@acme.test", position: "Engineer", team: "Core", locationName: "Berlin", detailHref: "/acme/hr/directory/u1" },
],
});
const { container, getByText } = render(
<Router>
<HrDirectoryPage vm={vm} />
</Router>,
);
expect(container.querySelector('[data-ui-id="ui.hr.directory.table"]')).toBeInTheDocument();
expect(container.querySelector('[data-row-id="u1"]')).toBeInTheDocument();
expect(getByText("Ada Lovelace")).toBeInTheDocument();
expect(getByText("Engineer")).toBeInTheDocument();
});
it("shows the empty state when there are no employees", () => {
const vm = buildHrDirectoryVM({ canManage: false, rows: [] });
const { container } = render(
<Router>
<HrDirectoryPage vm={vm} />
</Router>,
);
expect(container.querySelector('[data-ui-id="ui.hr.directory.empty"]')).toBeInTheDocument();
expect(container.querySelector('[data-ui-id="ui.hr.directory.table"]')).not.toBeInTheDocument();
});
});
@@ -0,0 +1,105 @@
// AK-P17a Interim-UI (AD-28) — employee directory screen composed from ~/ui
// (D-HR "MA-Verzeichnis", archetype A2). Pure presentational: renders the
// server-built HrDirectoryVM passed as a prop. The directory carries ONLY
// non-sensitive display fields (emergency contacts et al. are reveal-on-demand
// on the detail screen, never in this list). Final Subframe optics =
// tracked design-nachzug.
import { useTranslation } from "react-i18next";
import { FeatherMail } from "@subframe/core";
import type { HrDirectoryVM } from "@hivegrid/view-models";
import { Avatar } from "~/ui/components/Avatar";
import { EmptyState } from "~/ui/components/EmptyState";
import { IconButton } from "~/ui/components/IconButton";
import { Table } from "~/ui/components/Table";
export type HrDirectoryPageProps = {
vm: HrDirectoryVM;
};
function initials(name: string): string {
const parts = name.trim().split(/\s+/).filter(Boolean);
if (parts.length === 0) return "?";
if (parts.length === 1) return parts[0].slice(0, 2).toUpperCase();
return (parts[0][0] + parts[parts.length - 1][0]).toUpperCase();
}
export function HrDirectoryPage({ vm }: HrDirectoryPageProps) {
const { t } = useTranslation();
if (vm.status !== "ready" || !vm.data) {
return <div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.hr.directory" />;
}
const { rows, emptyHeadlineKey, emptyBodyKey } = vm.data;
return (
<div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.hr.directory">
<div className="flex flex-col gap-0">
<span className="text-heading-2 font-heading-2 text-text-neutral-primary">{t("hr.directory.title")}</span>
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">
{t("hr.directory.subtitle")}
</span>
</div>
{rows.length === 0 ? (
<div data-ui-id="ui.hr.directory.empty">
<EmptyState title={t(emptyHeadlineKey)} body={t(emptyBodyKey)} />
</div>
) : (
<div className="w-full overflow-x-auto">
<Table
data-ui-id="ui.hr.directory.table"
header={
<Table.HeaderRow>
<Table.HeaderCell>{t("hr.directory.column.name")}</Table.HeaderCell>
<Table.HeaderCell>{t("hr.directory.column.position")}</Table.HeaderCell>
<Table.HeaderCell>{t("hr.directory.column.team")}</Table.HeaderCell>
<Table.HeaderCell>{t("hr.directory.column.location")}</Table.HeaderCell>
<Table.HeaderCell> </Table.HeaderCell>
</Table.HeaderRow>
}
>
{rows.map((row) => (
<Table.Row key={row.userId} data-row-id={row.userId}>
<Table.Cell>
<div className="flex items-center gap-3">
<Avatar size="small">{initials(row.name)}</Avatar>
<a
href={row.detailHref}
className="text-body-default-medium-0 font-body-default-medium-0 text-text-feedback-link-default"
>
{row.name}
</a>
</div>
</Table.Cell>
<Table.Cell>
<span className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary">
{row.position ?? "—"}
</span>
</Table.Cell>
<Table.Cell>
<span className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary">
{row.team ?? "—"}
</span>
</Table.Cell>
<Table.Cell>
<span className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary">
{row.locationName ?? "—"}
</span>
</Table.Cell>
<Table.Cell>
{row.email ? (
<a href={`mailto:${row.email}`} className="contents no-underline" aria-label={t("hr.directory.action.mail")}>
<IconButton size="small" icon={<FeatherMail />} />
</a>
) : null}
</Table.Cell>
</Table.Row>
))}
</Table>
</div>
)}
</div>
);
}
@@ -0,0 +1,74 @@
// AK-P17a Interim-UI (AD-28) — HR hub launchpad composed from ~/ui (D-HR
// "HR-Hub-Start", archetype A1/A6). Pure presentational: the loader gates the
// connector + permission and passes the resolved quick-link list in as a prop;
// this screen only renders. The richer hub widgets (announcements, pending
// duties, birthdays) arrive with their data in follow-up tickets; the interim
// screen renders exactly what the loader provides. Final Subframe optics = a
// tracked design-nachzug once David's D-HR delta ships.
import { useTranslation } from "react-i18next";
import { FeatherArrowRight, FeatherLock } from "@subframe/core";
import { Card } from "~/ui/components/Card";
import { EmptyState } from "~/ui/components/EmptyState";
export type HrHubLink = {
/** i18n key for the link label (e.g. "hr.nav.directory"). */
readonly labelKey: string;
readonly href: string;
};
export type HrHubPageProps = {
/** False when the tenant has the HR module gated off (locked state). */
moduleActive: boolean;
links: readonly HrHubLink[];
};
export function HrHubPage({ moduleActive, links }: HrHubPageProps) {
const { t } = useTranslation();
if (!moduleActive) {
return (
<div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.hr.hub">
<div className="flex items-center gap-2 text-text-neutral-tertiary" data-ui-id="ui.hr.hub.locked">
<FeatherLock className="text-heading-3 font-heading-3" />
<EmptyState title={t("hr.hub.locked.headline")} body={t("hr.hub.locked.body")} />
</div>
</div>
);
}
return (
<div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.hr.hub">
{/* Header: title + description (0px rhythm) */}
<div className="flex flex-col gap-0">
<span className="text-heading-2 font-heading-2 text-text-neutral-primary">{t("hr.hub.title")}</span>
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">
{t("hr.hub.subtitle")}
</span>
</div>
<nav
className="grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3"
data-ui-id="ui.hr.hub.links"
>
{links.map((link) => (
<a
key={link.labelKey}
href={link.href}
className="no-underline"
data-row-id={link.labelKey}
>
<Card>
<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">
{t(link.labelKey)}
</span>
<FeatherArrowRight className="text-body-default-regular-0 font-body-default-regular-0 text-icon-neutral-tertiary" />
</div>
</Card>
</a>
))}
</nav>
</div>
);
}
@@ -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>
);
}
@@ -0,0 +1,159 @@
// AK-P17a Interim-UI (AD-28) — locations screen composed from ~/ui (D-HR
// "Standorte", archetype A2 + A5 create modal). Pure presentational: renders the
// server-built HrLocationListVM; admin create/set-default/archive run through the
// injected actions (route owns the fetcher). The create form uses a real Dialog
// (DialogLayout -> Dialog -> Dialog.Content), never a Card fake. Final Subframe
// optics = tracked design-nachzug.
import { useState } from "react";
import { useTranslation } from "react-i18next";
import { FeatherPlus } from "@subframe/core";
import type { HrLocationListVM } from "@hivegrid/view-models";
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
import { Button } from "~/ui/components/Button";
import { Checkbox } from "~/ui/components/Checkbox";
import { Dialog } from "~/ui/components/Dialog";
import { EmptyState } from "~/ui/components/EmptyState";
import { Table } from "~/ui/components/Table";
import { TextInput } from "~/ui/components/TextInput";
export type HrLocationsActions = {
onCreate: (input: { name: string; city: string; isDefault: boolean }) => void;
onSetDefault: (locationId: string) => void;
onArchive: (locationId: string) => void;
};
export type HrLocationsPageProps = {
vm: HrLocationListVM;
submitting: boolean;
actions: HrLocationsActions;
};
export function HrLocationsPage({ vm, submitting, actions }: HrLocationsPageProps) {
const { t } = useTranslation();
const [createOpen, setCreateOpen] = useState(false);
const [name, setName] = useState("");
const [city, setCity] = useState("");
const [isDefault, setIsDefault] = useState(false);
if (vm.status !== "ready" || !vm.data) {
return <div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.hr.locations" />;
}
const { rows, canManage, emptyHeadlineKey, emptyBodyKey } = vm.data;
function submitCreate() {
actions.onCreate({ name, city, isDefault });
setCreateOpen(false);
setName("");
setCity("");
setIsDefault(false);
}
return (
<div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.hr.locations">
<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.locations.title")}</span>
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">
{t("hr.locations.subtitle")}
</span>
</div>
{canManage ? (
<Button icon={<FeatherPlus />} onClick={() => setCreateOpen(true)} data-ui-id="ui.hr.locations.new">
{t("hr.locations.action.new")}
</Button>
) : null}
</div>
{rows.length === 0 ? (
<div data-ui-id="ui.hr.locations.empty">
<EmptyState title={t(emptyHeadlineKey)} body={t(emptyBodyKey)} />
</div>
) : (
<div className="w-full overflow-x-auto">
<Table
data-ui-id="ui.hr.locations.table"
header={
<Table.HeaderRow>
<Table.HeaderCell>{t("hr.locations.column.name")}</Table.HeaderCell>
<Table.HeaderCell>{t("hr.locations.column.city")}</Table.HeaderCell>
<Table.HeaderCell>{t("hr.locations.column.employees")}</Table.HeaderCell>
{canManage ? <Table.HeaderCell> </Table.HeaderCell> : null}
</Table.HeaderRow>
}
>
{rows.map((row) => (
<Table.Row key={row.id} data-row-id={row.id} data-default={row.isDefault}>
<Table.Cell>
<div className="flex items-center gap-2">
<a
href={row.detailHref}
className="text-body-default-medium-0 font-body-default-medium-0 text-text-feedback-link-default"
>
{row.name}
</a>
{row.isDefault ? (
<BadgeFeedback farbe="subtle-neutral" size="small">
{t("hr.locations.default")}
</BadgeFeedback>
) : null}
</div>
</Table.Cell>
<Table.Cell>
<span className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary">
{row.city ?? "—"}
</span>
</Table.Cell>
<Table.Cell>
<span className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary">
{row.employeeCount}
</span>
</Table.Cell>
{canManage ? (
<Table.Cell>
<div className="flex items-center justify-end gap-2">
{!row.isDefault ? (
<Button variant="tertiary" size="small" onClick={() => actions.onSetDefault(row.id)}>
{t("hr.locations.action.setDefault")}
</Button>
) : null}
<Button variant="tertiary" size="small" onClick={() => actions.onArchive(row.id)}>
{t("hr.locations.action.archive")}
</Button>
</div>
</Table.Cell>
) : null}
</Table.Row>
))}
</Table>
</div>
)}
<Dialog open={createOpen} onOpenChange={setCreateOpen}>
<Dialog.Content className="w-full max-w-[560px] p-4" data-ui-id="ui.hr.locations.create">
<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.locations.create.title")}</span>
<div className="flex w-full flex-col gap-4">
<TextInput label={t("hr.locations.field.name")} showLabel fillContainer>
<TextInput.Input value={name} onChange={(event) => setName(event.target.value)} data-ui-id="ui.hr.locations.create.name" />
</TextInput>
<TextInput label={t("hr.locations.field.city")} showLabel fillContainer>
<TextInput.Input value={city} onChange={(event) => setCity(event.target.value)} data-ui-id="ui.hr.locations.create.city" />
</TextInput>
<Checkbox label={t("hr.locations.field.isDefault")} checked={isDefault} onCheckedChange={(checked: boolean) => setIsDefault(checked)} />
</div>
<div className="flex justify-end gap-2">
<Button variant="neutral" onClick={() => setCreateOpen(false)}>
{t("hr.action.cancel")}
</Button>
<Button loading={submitting} disabled={name.trim().length === 0} onClick={submitCreate} data-ui-id="ui.hr.locations.create.submit">
{t("hr.locations.create.submit")}
</Button>
</div>
</div>
</Dialog.Content>
</Dialog>
</div>
);
}
@@ -0,0 +1,51 @@
import { vi, describe, it, expect } from "vitest";
import "@testing-library/jest-dom";
import { render, fireEvent } from "@testing-library/react";
import { buildHrDocumentListVM } from "@hivegrid/view-models";
import { HrMyDocumentsPage, type HrDocumentUploadState } from "./HrMyDocumentsPage";
vi.mock("react-i18next", () => ({
useTranslation: () => ({ t: (str: string) => str, i18n: { language: "de" } }),
}));
const IDLE: HrDocumentUploadState = { status: "idle", errorKey: null };
function vm(canUpload: boolean, rows: Parameters<typeof buildHrDocumentListVM>[0]["rows"] = []) {
return buildHrDocumentListVM({ canUpload, uploadHref: "/acme/hr/my-documents", rows });
}
describe("HrMyDocumentsPage (interim-UI, upload wiring)", () => {
it("hides the upload affordance when the VM says the viewer cannot upload", () => {
const { container } = render(<HrMyDocumentsPage vm={vm(false)} submitting={false} upload={IDLE} actions={{ onArchive: vi.fn(), onUpload: vi.fn(), onResetUpload: vi.fn() }} />);
expect(container.querySelector('[data-ui-id="ui.hr.documents.upload"]')).not.toBeInTheDocument();
});
it("opens the upload dialog and hands the picked file + metadata to onUpload", () => {
const onUpload = vi.fn();
const { container } = render(<HrMyDocumentsPage vm={vm(true)} submitting={false} upload={IDLE} actions={{ onArchive: vi.fn(), onUpload, onResetUpload: vi.fn() }} />);
// The trigger lives on the page; the dialog content is portalled to document.body.
fireEvent.click(container.querySelector('[data-ui-id="ui.hr.documents.upload"]') as HTMLElement);
const titleInput = document.querySelector('[data-ui-id="ui.hr.documents.upload.title"]') as HTMLInputElement;
fireEvent.change(titleInput, { target: { value: "Arbeitsvertrag" } });
const fileInput = document.querySelector('[data-ui-id="ui.hr.documents.upload.file"]') as HTMLInputElement;
const file = new File(["hello"], "vertrag.pdf", { type: "application/pdf" });
fireEvent.change(fileInput, { target: { files: [file] } });
fireEvent.click(document.querySelector('[data-ui-id="ui.hr.documents.upload.submit"]') as HTMLElement);
expect(onUpload).toHaveBeenCalledTimes(1);
const arg = onUpload.mock.calls[0][0];
expect(arg.title).toBe("Arbeitsvertrag");
expect(arg.file).toBe(file);
expect(arg.documentKind).toBe("other");
});
it("surfaces an upload error via the Alert", () => {
const { container } = render(
<HrMyDocumentsPage vm={vm(true)} submitting={false} upload={{ status: "error", errorKey: "hr.documents.upload.error.generic" }} actions={{ onArchive: vi.fn(), onUpload: vi.fn(), onResetUpload: vi.fn() }} />,
);
fireEvent.click(container.querySelector('[data-ui-id="ui.hr.documents.upload"]') as HTMLElement);
expect(document.querySelector('[data-ui-id="ui.hr.documents.upload.progress"][data-status="error"]')).toBeInTheDocument();
});
});
@@ -0,0 +1,265 @@
// AK-P17a Interim-UI (AD-28) — "my documents" screen composed from ~/ui (D-HR
// "Eigene Dokumente", archetype A2). Renders the server-built HrDocumentListVM;
// office-uploaded docs are read-only (no archive action), the employee can always
// open/download. Kind filter is client-side. Self-upload is wired: the dialog
// collects metadata + a file and hands it to `actions.onUpload`; the route drives
// the chunked upload (reusing the Files pipeline) and links the resulting File as
// an HrEmployeeDocument. Upload progress is injected as `upload`.
// Final Subframe optics = tracked design-nachzug.
import { useEffect, useRef, useState } from "react";
import { useTranslation } from "react-i18next";
import { FeatherUpload } from "@subframe/core";
import type { HrDocumentKind, HrDocumentListVM } from "@hivegrid/view-models";
import { Alert } from "~/ui/components/Alert";
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
import { Button } from "~/ui/components/Button";
import { Dialog } from "~/ui/components/Dialog";
import { EmptyState } from "~/ui/components/EmptyState";
import { Select } from "~/ui/components/Select";
import { Table } from "~/ui/components/Table";
import { TextInput } from "~/ui/components/TextInput";
/** Injected upload state (owned by the route, which posts the file multipart). */
export type HrDocumentUploadState = {
status: "idle" | "uploading" | "done" | "error";
errorKey: string | null;
};
export type HrMyDocumentsUploadInput = {
file: File;
title: string;
documentKind: HrDocumentKind;
validUntilIso: string | null;
};
export type HrMyDocumentsActions = {
/** POSTs intent=archive for an own (non-office) document. */
onArchive: (documentId: string) => void;
/** Hand a picked file + metadata to the route (multipart upload → createDocument). */
onUpload: (input: HrMyDocumentsUploadInput) => void;
/** Reset the injected upload state (called when a fresh dialog session opens). */
onResetUpload: () => void;
};
export type HrMyDocumentsPageProps = {
vm: HrDocumentListVM;
submitting: boolean;
upload: HrDocumentUploadState;
actions: HrMyDocumentsActions;
};
const FILTER_ALL = "__all__";
const KINDS: readonly HrDocumentKind[] = ["contract", "certificate", "identification", "qualification", "other"];
export function HrMyDocumentsPage({ vm, submitting, upload, actions }: HrMyDocumentsPageProps) {
const { t, i18n } = useTranslation();
const [kind, setKind] = useState<HrDocumentKind | null>(null);
const [uploadOpen, setUploadOpen] = useState(false);
const [form, setForm] = useState<{ title: string; documentKind: HrDocumentKind; validUntil: string }>({ title: "", documentKind: "other", validUntil: "" });
const [file, setFile] = useState<File | null>(null);
const fileInputRef = useRef<HTMLInputElement>(null);
// Close + reset the dialog once the route reports the upload finished.
useEffect(() => {
if (upload.status === "done" && uploadOpen) {
setUploadOpen(false);
setForm({ title: "", documentKind: "other", validUntil: "" });
setFile(null);
if (fileInputRef.current) fileInputRef.current.value = "";
}
}, [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" />;
}
const { rows, canUpload, emptyHeadlineKey, emptyBodyKey } = vm.data;
const dateFormatter = new Intl.DateTimeFormat(i18n.language, { dateStyle: "medium" });
const visible = rows.filter((row) => (kind ? row.documentKind === kind : true));
const busy = upload.status === "uploading";
function submitUpload() {
if (!file || form.title.trim().length === 0) return;
actions.onUpload({ file, title: form.title.trim(), documentKind: form.documentKind, validUntilIso: form.validUntil || null });
}
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>
{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>
) : null}
{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>
) : 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}
</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>
);
}
@@ -0,0 +1,110 @@
// AK-P17a Interim-UI (AD-28) — password-safe vault list composed from ~/ui (D-HR
// "Passwort-Safe", archetype A2 + A5 create modal). Pure presentational: shows
// ONLY the vaults the caller holds access to (no secret values here); creating a
// vault runs through the injected action (route owns the fetcher). Final Subframe
// optics = tracked design-nachzug.
import { useState } from "react";
import { useTranslation } from "react-i18next";
import { FeatherPlus } from "@subframe/core";
import type { VaultListVM } from "@hivegrid/view-models";
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 { TextInput } from "~/ui/components/TextInput";
export type HrPasswordSafeListActions = {
onCreateVault: (input: { name: string; description: string }) => void;
};
export type HrPasswordSafeListPageProps = {
vm: VaultListVM;
submitting: boolean;
actions: HrPasswordSafeListActions;
};
export function HrPasswordSafeListPage({ vm, submitting, actions }: HrPasswordSafeListPageProps) {
const { t } = useTranslation();
const [createOpen, setCreateOpen] = useState(false);
const [name, setName] = useState("");
const [description, setDescription] = useState("");
if (vm.status !== "ready" || !vm.data) {
return <div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.hr.passwordSafe" />;
}
const { rows, canCreate, emptyHeadlineKey, emptyBodyKey } = vm.data;
function submitCreate() {
actions.onCreateVault({ name, description });
setCreateOpen(false);
setName("");
setDescription("");
}
return (
<div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.hr.passwordSafe">
<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.passwordSafe.title")}</span>
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">
{t("hr.passwordSafe.subtitle")}
</span>
</div>
{canCreate ? (
<Button icon={<FeatherPlus />} onClick={() => setCreateOpen(true)} data-ui-id="ui.hr.passwordSafe.new">
{t("hr.passwordSafe.action.newVault")}
</Button>
) : null}
</div>
{rows.length === 0 ? (
<div data-ui-id="ui.hr.passwordSafe.empty">
<EmptyState title={t(emptyHeadlineKey)} body={t(emptyBodyKey)} />
</div>
) : (
<div className="grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3" data-ui-id="ui.hr.passwordSafe.list">
{rows.map((row) => (
<a key={row.id} href={row.detailHref} className="no-underline" data-row-id={row.id}>
<Card>
<div className="flex w-full flex-col gap-1">
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">{row.name}</span>
{row.description ? (
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">
{row.description}
</span>
) : null}
</div>
</Card>
</a>
))}
</div>
)}
<Dialog open={createOpen} onOpenChange={setCreateOpen}>
<Dialog.Content className="w-full max-w-[560px] p-4" data-ui-id="ui.hr.passwordSafe.create">
<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.passwordSafe.create.title")}</span>
<div className="flex w-full flex-col gap-4">
<TextInput label={t("hr.passwordSafe.field.vaultName")} showLabel fillContainer>
<TextInput.Input value={name} onChange={(event) => setName(event.target.value)} data-ui-id="ui.hr.passwordSafe.create.name" />
</TextInput>
<TextInput label={t("hr.passwordSafe.field.description")} showLabel fillContainer>
<TextInput.Input value={description} onChange={(event) => setDescription(event.target.value)} />
</TextInput>
</div>
<div className="flex justify-end gap-2">
<Button variant="neutral" onClick={() => setCreateOpen(false)}>
{t("hr.action.cancel")}
</Button>
<Button loading={submitting} disabled={name.trim().length === 0} onClick={submitCreate} data-ui-id="ui.hr.passwordSafe.create.submit">
{t("hr.passwordSafe.create.submit")}
</Button>
</div>
</div>
</Dialog.Content>
</Dialog>
</div>
);
}
@@ -0,0 +1,79 @@
// AK-P17b Interim-UI (AD-28) — employee payslips composed from ~/ui (D-HR
// "Lohnabrechnungen", archetype A2). Pure presentational: own list; opening a
// payslip is audited server-side and returns the File id (route opens it). Final
// Subframe optics = tracked design-nachzug.
import { useTranslation } from "react-i18next";
import { FeatherExternalLink } from "@subframe/core";
import type { HrPayslipOwnVM } from "@hivegrid/view-models";
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
import { Button } from "~/ui/components/Button";
import { EmptyState } from "~/ui/components/EmptyState";
import { Table } from "~/ui/components/Table";
export type HrPayslipsActions = { onOpen: (payslipId: string) => void };
export type HrPayslipsPageProps = {
vm: HrPayslipOwnVM;
submitting: boolean;
actions: HrPayslipsActions;
};
export function HrPayslipsPage({ vm, submitting, actions }: HrPayslipsPageProps) {
const { t } = useTranslation();
const rows = vm.data?.rows ?? [];
if (vm.status !== "ready" || !vm.data) {
return <div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.hr.payslips" />;
}
return (
<div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.hr.payslips">
<div className="flex flex-col gap-0">
<span className="text-heading-2 font-heading-2 text-text-neutral-primary">{t("hr.payslips.title")}</span>
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">{t("hr.payslips.subtitle")}</span>
</div>
{rows.length === 0 ? (
<div data-ui-id="ui.hr.payslips.empty">
<EmptyState title={t("hr.payslips.own.empty.headline")} body={t("hr.payslips.own.empty.body")} />
</div>
) : (
<div className="w-full overflow-x-auto">
<Table
data-ui-id="ui.hr.payslips.list"
header={
<Table.HeaderRow>
<Table.HeaderCell>{t("hr.payslips.column.period")}</Table.HeaderCell>
<Table.HeaderCell> </Table.HeaderCell>
<Table.HeaderCell> </Table.HeaderCell>
</Table.HeaderRow>
}
>
{rows.map((row) => (
<Table.Row key={row.id} data-row-id={row.id} data-read={row.isRead}>
<Table.Cell>
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">{row.periodLabel}</span>
</Table.Cell>
<Table.Cell>
{!row.isRead ? (
<BadgeFeedback farbe="subtle-warning" size="small">
{t("hr.payslips.unread")}
</BadgeFeedback>
) : null}
</Table.Cell>
<Table.Cell>
<div className="flex justify-end">
<Button variant="tertiary" size="small" icon={<FeatherExternalLink />} loading={submitting} onClick={() => actions.onOpen(row.id)}>
{t("hr.payslips.action.open")}
</Button>
</div>
</Table.Cell>
</Table.Row>
))}
</Table>
</div>
)}
</div>
);
}
@@ -0,0 +1,223 @@
// 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 { FeatherPlus } from "@subframe/core";
import type { HrRequestApproverVM, HrRequestKind, HrRequestOwnVM } from "@hivegrid/view-models";
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";
export type HrRequestsTab = "own" | "approvals";
export type HrRequestTemplateOption = { id: string; title: string; requestKind: HrRequestKind };
export type HrRequestsActions = {
onSubmit: (input: { templateId: string; requestKind: string; approverUserId: string; title: string; details: string }) => 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[];
kinds: readonly HrRequestKind[];
tabHref: (tab: HrRequestsTab) => string;
submitting: boolean;
actions: HrRequestsActions;
};
const NO_TEMPLATE = "__none__";
export function HrRequestsPage({ tab, canApprove, ownVm, approverVm, templates, kinds, tabHref, submitting, actions }: HrRequestsPageProps) {
const { t } = useTranslation();
const [newOpen, setNewOpen] = useState(false);
const [clarifyFor, setClarifyFor] = useState<string | null>(null);
const [text, setText] = useState("");
const [form, setForm] = useState({ templateId: NO_TEMPLATE, requestKind: kinds[0] ?? "expense", approverUserId: "", title: "", details: "" });
const tabs: HrRequestsTab[] = canApprove ? ["own", "approvals"] : ["own"];
const ownRows = ownVm.data?.rows ?? [];
const approverRows = approverVm.data?.rows ?? [];
function submitNew() {
if (!form.title.trim()) return;
actions.onSubmit({ ...form, templateId: form.templateId === NO_TEMPLATE ? "" : form.templateId });
setNewOpen(false);
setForm({ templateId: NO_TEMPLATE, requestKind: kinds[0] ?? "expense", approverUserId: "", title: "", details: "" });
}
return (
<div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.hr.requests">
<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.requests.title")}</span>
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">{t("hr.requests.subtitle")}</span>
</div>
{tab === "own" ? (
<Button icon={<FeatherPlus />} onClick={() => setNewOpen(true)} data-ui-id="ui.hr.requests.new">
{t("hr.requests.action.new")}
</Button>
) : null}
</div>
<div data-ui-id="ui.hr.requests.tabs">
<Tabs>
{tabs.map((entry) => (
<a key={entry} href={tabHref(entry)} className="contents no-underline">
<Tabs.Item active={tab === entry}>{t(`hr.requests.tab.${entry}`)}</Tabs.Item>
</a>
))}
</Tabs>
</div>
{tab === "own" ? (
ownRows.length === 0 ? (
<div data-ui-id="ui.hr.requests.own.empty">
<EmptyState title={t("hr.requests.own.empty.headline")} body={t("hr.requests.own.empty.body")} />
</div>
) : (
<div className="flex w-full flex-col gap-3" data-ui-id="ui.hr.requests.own.list">
{ownRows.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">{row.title}</span>
<span className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-tertiary">{t(row.kindLabelKey)}</span>
</div>
<div className="flex items-center gap-2">
<BadgeFeedback farbe="subtle-neutral" size="small">
{t(row.statusLabelKey)}
</BadgeFeedback>
{row.canWithdraw ? (
<Button variant="tertiary" size="small" loading={submitting} onClick={() => actions.onWithdraw(row.id)}>
{t("hr.requests.action.withdraw")}
</Button>
) : null}
</div>
</div>
</Card>
))}
</div>
)
) : null}
{tab === "approvals" ? (
approverRows.length === 0 ? (
<div data-ui-id="ui.hr.requests.approvals.empty">
<EmptyState title={t("hr.requests.approver.empty.headline")} body={t("hr.requests.approver.empty.body")} />
</div>
) : (
<div className="flex w-full flex-col gap-3" data-ui-id="ui.hr.requests.approvals.list">
{approverRows.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">{row.title}</span>
<span className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-tertiary">
{row.employeeLabel} · {t(row.kindLabelKey)}
</span>
</div>
<div className="flex items-center gap-2">
<Button variant="tertiary" size="small" onClick={() => { setText(""); setClarifyFor(row.id); }}>
{t("hr.requests.action.clarify")}
</Button>
<Button variant="destructive" size="small" loading={submitting} onClick={() => actions.onReject(row.id)}>
{t("hr.requests.action.reject")}
</Button>
<Button size="small" loading={submitting} onClick={() => actions.onApprove(row.id)}>
{t("hr.requests.action.approve")}
</Button>
</div>
</div>
</Card>
))}
</div>
)
) : null}
{/* New request dialog */}
<Dialog open={newOpen} onOpenChange={setNewOpen}>
<Dialog.Content className="w-full max-w-[560px] p-4" data-ui-id="ui.hr.requests.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.requests.action.new")}</span>
<div className="flex w-full flex-col gap-4">
<Select label={t("hr.requests.field.template")} showLabel value={form.templateId} onValueChange={(v: string) => setForm((s) => ({ ...s, templateId: v }))}>
<Select.Item value={NO_TEMPLATE}>{t("hr.requests.field.noTemplate")}</Select.Item>
{templates.map((tpl) => (
<Select.Item key={tpl.id} value={tpl.id}>
{tpl.title}
</Select.Item>
))}
</Select>
<Select label={t("hr.requests.field.kind")} showLabel value={form.requestKind} onValueChange={(v: string) => setForm((s) => ({ ...s, requestKind: v as HrRequestKind }))}>
{kinds.map((kind) => (
<Select.Item key={kind} value={kind}>
{t(`hr.requests.kind.${kind}`)}
</Select.Item>
))}
</Select>
<TextInput label={t("hr.requests.field.title")} showLabel fillContainer>
<TextInput.Input value={form.title} onChange={(e) => setForm((s) => ({ ...s, title: e.target.value }))} />
</TextInput>
<TextInput label={t("hr.requests.field.approver")} showLabel fillContainer>
<TextInput.Input value={form.approverUserId} onChange={(e) => setForm((s) => ({ ...s, approverUserId: e.target.value }))} />
</TextInput>
<TextArea label={t("hr.requests.field.details")} showLabel className="w-full">
<TextArea.Input value={form.details} onChange={(e) => setForm((s) => ({ ...s, details: e.target.value }))} />
</TextArea>
</div>
<div className="flex justify-end gap-2">
<Button variant="neutral" onClick={() => setNewOpen(false)}>
{t("hr.action.cancel")}
</Button>
<Button loading={submitting} disabled={!form.title.trim()} onClick={submitNew} data-ui-id="ui.hr.requests.newDialog.submit">
{t("hr.requests.action.submit")}
</Button>
</div>
</div>
</Dialog.Content>
</Dialog>
{/* Clarify dialog */}
<Dialog open={clarifyFor !== null} onOpenChange={(open) => !open && setClarifyFor(null)}>
<Dialog.Content className="w-full max-w-[560px] p-4" data-ui-id="ui.hr.requests.clarifyDialog">
<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.requests.action.clarify")}</span>
<TextArea label={t("hr.requests.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={() => setClarifyFor(null)}>
{t("hr.action.cancel")}
</Button>
<Button
loading={submitting}
disabled={text.trim().length === 0}
onClick={() => {
if (clarifyFor) actions.onClarify(clarifyFor, text);
setClarifyFor(null);
}}
>
{t("hr.action.confirm")}
</Button>
</div>
</div>
</Dialog.Content>
</Dialog>
</div>
);
}
@@ -0,0 +1,283 @@
// AK-P17b Interim-UI (AD-28) — sick-leave screen composed from ~/ui (D-HR "Krank",
// archetype A2 + A4). Pure presentational: URL-driven tabs (own / office). The AU
// certificate is sensitive — never rendered; a reveal action decrypts + opens it
// on demand (route owns the fetch/open). Report / attach / close run through
// injected actions. Final Subframe optics = tracked design-nachzug.
import { useState } from "react";
import { useTranslation } from "react-i18next";
import { FeatherPlus } from "@subframe/core";
import type { HrSickLeaveOfficeVM, HrSickLeaveOwnVM, HrSickLeaveRow } from "@hivegrid/view-models";
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";
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;
onRevealCertificate: (reportId: string) => void;
onClose: (reportId: string, returnDate: string) => void;
};
export type HrSickPageProps = {
tab: HrSickTab;
canManage: boolean;
ownVm: HrSickLeaveOwnVM;
officeVm: HrSickLeaveOfficeVM;
tabHref: (tab: HrSickTab) => string;
submitting: boolean;
actions: HrSickActions;
};
type DialogState =
| { type: "report" }
| { type: "reportFor" }
| { type: "attach"; reportId: string }
| { type: "close"; reportId: string }
| null;
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) {
const { t } = useTranslation();
const [dialog, setDialog] = useState<DialogState>(null);
const [text, setText] = useState("");
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>
</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>
<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>
</div>
</div>
</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}
</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>
{/* 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>
</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>
);
}
function SickCard({
row,
submitting,
onReveal,
onAttach,
onClose,
}: {
row: HrSickLeaveRow;
submitting: boolean;
onReveal: () => void;
onAttach: () => void;
onClose: () => void;
}) {
const { t } = useTranslation();
return (
<Card 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">
{row.startDateIso}
{row.returnDateIso ? ` – ${row.returnDateIso}` : ""}
</span>
<span className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-tertiary">
{row.hasCertificate ? t("hr.sick.certificate.present") : t("hr.sick.certificate.missing")}
</span>
</div>
<div className="flex items-center gap-2">
<BadgeFeedback farbe="subtle-neutral" size="small">
{t(row.statusLabelKey)}
</BadgeFeedback>
{row.hasCertificate ? (
<Button variant="tertiary" size="small" loading={submitting} onClick={onReveal} data-ui-id="ui.hr.sick.reveal">
{t("hr.sick.action.revealCertificate")}
</Button>
) : (
<Button variant="tertiary" size="small" onClick={onAttach}>
{t("hr.sick.action.attachCertificate")}
</Button>
)}
{row.canClose ? (
<Button variant="tertiary" size="small" onClick={onClose}>
{t("hr.sick.action.close")}
</Button>
) : null}
</div>
</div>
</Card>
);
}
@@ -0,0 +1,188 @@
// AK-P17b Interim-UI (AD-28) — survey participation + item editor composed from
// ~/ui (D-HR "Umfrage Teilnahme", archetype A3/A4). Pure presentational: answers
// held in local state and submitted via the injected action (route maps them to
// item:<id> form fields); managers add/remove items. Final Subframe optics =
// tracked design-nachzug.
import { useState } from "react";
import { useTranslation } from "react-i18next";
import { FeatherPlus } from "@subframe/core";
import type { HrSurveyItem, HrSurveyItemType, HrSurveyParticipationVM } from "@hivegrid/view-models";
import { Alert } from "~/ui/components/Alert";
import { Button } from "~/ui/components/Button";
import { Card } from "~/ui/components/Card";
import { Checkbox } from "~/ui/components/Checkbox";
import { Dialog } from "~/ui/components/Dialog";
import { Select } from "~/ui/components/Select";
import { TextInput } from "~/ui/components/TextInput";
const ITEM_TYPES: readonly HrSurveyItemType[] = ["text", "rating_5", "nps", "choice", "boolean", "date"];
export type HrSurveyParticipationActions = {
onSubmit: (answers: Record<string, string>) => void;
onAddItem: (input: { itemType: string; prompt: string; options: string; required: boolean }) => void;
onRemoveItem: (itemId: string) => void;
};
export type HrSurveyParticipationPageProps = {
vm: HrSurveyParticipationVM;
canManage: boolean;
status: string;
submitting: boolean;
actions: HrSurveyParticipationActions;
};
// Controlled answer field per item type. Date uses a native input styled with the
// ~/ui design tokens (same sanctioned exception as the tasks DateField).
function AnswerField({ item, value, onChange }: { item: HrSurveyItem; value: string; onChange: (v: string) => void }) {
if (item.itemType === "boolean") {
return <Checkbox label="" checked={value === "true"} onCheckedChange={(c: boolean) => onChange(c ? "true" : "")} />;
}
if (item.itemType === "choice") {
return (
<Select value={value} onValueChange={onChange}>
{item.options.map((o) => (
<Select.Item key={o} value={o}>
{o}
</Select.Item>
))}
</Select>
);
}
if (item.itemType === "date") {
return (
<input
type="date"
value={value}
onChange={(e) => onChange(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"
/>
);
}
const numeric = item.itemType === "rating_5" || item.itemType === "nps";
return (
<TextInput fillContainer>
<TextInput.Input type={numeric ? "number" : "text"} value={value} onChange={(e) => onChange(e.target.value)} />
</TextInput>
);
}
export function HrSurveyParticipationPage({ vm, canManage, status, submitting, actions }: HrSurveyParticipationPageProps) {
const { t } = useTranslation();
const data = vm.data;
const [answers, setAnswers] = useState<Record<string, string>>({});
const [addOpen, setAddOpen] = useState(false);
const [item, setItem] = useState({ itemType: "text", prompt: "", options: "", required: false });
if (vm.status !== "ready" || !data) {
return <div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.hr.survey.participate" />;
}
function addItem() {
if (!item.prompt.trim()) return;
actions.onAddItem(item);
setAddOpen(false);
setItem({ itemType: "text", prompt: "", options: "", required: false });
}
return (
<div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.hr.survey.participate" data-row-id={data.surveyId}>
<div className="flex flex-col gap-0">
<span className="text-heading-2 font-heading-2 text-text-neutral-primary">{data.title}</span>
{data.description ? (
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">{data.description}</span>
) : null}
</div>
{data.isAnonymous ? <Alert variant="information" title={t(data.anonymousHintKey)} /> : null}
{data.alreadySubmitted ? (
<div data-ui-id="ui.hr.survey.submitted">
<Alert variant="success" title={t(data.submittedHintKey)} />
</div>
) : status === "open" ? (
<Card>
<div className="flex w-full flex-col gap-4" data-ui-id="ui.hr.survey.form">
{data.items.map((surveyItem) => (
<div key={surveyItem.id} className="flex flex-col gap-1" data-row-id={surveyItem.id}>
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">
{surveyItem.prompt}
{surveyItem.required ? " *" : ""}
</span>
<AnswerField
item={surveyItem}
value={answers[surveyItem.id] ?? ""}
onChange={(v) => setAnswers((s) => ({ ...s, [surveyItem.id]: v }))}
/>
</div>
))}
<div className="flex justify-end">
<Button loading={submitting} onClick={() => actions.onSubmit(answers)} data-ui-id="ui.hr.survey.submit">
{t("hr.surveys.action.submit")}
</Button>
</div>
</div>
</Card>
) : (
<div data-ui-id="ui.hr.survey.closed">
<Alert variant="neutral" title={t("hr.surveys.notOpen")} />
</div>
)}
{canManage ? (
<div className="flex w-full flex-col gap-3" data-ui-id="ui.hr.survey.editor">
<div className="flex items-center justify-between">
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">{t("hr.surveys.editor.title")}</span>
<Button variant="secondary" size="small" icon={<FeatherPlus />} onClick={() => setAddOpen(true)}>
{t("hr.surveys.editor.add")}
</Button>
</div>
{data.items.map((surveyItem) => (
<Card key={`edit-${surveyItem.id}`}>
<div className="flex w-full items-center justify-between gap-4">
<span className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary">
{t(surveyItem.typeLabelKey)} · {surveyItem.prompt}
</span>
<Button variant="tertiary" size="small" loading={submitting} onClick={() => actions.onRemoveItem(surveyItem.id)}>
{t("hr.surveys.editor.remove")}
</Button>
</div>
</Card>
))}
</div>
) : null}
<Dialog open={addOpen} onOpenChange={setAddOpen}>
<Dialog.Content className="w-full max-w-[560px] p-4" data-ui-id="ui.hr.survey.addItem">
<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.surveys.editor.add")}</span>
<div className="flex w-full flex-col gap-4">
<Select label={t("hr.surveys.editor.itemType")} showLabel value={item.itemType} onValueChange={(v: string) => setItem((s) => ({ ...s, itemType: v }))}>
{ITEM_TYPES.map((type) => (
<Select.Item key={type} value={type}>
{t(`hr.surveys.itemType.${type}`)}
</Select.Item>
))}
</Select>
<TextInput label={t("hr.surveys.editor.prompt")} showLabel fillContainer>
<TextInput.Input value={item.prompt} onChange={(e) => setItem((s) => ({ ...s, prompt: e.target.value }))} />
</TextInput>
<TextInput label={t("hr.surveys.editor.options")} showLabel fillContainer>
<TextInput.Input value={item.options} onChange={(e) => setItem((s) => ({ ...s, options: e.target.value }))} />
</TextInput>
<Checkbox label={t("hr.surveys.editor.required")} checked={item.required} onCheckedChange={(c: boolean) => setItem((s) => ({ ...s, required: c }))} />
</div>
<div className="flex justify-end gap-2">
<Button variant="neutral" onClick={() => setAddOpen(false)}>
{t("hr.action.cancel")}
</Button>
<Button loading={submitting} disabled={!item.prompt.trim()} onClick={addItem} data-ui-id="ui.hr.survey.addItem.submit">
{t("hr.surveys.editor.add")}
</Button>
</div>
</div>
</Dialog.Content>
</Dialog>
</div>
);
}
@@ -0,0 +1,87 @@
// AK-P17b Interim-UI (AD-28) — survey results composed from ~/ui (D-HR "Umfrage
// Ergebnisse", archetype A3). Pure presentational: per-item distribution (bar) +
// average + free-text responses. Final Subframe optics (richer charts) = tracked
// design-nachzug.
import { useTranslation } from "react-i18next";
import type { HrSurveyResultsVM } from "@hivegrid/view-models";
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
import { Card } from "~/ui/components/Card";
import { EmptyState } from "~/ui/components/EmptyState";
import { Progress } from "~/ui/components/Progress";
export type HrSurveyResultsPageProps = { vm: HrSurveyResultsVM };
export function HrSurveyResultsPage({ vm }: HrSurveyResultsPageProps) {
const { t } = useTranslation();
const data = vm.data;
if (vm.status !== "ready" || !data) {
return <div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.hr.survey.results" />;
}
return (
<div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.hr.survey.results" data-row-id={data.surveyId}>
<div className="flex flex-col gap-0">
<span className="text-heading-2 font-heading-2 text-text-neutral-primary">{data.title}</span>
<div className="flex items-center gap-2">
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">
{t("hr.surveys.results.count", { count: data.submissionCount })}
</span>
{data.isAnonymous ? (
<BadgeFeedback farbe="subtle-neutral" size="small">
{t("hr.surveys.anonymous")}
</BadgeFeedback>
) : null}
</div>
</div>
{data.submissionCount === 0 ? (
<div data-ui-id="ui.hr.survey.results.empty">
<EmptyState title={t("hr.surveys.results.empty.headline")} body={t("hr.surveys.results.empty.body")} />
</div>
) : (
<div className="flex w-full flex-col gap-4" data-ui-id="ui.hr.survey.results.items">
{data.items.map((item) => {
const entries = Object.entries(item.distribution);
const max = entries.reduce((m, [, count]) => Math.max(m, count), 0) || 1;
return (
<Card key={item.itemId} data-row-id={item.itemId}>
<div className="flex w-full flex-col gap-2">
<div className="flex items-center justify-between gap-3">
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">{item.prompt}</span>
<span className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-tertiary">
{t("hr.surveys.results.responses", { count: item.responseCount })}
{item.average != null ? ` · ⌀ ${item.average.toFixed(2)}` : ""}
</span>
</div>
{entries.length > 0 ? (
<div className="flex w-full flex-col gap-2">
{entries.map(([key, count]) => (
<div key={key} className="flex items-center gap-3">
<span className="w-24 shrink-0 text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-secondary">{key}</span>
<div className="flex-1">
<Progress value={(count / max) * 100} />
</div>
<span className="w-8 shrink-0 text-right text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-tertiary">{count}</span>
</div>
))}
</div>
) : null}
{item.textResponses.length > 0 ? (
<div className="flex w-full flex-col gap-1">
{item.textResponses.map((text, index) => (
<span key={index} className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">
{`“${text}”`}
</span>
))}
</div>
) : null}
</div>
</Card>
);
})}
</div>
)}
</div>
);
}
@@ -0,0 +1,149 @@
// AK-P17b Interim-UI (AD-28) — surveys list composed from ~/ui (D-HR "Umfragen",
// archetype A2 + A5). Pure presentational: participate / results links; managers
// create (Dialog) and open/close/archive via injected actions. Final Subframe
// optics = tracked design-nachzug.
import { useState } from "react";
import { useTranslation } from "react-i18next";
import { FeatherPlus } from "@subframe/core";
import type { HrSurveyListVM } from "@hivegrid/view-models";
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
import { Button } from "~/ui/components/Button";
import { Card } from "~/ui/components/Card";
import { Checkbox } from "~/ui/components/Checkbox";
import { Dialog } from "~/ui/components/Dialog";
import { EmptyState } from "~/ui/components/EmptyState";
import { LinkButton } from "~/ui/components/LinkButton";
import { Select } from "~/ui/components/Select";
import { TextInput } from "~/ui/components/TextInput";
const VISIBILITIES = ["admins", "participants", "everyone"] as const;
export type HrSurveysListActions = {
onCreate: (input: { title: string; description: string; isAnonymous: boolean; resultVisibility: string }) => void;
onSetStatus: (surveyId: string, status: "open" | "close") => void;
onArchive: (surveyId: string) => void;
};
export type HrSurveysListPageProps = {
vm: HrSurveyListVM;
canManage: boolean;
submitting: boolean;
actions: HrSurveysListActions;
};
export function HrSurveysListPage({ vm, canManage, submitting, actions }: HrSurveysListPageProps) {
const { t } = useTranslation();
const [open, setOpen] = useState(false);
const [form, setForm] = useState({ title: "", description: "", isAnonymous: false, resultVisibility: "admins" });
const rows = vm.data?.rows ?? [];
function submit() {
if (!form.title.trim()) return;
actions.onCreate(form);
setOpen(false);
setForm({ title: "", description: "", isAnonymous: false, resultVisibility: "admins" });
}
return (
<div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.hr.surveys">
<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.surveys.title")}</span>
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">{t("hr.surveys.subtitle")}</span>
</div>
{canManage ? (
<Button icon={<FeatherPlus />} onClick={() => setOpen(true)} data-ui-id="ui.hr.surveys.newBtn">
{t("hr.surveys.action.create")}
</Button>
) : null}
</div>
{rows.length === 0 ? (
<div data-ui-id="ui.hr.surveys.empty">
<EmptyState title={t("hr.surveys.empty.headline")} body={t("hr.surveys.empty.body")} />
</div>
) : (
<div className="flex w-full flex-col gap-2" data-ui-id="ui.hr.surveys.list">
{rows.map((row) => (
<Card key={row.id} data-row-id={row.id} data-status={row.status}>
<div className="flex w-full items-center justify-between gap-4">
<div className="flex items-center gap-2">
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">{row.title}</span>
<BadgeFeedback farbe={row.status === "open" ? "subtle-positive" : "subtle-neutral"} size="small">
{t(row.statusLabelKey)}
</BadgeFeedback>
{row.isAnonymous ? (
<BadgeFeedback farbe="subtle-neutral" size="small">
{t("hr.surveys.anonymous")}
</BadgeFeedback>
) : null}
</div>
<div className="flex items-center gap-2">
{row.status === "open" && !row.hasSubmitted ? (
<a href={row.participateHref} className="contents no-underline">
<LinkButton variant="subtle">{t("hr.surveys.action.participate")}</LinkButton>
</a>
) : null}
{row.canViewResults ? (
<a href={row.resultsHref} className="contents no-underline">
<LinkButton variant="subtle">{t("hr.surveys.action.results")}</LinkButton>
</a>
) : null}
{canManage ? (
<>
{row.status !== "open" ? (
<Button variant="tertiary" size="small" loading={submitting} onClick={() => actions.onSetStatus(row.id, "open")}>
{t("hr.surveys.action.open")}
</Button>
) : (
<Button variant="tertiary" size="small" loading={submitting} onClick={() => actions.onSetStatus(row.id, "close")}>
{t("hr.surveys.action.close")}
</Button>
)}
<a href={row.participateHref} className="contents no-underline">
<LinkButton variant="subtle">{t("hr.surveys.action.edit")}</LinkButton>
</a>
</>
) : null}
</div>
</div>
</Card>
))}
</div>
)}
<Dialog open={open} onOpenChange={setOpen}>
<Dialog.Content className="w-full max-w-[560px] p-4" data-ui-id="ui.hr.surveys.new">
<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.surveys.action.create")}</span>
<div className="flex w-full flex-col gap-4">
<TextInput label={t("hr.surveys.field.title")} showLabel fillContainer>
<TextInput.Input value={form.title} onChange={(e) => setForm((s) => ({ ...s, title: e.target.value }))} />
</TextInput>
<TextInput label={t("hr.surveys.field.description")} showLabel fillContainer>
<TextInput.Input value={form.description} onChange={(e) => setForm((s) => ({ ...s, description: e.target.value }))} />
</TextInput>
<Select label={t("hr.surveys.field.resultVisibility")} showLabel value={form.resultVisibility} onValueChange={(v: string) => setForm((s) => ({ ...s, resultVisibility: v }))}>
{VISIBILITIES.map((v) => (
<Select.Item key={v} value={v}>
{t(`hr.surveys.visibility.${v}`)}
</Select.Item>
))}
</Select>
<Checkbox label={t("hr.surveys.field.anonymous")} checked={form.isAnonymous} onCheckedChange={(c: boolean) => setForm((s) => ({ ...s, isAnonymous: c }))} />
</div>
<div className="flex justify-end gap-2">
<Button variant="neutral" onClick={() => setOpen(false)}>
{t("hr.action.cancel")}
</Button>
<Button loading={submitting} disabled={!form.title.trim()} onClick={submit} data-ui-id="ui.hr.surveys.new.submit">
{t("hr.surveys.action.create")}
</Button>
</div>
</div>
</Dialog.Content>
</Dialog>
</div>
);
}
@@ -0,0 +1,64 @@
import { vi, describe, it, expect } from "vitest";
import "@testing-library/jest-dom";
import { render, fireEvent, waitFor } from "@testing-library/react";
import { BrowserRouter as Router } from "react-router";
import { buildVaultDetailVM } from "@hivegrid/view-models";
import { HrVaultDetailPage } from "./HrVaultDetailPage";
vi.mock("react-i18next", () => ({
useTranslation: () => ({ t: (str: string) => str, i18n: { language: "de" } }),
}));
function vault(overrides: Record<string, unknown> = {}) {
return buildVaultDetailVM({
vaultId: "v1",
vaultName: "Team Vault",
accessLevel: "admin",
exportHref: "/acme/hr/password-safe/v1/export",
rows: [
{ id: "e1", title: "GitHub", tags: ["dev"], url: "https://github.com", hasUsername: true, hasPassword: true, hasNotes: false, revealHref: "/acme/hr/password-safe/v1/reveal" },
],
...overrides,
});
}
const noopActions = {
onReveal: vi.fn(async () => null),
onCreateEntry: vi.fn(),
onArchiveEntry: vi.fn(),
onGrantAccess: vi.fn(),
};
describe("HrVaultDetailPage (interim-UI, security-critical)", () => {
it("never renders secret values in the entry list — only reveal controls", () => {
const { container, queryByText } = render(
<Router>
<HrVaultDetailPage vm={vault()} backHref=".." submitting={false} actions={noopActions} />
</Router>,
);
// The entry surface renders...
expect(container.querySelector('[data-row-id="e1"]')).toBeInTheDocument();
// ...with reveal controls, but no plaintext secret anywhere before an explicit reveal.
expect(container.querySelectorAll('[data-ui-id="ui.hr.vault.reveal"]').length).toBeGreaterThan(0);
expect(queryByText("s3cret")).not.toBeInTheDocument();
expect(container.querySelector('[data-ui-id="ui.hr.vault.revealed"]')).not.toBeInTheDocument();
});
it("reveals a single field on demand via the injected onReveal action and then offers copy", async () => {
const onReveal = vi.fn(async () => "s3cret");
const { container, findByText } = render(
<Router>
<HrVaultDetailPage vm={vault()} backHref=".." submitting={false} actions={{ ...noopActions, onReveal }} />
</Router>,
);
const revealBtn = container.querySelector('[data-ui-id="ui.hr.vault.reveal"]') as HTMLElement;
fireEvent.click(revealBtn);
await waitFor(() => expect(onReveal).toHaveBeenCalledWith("e1", "username"));
// The plaintext now appears next to a copy control; the 30s clipboard wipe is
// driven by that CopyToClipboardButton's onCopy (exercised end-to-end in the
// browser — the Subframe copy primitive is not reliably triggerable in jsdom).
expect(await findByText("s3cret")).toBeInTheDocument();
expect(container.querySelector('[data-ui-id="ui.hr.vault.revealed"]')).toBeInTheDocument();
});
});
@@ -0,0 +1,318 @@
// AK-P17a Interim-UI (AD-28) — vault detail composed from ~/ui (D-HR
// "Passwort-Safe Detail", archetype A3 + reveal). SECURITY-CRITICAL: secret
// values are NEVER in the list — each entry shows only "hasX" flags. A value is
// fetched ONLY on an explicit, audited reveal (route action) and, once copied, the
// clipboard is wiped after copyAutoClearMs (30s, DoD #3). Create-entry / grant-
// access run through injected actions. Final Subframe optics = design-nachzug.
import { useEffect, useRef, useState } from "react";
import { useTranslation } from "react-i18next";
import { FeatherPlus } from "@subframe/core";
import type { EntryRow, VaultDetailVM } from "@hivegrid/view-models";
import { Breadcrumbs } from "~/ui/components/Breadcrumbs";
import { Button } from "~/ui/components/Button";
import { Card } from "~/ui/components/Card";
import { CopyToClipboardButton } from "~/ui/components/CopyToClipboardButton";
import { Dialog } from "~/ui/components/Dialog";
import { EmptyState } from "~/ui/components/EmptyState";
import { LinkButton } from "~/ui/components/LinkButton";
import { Select } from "~/ui/components/Select";
import { Tag_Label } from "~/ui/components/Tag_Label";
import { TextInput } from "~/ui/components/TextInput";
export type VaultSecretField = "username" | "password" | "notes";
export type VaultAccessLevel = "read" | "write" | "admin";
export type HrVaultDetailActions = {
/** Reveal ONE field of ONE entry (audited server-side); resolves the plaintext. */
onReveal: (entryId: string, field: VaultSecretField) => Promise<string | null>;
onCreateEntry: (input: { title: string; url: string; username: string; password: string; notes: string }) => void;
onArchiveEntry: (entryId: string) => void;
onGrantAccess: (input: { targetUserId: string; permissionLevel: VaultAccessLevel }) => void;
};
export type HrVaultDetailPageProps = {
vm: VaultDetailVM;
backHref: string;
submitting: boolean;
actions: HrVaultDetailActions;
};
/** One revealable secret field: reveal on demand, copy, wipe clipboard after the
* VM-supplied window (30s). The value is held only in local component state. */
function SecretField({
entryId,
field,
labelKey,
autoClearMs,
onReveal,
}: {
entryId: string;
field: VaultSecretField;
labelKey: string;
autoClearMs: number;
onReveal: HrVaultDetailActions["onReveal"];
}) {
const { t } = useTranslation();
const [value, setValue] = useState<string | null>(null);
const [loading, setLoading] = useState(false);
const [copied, setCopied] = useState(false);
const clearTimer = useRef<ReturnType<typeof setTimeout> | null>(null);
useEffect(() => () => {
if (clearTimer.current) clearTimeout(clearTimer.current);
}, []);
async function reveal() {
setLoading(true);
try {
setValue(await onReveal(entryId, field));
} finally {
setLoading(false);
}
}
function scheduleClipboardWipe() {
setCopied(true);
if (clearTimer.current) clearTimeout(clearTimer.current);
clearTimer.current = setTimeout(() => {
// Wipe the clipboard so a copied secret does not linger (DoD #3).
void navigator.clipboard?.writeText("").catch(() => {});
setCopied(false);
}, autoClearMs);
}
return (
<div className="flex items-center justify-between gap-3" data-ui-id={`ui.hr.vault.field.${field}`}>
<span className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-tertiary">{t(labelKey)}</span>
{value === null ? (
<Button variant="tertiary" size="small" loading={loading} onClick={reveal} data-ui-id="ui.hr.vault.reveal">
{t("hr.passwordSafe.detail.reveal")}
</Button>
) : (
<div className="flex items-center gap-2">
<span className="font-mono text-body-default-regular-0 text-text-neutral-primary" data-ui-id="ui.hr.vault.revealed">
{value}
</span>
<CopyToClipboardButton
clipboardText={value}
tooltipText={t("hr.passwordSafe.detail.copy")}
onCopy={scheduleClipboardWipe}
/>
<Button variant="tertiary" size="small" onClick={() => setValue(null)}>
{t("hr.passwordSafe.detail.hide")}
</Button>
</div>
)}
{copied ? (
<span className="text-body-small-regular-0 font-body-small-regular-0 text-text-feedback-warning" data-ui-id="ui.hr.vault.copyHint">
{t("hr.passwordSafe.detail.copyCleared")}
</span>
) : null}
</div>
);
}
function EntryCard({
entry,
autoClearMs,
canWrite,
submitting,
onReveal,
onArchive,
}: {
entry: EntryRow;
autoClearMs: number;
canWrite: boolean;
submitting: boolean;
onReveal: HrVaultDetailActions["onReveal"];
onArchive: (entryId: string) => void;
}) {
const { t } = useTranslation();
return (
<Card data-row-id={entry.id}>
<div className="flex w-full items-start 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">{entry.title}</span>
{entry.url ? (
<a href={entry.url} target="_blank" rel="noreferrer" className="text-body-small-regular-0 font-body-small-regular-0 text-text-feedback-link-default">
{entry.url}
</a>
) : null}
{entry.tags.length > 0 ? (
<div className="flex flex-wrap items-center gap-1">
{entry.tags.map((tag) => (
<Tag_Label key={tag} tone="neutral-subtle" size="small" noAction>
{tag}
</Tag_Label>
))}
</div>
) : null}
</div>
{canWrite ? (
<Button variant="tertiary" size="small" loading={submitting} onClick={() => onArchive(entry.id)} data-ui-id="ui.hr.vault.archiveEntry">
{t("hr.passwordSafe.detail.archiveEntry")}
</Button>
) : null}
</div>
<div className="flex w-full flex-col gap-2">
{entry.hasUsername ? (
<SecretField entryId={entry.id} field="username" labelKey="hr.passwordSafe.field.username" autoClearMs={autoClearMs} onReveal={onReveal} />
) : null}
{entry.hasPassword ? (
<SecretField entryId={entry.id} field="password" labelKey="hr.passwordSafe.field.password" autoClearMs={autoClearMs} onReveal={onReveal} />
) : null}
{entry.hasNotes ? (
<SecretField entryId={entry.id} field="notes" labelKey="hr.passwordSafe.field.notes" autoClearMs={autoClearMs} onReveal={onReveal} />
) : null}
</div>
</Card>
);
}
export function HrVaultDetailPage({ vm, backHref, submitting, actions }: HrVaultDetailPageProps) {
const { t } = useTranslation();
const [entryOpen, setEntryOpen] = useState(false);
const [accessOpen, setAccessOpen] = useState(false);
const [entry, setEntry] = useState({ title: "", url: "", username: "", password: "", notes: "" });
const [access, setAccess] = useState<{ targetUserId: string; permissionLevel: VaultAccessLevel }>({ targetUserId: "", permissionLevel: "read" });
if (vm.status !== "ready" || !vm.data) {
return <div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.hr.vault" />;
}
const { vaultName, rows, canWrite, canManageAccess, copyAutoClearMs, exportHref, emptyHeadlineKey, emptyBodyKey } = vm.data;
function submitEntry() {
actions.onCreateEntry(entry);
setEntryOpen(false);
setEntry({ title: "", url: "", username: "", password: "", notes: "" });
}
function submitAccess() {
actions.onGrantAccess(access);
setAccessOpen(false);
setAccess({ targetUserId: "", permissionLevel: "read" });
}
return (
<div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.hr.vault">
<Breadcrumbs>
<a href={backHref} className="contents no-underline" data-ui-id="ui.hr.vault.back">
<Breadcrumbs.Item>{t("hr.passwordSafe.detail.back")}</Breadcrumbs.Item>
</a>
<Breadcrumbs.Divider />
<Breadcrumbs.Item active>{vaultName}</Breadcrumbs.Item>
</Breadcrumbs>
<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">{vaultName}</span>
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">
{t("hr.passwordSafe.detail.subtitle")}
</span>
</div>
<div className="flex items-center gap-2">
<a href={exportHref} className="contents no-underline" data-ui-id="ui.hr.vault.export">
<LinkButton variant="subtle">{t("hr.passwordSafe.detail.export")}</LinkButton>
</a>
{canManageAccess ? (
<Button variant="secondary" onClick={() => setAccessOpen(true)} data-ui-id="ui.hr.vault.manageAccess">
{t("hr.passwordSafe.detail.manageAccess")}
</Button>
) : null}
{canWrite ? (
<Button icon={<FeatherPlus />} onClick={() => setEntryOpen(true)} data-ui-id="ui.hr.vault.newEntry">
{t("hr.passwordSafe.detail.newEntry")}
</Button>
) : null}
</div>
</div>
{rows.length === 0 ? (
<div data-ui-id="ui.hr.vault.empty">
<EmptyState title={t(emptyHeadlineKey)} body={t(emptyBodyKey)} />
</div>
) : (
<div className="flex w-full flex-col gap-4" data-ui-id="ui.hr.vault.entries">
{rows.map((row) => (
<EntryCard
key={row.id}
entry={row}
autoClearMs={copyAutoClearMs}
canWrite={canWrite}
submitting={submitting}
onReveal={actions.onReveal}
onArchive={actions.onArchiveEntry}
/>
))}
</div>
)}
{/* New entry dialog (canWrite) */}
<Dialog open={entryOpen} onOpenChange={setEntryOpen}>
<Dialog.Content className="w-full max-w-[560px] p-4" data-ui-id="ui.hr.vault.createEntry">
<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.passwordSafe.detail.newEntry")}</span>
<div className="flex w-full flex-col gap-4">
<TextInput label={t("hr.passwordSafe.field.entryTitle")} showLabel fillContainer>
<TextInput.Input value={entry.title} onChange={(e) => setEntry((s) => ({ ...s, title: e.target.value }))} data-ui-id="ui.hr.vault.createEntry.title" />
</TextInput>
<TextInput label={t("hr.passwordSafe.field.url")} showLabel fillContainer>
<TextInput.Input value={entry.url} onChange={(e) => setEntry((s) => ({ ...s, url: e.target.value }))} />
</TextInput>
<TextInput label={t("hr.passwordSafe.field.username")} showLabel fillContainer>
<TextInput.Input value={entry.username} onChange={(e) => setEntry((s) => ({ ...s, username: e.target.value }))} />
</TextInput>
<TextInput label={t("hr.passwordSafe.field.password")} showLabel fillContainer type="password">
<TextInput.Input type="password" value={entry.password} onChange={(e) => setEntry((s) => ({ ...s, password: e.target.value }))} />
</TextInput>
<TextInput label={t("hr.passwordSafe.field.notes")} showLabel fillContainer>
<TextInput.Input value={entry.notes} onChange={(e) => setEntry((s) => ({ ...s, notes: e.target.value }))} />
</TextInput>
</div>
<div className="flex justify-end gap-2">
<Button variant="neutral" onClick={() => setEntryOpen(false)}>
{t("hr.action.cancel")}
</Button>
<Button loading={submitting} disabled={entry.title.trim().length === 0} onClick={submitEntry} data-ui-id="ui.hr.vault.createEntry.submit">
{t("hr.passwordSafe.detail.createEntry.submit")}
</Button>
</div>
</div>
</Dialog.Content>
</Dialog>
{/* Grant access dialog (canManageAccess) */}
<Dialog open={accessOpen} onOpenChange={setAccessOpen}>
<Dialog.Content className="w-full max-w-[560px] p-4" data-ui-id="ui.hr.vault.grantAccess">
<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.passwordSafe.detail.manageAccess")}</span>
<div className="flex w-full flex-col gap-4">
<TextInput label={t("hr.passwordSafe.field.targetUser")} showLabel fillContainer>
<TextInput.Input value={access.targetUserId} onChange={(e) => setAccess((s) => ({ ...s, targetUserId: e.target.value }))} data-ui-id="ui.hr.vault.grantAccess.user" />
</TextInput>
<Select
label={t("hr.passwordSafe.field.permissionLevel")}
showLabel
value={access.permissionLevel}
onValueChange={(value: string) => setAccess((s) => ({ ...s, permissionLevel: value as VaultAccessLevel }))}
>
<Select.Item value="read">{t("hr.passwordSafe.access.read")}</Select.Item>
<Select.Item value="write">{t("hr.passwordSafe.access.write")}</Select.Item>
<Select.Item value="admin">{t("hr.passwordSafe.access.admin")}</Select.Item>
</Select>
</div>
<div className="flex justify-end gap-2">
<Button variant="neutral" onClick={() => setAccessOpen(false)}>
{t("hr.action.cancel")}
</Button>
<Button loading={submitting} disabled={access.targetUserId.trim().length === 0} onClick={submitAccess} data-ui-id="ui.hr.vault.grantAccess.submit">
{t("hr.passwordSafe.detail.grantAccess.submit")}
</Button>
</div>
</div>
</Dialog.Content>
</Dialog>
</div>
);
}