diff --git a/apps/frontend/app/(client)/(code-editor)/_components/EditorHeader/EditorHeader.tsx b/apps/frontend/app/(client)/(code-editor)/_components/EditorHeader/EditorHeader.tsx index 76b6da54ed..4f19b249b9 100644 --- a/apps/frontend/app/(client)/(code-editor)/_components/EditorHeader/EditorHeader.tsx +++ b/apps/frontend/app/(client)/(code-editor)/_components/EditorHeader/EditorHeader.tsx @@ -127,12 +127,16 @@ export default function Editor({ }, [currentModal]) useEffect(() => { - if (!templateString) return + if (!templateString) { + return + } const parsedTemplates = JSON.parse(templateString) const filteredTemplate = parsedTemplates.filter( (template: Template) => template.language === language ) - if (filteredTemplate.length === 0) return + if (filteredTemplate.length === 0) { + return + } setTemplateCode(filteredTemplate[0].code[0].text) }, [language]) @@ -200,7 +204,9 @@ export default function Editor({ if (res.status === 401) { showSignIn() toast.error('Log in first to submit your code') - } else toast.error('Please try again later.') + } else { + toast.error('Please try again later.') + } } } @@ -223,16 +229,22 @@ export default function Editor({ localStorage.setItem(storageKey.current, templateCode) setCode(templateCode) toast.success('Successfully reset the code') - } else toast.error('Failed to reset the code') + } else { + toast.error('Failed to reset the code') + } } const checkSaved = () => { const code = getCode() if (storageKey.current !== undefined) { const storedCode = getCodeFromLocalStorage(storageKey.current) - if (storedCode && storedCode === code) return true - else if (!storedCode && templateCode === code) return true - else return false + if (storedCode && storedCode === code) { + return true + } else if (!storedCode && templateCode === code) { + return true + } else { + return false + } } return true } diff --git a/apps/frontend/app/(client)/(code-editor)/_components/EditorHeader/RunTestButton.tsx b/apps/frontend/app/(client)/(code-editor)/_components/EditorHeader/RunTestButton.tsx index a5c3cf61f8..b6f806d174 100644 --- a/apps/frontend/app/(client)/(code-editor)/_components/EditorHeader/RunTestButton.tsx +++ b/apps/frontend/app/(client)/(code-editor)/_components/EditorHeader/RunTestButton.tsx @@ -93,7 +93,7 @@ export default function RunTestButton({ } }) - const submitTest = async () => { + const submitTest = () => { const code = getCode() const testcases = getUserTestcases() diff --git a/apps/frontend/app/(client)/(code-editor)/_components/EditorResizablePanel.tsx b/apps/frontend/app/(client)/(code-editor)/_components/EditorResizablePanel.tsx index 3a3b0344ee..96fa607aeb 100644 --- a/apps/frontend/app/(client)/(code-editor)/_components/EditorResizablePanel.tsx +++ b/apps/frontend/app/(client)/(code-editor)/_components/EditorResizablePanel.tsx @@ -9,7 +9,7 @@ import { import { ScrollArea, ScrollBar } from '@/components/shadcn/scroll-area' import { Tabs, TabsList, TabsTrigger } from '@/components/shadcn/tabs' import { useLanguageStore, useCodeStore } from '@/stores/editor' -import type { Language, ProblemDetail } from '@/types/type' +import type { ProblemDetail } from '@/types/type' import type { Route } from 'next' import Link from 'next/link' import { usePathname } from 'next/navigation' @@ -154,7 +154,7 @@ function CodeEditorInEditorResizablePanel({ return ( diff --git a/apps/frontend/app/(client)/(code-editor)/_components/WhitespaceVisualizer.tsx b/apps/frontend/app/(client)/(code-editor)/_components/WhitespaceVisualizer.tsx index f2289b93e8..35b5b31229 100644 --- a/apps/frontend/app/(client)/(code-editor)/_components/WhitespaceVisualizer.tsx +++ b/apps/frontend/app/(client)/(code-editor)/_components/WhitespaceVisualizer.tsx @@ -26,7 +26,7 @@ export function WhitespaceVisualizer({ const visibleLines = lines.slice(0, 3).join('\n') const truncatedText = lines.length > 3 - ? visibleLines + '\n...' + ? `${visibleLines}\n...` : visibleLines return ( diff --git a/apps/frontend/app/(client)/(code-editor)/contest/[contestId]/finished/problem/[problemId]/_components/ContestEditorSkeleton.tsx b/apps/frontend/app/(client)/(code-editor)/contest/[contestId]/finished/problem/[problemId]/_components/ContestEditorSkeleton.tsx index 348b61e0a1..7206a4ecae 100644 --- a/apps/frontend/app/(client)/(code-editor)/contest/[contestId]/finished/problem/[problemId]/_components/ContestEditorSkeleton.tsx +++ b/apps/frontend/app/(client)/(code-editor)/contest/[contestId]/finished/problem/[problemId]/_components/ContestEditorSkeleton.tsx @@ -35,11 +35,8 @@ export default function ContestEditorSkeleton() { - + /> +
-

+            
           
diff --git a/apps/frontend/app/(client)/(code-editor)/contest/[contestId]/problem/[problemId]/layout.tsx b/apps/frontend/app/(client)/(code-editor)/contest/[contestId]/problem/[problemId]/layout.tsx index 8377f880dc..84d40332e0 100644 --- a/apps/frontend/app/(client)/(code-editor)/contest/[contestId]/problem/[problemId]/layout.tsx +++ b/apps/frontend/app/(client)/(code-editor)/contest/[contestId]/problem/[problemId]/layout.tsx @@ -1,6 +1,6 @@ import EditorLayout from '@/app/(client)/(code-editor)/_components/EditorLayout' -export default async function layout({ +export default function layout({ params, children }: { diff --git a/apps/frontend/app/(client)/(code-editor)/contest/[contestId]/problem/[problemId]/submission/[submissionId]/page.tsx b/apps/frontend/app/(client)/(code-editor)/contest/[contestId]/problem/[problemId]/submission/[submissionId]/page.tsx index 41de08b3f7..9433400ac3 100644 --- a/apps/frontend/app/(client)/(code-editor)/contest/[contestId]/problem/[problemId]/submission/[submissionId]/page.tsx +++ b/apps/frontend/app/(client)/(code-editor)/contest/[contestId]/problem/[problemId]/submission/[submissionId]/page.tsx @@ -4,7 +4,7 @@ import Link from 'next/link' import { Suspense } from 'react' import SubmissionDetail from '../_components/SubmissionDetail' -export default async function Page({ +export default function Page({ params }: { params: { diff --git a/apps/frontend/app/(client)/(code-editor)/contest/[contestId]/problem/[problemId]/submission/_components/SubmissionDetail.tsx b/apps/frontend/app/(client)/(code-editor)/contest/[contestId]/problem/[problemId]/submission/_components/SubmissionDetail.tsx index 78121bba16..f11af3c0c4 100644 --- a/apps/frontend/app/(client)/(code-editor)/contest/[contestId]/problem/[problemId]/submission/_components/SubmissionDetail.tsx +++ b/apps/frontend/app/(client)/(code-editor)/contest/[contestId]/problem/[problemId]/submission/_components/SubmissionDetail.tsx @@ -34,7 +34,7 @@ export default async function SubmissionDetail({ const submission: SubmissionDetail = res.ok ? await res.json() : dataIfError - if (submission.result == 'Judging') { + if (submission.result === 'Judging') { revalidateTag(`submission/${submissionId}`) } @@ -107,9 +107,7 @@ export default async function SubmissionDetail({ )} - {res.ok ? ( - <> - ) : ( + {res.ok ? null : (

Access Denied

diff --git a/apps/frontend/app/(client)/(code-editor)/problem/[problemId]/layout.tsx b/apps/frontend/app/(client)/(code-editor)/problem/[problemId]/layout.tsx index f26f701614..bccdb3ac48 100644 --- a/apps/frontend/app/(client)/(code-editor)/problem/[problemId]/layout.tsx +++ b/apps/frontend/app/(client)/(code-editor)/problem/[problemId]/layout.tsx @@ -1,6 +1,6 @@ import EditorLayout from '@/app/(client)/(code-editor)/_components/EditorLayout' -export default async function layout({ +export default function layout({ params, children }: { diff --git a/apps/frontend/app/(client)/(code-editor)/problem/[problemId]/submission/[submissionId]/page.tsx b/apps/frontend/app/(client)/(code-editor)/problem/[problemId]/submission/[submissionId]/page.tsx index 70320beb64..44716bc753 100644 --- a/apps/frontend/app/(client)/(code-editor)/problem/[problemId]/submission/[submissionId]/page.tsx +++ b/apps/frontend/app/(client)/(code-editor)/problem/[problemId]/submission/[submissionId]/page.tsx @@ -4,7 +4,7 @@ import Link from 'next/link' import { Suspense } from 'react' import SubmissionDetail from '../_components/SubmissionDetail' -export default async function Page({ +export default function Page({ params }: { params: { diff --git a/apps/frontend/app/(client)/(code-editor)/problem/[problemId]/submission/_components/SubmissionDetail.tsx b/apps/frontend/app/(client)/(code-editor)/problem/[problemId]/submission/_components/SubmissionDetail.tsx index a270edbc70..801b39d32c 100644 --- a/apps/frontend/app/(client)/(code-editor)/problem/[problemId]/submission/_components/SubmissionDetail.tsx +++ b/apps/frontend/app/(client)/(code-editor)/problem/[problemId]/submission/_components/SubmissionDetail.tsx @@ -31,7 +31,7 @@ export default async function SubmissionDetail({ const submission: SubmissionDetail = res.ok ? await res.json() : dataIfError - if (submission.result == 'Judging') { + if (submission.result === 'Judging') { revalidateTag(`submission/${submissionId}`) } @@ -98,9 +98,7 @@ export default async function SubmissionDetail({
)} - {res.ok ? ( - <> - ) : ( + {res.ok ? null : (

Access Denied

diff --git a/apps/frontend/app/(client)/(main)/_components/SearchBar.tsx b/apps/frontend/app/(client)/(main)/_components/SearchBar.tsx index 959686c5c4..1b889f04cf 100644 --- a/apps/frontend/app/(client)/(main)/_components/SearchBar.tsx +++ b/apps/frontend/app/(client)/(main)/_components/SearchBar.tsx @@ -29,10 +29,12 @@ export default function SearchBar({ className }: SearchBarProps) { // set search data to newParam if (data.search) { newParam.set('search', data.search) - } else newParam.delete('search') + } else { + newParam.delete('search') + } const newParamString = newParam.toString() router.push( - `${pathname}${newParamString ? '?' + newParamString : ''}` as Route, + `${pathname}${newParamString ? `?${newParamString}` : ''}` as Route, { scroll: false } diff --git a/apps/frontend/app/(client)/(main)/contest/[contestId]/@tabs/_components/RegisterButton.tsx b/apps/frontend/app/(client)/(main)/contest/[contestId]/@tabs/_components/RegisterButton.tsx index c4b511da2e..f9631e117c 100644 --- a/apps/frontend/app/(client)/(main)/contest/[contestId]/@tabs/_components/RegisterButton.tsx +++ b/apps/frontend/app/(client)/(main)/contest/[contestId]/@tabs/_components/RegisterButton.tsx @@ -70,7 +70,7 @@ export default function RegisterButton({ resolver: zodResolver(schema) }) - const onSubmit = async () => { + const onSubmit = () => { clickRegister(id) } diff --git a/apps/frontend/app/(client)/(main)/contest/[contestId]/@tabs/page.tsx b/apps/frontend/app/(client)/(main)/contest/[contestId]/@tabs/page.tsx index 9f1181e29f..cccbbf424b 100644 --- a/apps/frontend/app/(client)/(main)/contest/[contestId]/@tabs/page.tsx +++ b/apps/frontend/app/(client)/(main)/contest/[contestId]/@tabs/page.tsx @@ -34,12 +34,17 @@ export default async function ContestTop({ params }: ContestTopProps) { const startTime = new Date(data.startTime) const endTime = new Date(data.endTime) const currentTime = new Date() - const state = - currentTime >= endTime - ? 'Finished' - : currentTime < startTime - ? 'Upcoming' - : 'Ongoing' + const state = (() => { + if (currentTime >= endTime) { + return 'Finished' + } + + if (currentTime < startTime) { + return 'Upcoming' + } + + return 'Ongoing' + })() return ( <> diff --git a/apps/frontend/app/(client)/(main)/contest/[contestId]/@tabs/problem/_components/Columns.tsx b/apps/frontend/app/(client)/(main)/contest/[contestId]/@tabs/problem/_components/Columns.tsx index 73c9c3bc23..583b2ea33c 100644 --- a/apps/frontend/app/(client)/(main)/contest/[contestId]/@tabs/problem/_components/Columns.tsx +++ b/apps/frontend/app/(client)/(main)/contest/[contestId]/@tabs/problem/_components/Columns.tsx @@ -51,10 +51,8 @@ export const columns: ColumnDef[] = [ header: () => 'Score', accessorKey: 'score', cell: ({ row }) => - row.original.maxScore != null ? ( - `${row.original.score ?? '-'} / ${row.original.maxScore}` - ) : ( - <> - ) + row.original.maxScore !== null + ? `${row.original.score ?? '-'} / ${row.original.maxScore}` + : null } ] diff --git a/apps/frontend/app/(client)/(main)/contest/[contestId]/@tabs/problem/_components/SubmissionDetailContent.tsx b/apps/frontend/app/(client)/(main)/contest/[contestId]/@tabs/problem/_components/SubmissionDetailContent.tsx index 8e853cde6f..2600d3f6f0 100644 --- a/apps/frontend/app/(client)/(main)/contest/[contestId]/@tabs/problem/_components/SubmissionDetailContent.tsx +++ b/apps/frontend/app/(client)/(main)/contest/[contestId]/@tabs/problem/_components/SubmissionDetailContent.tsx @@ -13,7 +13,7 @@ import { TableRow } from '@/components/shadcn/table' import { dateFormatter, getResultColor } from '@/libs/utils' -import type { ContestProblem, Language } from '@/types/type' +import type { ContestProblem } from '@/types/type' import { useSuspenseQuery } from '@tanstack/react-query' interface SubmissionDetailProps { @@ -109,11 +109,7 @@ export function SubmissionDetailContent({ {item.cpuTime} ms - {( - (item?.memoryUsage as number) / - (1024 * 1024) - ).toFixed(2)}{' '} - MB + {(item?.memoryUsage / (1024 * 1024)).toFixed(2)} MB ))} @@ -125,7 +121,7 @@ export function SubmissionDetailContent({

Source Code

diff --git a/apps/frontend/app/(client)/(main)/contest/_components/ContestCardList.tsx b/apps/frontend/app/(client)/(main)/contest/_components/ContestCardList.tsx index 7dd495f80d..895f03a40f 100644 --- a/apps/frontend/app/(client)/(main)/contest/_components/ContestCardList.tsx +++ b/apps/frontend/app/(client)/(main)/contest/_components/ContestCardList.tsx @@ -66,9 +66,13 @@ function ContestCardCarousel({ const chunks = [] if (itemsPerSlide === 3) { - for (let i = 0; i < data.length; i += 3) chunks.push(data.slice(i, i + 3)) + for (let i = 0; i < data.length; i += 3) { + chunks.push(data.slice(i, i + 3)) + } } else if (itemsPerSlide === 2) { - for (let i = 0; i < data.length; i += 2) chunks.push(data.slice(i, i + 2)) + for (let i = 0; i < data.length; i += 2) { + chunks.push(data.slice(i, i + 2)) + } } return ( @@ -117,15 +121,15 @@ export default async function Contest({ session ? await getRegisteredContests() : await getContests() ).filter( (contest) => - contest.status.toLowerCase() === 'registered' + type.toLowerCase() || + contest.status.toLowerCase() === `registered${type.toLowerCase()}` || contest.status.toLowerCase() === type.toLowerCase() ) - data.sort((a, b) => +new Date(a.startTime) - +new Date(b.startTime)) + data.sort( + (a, b) => new Date(a.startTime).getTime() - new Date(b.startTime).getTime() + ) - return data.length === 0 ? ( - <> - ) : ( + return data.length === 0 ? null : ( <> diff --git a/apps/frontend/app/(client)/(main)/contest/_components/ContestTabs.tsx b/apps/frontend/app/(client)/(main)/contest/_components/ContestTabs.tsx index 4bb141743c..66ca15f6de 100644 --- a/apps/frontend/app/(client)/(main)/contest/_components/ContestTabs.tsx +++ b/apps/frontend/app/(client)/(main)/contest/_components/ContestTabs.tsx @@ -10,7 +10,9 @@ export default function ContestTabs({ contestId }: { contestId: string }) { const pathname = usePathname() const isCurrentTab = (tab: string) => { - if (tab === '') return pathname === `/contest/${id}` + if (tab === '') { + return pathname === `/contest/${id}` + } return pathname.startsWith(`/contest/${id}/${tab}`) } diff --git a/apps/frontend/app/(client)/(main)/contest/_components/FinishedTableColumns.tsx b/apps/frontend/app/(client)/(main)/contest/_components/FinishedTableColumns.tsx index 2383f38076..f65c384baa 100644 --- a/apps/frontend/app/(client)/(main)/contest/_components/FinishedTableColumns.tsx +++ b/apps/frontend/app/(client)/(main)/contest/_components/FinishedTableColumns.tsx @@ -35,8 +35,9 @@ export const columns: ColumnDef[] = [ header: 'Period', accessorKey: 'period', cell: ({ row }) => - dateFormatter(row.original.startTime, 'YYYY-MM-DD') + - ' ~ ' + - dateFormatter(row.original.endTime, 'YYYY-MM-DD') + `${dateFormatter(row.original.startTime, 'YYYY-MM-DD')} ~ ${dateFormatter( + row.original.endTime, + 'YYYY-MM-DD' + )}` } ] diff --git a/apps/frontend/app/(client)/(main)/contest/_components/RegisteredContestTable.tsx b/apps/frontend/app/(client)/(main)/contest/_components/RegisteredContestTable.tsx index 2871330784..5fce4f958d 100644 --- a/apps/frontend/app/(client)/(main)/contest/_components/RegisteredContestTable.tsx +++ b/apps/frontend/app/(client)/(main)/contest/_components/RegisteredContestTable.tsx @@ -53,18 +53,16 @@ export default async function RegisteredContestTable({ const data = await getFinishedContests(search) return ( - <> - - + ) } diff --git a/apps/frontend/app/(client)/(main)/contest/_components/RegisteredTableColumns.tsx b/apps/frontend/app/(client)/(main)/contest/_components/RegisteredTableColumns.tsx index 6344353655..5428499659 100644 --- a/apps/frontend/app/(client)/(main)/contest/_components/RegisteredTableColumns.tsx +++ b/apps/frontend/app/(client)/(main)/contest/_components/RegisteredTableColumns.tsx @@ -29,8 +29,9 @@ export const columns: ColumnDef[] = [ header: 'Period', accessorKey: 'period', cell: ({ row }) => - dateFormatter(row.original.startTime, 'YYYY-MM-DD') + - ' ~ ' + - dateFormatter(row.original.endTime, 'YYYY-MM-DD') + `${dateFormatter(row.original.startTime, 'YYYY-MM-DD')} ~ ${dateFormatter( + row.original.endTime, + 'YYYY-MM-DD' + )}` } ] diff --git a/apps/frontend/app/(client)/(main)/notice/[noticeId]/page.tsx b/apps/frontend/app/(client)/(main)/notice/[noticeId]/page.tsx index a2f5aefa28..c871cb9c10 100644 --- a/apps/frontend/app/(client)/(main)/notice/[noticeId]/page.tsx +++ b/apps/frontend/app/(client)/(main)/notice/[noticeId]/page.tsx @@ -23,7 +23,7 @@ export default async function NoticeDetail({ current: { title, content, createTime, createdBy }, prev, next - } = await fetch(baseUrl + `/notice/${noticeId}`).then((res) => res.json()) + } = await fetch(`${baseUrl}/notice/${noticeId}`).then((res) => res.json()) return (
diff --git a/apps/frontend/app/(client)/(main)/problem/_components/Columns.tsx b/apps/frontend/app/(client)/(main)/problem/_components/Columns.tsx index 70e5aa2eb9..b550b94893 100644 --- a/apps/frontend/app/(client)/(main)/problem/_components/Columns.tsx +++ b/apps/frontend/app/(client)/(main)/problem/_components/Columns.tsx @@ -1,7 +1,7 @@ 'use client' import { Badge } from '@/components/shadcn/badge' -import type { Level, Problem } from '@/types/type' +import type { Problem } from '@/types/type' import type { ColumnDef } from '@tanstack/react-table' import SortButton from './SortButton' @@ -19,7 +19,7 @@ export const columns: ColumnDef[] = [ header: () => Level, accessorKey: 'difficulty', cell: ({ row }) => ( - + {row.original.difficulty} ) diff --git a/apps/frontend/app/(client)/(main)/problem/_components/SortButton.tsx b/apps/frontend/app/(client)/(main)/problem/_components/SortButton.tsx index eade0ed628..fe8f1cebdb 100644 --- a/apps/frontend/app/(client)/(main)/problem/_components/SortButton.tsx +++ b/apps/frontend/app/(client)/(main)/problem/_components/SortButton.tsx @@ -23,11 +23,13 @@ export default function SortButton({ children, order }: SortButtonProps) { const newParam = new URLSearchParams() // set all searchParam to newParam param.forEach((value, key) => newParam.set(key, value)) - if (!currentOrder || !currentOrder.includes(order)) + if (!currentOrder || !currentOrder.includes(order)) { newParam.set('order', `${order}-desc`) - else if (currentOrder == `${order}-desc`) + } else if (currentOrder === `${order}-desc`) { newParam.set('order', `${order}-asc`) - else if (currentOrder == `${order}-asc`) newParam.delete('order') + } else if (currentOrder === `${order}-asc`) { + newParam.delete('order') + } router.push(`${pathname}?${newParam.toString()}` as Route) }} className="items-center justify-center gap-1 md:text-base" @@ -37,11 +39,11 @@ export default function SortButton({ children, order }: SortButtonProps) {
diff --git a/apps/frontend/app/(client)/(main)/settings/_components/MajorSection.tsx b/apps/frontend/app/(client)/(main)/settings/_components/MajorSection.tsx index a18dafcfe9..2e2c063030 100644 --- a/apps/frontend/app/(client)/(main)/settings/_components/MajorSection.tsx +++ b/apps/frontend/app/(client)/(main)/settings/_components/MajorSection.tsx @@ -27,6 +27,16 @@ export default function MajorSection() { defaultProfileValues } = useSettingsContext() + const getMajorDisplayValue = () => { + if (updateNow) { + return majorValue === 'none' + ? 'Department Information Unavailable / 학과 정보 없음' + : majorValue + } + + return majorValue || defaultProfileValues.major + } + return ( <> @@ -39,22 +49,19 @@ export default function MajorSection() { role="combobox" className={cn( 'justify-between border-gray-200 font-normal text-neutral-600 hover:bg-white', - updateNow - ? `${majorValue === 'none' || isLoading ? 'border-red-500 text-neutral-400' : 'border-primary'}` - : majorValue === defaultProfileValues.major + (() => { + if (updateNow) { + return majorValue === 'none' || isLoading + ? 'border-red-500 text-neutral-400' + : 'border-primary' + } + return majorValue === defaultProfileValues.major ? 'text-neutral-400' : 'border-primary' + })() )} > - {isLoading - ? 'Loading...' - : updateNow - ? majorValue === 'none' - ? 'Department Information Unavailable / 학과 정보 없음' - : majorValue - : !majorValue - ? defaultProfileValues.major - : majorValue} + {isLoading ? 'Loading...' : getMajorDisplayValue()} diff --git a/apps/frontend/app/(client)/(main)/settings/_components/NameSection.tsx b/apps/frontend/app/(client)/(main)/settings/_components/NameSection.tsx index d8a4714144..08373228ff 100644 --- a/apps/frontend/app/(client)/(main)/settings/_components/NameSection.tsx +++ b/apps/frontend/app/(client)/(main)/settings/_components/NameSection.tsx @@ -23,7 +23,7 @@ export default function NameSection({ realName }: NameSectionProps) { ? 'Loading...' : defaultProfileValues.userProfile?.realName || 'Enter your name' } - disabled={!!updateNow} + disabled={Boolean(updateNow)} {...register('realName')} className={cn( realName && (errors.realName ? 'border-red-500' : 'border-primary'), diff --git a/apps/frontend/app/(client)/(main)/settings/_components/StudentIdSection.tsx b/apps/frontend/app/(client)/(main)/settings/_components/StudentIdSection.tsx index fbe6c51b61..37f5be7fc6 100644 --- a/apps/frontend/app/(client)/(main)/settings/_components/StudentIdSection.tsx +++ b/apps/frontend/app/(client)/(main)/settings/_components/StudentIdSection.tsx @@ -13,26 +13,29 @@ export default function StudentIdSection({ studentId }: StudentIdSectionProps) { defaultProfileValues, formState: { register, errors } } = useSettingsContext() + return ( <> { + if (updateNow) { + return '2024123456' + } + return isLoading ? 'Loading...' : defaultProfileValues.studentId + })()} disabled={!updateNow} {...register('studentId')} className={cn( 'text-neutral-600 placeholder:text-neutral-400 focus-visible:ring-0', - updateNow - ? errors.studentId || !studentId - ? 'border-red-500' - : 'border-primary' - : 'border-neutral-300 disabled:bg-neutral-200' + (() => { + if (updateNow) { + return errors.studentId || !studentId + ? 'border-red-500' + : 'border-primary' + } + return 'border-neutral-300 disabled:bg-neutral-200' + })() )} /> {errors.studentId && ( diff --git a/apps/frontend/app/(client)/(main)/settings/_libs/hooks/useCheckPassword.ts b/apps/frontend/app/(client)/(main)/settings/_libs/hooks/useCheckPassword.ts index d5830d534e..80f46baa69 100644 --- a/apps/frontend/app/(client)/(main)/settings/_libs/hooks/useCheckPassword.ts +++ b/apps/frontend/app/(client)/(main)/settings/_libs/hooks/useCheckPassword.ts @@ -25,7 +25,7 @@ export const useCheckPassword = ( const checkPassword = async () => { setIsCheckButtonClicked(true) try { - const response = await safeFetcher.post('auth/login', { + await safeFetcher.post('auth/login', { json: { username: defaultProfileValues.username, password: currentPassword diff --git a/apps/frontend/app/(client)/(main)/settings/page.tsx b/apps/frontend/app/(client)/(main)/settings/page.tsx index 0bcd37694b..99bc13e7e4 100644 --- a/apps/frontend/app/(client)/(main)/settings/page.tsx +++ b/apps/frontend/app/(client)/(main)/settings/page.tsx @@ -72,7 +72,7 @@ export default function Page() { watch, formState: { errors } } = useForm({ - resolver: zodResolver(schemaSettings(!!updateNow)), + resolver: zodResolver(schemaSettings(Boolean(updateNow))), mode: 'onChange', defaultValues: { currentPassword: '', @@ -90,7 +90,7 @@ export default function Page() { const studentId = watch('studentId') const { isConfirmModalOpen, setIsConfirmModalOpen, confirmAction } = - useConfirmNavigation(bypassConfirmation, !!updateNow) + useConfirmNavigation(bypassConfirmation, Boolean(updateNow)) const { isPasswordCorrect, newPasswordAble, @@ -107,20 +107,20 @@ export default function Page() { const isPasswordsMatch = newPassword === confirmPassword && newPassword !== '' const saveAblePassword: boolean = - !!currentPassword && - !!newPassword && - !!confirmPassword && + Boolean(currentPassword) && + Boolean(newPassword) && + Boolean(confirmPassword) && isPasswordCorrect && newPasswordAble && isPasswordsMatch const saveAbleOthers: boolean = - !!realName || !!(majorValue !== defaultProfileValues.major) + Boolean(realName) || Boolean(majorValue !== defaultProfileValues.major) const saveAble = (saveAblePassword || saveAbleOthers) && ((isPasswordsMatch && !errors.newPassword) || (!newPassword && !confirmPassword)) const saveAbleUpdateNow = - !!studentId && majorValue !== 'none' && !errors.studentId + Boolean(studentId) && majorValue !== 'none' && !errors.studentId // 일치 여부에 따라 New Password Input, Re-enter Password Input 창의 border 색상을 바꿈 useEffect(() => { if (isPasswordsMatch) { @@ -175,7 +175,9 @@ export default function Page() { value: string | undefined, defaultValue: string ) => { - if (value === '') setValue(field, defaultValue) + if (value === '') { + setValue(field, defaultValue) + } } const onSubmitClick = () => { @@ -209,7 +211,7 @@ export default function Page() { register, errors }, - updateNow: !!updateNow, + updateNow: Boolean(updateNow), isLoading } diff --git a/apps/frontend/app/(handler)/next-auth/api/auth/[...nextauth]/route.ts b/apps/frontend/app/(handler)/next-auth/api/auth/[...nextauth]/route.ts index 9cb99cb548..68fb4ac9db 100644 --- a/apps/frontend/app/(handler)/next-auth/api/auth/[...nextauth]/route.ts +++ b/apps/frontend/app/(handler)/next-auth/api/auth/[...nextauth]/route.ts @@ -6,7 +6,7 @@ interface RouteHandlerContext { params: { nextauth: string[] } } -const handler = async (req: NextRequest, res: RouteHandlerContext) => { +const handler = (req: NextRequest, res: RouteHandlerContext) => { return NextAuth(req, res, authOptions) } diff --git a/apps/frontend/app/admin/_components/SwitchField.tsx b/apps/frontend/app/admin/_components/SwitchField.tsx index a0c899cc1f..fc50ba8f5a 100644 --- a/apps/frontend/app/admin/_components/SwitchField.tsx +++ b/apps/frontend/app/admin/_components/SwitchField.tsx @@ -46,9 +46,13 @@ export default function SwitchField({ { - if (name == 'invitationCode') setValue(name, null) - else if (name == 'hint' || name == 'source') setValue(name, '') - else setValue(name, !getValues(name)) + if (name === 'invitationCode') { + setValue(name, null) + } else if (name === 'hint' || name === 'source') { + setValue(name, '') + } else { + setValue(name, !getValues(name)) + } setIsEnabled(!isEnabled) }} checked={isEnabled} @@ -56,25 +60,38 @@ export default function SwitchField({ /> {isEnabled && - (formElement == 'input' ? ( - trigger(name) - })} - /> - ) : formElement == 'textarea' ? ( -