mirror of
https://github.com/i701/sarlink-portal.git
synced 2025-07-15 11:05:50 +00:00
48 lines
1.3 KiB
TypeScript
48 lines
1.3 KiB
TypeScript
import { redirect } from "next/navigation";
|
|
import { getServerSession } from "next-auth";
|
|
import { authOptions } from "@/app/auth";
|
|
import ClientErrorMessage from "@/components/client-error-message";
|
|
import UserUpdateForm from "@/components/user/user-update-form";
|
|
import { getProfileById } from "@/queries/users";
|
|
import { tryCatch } from "@/utils/tryCatch";
|
|
// import {
|
|
// Select,
|
|
// SelectContent,
|
|
// SelectGroup,
|
|
// SelectItem,
|
|
// SelectLabel,
|
|
// SelectTrigger,
|
|
// SelectValue,
|
|
// } from "@/components/ui/select";
|
|
|
|
export default async function UserUpdate({
|
|
params,
|
|
}: {
|
|
params: Promise<{
|
|
userId: string;
|
|
}>;
|
|
}) {
|
|
const { userId } = await params;
|
|
const session = await getServerSession(authOptions);
|
|
if (!session?.user?.is_admin) return null
|
|
const [error, user] = await tryCatch(getProfileById(userId));
|
|
|
|
|
|
if (error) {
|
|
if (error.message === "UNAUTHORIZED") {
|
|
redirect("/auth/signin");
|
|
} else {
|
|
return <ClientErrorMessage message={error.message} />;
|
|
}
|
|
}
|
|
|
|
return (
|
|
<div>
|
|
<div className="flex items-center justify-between text-gray-500 text-2xl font-bold title-bg py-4 px-2 mb-4">
|
|
<h3 className="text-sarLinkOrange text-2xl">Verify user</h3>
|
|
</div>
|
|
<UserUpdateForm user={user} />
|
|
</div>
|
|
);
|
|
}
|