Skip to content

Commit 36a7214

Browse files
authored
fix: open correct submissions list on submit (#31)
1 parent 1e9a49c commit 36a7214

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/widgets/code-panel/ui/CodePanel/CodeEditor/CodeEditor.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useEffect, useState } from "react";
2-
import { useNavigate, useParams } from "react-router-dom";
2+
import { useLocation, useNavigate, useParams } from "react-router-dom";
33
import { useDebouncedCallback } from "use-debounce";
44
import { useDuelTaskSelection, useGetDuelQuery } from "entities/duel";
55
import { selectCurrentUser } from "entities/user";
@@ -17,6 +17,7 @@ import styles from "./CodeEditor.module.scss";
1717
function CodeEditor() {
1818
const { duelId } = useParams();
1919

20+
const location = useLocation();
2021
const navigate = useNavigate();
2122
const dispatch = useAppDispatch();
2223

@@ -66,7 +67,16 @@ function CodeEditor() {
6667
};
6768

6869
const onSubmissionStart = () => {
69-
if (duelId) navigate(`/duel/${duelId}/submissions`);
70+
if (!duelId) return;
71+
const nextParams = new URLSearchParams(location.search);
72+
if (selectedTaskKey) {
73+
nextParams.set("task", selectedTaskKey);
74+
}
75+
const search = nextParams.toString();
76+
navigate({
77+
pathname: `/duel/${duelId}/submissions`,
78+
search: search ? `?${search}` : "",
79+
});
7080
};
7181

7282
useEffect(() => {

0 commit comments

Comments
 (0)