Reworks the app from a two-role (hr_admin/manager) model to a single HR-only role gated by profiles.is_active, fixes transfer/promote/karenz/ reorg RPCs to actually defer future-dated changes via a new pending_org_changes table instead of writing them immediately (applied by a daily Vercel Cron route), makes reorg undo append-only instead of deleting history, adds Karenz-return and history-date integrity guards, deprecates the salary column, and adds explicit schema grants + perf indexes needed to run against a fresh (non-hosted) Postgres instance. Adds vitest unit + integration test suites (the latter against a real local Supabase instance) covering all of the above, plus lint/typecheck/ build wiring (`npm run check`).
43 lines
1.3 KiB
TypeScript
43 lines
1.3 KiB
TypeScript
import { OrgChartClient } from "@/components/orgchart/OrgChartClient";
|
|
import { loadOpenPositions } from "@/lib/positions";
|
|
import { createClient } from "@/lib/supabase/server";
|
|
|
|
export default async function OrgChartPage() {
|
|
const supabase = await createClient();
|
|
|
|
const [
|
|
{ data: employees },
|
|
{ data: divisions },
|
|
{ data: departments },
|
|
{ data: teams },
|
|
openPositions,
|
|
{ data: reorgScenarios },
|
|
] = await Promise.all([
|
|
supabase
|
|
.from("employees")
|
|
.select("id, personnel_number, first_name, last_name, job_title, manager_id, team_id, division_id, is_lead, org_level")
|
|
.in("status", ["Aktiv", "Karenz"]),
|
|
supabase.from("divisions").select("*").order("name"),
|
|
supabase.from("departments").select("*"),
|
|
supabase.from("teams").select("*"),
|
|
loadOpenPositions(supabase),
|
|
supabase
|
|
.from("reorg_scenarios")
|
|
.select("id, name, effective_date, applied, applied_at")
|
|
.eq("applied", true)
|
|
.order("applied_at", { ascending: false })
|
|
.limit(5),
|
|
]);
|
|
|
|
return (
|
|
<OrgChartClient
|
|
employees={employees ?? []}
|
|
divisions={divisions ?? []}
|
|
departments={departments ?? []}
|
|
teams={teams ?? []}
|
|
openPositions={openPositions}
|
|
reorgScenarios={reorgScenarios ?? []}
|
|
/>
|
|
);
|
|
}
|