Skip to content

Commit 07e1997

Browse files
authored
Merge pull request #93 from CS3219-AY2425S1/ms4-frontend
Ms4 frontend
2 parents ab01079 + a618f19 commit 07e1997

File tree

3 files changed

+37
-46
lines changed

3 files changed

+37
-46
lines changed

frontend/src/app/dashboard/_components/FindMatch/ConfigurationPanel.tsx

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { Category } from "@/types/Category";
2121
import { Checkbox } from "@/components/ui/checkbox";
2222
import { useState } from "react";
2323
import { cn } from "@/lib/utils";
24+
import { CaretDownIcon } from "@radix-ui/react-icons";
2425

2526
interface MatchConfigurationPanelProps {
2627
difficulties: Difficulty[];
@@ -84,7 +85,16 @@ export default function ConfigurationPanel({
8485
<Button
8586
onClick={() => setCollapseDifficulties(!collapseDifficulties)}
8687
>
87-
Select difficulties
88+
<div className="flex flex-row justify-between w-full">
89+
<span>Select difficulties</span>
90+
<CaretDownIcon
91+
className={cn(
92+
"w-6 h-6",
93+
"transition-all duration-300",
94+
collapseDifficulties && "transform rotate-180"
95+
)}
96+
/>
97+
</div>
8898
</Button>
8999
<div
90100
ref={difficultyRef}
@@ -134,7 +144,16 @@ export default function ConfigurationPanel({
134144
))}
135145
</div>
136146
<Button onClick={() => setCollapseTopics(!collapseTopics)}>
137-
Select topics
147+
<div className="flex flex-row items-center justify-between w-full">
148+
<span>Select topics</span>
149+
<CaretDownIcon
150+
className={cn(
151+
"w-6 h-6",
152+
"transition-all duration-300",
153+
collapseTopics && "transform rotate-180"
154+
)}
155+
/>
156+
</div>
138157
</Button>
139158
<div
140159
ref={topicsRef}

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

Lines changed: 11 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import React, { useCallback } from "react";
1111
import { zodResolver } from "@hookform/resolvers/zod";
1212
import { useForm } from "react-hook-form";
1313
import { z } from "zod";
14-
import { UserProfile } from "@/types/User";
14+
import { UserProfile, UserProfileSchema } from "@/types/User";
1515

1616
import { Form } from "@/components/ui/form";
1717
import { Button } from "@/components/ui/button";
@@ -20,9 +20,7 @@ import { RadioGroupInput } from "@/components/form/RadioGroupInput";
2020
import { useToast } from "@/hooks/use-toast";
2121
import { editUserProfile } from "@/services/userService";
2222
import { useRouter } from "next/navigation";
23-
import { LanguageEnum } from "@/types/Languages";
2423
import { ProficiencyEnum } from "@/types/Proficiency";
25-
import { RoleEnum } from "@/types/Role";
2624

2725
interface EditProfileModalProps {
2826
isOpen: boolean;
@@ -33,12 +31,7 @@ interface EditProfileModalProps {
3331
const FormSchema = z.object({
3432
displayName: z.string().min(1, "Display Name is required"),
3533
username: z.string().min(1, "Username is required"),
36-
email: z.string().email("Invalid email format"),
37-
roles: z.array(RoleEnum),
3834
proficiency: ProficiencyEnum,
39-
languages: z.array(LanguageEnum),
40-
isOnboarded: z.boolean(),
41-
profilePictureUrl: z.string(),
4235
});
4336

4437
export function EditProfile({
@@ -54,14 +47,20 @@ export function EditProfile({
5447
defaultValues: {
5548
displayName: userProfile.displayName,
5649
username: userProfile.username,
57-
email: userProfile.email,
5850
proficiency: userProfile.proficiency,
5951
},
6052
});
6153

54+
const { handleSubmit } = form;
55+
6256
const onSubmit = useCallback(
6357
async (data: z.infer<typeof FormSchema>) => {
64-
const response = await editUserProfile(data);
58+
const newProfielUser = UserProfileSchema.parse({
59+
...userProfile,
60+
...data,
61+
});
62+
63+
const response = await editUserProfile(newProfielUser);
6564

6665
if (response.statusCode !== 200) {
6766
toast({
@@ -80,7 +79,7 @@ export function EditProfile({
8079
}
8180
},
8281

83-
[toast, setIsOpen, router]
82+
[toast, setIsOpen, router, userProfile]
8483
);
8584

8685
return (
@@ -90,37 +89,9 @@ export function EditProfile({
9089
<DialogTitle className="text-primary">Edit Profile</DialogTitle>
9190
<Form {...form}>
9291
<form
93-
onSubmit={form.handleSubmit(onSubmit)}
92+
onSubmit={handleSubmit(onSubmit)}
9493
className="flex flex-col space-y-4"
9594
>
96-
{/* Profile Image Upload */}
97-
{/*<FormLabel className="pt-8">Profile Image</FormLabel>
98-
<div className="flex flex-row justify-center items-center p-2">
99-
<input
100-
type="file"
101-
className="hidden"
102-
id="profile-upload"
103-
accept="image/*"
104-
/>
105-
106-
<Avatar>
107-
<AvatarImage/>
108-
<AvatarFallback className="text-base font-normal text-foreground">
109-
<CodeXml/>
110-
</AvatarFallback>
111-
</Avatar>
112-
113-
<div className="pl-6">
114-
<label
115-
htmlFor="profile-upload"
116-
className="bg-background-200 text-sm rounded-lg font-bold p-2 cursor-pointer"
117-
>
118-
Upload Image
119-
</label>
120-
<DialogDescription className="pt-2">.png, .jpeg files up to 2MB. Recommended size is 256x256px.</DialogDescription>
121-
</div>
122-
</div> */}
123-
12495
{/* Display Name */}
12596
<TextInput
12697
label="Display Name"
@@ -141,9 +112,6 @@ export function EditProfile({
141112
</p>
142113
)}
143114

144-
{/* Email */}
145-
{/* <TextInput label="Email" name="email" placeholder="Email" /> */}
146-
147115
{/* Proficiency Radio Buttons */}
148116
<RadioGroupInput
149117
label="Proficiency"

frontend/src/contexts/FindMatchContext.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,14 @@ export function FindMatchProvider({
188188

189189
const onMatchConfirmed = useCallback(
190190
({ message, sessionId }: { message: string; sessionId: string }) => {
191+
toast({
192+
title: "Match Confirmed",
193+
description: `You should be redirected to /${sessionId}`,
194+
});
191195
console.log("Redirect to:", sessionId, message);
192196
reset();
193197
},
194-
[]
198+
[toast]
195199
);
196200

197201
const handleError = useCallback(

0 commit comments

Comments
 (0)