From db93e02e225cdc1535839d8fa6d20b0933966bd5 Mon Sep 17 00:00:00 2001 From: Kohminchae <72334086+Kohminchae@users.noreply.github.com> Date: Mon, 18 Nov 2024 19:50:26 +0900 Subject: [PATCH] fix(fe): alert after click submission in code editor (#2219) * fix(fe): alert after click submission in code editor * chore(fe): remove unused code --- .../_components/EditorHeader/EditorHeader.tsx | 8 ++++---- .../[problemId]/submission/_components/DataTable.tsx | 4 ++-- .../[problemId]/submission/_components/DataTable.tsx | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) 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 542e4d9cf..c16cafbf0 100644 --- a/apps/frontend/app/(client)/(code-editor)/_components/EditorHeader/EditorHeader.tsx +++ b/apps/frontend/app/(client)/(code-editor)/_components/EditorHeader/EditorHeader.tsx @@ -69,7 +69,7 @@ export default function Editor({ const loading = isTesting || isSubmitting const [submissionId, setSubmissionId] = useState(null) - const [templateCode, setTemplateCode] = useState(null) + const [templateCode, setTemplateCode] = useState('') const [userName, setUserName] = useState('') const router = useRouter() const pathname = usePathname() @@ -141,7 +141,7 @@ export default function Editor({ ) if (storageKey.current !== undefined) { const storedCode = getCodeFromLocalStorage(storageKey.current) - setCode(storedCode || (templateCode ?? '')) + setCode(storedCode || templateCode) } }, [userName, problem, contestId, language, templateCode]) @@ -211,8 +211,8 @@ export default function Editor({ const resetCode = () => { if (storageKey.current !== undefined) { - localStorage.setItem(storageKey.current, templateCode ?? '') - setCode(templateCode ?? '') + localStorage.setItem(storageKey.current, templateCode) + setCode(templateCode) toast.success('Successfully reset the code') } else toast.error('Failed to reset the code') } diff --git a/apps/frontend/app/(client)/(code-editor)/contest/[contestId]/problem/[problemId]/submission/_components/DataTable.tsx b/apps/frontend/app/(client)/(code-editor)/contest/[contestId]/problem/[problemId]/submission/_components/DataTable.tsx index e1abb7050..0d63197ab 100644 --- a/apps/frontend/app/(client)/(code-editor)/contest/[contestId]/problem/[problemId]/submission/_components/DataTable.tsx +++ b/apps/frontend/app/(client)/(code-editor)/contest/[contestId]/problem/[problemId]/submission/_components/DataTable.tsx @@ -119,7 +119,7 @@ export default function DataTable({ data-state={row.getIsSelected() && 'selected'} className="cursor-pointer border-t border-slate-600 text-slate-300 hover:bg-slate-600/50 hover:font-semibold" onClick={() => { - router.push(href) + router.replace(href) }} > {row.getVisibleCells().map((cell) => ( @@ -139,7 +139,7 @@ export default function DataTable({ )} {/* for prefetch */} - + ))} diff --git a/apps/frontend/app/(client)/(code-editor)/problem/[problemId]/submission/_components/DataTable.tsx b/apps/frontend/app/(client)/(code-editor)/problem/[problemId]/submission/_components/DataTable.tsx index 908f41c8f..e3b1e95ca 100644 --- a/apps/frontend/app/(client)/(code-editor)/problem/[problemId]/submission/_components/DataTable.tsx +++ b/apps/frontend/app/(client)/(code-editor)/problem/[problemId]/submission/_components/DataTable.tsx @@ -117,7 +117,7 @@ export default function DataTable({ data-state={row.getIsSelected() && 'selected'} className="cursor-pointer border-t border-slate-600 text-slate-300 hover:bg-slate-600/50 hover:font-semibold" onClick={() => { - router.push(href) + router.replace(href) }} > {row.getVisibleCells().map((cell) => ( @@ -137,7 +137,7 @@ export default function DataTable({ )} {/* for prefetch */} - + ))}