Skip to content

Commit c677a81

Browse files
committed
Fix build errors
1 parent b21b159 commit c677a81

File tree

5 files changed

+70
-53
lines changed

5 files changed

+70
-53
lines changed

frontend/src/app/profile/_components/ProfileCard.tsx

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,19 @@
1-
21
import UserAvatar from "@/components/UserAvatar";
32
import { Card } from "@/components/ui/card";
43
import { Zap } from "lucide-react";
54
import { UserProfile } from "@/types/User";
65

76
interface ProfileCardProps {
8-
userProfile: UserProfile
7+
userProfile: UserProfile;
98
}
109

11-
export function ProfileCard({userProfile}: ProfileCardProps) {
10+
export function ProfileCard({ userProfile }: ProfileCardProps) {
1211
return (
1312
<Card className="p-5">
1413
<div className="flex flex-col gap-5">
1514
<div className="flex items-center gap-4">
1615
<UserAvatar
17-
userProfile={{
18-
username: "jmsandiegoo",
19-
20-
displayName: "Jm San Diego",
21-
proficiency: "Advanced",
22-
languages: ["Python"],
23-
isOnboarded: true,
24-
roles: ["user"],
25-
//profilePictureUrl: "testlink.com",
26-
}}
16+
userProfile={userProfile}
2717
isHoverEnabled={false}
2818
className="w-16 h-16"
2919
/>

frontend/src/app/profile/_components/QuestionHistory/QuestionColumns/CollaboratorsColumn.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { UserProfile } from "@/types/User";
55

66
const mockCollaborators: UserProfile[] = [
77
{
8+
id: "1",
89
username: "jmsandiegoo",
910
1011
displayName: "Jm San Diego",
@@ -14,6 +15,7 @@ const mockCollaborators: UserProfile[] = [
1415
roles: ["user"],
1516
},
1617
{
18+
id: "2",
1719
username: "charliebrown",
1820
1921
displayName: "Charlie Brown",

frontend/src/app/reset-password/_components/ResetPasswordForm.tsx

Lines changed: 55 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -12,59 +12,79 @@ import Link from "next/link";
1212
import { z } from "zod";
1313
import { zodResolver } from "@hookform/resolvers/zod";
1414
import { confirmResetPassword, verifyCode } from "@/services/authService";
15-
import { useRouter } from "next/navigation";
15+
import { useRouter, useSearchParams } from "next/navigation";
1616
import { useToast } from "@/hooks/use-toast";
1717
import { TextInput } from "@/components/form/TextInput";
1818
import { LoadingSpinner } from "@/components/LoadingSpinner";
1919
import { Button } from "@/components/ui/button";
2020
import { Form } from "@/components/ui/form";
2121
import { Lock } from "lucide-react";
22+
import { useCallback } from "react";
2223

23-
24-
const FormSchema = z.object({
25-
newPassword: z.string().min(6, "Password must be at least 6 characters"),
26-
confirmPassword: z.string().min(6, "Password must be at least 6 characters"),
27-
}).refine(data => data.newPassword === data.confirmPassword, {
28-
message: "Passwords do not match",
29-
path: ["confirmPassword"],
30-
});
24+
const FormSchema = z
25+
.object({
26+
newPassword: z.string().min(6, "Password must be at least 6 characters"),
27+
confirmPassword: z
28+
.string()
29+
.min(6, "Password must be at least 6 characters"),
30+
})
31+
.refine((data) => data.newPassword === data.confirmPassword, {
32+
message: "Passwords do not match",
33+
path: ["confirmPassword"],
34+
});
3135

3236
export default function ResetPassword() {
3337
const router = useRouter();
38+
const searchParams = useSearchParams();
3439
const { toast } = useToast();
40+
3541
const methods = useForm<z.infer<typeof FormSchema>>({
3642
resolver: zodResolver(FormSchema),
3743
});
3844
const { handleSubmit, formState } = methods;
3945

40-
const { searchParams } = new URL(window.location.href);
4146
const token = searchParams.get("token");
4247

43-
const onSubmit = async (data: z.infer<typeof FormSchema>) => {
44-
if (!token) {
45-
toast({ title: "Error!", description: "Invalid token." });
46-
return;
47-
}
48+
const onSubmit = useCallback(
49+
async (data: z.infer<typeof FormSchema>) => {
50+
if (!token) {
51+
toast({ title: "Error!", description: "Invalid token." });
52+
return;
53+
}
4854

49-
try {
50-
const verificationResponse = await verifyCode(token);
55+
try {
56+
const verificationResponse = await verifyCode(token);
5157

52-
if (verificationResponse.statusCode === 201) {
53-
const resetPasswordResponse = await confirmResetPassword(token, data.newPassword);
58+
if (verificationResponse.statusCode === 201) {
59+
const resetPasswordResponse = await confirmResetPassword(
60+
token,
61+
data.newPassword
62+
);
5463

55-
if (resetPasswordResponse.statusCode === 201) {
56-
toast({ title: "Success!", description: "Your password has been reset." });
57-
router.push('/forgotpassword/passwordupdated');
64+
if (resetPasswordResponse.statusCode === 201) {
65+
toast({
66+
title: "Success!",
67+
description: "Your password has been reset.",
68+
});
69+
router.push("/forgotpassword/passwordupdated");
70+
} else {
71+
toast({
72+
title: "Error!",
73+
description: resetPasswordResponse.message,
74+
});
75+
}
5876
} else {
59-
toast({ title: "Error!", description: resetPasswordResponse.message });
77+
toast({ title: "Error!", description: verificationResponse.message });
6078
}
61-
} else {
62-
toast({ title: "Error!", description: verificationResponse.message });
79+
} catch (error) {
80+
toast({
81+
title: "Error!",
82+
description: "An error occurred. Please try again.",
83+
});
6384
}
64-
} catch (error) {
65-
toast({ title: "Error!", description: "An error occurred. Please try again." });
66-
}
67-
};
85+
},
86+
[router, toast, token]
87+
);
6888

6989
return (
7090
<Card className="p-2 mt-3">
@@ -81,7 +101,7 @@ export default function ResetPassword() {
81101
<div className="flex flex-col gap-y-4">
82102
<TextInput
83103
label={""}
84-
name="newPassword"
104+
name="newPassword"
85105
placeholder="New Password"
86106
type="password"
87107
Icon={Lock}
@@ -101,18 +121,17 @@ export default function ResetPassword() {
101121
disabled={formState.isSubmitting}
102122
className="w-full py-2 mt-5 rounded-md bg-primary"
103123
>
104-
{formState.isSubmitting ? (
105-
<LoadingSpinner />
106-
) : (
107-
"Reset Password"
108-
)}
124+
{formState.isSubmitting ? <LoadingSpinner /> : "Reset Password"}
109125
</Button>
110126
</form>
111127
</Form>
112128
<div className="justify-center mt-6 text-sm text-center">
113129
<p>
114130
Back to{" "}
115-
<Link href="/auth/signin" className="hover:underline text-primary">
131+
<Link
132+
href="/auth/signin"
133+
className="hover:underline text-primary"
134+
>
116135
Sign in
117136
</Link>
118137
</p>

frontend/src/app/reset-password/page.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
import ResetPassword from "../reset-password/_components/ResetPasswordForm";
1+
"use client";
22

3-
export default function SigninPage() {
3+
import { Suspense } from "react";
4+
import ResetPassword from "./_components/ResetPasswordForm";
5+
6+
export default function Page() {
47
return (
5-
<div className="min-h-screen flex items-center justify-center">
8+
<div className="flex items-center justify-center min-h-screen">
69
<div className="max-w-sm mx-auto">
7-
<ResetPassword />
10+
<Suspense fallback={<div>Loading...</div>}>
11+
<ResetPassword />
12+
</Suspense>
813
</div>
914
</div>
1015
);

frontend/src/components/form/UserAvatarInput.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export function UserAvatarInput<TFieldValues extends FieldValues>({
3333
<UserAvatar
3434
isHoverEnabled={false}
3535
userProfile={{
36+
id: "1",
3637
username: "_",
3738
email: "_",
3839
displayName: "_",

0 commit comments

Comments
 (0)