-
Notifications
You must be signed in to change notification settings - Fork 456
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e233092
commit f500dfd
Showing
16 changed files
with
955 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ const prisma = new PrismaClient(); | |
|
||
const users = [ | ||
{ id: '1', name: 'Jack', email: '[email protected]' }, | ||
{ id: '2', name: 'Admin', email: '[email protected]', role: Role.ADMIN }, | ||
{ id: '2', name: 'Admin', email: '[email protected]', role: Role.ADMIN , onBoard : true }, | ||
{ id: '3', name: 'Hr', email: '[email protected]', role: Role.HR }, | ||
]; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import VerticalLinearStepper from '@/components/user-multistep-form/user-multistep-form'; | ||
import { authOptions } from '@/lib/authOptions'; | ||
import { getServerSession } from 'next-auth'; | ||
import { redirect } from 'next/navigation'; | ||
|
||
export default async function Home() { | ||
const session = await getServerSession(authOptions); | ||
if (!session || session.user.role !== 'USER') redirect('/'); | ||
if (session.user.onBoard === true) redirect('/profile'); | ||
return ( | ||
<div className="flex flex-col justify-center place-items-center"> | ||
<h1 className="text-xl font-bold md:text-3xl md:font-extrabold m-auto"> | ||
Hey {session?.user.name} let's get you set up and started! | ||
</h1> | ||
<VerticalLinearStepper /> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
117 changes: 117 additions & 0 deletions
117
src/components/user-multistep-form/add-project-form.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
import { | ||
projectSchema, | ||
projectSchemaType, | ||
} from '@/lib/validators/user.profile.validator'; | ||
import { zodResolver } from '@hookform/resolvers/zod'; | ||
import { useForm } from 'react-hook-form'; | ||
import { | ||
Form, | ||
FormItem, | ||
FormLabel, | ||
FormControl, | ||
FormMessage, | ||
FormField, | ||
} from '../ui/form'; | ||
import { Input } from '../ui/input'; | ||
import { Button } from '../ui/button'; | ||
import { Textarea } from '../ui/textarea'; | ||
import { useToast } from '../ui/use-toast'; | ||
import { addUserProjects } from '@/actions/user.profile.actions'; | ||
|
||
export const AddProject = () => { | ||
const form = useForm<projectSchemaType>({ | ||
resolver: zodResolver(projectSchema), | ||
defaultValues: { | ||
projectName: '', | ||
projectSummary: '', | ||
projectGithub: '', | ||
projectLiveLink: '', | ||
}, | ||
}); | ||
|
||
const { toast } = useToast(); | ||
|
||
const onSubmit = async (data: projectSchemaType) => { | ||
try { | ||
const response = await addUserProjects(data); | ||
|
||
if (!response.status) { | ||
return toast({ | ||
title: response.message || 'Error', | ||
variant: 'destructive', | ||
}); | ||
} | ||
toast({ | ||
title: response.message, | ||
variant: 'success', | ||
}); | ||
form.reset(form.formState.defaultValues); | ||
} catch (_error) { | ||
toast({ | ||
title: 'Something went wrong while Adding Projects', | ||
description: 'Internal server error', | ||
variant: 'destructive', | ||
}); | ||
} | ||
}; | ||
|
||
return ( | ||
<Form {...form}> | ||
<form onSubmit={form.handleSubmit(onSubmit)}> | ||
<FormField | ||
control={form.control} | ||
name="projectName" | ||
render={({ field }) => ( | ||
<FormItem> | ||
<FormLabel>Project Name</FormLabel> | ||
<FormControl> | ||
<Input {...field} /> | ||
</FormControl> | ||
</FormItem> | ||
)} | ||
/> | ||
<FormField | ||
control={form.control} | ||
name="projectGithub" | ||
render={({ field }) => ( | ||
<FormItem> | ||
<FormLabel>Project Github Link</FormLabel> | ||
<FormControl> | ||
<Input {...field} /> | ||
</FormControl> | ||
</FormItem> | ||
)} | ||
/> | ||
<FormField | ||
control={form.control} | ||
name="projectLiveLink" | ||
render={({ field }) => ( | ||
<FormItem> | ||
<FormLabel>Project Live Link</FormLabel> | ||
<FormControl> | ||
<Input {...field} /> | ||
</FormControl> | ||
<FormMessage /> | ||
</FormItem> | ||
)} | ||
/> | ||
<FormField | ||
control={form.control} | ||
name="projectSummary" | ||
render={({ field }) => ( | ||
<FormItem> | ||
<FormLabel>Project Summary</FormLabel> | ||
<FormControl> | ||
<Textarea {...field} /> | ||
</FormControl> | ||
<FormMessage /> | ||
</FormItem> | ||
)} | ||
/> | ||
<Button type="submit" className="mt-4"> | ||
Submit | ||
</Button> | ||
</form> | ||
</Form> | ||
); | ||
}; |
Oops, something went wrong.