Skip to content

Commit

Permalink
feat: add saved mark
Browse files Browse the repository at this point in the history
  • Loading branch information
SidonieBouthors committed Sep 4, 2024
1 parent 1d3bddd commit ca6154f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions app/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ export default function Home({ username }: { username: string }) {

const [consoleOutput, setConsoleOutput] = useState<ConsoleMessage[]>([]);

const [lastSubmission, setLastSubmission] = useState<{
lang: SubmissionLanguage;
code: string;
} | null>(null);

useEffect(() => {
getInitialCode(SubmissionLanguage.Java).then((code) => setFile(code));
}, []);
Expand Down Expand Up @@ -177,12 +182,15 @@ export default function Home({ username }: { username: string }) {
className="button"
onClick={() =>
submitCode(selectedLang, file, username).then(
() => alert("Code submitted !"),
() => {
alert("Code submitted !");
setLastSubmission({ lang: selectedLang, code: file });
},
(err) => alert(err.message)
)
}
>
Submit
Submit {(lastSubmission == null || lastSubmission.lang != selectedLang || lastSubmission.code != file) ? "✗" : "✓"}
</button>

<button
Expand Down

0 comments on commit ca6154f

Please sign in to comment.