From bef34aab2f2654b87107fdef10265eae17bc194c Mon Sep 17 00:00:00 2001 From: dloh2236 <94659651+dloh2236@users.noreply.github.com> Date: Sat, 9 Nov 2024 18:27:46 +0800 Subject: [PATCH] Fix lint errors that won't break --- .../sign-in/forgot-password/reset/page.tsx | 4 +- .../peerprep/app/@landing/sign-up/page.tsx | 6 +-- frontend/peerprep/auth/actions.ts | 37 ++++++++++++++++--- .../components/greetingmessageheader.tsx | 2 +- .../session-history/SessionHistory.tsx | 3 +- 5 files changed, 38 insertions(+), 14 deletions(-) diff --git a/frontend/peerprep/app/@landing/sign-in/forgot-password/reset/page.tsx b/frontend/peerprep/app/@landing/sign-in/forgot-password/reset/page.tsx index bf96da05ac..12bc9744ec 100644 --- a/frontend/peerprep/app/@landing/sign-in/forgot-password/reset/page.tsx +++ b/frontend/peerprep/app/@landing/sign-in/forgot-password/reset/page.tsx @@ -2,7 +2,7 @@ import { useState } from "react"; import { Input } from "@nextui-org/input"; -import { useRouter, useSearchParams } from "next/navigation"; +import { useRouter } from "next/navigation"; import { CircularProgress, Tooltip } from "@nextui-org/react"; import BoxIcon from "@/components/boxicons"; @@ -22,7 +22,7 @@ export default function ResetPasswordPage() { const [isLoading, setIsLoading] = useState(false); const [isFormSubmitted, setIsFormSubmitted] = useState(false); const [toast, setToast] = useState<{ message: string; type: string } | null>( - null + null, ); const toggleVisibility = () => setIsVisible(!isVisible); diff --git a/frontend/peerprep/app/@landing/sign-up/page.tsx b/frontend/peerprep/app/@landing/sign-up/page.tsx index a1f9df27f3..3b879105a0 100644 --- a/frontend/peerprep/app/@landing/sign-up/page.tsx +++ b/frontend/peerprep/app/@landing/sign-up/page.tsx @@ -27,7 +27,7 @@ export default function SignUpPage() { const [isLoading, setIsLoading] = useState(false); const [isFormSubmitted, setIsFormSubmitted] = useState(false); const [toast, setToast] = useState<{ message: string; type: string } | null>( - null + null, ); // Toggle password visibility @@ -65,9 +65,9 @@ export default function SignUpPage() { setTimeout( () => router.push( - `sign-up/email-verification?email=${encodeURIComponent(email)}` + `sign-up/email-verification?email=${encodeURIComponent(email)}`, ), - 500 + 500, ); } else { setToast({ diff --git a/frontend/peerprep/auth/actions.ts b/frontend/peerprep/auth/actions.ts index dcaa1da52d..80345fc05f 100644 --- a/frontend/peerprep/auth/actions.ts +++ b/frontend/peerprep/auth/actions.ts @@ -467,7 +467,11 @@ export const editUsername = async (newUsername: string) => { } try { - const updatedToken = await updateTokenWithField(session.accessToken, "username", secret); + const updatedToken = await updateTokenWithField( + session.accessToken, + "username", + secret, + ); const response = await fetch( `${USER_SERVICE_URL}/users/${session.userId}`, { @@ -610,7 +614,11 @@ export const verifyEmailCode = async (code: number, newEmail: string) => { } if (verificationCode === code) { - const updatedToken = await updateTokenWithField(accessToken, "email", secret); + const updatedToken = await updateTokenWithField( + accessToken, + "email", + secret, + ); // If code matches, update the email console.log(newEmail); @@ -686,7 +694,11 @@ export const changePassword = async (newPassword: string) => { } try { - const updatedToken = await updateTokenWithField(session.accessToken, "password", secret); + const updatedToken = await updateTokenWithField( + session.accessToken, + "password", + secret, + ); const response = await fetch( `${USER_SERVICE_URL}/users/${session.userId}`, @@ -746,7 +758,11 @@ export const resetPassword = async (newPassword: string) => { const userId = payload.id; - const updatedToken = await updateTokenWithField(resetToken, "password", secret); + const updatedToken = await updateTokenWithField( + resetToken, + "password", + secret, + ); const response = await fetch(`${USER_SERVICE_URL}/users/${userId}`, { method: "PATCH", @@ -761,6 +777,7 @@ export const resetPassword = async (newPassword: string) => { if (response.ok) { await session.destroy(); + return { status: "success", message: "Password updated successfully" }; } else { const errorData = await response.json(); @@ -792,7 +809,11 @@ export const deleteUser = async () => { return { status: "error", message: "Internal application error" }; } - const updatedToken = await updateTokenWithField(session.accessToken, "delete", secret); + const updatedToken = await updateTokenWithField( + session.accessToken, + "delete", + secret, + ); const response = await fetch(`${USER_SERVICE_URL}/users/${session.userId}`, { method: "DELETE", @@ -863,7 +884,11 @@ export const forgetPassword = async (identifier: string) => { } }; -async function updateTokenWithField(token: string, field: string, secret: string): Promise { +async function updateTokenWithField( + token: string, + field: string, + secret: string, +): Promise { const secretKey = new TextEncoder().encode(secret); try { diff --git a/frontend/peerprep/components/greetingmessageheader.tsx b/frontend/peerprep/components/greetingmessageheader.tsx index 6f7aea5a70..6c80858531 100644 --- a/frontend/peerprep/components/greetingmessageheader.tsx +++ b/frontend/peerprep/components/greetingmessageheader.tsx @@ -78,7 +78,7 @@ export const GreetingMessageHeader = ({ user }: GreetingMessageProps) => { margin: "10px", }} > - Mistakes are only mistakes if you don't learn from them 🧑‍💻 + Mistakes are only mistakes if you don't learn from them 🧑‍💻 ); } diff --git a/frontend/peerprep/components/session-history/SessionHistory.tsx b/frontend/peerprep/components/session-history/SessionHistory.tsx index 7a22ea936a..a6d0e29890 100644 --- a/frontend/peerprep/components/session-history/SessionHistory.tsx +++ b/frontend/peerprep/components/session-history/SessionHistory.tsx @@ -1,6 +1,5 @@ import React from "react"; import { Card, Skeleton, Spinner } from "@nextui-org/react"; -import { useRouter } from "next/navigation"; import { useMatchHistoryFetcher } from "@/services/userService"; import SessionHistoryCard from "@/components/session-history/SessionHistoryCard"; @@ -43,7 +42,7 @@ interface Match { const SessionCard = ({ match }: { match: Match }) => { const { questionData, questionLoading } = useQuestionDataFetcher( - match.questionId + match.questionId, ); if (questionLoading) {