-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #231 from yosupo06/refactor/editor
minor refactor of editor and hack page
- Loading branch information
Showing
7 changed files
with
159 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import Box from "@mui/material/Box"; | ||
import Typography from "@mui/material/Typography"; | ||
import React from "react"; | ||
import { useParams } from "react-router-dom"; | ||
import { useHackInfo } from "../api/client_wrapper"; | ||
import CircularProgress from "@mui/material/CircularProgress"; | ||
import Link from "@mui/material/Link"; | ||
import { Alert, Container } from "@mui/material"; | ||
import { HackInfoResponse } from "../proto/library_checker"; | ||
import { RpcError } from "@protobuf-ts/runtime-rpc"; | ||
|
||
const HackInfo: React.FC = () => { | ||
const { ID } = useParams<"ID">(); | ||
if (!ID) { | ||
throw new Error(`hack ID is not defined`); | ||
} | ||
const hackInfoQuery = useHackInfo(parseInt(ID), { | ||
refetchInterval: 1000, | ||
}); | ||
|
||
if (hackInfoQuery.isLoading) { | ||
return ( | ||
<Container> | ||
<CircularProgress /> | ||
</Container> | ||
); | ||
} | ||
|
||
if (hackInfoQuery.isError) { | ||
return ( | ||
<Container> | ||
<Alert severity="error"> | ||
{(hackInfoQuery.error as RpcError).toString()} | ||
</Alert> | ||
</Container> | ||
); | ||
} | ||
return ( | ||
<Container> | ||
<Typography variant="h2" paragraph={true}> | ||
Hack #{ID} | ||
</Typography> | ||
<HackInfoBody info={hackInfoQuery.data} /> | ||
</Container> | ||
); | ||
}; | ||
|
||
export default HackInfo; | ||
|
||
const HackInfoBody: React.FC<{ | ||
info: HackInfoResponse; | ||
}> = (props) => { | ||
const { info } = props; | ||
return ( | ||
<Box> | ||
<Typography> | ||
Submission:{" "} | ||
<Link href={`/submission/${info.overview?.submissionId}`}> | ||
#{info.overview?.submissionId} | ||
</Link> | ||
</Typography> | ||
<Typography>Status: {info.overview?.status}</Typography> | ||
<Typography>TestCase</Typography> | ||
<pre>{new TextDecoder().decode(info.testCase)}</pre> | ||
<Typography>Checker output</Typography> | ||
<pre>{new TextDecoder().decode(info.checkerOut)}</pre> | ||
</Box> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters