Skip to content

Commit

Permalink
fix(fe): alert after click submission in code editor (#2219)
Browse files Browse the repository at this point in the history
* fix(fe): alert after click submission in code editor

* chore(fe): remove unused code
  • Loading branch information
Kohminchae authored Nov 18, 2024
1 parent a8009d2 commit db93e02
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default function Editor({
const loading = isTesting || isSubmitting

const [submissionId, setSubmissionId] = useState<number | null>(null)
const [templateCode, setTemplateCode] = useState<string | null>(null)
const [templateCode, setTemplateCode] = useState<string>('')
const [userName, setUserName] = useState('')
const router = useRouter()
const pathname = usePathname()
Expand Down Expand Up @@ -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])

Expand Down Expand Up @@ -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')
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export default function DataTable<TData extends Item, TValue>({
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) => (
Expand All @@ -139,7 +139,7 @@ export default function DataTable<TData extends Item, TValue>({
)}
</div>
{/* for prefetch */}
<Link href={href} />
<Link replace href={href} />
</TableCell>
))}
</TableRow>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export default function DataTable<TData extends Item, TValue>({
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) => (
Expand All @@ -137,7 +137,7 @@ export default function DataTable<TData extends Item, TValue>({
)}
</div>
{/* for prefetch */}
<Link href={href} />
<Link replace href={href} />
</TableCell>
))}
</TableRow>
Expand Down

0 comments on commit db93e02

Please sign in to comment.