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`).
46 lines
1.9 KiB
TypeScript
46 lines
1.9 KiB
TypeScript
import { notFound } from "next/navigation";
|
|
import { EmployeeDetail } from "@/components/employees/EmployeeDetail";
|
|
import { createClient } from "@/lib/supabase/server";
|
|
|
|
type PageProps = { params: Promise<{ id: string }> };
|
|
|
|
export default async function EmployeeDetailPage({ params }: PageProps) {
|
|
const { id } = await params;
|
|
const supabase = await createClient();
|
|
|
|
const { data: employee } = await supabase.from("employees").select("*").eq("id", id).single();
|
|
if (!employee) notFound();
|
|
|
|
const [{ data: manager }, { data: directReports }, { data: history }, { data: divisions }, { data: departments }, { data: teams }, { data: locations }, { data: openPositions }] =
|
|
await Promise.all([
|
|
employee.manager_id
|
|
? supabase.from("employees").select("id, first_name, last_name, job_title").eq("id", employee.manager_id).single()
|
|
: Promise.resolve({ data: null }),
|
|
supabase
|
|
.from("employees")
|
|
.select("id, first_name, last_name, job_title, status")
|
|
.eq("manager_id", id)
|
|
.order("last_name"),
|
|
supabase.from("employee_history").select("*").eq("employee_id", id).order("event_date", { ascending: false }).order("created_at", { ascending: false }),
|
|
supabase.from("divisions").select("*").order("name"),
|
|
supabase.from("departments").select("*"),
|
|
supabase.from("teams").select("*"),
|
|
supabase.from("locations").select("*").order("name"),
|
|
supabase.from("positions").select("id, position_number, title, team_id, is_lead").eq("status", "open"),
|
|
]);
|
|
|
|
return (
|
|
<EmployeeDetail
|
|
employee={employee}
|
|
manager={manager ?? null}
|
|
directReports={directReports ?? []}
|
|
history={history ?? []}
|
|
divisions={divisions ?? []}
|
|
departments={departments ?? []}
|
|
teams={teams ?? []}
|
|
locations={locations ?? []}
|
|
openPositions={openPositions ?? []}
|
|
/>
|
|
);
|
|
}
|