fosrl.pangolin/src/app/admin/users/page.tsx

62 lines
2 KiB
TypeScript
Raw Normal View History

2025-03-21 18:04:14 -04:00
import { internal } from "@app/lib/api";
import { authCookieHeader } from "@app/lib/api/cookies";
import { AxiosResponse } from "axios";
import SettingsSectionTitle from "@app/components/SettingsSectionTitle";
import { AdminListUsersResponse } from "@server/routers/user/adminListUsers";
import UsersTable, { GlobalUserRow } from "./AdminUsersTable";
2025-04-17 21:21:41 -04:00
import { Alert, AlertDescription, AlertTitle } from "@app/components/ui/alert";
import { InfoIcon } from "lucide-react";
2025-05-25 19:01:20 +00:00
import { getTranslations } from "next-intl/server";
2025-03-21 18:04:14 -04:00
type PageProps = {
params: Promise<{ orgId: string }>;
};
export const dynamic = "force-dynamic";
export default async function UsersPage(props: PageProps) {
let rows: AdminListUsersResponse["users"] = [];
try {
const res = await internal.get<AxiosResponse<AdminListUsersResponse>>(
`/users`,
await authCookieHeader()
);
rows = res.data.data.users;
} catch (e) {
console.error(e);
}
2025-05-17 18:17:22 +00:00
const t = await getTranslations();
2025-03-21 18:04:14 -04:00
const userRows: GlobalUserRow[] = rows.map((row) => {
return {
id: row.id,
email: row.email,
2025-04-13 17:57:27 -04:00
name: row.name,
username: row.username,
type: row.type,
idpId: row.idpId,
idpName: row.idpName || t('idpNameInternal'),
2025-03-21 18:04:14 -04:00
dateCreated: row.dateCreated,
serverAdmin: row.serverAdmin
};
});
return (
<>
<SettingsSectionTitle
2025-05-06 06:49:47 +00:00
title={t('userTitle')}
description={t('userDescription')}
2025-03-21 18:04:14 -04:00
/>
2025-04-17 21:21:41 -04:00
<Alert variant="neutral" className="mb-6">
<InfoIcon className="h-4 w-4" />
2025-05-06 06:49:47 +00:00
<AlertTitle className="font-semibold">{t('userAbount')}</AlertTitle>
2025-04-17 21:21:41 -04:00
<AlertDescription>
2025-05-06 06:49:47 +00:00
{t('userAbountDescription')}
2025-04-17 21:21:41 -04:00
</AlertDescription>
</Alert>
2025-03-21 18:04:14 -04:00
<UsersTable users={userRows} />
</>
);
}