Update hivegrid-cloud reference to latest main
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e98d38e716
commit
7b21524c86
3781 files changed
+373484
-225607
No files matched your search
+159
@@ -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>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user