mirror of
https://github.com/i701/sarlink-portal.git
synced 2025-07-28 05:03:33 +00:00
feat(user-agreement): implement user agreement upload functionality and update related components ✨
This commit is contained in:
47
app/(dashboard)/users/[userId]/agreement/page.tsx
Normal file
47
app/(dashboard)/users/[userId]/agreement/page.tsx
Normal file
@ -0,0 +1,47 @@
|
||||
import { redirect } from "next/navigation";
|
||||
import { getServerSession } from "next-auth";
|
||||
import { authOptions } from "@/app/auth";
|
||||
import ClientErrorMessage from "@/components/client-error-message";
|
||||
import UserAgreementForm from "@/components/user/user-agreement-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">Upload user user agreement</h3>
|
||||
</div>
|
||||
<UserAgreementForm user={user} />
|
||||
</div>
|
||||
);
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
import { PencilIcon } from "lucide-react";
|
||||
import { FileTextIcon, PencilIcon } from "lucide-react";
|
||||
import Image from "next/image";
|
||||
import Link from "next/link";
|
||||
import { redirect } from "next/navigation";
|
||||
@ -42,7 +42,7 @@ export default async function VerifyUserPage({
|
||||
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>
|
||||
<h3 className="text-sarLinkOrange text-2xl">User Information</h3>
|
||||
|
||||
<div className="flex gap-2">
|
||||
{dbUser && !dbUser?.verified && <UserVerifyDialog user={dbUser} />}
|
||||
@ -53,6 +53,12 @@ export default async function VerifyUserPage({
|
||||
Update User
|
||||
</Button>
|
||||
</Link>
|
||||
<Link href={'agreement'}>
|
||||
<Button className="hover:cursor-pointer">
|
||||
<FileTextIcon />
|
||||
Update Agreement
|
||||
</Button>
|
||||
</Link>
|
||||
{dbUser?.verified && (
|
||||
<Badge variant={"secondary"} className="bg-lime-500">
|
||||
Verified
|
||||
|
4
app/next-auth.d.ts
vendored
4
app/next-auth.d.ts
vendored
@ -1,6 +1,7 @@
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||
// @ts-expect-error importing unused types are required here
|
||||
import NextAuth, { DefaultSession, type User, Session } from "next-auth";
|
||||
import NextAuth, { DefaultSession, Session, type User } from "next-auth";
|
||||
|
||||
/* eslint-enable @typescript-eslint/no-unused-vars */
|
||||
declare module "next-auth" {
|
||||
/**
|
||||
@ -26,6 +27,7 @@ declare module "next-auth" {
|
||||
date_joined?: string;
|
||||
is_superuser?: boolean;
|
||||
is_admin?: boolean;
|
||||
agreement?: string;
|
||||
};
|
||||
expires: ISODateString;
|
||||
}
|
||||
|
Reference in New Issue
Block a user