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
+70
@@ -0,0 +1,70 @@
|
||||
// P17 HR-Hub core (AK-P17a) — HR hub start route. Loader gates on the connector
|
||||
// (module off -> locked empty state) and hr.read_own (missing -> 404), then
|
||||
// renders quick links to the HR areas. Interim-UI (AD-28): the loader builds the
|
||||
// data, HrHubPage renders it from ~/ui; final Subframe optics = design-nachzug.
|
||||
|
||||
import { type LoaderFunctionArgs, useLoaderData } from "react-router";
|
||||
import { getTranslations } from "~/locale/i18next.server";
|
||||
import { loadHrContext, notFoundResponse, requireHrPermission } from "~/utils/integrations/hrAccess.server";
|
||||
import {
|
||||
hrAnnouncementsPath,
|
||||
hrDirectoryPath,
|
||||
hrLeavePath,
|
||||
hrLocationsPath,
|
||||
hrMyDocumentsPath,
|
||||
hrPasswordSafePath,
|
||||
hrPayslipsPath,
|
||||
hrRequestsPath,
|
||||
hrSickPath,
|
||||
hrSurveysPath,
|
||||
HR_MODULE_KEY,
|
||||
} from "~/utils/integrations/hrRoutePaths";
|
||||
import ServerError from "~/components/ui/errors/ServerError";
|
||||
import { HrHubPage, type HrHubLink } from "~/components/screens/hr/HrHubPage";
|
||||
|
||||
type LoaderData = { title: string; moduleActive: boolean; links: HrHubLink[]; canViewAdmin: boolean };
|
||||
|
||||
export const loader = async ({ request, params }: LoaderFunctionArgs) => {
|
||||
const { t } = await getTranslations(request);
|
||||
const ctx = await loadHrContext({ request, params });
|
||||
const tenantSlug = params.tenant ?? "";
|
||||
|
||||
if (!ctx.hasModule) {
|
||||
return Response.json({ title: `${t("hr.hub.title")} | ${process.env.APP_NAME}`, moduleActive: false, links: [], canViewAdmin: false } satisfies LoaderData);
|
||||
}
|
||||
|
||||
try {
|
||||
requireHrPermission(ctx, "hr.read_own");
|
||||
} catch {
|
||||
throw notFoundResponse();
|
||||
}
|
||||
|
||||
const links: HrHubLink[] = [
|
||||
{ labelKey: "hr.nav.leave", href: hrLeavePath(tenantSlug) },
|
||||
{ labelKey: "hr.nav.sick", href: hrSickPath(tenantSlug) },
|
||||
{ labelKey: "hr.nav.announcements", href: hrAnnouncementsPath(tenantSlug) },
|
||||
{ labelKey: "hr.nav.payslips", href: hrPayslipsPath(tenantSlug) },
|
||||
{ labelKey: "hr.nav.requests", href: hrRequestsPath(tenantSlug) },
|
||||
{ labelKey: "hr.nav.surveys", href: hrSurveysPath(tenantSlug) },
|
||||
{ labelKey: "hr.nav.directory", href: hrDirectoryPath(tenantSlug) },
|
||||
{ labelKey: "hr.nav.locations", href: hrLocationsPath(tenantSlug) },
|
||||
{ labelKey: "hr.nav.myDocuments", href: hrMyDocumentsPath(tenantSlug) },
|
||||
];
|
||||
if (ctx.permissions.includes("hr.passwordsafe.use")) {
|
||||
links.push({ labelKey: "hr.nav.passwordSafe", href: hrPasswordSafePath(tenantSlug) });
|
||||
}
|
||||
const canViewAdmin = ctx.permissions.includes("hr.passwordsafe.admin");
|
||||
|
||||
return Response.json({ title: `${t("hr.hub.title")} | ${process.env.APP_NAME}`, moduleActive: true, links, canViewAdmin } satisfies LoaderData);
|
||||
};
|
||||
|
||||
export default function HrHubRoute() {
|
||||
const { moduleActive, links } = useLoaderData<LoaderData>();
|
||||
return <HrHubPage moduleActive={moduleActive} links={links} />;
|
||||
}
|
||||
|
||||
export function ErrorBoundary() {
|
||||
return <ServerError />;
|
||||
}
|
||||
|
||||
export const handle = { moduleKey: HR_MODULE_KEY };
|
||||
Reference in new issue
Block a user