Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
+69
-22
@@ -6,12 +6,13 @@
|
||||
|
||||
import { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
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 { EmptyState } from "~/ui/components/EmptyState";
|
||||
import { Select } from "~/ui/components/Select";
|
||||
import { Table } from "~/ui/components/Table";
|
||||
import { TextArea } from "~/ui/components/TextArea";
|
||||
import { TextInput } from "~/ui/components/TextInput";
|
||||
|
||||
export type PayslipPreviewRow = {
|
||||
@@ -26,16 +27,26 @@ export type PayslipPreviewRow = {
|
||||
|
||||
export type PayslipAdminRow = { id: string; employeeLabel: string; periodLabel: string; isRead: boolean };
|
||||
|
||||
export type PayslipMemberOption = {
|
||||
userId: string;
|
||||
displayName: string;
|
||||
team: string | null;
|
||||
roleNames: readonly string[];
|
||||
};
|
||||
|
||||
export type HrAdminPayslipsActions = {
|
||||
onMatch: (input: { periodYear: string; periodMonth: string; files: string }) => void;
|
||||
onConfirm: (input: { fileId: string; employeeUserId: string; periodYear: string; periodMonth: string }) => void;
|
||||
onMatch: (input: { periodYear: string; periodMonth: string; files: readonly File[] }) => void;
|
||||
onConfirm: (input: { file: File; employeeUserId: string; periodYear: string; periodMonth: string }) => void;
|
||||
};
|
||||
|
||||
export type HrAdminPayslipsPageProps = {
|
||||
rows: readonly PayslipAdminRow[];
|
||||
preview: readonly PayslipPreviewRow[];
|
||||
memberOptions: readonly PayslipMemberOption[];
|
||||
period: { year: string; month: string };
|
||||
submitting: boolean;
|
||||
errorKey: string | null;
|
||||
feedbackKey: string | null;
|
||||
actions: HrAdminPayslipsActions;
|
||||
};
|
||||
|
||||
@@ -45,11 +56,12 @@ function toneFarbe(tone: string): "subtle-positive" | "subtle-warning" | "subtle
|
||||
return "subtle-neutral";
|
||||
}
|
||||
|
||||
export function HrAdminPayslipsPage({ rows, preview, period, submitting, actions }: HrAdminPayslipsPageProps) {
|
||||
export function HrAdminPayslipsPage({ rows, preview, memberOptions, period, submitting, errorKey, feedbackKey, actions }: HrAdminPayslipsPageProps) {
|
||||
const { t } = useTranslation();
|
||||
const [year, setYear] = useState("");
|
||||
const [month, setMonth] = useState("");
|
||||
const [files, setFiles] = useState("");
|
||||
const [files, setFiles] = useState<File[]>([]);
|
||||
const [matchedFiles, setMatchedFiles] = useState<File[]>([]);
|
||||
const [assignees, setAssignees] = useState<Record<string, string>>({});
|
||||
|
||||
return (
|
||||
@@ -70,15 +82,38 @@ export function HrAdminPayslipsPage({ rows, preview, period, submitting, actions
|
||||
<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>
|
||||
<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.payslips.field.filesHint")}</span>
|
||||
<input
|
||||
type="file"
|
||||
accept="application/pdf,.pdf"
|
||||
multiple
|
||||
onChange={(event) => setFiles(Array.from(event.target.files ?? []))}
|
||||
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.admin.payslips.files"
|
||||
/>
|
||||
</label>
|
||||
{files.length > 0 ? (
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary" data-ui-id="ui.hr.admin.payslips.files.selected">
|
||||
{t("hr.payslips.upload.selected", { count: files.length })}
|
||||
</span>
|
||||
) : null}
|
||||
{errorKey ? <Alert variant="error" description={t(errorKey)} notDismissible data-ui-id="ui.hr.admin.payslips.error" /> : null}
|
||||
{submitting ? (
|
||||
<Alert variant="information" description={t("hr.payslips.upload.checking")} notDismissible data-ui-id="ui.hr.admin.payslips.loading" />
|
||||
) : null}
|
||||
{!submitting && feedbackKey ? (
|
||||
<Alert variant="success" description={t(feedbackKey)} notDismissible data-ui-id="ui.hr.admin.payslips.success" />
|
||||
) : null}
|
||||
<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 })}
|
||||
disabled={!year.trim() || !month.trim() || files.length === 0}
|
||||
onClick={() => {
|
||||
setMatchedFiles(files);
|
||||
actions.onMatch({ periodYear: year, periodMonth: month, files });
|
||||
}}
|
||||
data-ui-id="ui.hr.admin.payslips.match.submit"
|
||||
>
|
||||
{t("hr.payslips.action.match")}
|
||||
@@ -91,7 +126,7 @@ export function HrAdminPayslipsPage({ rows, preview, period, submitting, actions
|
||||
<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}>
|
||||
<Card key={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>
|
||||
@@ -99,23 +134,35 @@ export function HrAdminPayslipsPage({ rows, preview, period, submitting, actions
|
||||
{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>
|
||||
<div className="flex items-end gap-2 mobile:flex-col mobile:items-stretch">
|
||||
<Select
|
||||
label={t("hr.payslips.field.employee")}
|
||||
showLabel
|
||||
triggerAriaLabel={t("hr.payslips.field.employee")}
|
||||
value={assignees[row.fileId] ?? row.employeeUserId ?? undefined}
|
||||
placeholder={t("hr.payslips.field.employeePlaceholder")}
|
||||
onValueChange={(employeeUserId: string) => setAssignees((current) => ({ ...current, [row.fileId]: employeeUserId }))}
|
||||
className="max-w-none grow"
|
||||
>
|
||||
{memberOptions.map((member) => (
|
||||
<Select.Item key={member.userId} value={member.userId}>
|
||||
{member.displayName} · {member.team ?? t("hr.picker.noTeam")} · {member.roleNames.join(", ") || t("hr.picker.noRole")}
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
<Button
|
||||
loading={submitting}
|
||||
onClick={() =>
|
||||
disabled={!(assignees[row.fileId] ?? row.employeeUserId) || !matchedFiles[Number(row.fileId)]}
|
||||
onClick={() => {
|
||||
const file = matchedFiles[Number(row.fileId)];
|
||||
if (!file) return;
|
||||
actions.onConfirm({
|
||||
fileId: row.fileId,
|
||||
file,
|
||||
employeeUserId: assignees[row.fileId] ?? row.employeeUserId ?? "",
|
||||
periodYear: period.year,
|
||||
periodMonth: period.month,
|
||||
})
|
||||
}
|
||||
});
|
||||
}}
|
||||
>
|
||||
{t("hr.payslips.action.assign")}
|
||||
</Button>
|
||||
|
||||
Reference in new issue
Block a user