Files
HiveGrid-Wireframes/03 Quellen und Referenzen/hivegrid-cloud/apps/web/app/components/screens/hr/HrPayslipsPage.tsx
T

92 lines
3.4 KiB
TypeScript

// 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, FeatherFileText } from "@subframe/core";
import type { HrPayslipOwnVM } from "@hivegrid/view-models";
import { PAGE_HEADER_ICON_CLASS, PageBody, PageHeader, PageShell } from "../shared/PageShell";
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 (
<PageShell uiId="ui.hr.payslips">
<PageHeader
icon={<FeatherFileText className={PAGE_HEADER_ICON_CLASS} />}
title={t("hr.payslips.title")}
subtitle={t("hr.payslips.subtitle")}
/>
<PageBody>{null}</PageBody>
</PageShell>
);
}
return (
<PageShell uiId="ui.hr.payslips">
<PageHeader
icon={<FeatherFileText className={PAGE_HEADER_ICON_CLASS} />}
title={t("hr.payslips.title")}
subtitle={t("hr.payslips.subtitle")}
/>
<PageBody>
{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>
)}
</PageBody>
</PageShell>
);
}