198 lines
6.1 KiB
TypeScript
198 lines
6.1 KiB
TypeScript
// R-UX3 Interim-UI (AD-28) — task-oriented personnel hub composed from ~/ui.
|
|
// Visibility, counts and allowed actions arrive in the VM; this component has
|
|
// no role names, permissions or client-side data filtering.
|
|
|
|
import type { ReactNode } from "react";
|
|
import { useTranslation } from "react-i18next";
|
|
import { AppLink } from "~/components/app/AppLink";
|
|
import {
|
|
FeatherArrowRight,
|
|
FeatherBell,
|
|
FeatherBriefcase,
|
|
FeatherClipboard,
|
|
FeatherLock,
|
|
FeatherUser,
|
|
} from "@subframe/core";
|
|
import type { HrHubItem, HrHubSection, HrHubVM } from "@hivegrid/view-models";
|
|
import {
|
|
PAGE_HEADER_ICON_CLASS,
|
|
PageBody,
|
|
PageHeader,
|
|
PageShell,
|
|
} from "../shared/PageShell";
|
|
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
|
|
import { Card } from "~/ui/components/Card";
|
|
import { EmptyState } from "~/ui/components/EmptyState";
|
|
|
|
export type HrHubPageProps = {
|
|
vm: HrHubVM;
|
|
};
|
|
|
|
function TaskCount({ count }: { count: number }) {
|
|
const { t } = useTranslation();
|
|
if (count <= 0) return null;
|
|
return (
|
|
<BadgeFeedback farbe="subtle-warning" size="small">
|
|
{t("hr.hub.openCount", { count })}
|
|
</BadgeFeedback>
|
|
);
|
|
}
|
|
|
|
function HubItemCard({ item, priority = false }: { item: HrHubItem; priority?: boolean }) {
|
|
const { t } = useTranslation();
|
|
return (
|
|
<AppLink
|
|
href={item.href}
|
|
className="group/item min-w-0 no-underline"
|
|
data-row-id={item.id}
|
|
data-ui-id={`ui.hr.hub.item.${item.id}`}
|
|
>
|
|
<Card>
|
|
<div
|
|
className={
|
|
priority
|
|
? "flex min-h-28 w-full items-start justify-between gap-4"
|
|
: "flex min-h-24 w-full items-start justify-between gap-4"
|
|
}
|
|
>
|
|
<div className="flex min-w-0 grow flex-col gap-2">
|
|
<div className="flex flex-wrap items-center gap-2">
|
|
<span className="text-body-large-medium-0 font-body-large-medium-0 text-text-neutral-primary">
|
|
{t(item.labelKey)}
|
|
</span>
|
|
<TaskCount count={item.count} />
|
|
</div>
|
|
<span className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-secondary">
|
|
{t(item.descriptionKey)}
|
|
</span>
|
|
</div>
|
|
<FeatherArrowRight
|
|
aria-hidden="true"
|
|
className="mt-1 shrink-0 text-body-default-regular-0 font-body-default-regular-0 text-icon-neutral-tertiary transition-transform group-hover/item:translate-x-0.5"
|
|
/>
|
|
</div>
|
|
</Card>
|
|
</AppLink>
|
|
);
|
|
}
|
|
|
|
function HubSectionView({
|
|
section,
|
|
icon,
|
|
}: {
|
|
section: HrHubSection;
|
|
icon: ReactNode;
|
|
}) {
|
|
const { t } = useTranslation();
|
|
if (!section.visible) return null;
|
|
return (
|
|
<section
|
|
className="flex w-full flex-col gap-4"
|
|
aria-labelledby={`hr-hub-${section.id}`}
|
|
data-ui-id={`ui.hr.hub.section.${section.id}`}
|
|
>
|
|
<div className="flex items-start gap-3">
|
|
<span className="mt-0.5 text-heading-3 font-heading-3 text-icon-brand-primary">
|
|
{icon}
|
|
</span>
|
|
<div className="flex min-w-0 grow flex-col gap-1">
|
|
<div className="flex flex-wrap items-center gap-2">
|
|
<h2
|
|
id={`hr-hub-${section.id}`}
|
|
className="text-heading-3 font-heading-3 text-text-neutral-primary"
|
|
>
|
|
{t(section.labelKey)}
|
|
</h2>
|
|
<TaskCount count={section.count} />
|
|
</div>
|
|
<p className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-secondary">
|
|
{t(section.descriptionKey)}
|
|
</p>
|
|
</div>
|
|
</div>
|
|
<div className="grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3">
|
|
{section.items.map((item) => (
|
|
<HubItemCard key={item.id} item={item} />
|
|
))}
|
|
</div>
|
|
</section>
|
|
);
|
|
}
|
|
|
|
export function HrHubPage({ vm }: HrHubPageProps) {
|
|
const { t } = useTranslation();
|
|
|
|
if (!vm.moduleActive) {
|
|
return (
|
|
<PageShell uiId="ui.hr.hub">
|
|
<PageHeader
|
|
icon={<FeatherUser className={PAGE_HEADER_ICON_CLASS} />}
|
|
title={t("hr.hub.title")}
|
|
subtitle={t("hr.hub.subtitle")}
|
|
/>
|
|
<PageBody>
|
|
<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>
|
|
</PageBody>
|
|
</PageShell>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<PageShell uiId="ui.hr.hub">
|
|
<PageHeader
|
|
icon={<FeatherUser className={PAGE_HEADER_ICON_CLASS} />}
|
|
title={t("hr.hub.title")}
|
|
subtitle={t("hr.hub.subtitle")}
|
|
actions={<TaskCount count={vm.openTaskCount} />}
|
|
/>
|
|
<PageBody>
|
|
<section
|
|
className="flex w-full flex-col gap-4"
|
|
aria-labelledby="hr-hub-priority"
|
|
data-ui-id="ui.hr.hub.priority"
|
|
>
|
|
<div className="flex flex-col gap-1">
|
|
<h2
|
|
id="hr-hub-priority"
|
|
className="text-heading-3 font-heading-3 text-text-neutral-primary"
|
|
>
|
|
{t("hr.hub.priority.title")}
|
|
</h2>
|
|
<p className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-secondary">
|
|
{t(
|
|
vm.openTaskCount > 0
|
|
? "hr.hub.priority.body"
|
|
: "hr.hub.priority.emptyBody",
|
|
)}
|
|
</p>
|
|
</div>
|
|
<div className="grid grid-cols-1 gap-4 sm:grid-cols-2">
|
|
{vm.priorityActions.map((item) => (
|
|
<HubItemCard key={item.id} item={item} priority />
|
|
))}
|
|
</div>
|
|
</section>
|
|
|
|
<HubSectionView
|
|
section={vm.forMe}
|
|
icon={<FeatherClipboard aria-hidden="true" />}
|
|
/>
|
|
<HubSectionView
|
|
section={vm.myTeam}
|
|
icon={<FeatherBell aria-hidden="true" />}
|
|
/>
|
|
<HubSectionView
|
|
section={vm.administration}
|
|
icon={<FeatherBriefcase aria-hidden="true" />}
|
|
/>
|
|
</PageBody>
|
|
</PageShell>
|
|
);
|
|
}
|