diff --git a/src/app/(dashboard)/people/page.tsx b/src/app/(dashboard)/people/page.tsx index dca1681..5ac5308 100644 --- a/src/app/(dashboard)/people/page.tsx +++ b/src/app/(dashboard)/people/page.tsx @@ -13,21 +13,36 @@ import { type PersonDepartmentCopy, type PersonFallbackCopy, } from "./_components/person.copy" +import TeamsTab from "./_components/teams.tab" import { formatUserRole, type UserFallbackCopy, type UserRoleCopy, } from "./_components/user.copy" +const VALID_TABS = ["people", "teams"] as const + +type Tab = (typeof VALID_TABS)[number] + +function resolveTab(raw: string | undefined): Tab { + if (raw && VALID_TABS.includes(raw as Tab)) { + return raw as Tab + } + + return "people" +} + export default async function PeoplePage(props: { searchParams?: Promise<{ page?: string search?: string + tab?: string }> }) { const searchParams = await props.searchParams const currentPage = searchParams?.page ? parseInt(searchParams.page, 10) : 1 const search = searchParams?.search || "" + const activeTab = resolveTab(searchParams?.tab) const { data: people, totalPages } = await PersonService.findAllPaginated({ page: currentPage, pageSize: 10, @@ -35,6 +50,7 @@ export default async function PeoplePage(props: { }) const { dictionary } = await getI18n() const copy = dictionary.inventory.people + const teamCopy = dictionary.inventory.teams const userCopy = dictionary.admin.users const userStatusCopy = userCopy.status const userRoleLabels = userCopy.roles as UserRoleCopy @@ -42,7 +58,7 @@ export default async function PeoplePage(props: { const departmentCopy = copy.departments as PersonDepartmentCopy const personFallbackCopy = copy.fallback as PersonFallbackCopy - return ( + const peopleList = (
) + + return ( +
+ + {activeTab === "teams" && } + {activeTab === "people" && peopleList} +
+ ) } diff --git a/tests/unit/app/people/person-pages.test.ts b/tests/unit/app/people/person-pages.test.ts index c64a4c4..aecbcc3 100644 --- a/tests/unit/app/people/person-pages.test.ts +++ b/tests/unit/app/people/person-pages.test.ts @@ -44,6 +44,10 @@ vi.mock("@/components/common/pagination", () => ({ createElement("nav", { "aria-label": "Pagination" }, totalPages), })) +vi.mock("@/app/(dashboard)/people/_components/teams.tab", () => ({ + default: () => null, +})) + describe("person pages", () => { beforeEach(() => { vi.clearAllMocks()