diff --git a/devsoc24-portal-fe/src/app/profile/profile-form.tsx b/devsoc24-portal-fe/src/app/profile/profile-form.tsx index f0a6093..c3b052f 100644 --- a/devsoc24-portal-fe/src/app/profile/profile-form.tsx +++ b/devsoc24-portal-fe/src/app/profile/profile-form.tsx @@ -12,19 +12,25 @@ import { Label } from "@/components/ui/label"; import { Input } from "@/components/ui/input"; import { Textarea } from "@/components/ui/textarea"; import { Button } from "@/components/ui/button"; -import { ideaSchema } from "@/schemas/idea"; -import toast, { Toaster } from 'react-hot-toast'; - +import { profileSchema } from "@/schemas/profile"; +import toast, { Toaster } from "react-hot-toast"; +import blocks from "@/../public/hostels.json"; import axios from "axios"; import { useRouter } from "next/navigation"; interface FormValues { - title: string; - track: string; - description: string; - figma_link?: string; - github_link?: string; - others: string; + first_name: string; + last_name: string; + email: string; + phone: string; + gender: string; + vit_email: string; + block: string; + room: string; + college: string; + city: string; + state: string; + reg_no: string; } interface SubmitProjectResponse { @@ -33,7 +39,7 @@ interface SubmitProjectResponse { data: unknown; } -interface GetIdea{ +interface GetIdea { data: FormValues; message: string; status: string; @@ -45,47 +51,51 @@ import { useEffect } from "react"; const tracks = ["Track 1", "Track 2", "Track 3"]; export default function Profile() { - useEffect(() => { - async function getIdeaSubmission() { - try { - const res = await axios.get(`${process.env.NEXT_PUBLIC_API_URL}/idea`, { - withCredentials: true, - }); - console.log(res.data.data); - form.reset(res.data.data); - } catch (error) { - console.log("Error getting idea submission:", error) - } - } - void getIdeaSubmission(); - }, []); + // useEffect(() => { + // async function getIdeaSubmission() { + // try { + // const res = await axios.get( + // `${process.env.NEXT_PUBLIC_API_URL}/idea`, + // { + // withCredentials: true, + // }, + // ); + // console.log(res.data.data); + // form.reset(res.data.data); + // } catch (error) { + // console.log("Error getting idea submission:", error); + // } + // } + // void getIdeaSubmission(); + // }, []); const form = useForm({ - resolver: zodResolver(ideaSchema), + resolver: zodResolver(profileSchema), defaultValues: { - title: "", - track: "", - description: "", - figma_link: "", - github_link: "", - others: "", + first_name: "", + last_name: "", + phone: "", + vit_email: "", + block: "", + room: "", + reg_no: "", }, mode: "onChange", }); async function onSubmit(data: FormValues) { - try { + // try { console.log(data); - // const toastId = toast.loading("Idea Submitted", { autoClose: false }); - const res = await axios.patch( - `${process.env.NEXT_PUBLIC_API_URL}/idea/update`, - data, - { - withCredentials: true, - }, - ); + // const toastId = toast.loading("Idea Submitted", { autoClose: false }); + // const res = await axios.patch( + // `${process.env.NEXT_PUBLIC_API_URL}/idea/update`, + // data, + // { + // withCredentials: true, + // }, + // ); - if (res.data.status === "success") { + // if (res.data.status === "success") { // toast.update(toastId, { // render: ( //
@@ -96,7 +106,7 @@ export default function Profile() { // isLoading: false, // autoClose: 2000, // }); - } else { + // } else { // toast.update(toastId, { // render: ( //
@@ -108,41 +118,44 @@ export default function Profile() { // isLoading: false, // autoClose: 2000, // }); - } - } catch (error) { - console.error("Error submitting idea:", error); - toast.error("Failed to submit idea"); - } + // } + // } catch (error) { + // console.error("Error submitting idea:", error); + // toast.error("Failed to submit idea"); + // } } return ( <>
- +
(
( - ( - - -
- - -
-
- -
- )} - /> + name="last_name" + render={({ field }) => ( + + +
+ + +
+
+ +
)} >
(
-