-
Notifications
You must be signed in to change notification settings - Fork 5
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 #284 from jadmsaadaot/SUBMIT-task#264
Add submission history in UI component
- Loading branch information
Showing
11 changed files
with
471 additions
and
223 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 was deleted.
Oops, something went wrong.
76 changes: 76 additions & 0 deletions
76
submit-web/src/components/Submission/InfoBox/AdminInfoBox.tsx
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,76 @@ | ||
import { SubmissionPackage } from "@/models/Package"; | ||
import { Grid, Stack, Typography } from "@mui/material"; | ||
import { BCDesignTokens } from "epic.theme"; | ||
import { get, isArray } from "lodash"; | ||
import { useMemo } from "react"; | ||
import VersionGroup from "../VersionGroup"; | ||
import { SubmissionHistory } from "./SubmissionHistory"; | ||
|
||
type InfoBoxProps = { | ||
submissionPackage: SubmissionPackage; | ||
}; | ||
export const AdminInfoBox = ({ submissionPackage }: InfoBoxProps) => { | ||
const { version } = submissionPackage; | ||
|
||
const condition = useMemo(() => { | ||
if (!submissionPackage.meta) return ""; | ||
const condition = get(submissionPackage, "meta.main_condition"); | ||
|
||
return get(condition, "condition_number", ""); | ||
}, [submissionPackage]); | ||
|
||
const supportingConditions = useMemo(() => { | ||
if (!submissionPackage.meta) return ""; | ||
const conditions = get(submissionPackage, "meta.supporting_conditions"); | ||
if (!conditions || !isArray(conditions)) return ""; | ||
|
||
return conditions | ||
.map((condition) => condition.condition_number) | ||
.filter(Boolean) | ||
.join(", "); | ||
}, [submissionPackage]); | ||
|
||
return ( | ||
<Grid | ||
container | ||
sx={{ | ||
borderRadius: "4px", | ||
border: `1px solid ${BCDesignTokens.surfaceColorBorderDefault}`, | ||
p: BCDesignTokens.layoutPaddingSmall, | ||
}} | ||
rowSpacing={1} | ||
> | ||
<Grid | ||
item | ||
xs={12} | ||
container | ||
alignContent={"flex-end"} | ||
justifyContent={"flex-end"} | ||
> | ||
<Typography color={BCDesignTokens.themeGray70} sx={{ mr: 1 }}> | ||
Version:{" "} | ||
</Typography> | ||
<VersionGroup currentPackageVersion={version} /> | ||
</Grid> | ||
|
||
<Grid item xs={12} lg={4} container> | ||
<Stack direction={"row"}> | ||
<Typography color={BCDesignTokens.themeGray70}>Condition:</Typography> | ||
<Typography color={"inherit"}>{condition}</Typography> | ||
</Stack> | ||
</Grid> | ||
|
||
<Grid item xs={12} lg={4} container> | ||
<Stack direction={"row"}> | ||
<Typography color={BCDesignTokens.themeGray70}> | ||
Supporting Conditions: | ||
</Typography> | ||
<Typography color={"inherit"}>{supportingConditions}</Typography> | ||
</Stack> | ||
</Grid> | ||
<Grid item xs={12} container> | ||
<SubmissionHistory submissionPackageId={String(submissionPackage.id)} /> | ||
</Grid> | ||
</Grid> | ||
); | ||
}; |
Oops, something went wrong.