-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fb14aa8
commit 0cbf589
Showing
9 changed files
with
113 additions
and
146 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
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,67 @@ | ||
import Stack from '@mui/material/Stack'; | ||
import Typography from '@mui/material/Typography'; | ||
import AlertBar from 'components/alert/AlertBar'; | ||
import { useMemo } from 'react'; | ||
import { CSVError } from 'utils/csv-utils'; | ||
import { v4 } from 'uuid'; | ||
|
||
interface CSVErrorsProps { | ||
errors: CSVError[]; | ||
} | ||
|
||
/** | ||
* Returns a stack of CSV errors with information about solutions | ||
* | ||
* @param {CSVErrorsProps} props | ||
* @returns {*} | ||
*/ | ||
export const CSVErrors = (props: CSVErrorsProps) => { | ||
const rows: (CSVError & { id: string })[] = useMemo(() => { | ||
return props.errors.map((error) => { | ||
return { | ||
id: v4(), | ||
...error | ||
}; | ||
}); | ||
}, [props.errors]); | ||
|
||
return ( | ||
<Stack gap={1}> | ||
{rows.map((error) => { | ||
return ( | ||
<AlertBar | ||
key={error.id} | ||
severity="error" | ||
variant="standard" | ||
title={error.error} | ||
text={ | ||
<Stack gap={1}> | ||
<Typography variant="body2">{error.solution}</Typography> | ||
<Stack gap={3} flexDirection="row"> | ||
<Stack> | ||
<Typography variant="body2" fontWeight={700}> | ||
Row | ||
</Typography> | ||
<Typography variant="body2">{error.row}</Typography> | ||
</Stack> | ||
<Stack> | ||
<Typography variant="body2" fontWeight={700}> | ||
Column | ||
</Typography> | ||
<Typography variant="body2">{error.header}</Typography> | ||
</Stack> | ||
<Stack> | ||
<Typography variant="body2" fontWeight={700}> | ||
Value | ||
</Typography> | ||
<Typography variant="body2">{error.cell}</Typography> | ||
</Stack> | ||
</Stack> | ||
</Stack> | ||
} | ||
/> | ||
); | ||
})} | ||
</Stack> | ||
); | ||
}; |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,47 +1,40 @@ | ||
import { Divider, Paper, Toolbar, Typography } from '@mui/material'; | ||
import { Toolbar, Typography } from '@mui/material'; | ||
import { Box, Stack } from '@mui/system'; | ||
import { ReactElement } from 'react'; | ||
import { CSVError } from 'utils/csv-utils'; | ||
import { CSVErrorsTable } from './CSVErrorsTable'; | ||
import { CSVErrors } from './CSVErrors'; | ||
|
||
interface CSVErrorsTableContainerProps { | ||
interface CSVErrorsContainerProps { | ||
errors: CSVError[]; | ||
title?: ReactElement; | ||
} | ||
|
||
/** | ||
* Renders a CSV errors table with toolbar. | ||
* | ||
* @param {CSVErrorsTableContainerProps} props | ||
* @returns {*} {JSX.Element} | ||
* @param {CSVErrorsContainerProps} props | ||
* @returns {*} | ||
*/ | ||
export const CSVErrorsTableContainer = (props: CSVErrorsTableContainerProps) => { | ||
export const CSVErrorsContainer = (props: CSVErrorsContainerProps) => { | ||
return ( | ||
<Paper component={Stack} flexDirection="column" flex="1 1 auto" height="100%"> | ||
<Toolbar | ||
disableGutters | ||
sx={{ | ||
pl: 2, | ||
pr: 3 | ||
}}> | ||
<Stack flexDirection="column" flex="1 1 auto" height="100%"> | ||
<Toolbar disableGutters> | ||
{props.title ?? ( | ||
<Typography | ||
sx={{ | ||
flexGrow: '1', | ||
fontSize: '1.125rem', | ||
fontWeight: 700 | ||
}}> | ||
CSV Errors Detected ‌ | ||
Errors ‌ | ||
<Typography sx={{ fontWeight: '400' }} component="span" variant="inherit" color="textSecondary"> | ||
({props.errors.length}) | ||
</Typography> | ||
</Typography> | ||
)} | ||
</Toolbar> | ||
<Divider /> | ||
<Box width="100%" height="100%"> | ||
<CSVErrorsTable errors={props.errors} /> | ||
<CSVErrors errors={props.errors} /> | ||
</Box> | ||
</Paper> | ||
</Stack> | ||
); | ||
}; |
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
Oops, something went wrong.