Skip to content

Commit

Permalink
fixed gender save
Browse files Browse the repository at this point in the history
  • Loading branch information
Abh1noob committed Mar 13, 2024
1 parent b608f04 commit b4d05a9
Show file tree
Hide file tree
Showing 14 changed files with 30 additions and 35 deletions.
2 changes: 1 addition & 1 deletion devsoc24-portal-fe/src/api/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export async function signup(email: string, password: string) {
);
return data;
} catch (err) {
console.log(err);
// console.log(err);
if (axios.isAxiosError(err)) {
const error = err as AxiosError;
return error.response?.status ?? 500;
Expand Down
2 changes: 1 addition & 1 deletion devsoc24-portal-fe/src/app/edit-idea/edit-idea-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default function EditIdeaForm() {
// console.log(res.data.data);
form.reset(res.data.data);
} catch (error) {
console.log("Error getting idea submission:", error);
// console.log("Error getting idea submission:", error);
}
}
void getIdeaSubmission();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default function EditProjectForm() {
// console.log(res.data.data);
form.reset(res.data.data);
} catch (error) {
console.log("Error getting idea submission:", error);
// console.log("Error getting idea submission:", error);
}
}
void getIdeaSubmission();
Expand Down
8 changes: 4 additions & 4 deletions devsoc24-portal-fe/src/app/home/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export default function HomePage() {
// console.log("401");
break;
default:
console.log(e);
// console.log(e);
break;
}
}
Expand Down Expand Up @@ -116,7 +116,7 @@ export default function HomePage() {
// console.log("Not in team");
break;
default:
console.log(e);
// console.log(e);
break;
}
}
Expand Down Expand Up @@ -152,7 +152,7 @@ export default function HomePage() {
setTeam(true);
break;
default:
console.log(e);
// console.log(e);
break;
}
}
Expand Down Expand Up @@ -189,7 +189,7 @@ export default function HomePage() {
setIdea(409);
break;
default:
console.log(e);
// console.log(e);
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion devsoc24-portal-fe/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default function RootLayout({
// console.log(res);
})
.catch((e) => {
console.log(e);
// console.log(e);
});
}, 270000);
}, []);
Expand Down
2 changes: 1 addition & 1 deletion devsoc24-portal-fe/src/app/login-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default function LoginForm() {
return `Logged in successfully!`;
},
error: (err: AxiosError) => {
console.log("ERR", err);
// console.log("ERR", err);
switch (err.response?.status) {
case 404:
return `Account not found!`;
Expand Down
5 changes: 2 additions & 3 deletions devsoc24-portal-fe/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"use client";

"use client"
import React, { useEffect, useState } from "react";
import Logo from "@/components/logo";
import { Card, CardContent, CardHeader } from "@/components/ui/card";
Expand Down Expand Up @@ -34,7 +33,7 @@ export default function Page() {
<div className="flex max-w-[90vw] grow items-center justify-center">
<Card className="w-fit">
<CardHeader className="items-center">
<Image src={titles[currentTitleIndex] as string} alt="title" />
<Image src={titles[currentTitleIndex] as string} alt="title" priority />
</CardHeader>
<div className="mt-3 flex flex-col items-center">
<p className="text-2xl font-semibold text-black">Welcome back!</p>
Expand Down
2 changes: 1 addition & 1 deletion devsoc24-portal-fe/src/app/profile/profile-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default function Profile() {
// console.log(response.data.data);
form.reset(response.data.data);
} catch (error) {
console.log("Error getting idea submission:", error);
// console.log("Error getting idea submission:", error);
}
}
void getIdeaSubmission();
Expand Down
28 changes: 12 additions & 16 deletions devsoc24-portal-fe/src/app/signup/details/personal-details-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,30 +49,22 @@ export default function PersonalDetails({
mode: "onChange",
shouldUnregister: false,
});
const [gender, setGender] = useState("");

useEffect(() => {
form.setValue("firstName", localStorage.getItem("first_name") ?? "");
form.setValue("lastName", localStorage.getItem("last_name") ?? "");
form.setValue("email", email ?? "");
form.setValue("phoneNumber", localStorage.getItem("phone_number") ?? "");
form.setValue("country", localStorage.getItem("country") ?? "+91");
const temp = localStorage.getItem("gender") as
| "Male"
| "Female"
| "Others"
| "Prefer Not to Say";

setGender(temp);
}, []);

useEffect(() => {
form.setValue(
"gender",
gender as "Male" | "Female" | "Others" | "Prefer Not to Say",
(localStorage.getItem("gender") as
| "Male"
| "Female"
| "Others"
| "Prefer Not to Say") ?? "",
);
setGender(form.getValues("gender"));
// console.log("Form Values:", form.getValues());
}, [gender]);
}, []);

async function onSubmit(data: PersonalDetailsFormValues) {
localStorage.setItem("first_name", data.firstName);
Expand Down Expand Up @@ -228,7 +220,11 @@ export default function PersonalDetails({
<FormLabel>Gender</FormLabel>
<Select
onValueChange={field.onChange}
defaultValue={form.getValues("gender")}
defaultValue={
typeof localStorage !== "undefined"
? localStorage.getItem("gender") ?? undefined
: undefined
}
>
<FormControl>
<SelectTrigger>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function Submission() {
// console.log(res.data.data);
setIdeaDetails(res.data.data);
} catch (error) {
console.log("Error getting idea submission:", error)
// console.log("Error getting idea submission:", error)
}
}
void getIdeaSubmission();
Expand Down
4 changes: 2 additions & 2 deletions devsoc24-portal-fe/src/components/team/joinTeam.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function JoinTeam() {
case 202:
// console.log("Accepted");
default:
console.log(e);
// console.log(e);
}
}
}
Expand Down Expand Up @@ -67,7 +67,7 @@ function JoinTeam() {
setTeam(true);
break;
default:
console.log(e);
// console.log(e);
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion devsoc24-portal-fe/src/components/team/kick.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const Kick = () => {
// console.log("Not in team");
break;
default:
console.log(e);
// console.log(e);
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion devsoc24-portal-fe/src/components/team/leaveTeam.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const LeaveTeam = () => {
// console.log("Not in team");
break;
default:
console.log(e);
// console.log(e);
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion devsoc24-portal-fe/src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const refresh = async () => {
// console.log("REFESH: ", e);
}
default:
console.log(e);
// console.log(e);
}
}
}
Expand Down

0 comments on commit b4d05a9

Please sign in to comment.