-
Notifications
You must be signed in to change notification settings - Fork 13
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
Showing
15 changed files
with
911 additions
and
12 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
97 changes: 97 additions & 0 deletions
97
src/app/components/system-maintenance/code-set/code-sets-view.jsx
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,97 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import { | ||
Paper, | ||
Table, | ||
TableBody, | ||
TableCell, | ||
TableContainer, | ||
TableRow, | ||
makeStyles, | ||
} from '@material-ui/core'; | ||
import { arrayOf, object } from 'prop-types'; | ||
|
||
import { ChplSortableHeaders, sortComparator } from 'components/util/sortable-headers'; | ||
import { sortCriteria } from 'services/criteria.service'; | ||
import { getDisplayDateFormat } from 'services/date-util'; | ||
import { utilStyles } from 'themes'; | ||
|
||
const headers = [ | ||
{ property: 'name', text: 'Name', sortable: true }, | ||
{ property: 'startDay', text: 'Start Date', sortable: true }, | ||
{ property: 'requiredDay', text: 'Required Date', sortable: true }, | ||
{ text: 'Applicable Criteria' }, | ||
]; | ||
|
||
const useStyles = makeStyles({ | ||
...utilStyles, | ||
}); | ||
|
||
function ChplCodeSetsView({ codeSets: initialCodeSets }) { | ||
const [codeSets, setCodeSets] = useState([]); | ||
const [order, setOrder] = useState('asc'); | ||
const [orderBy, setOrderBy] = useState('name'); | ||
const classes = useStyles(); | ||
|
||
useEffect(() => { | ||
setCodeSets(initialCodeSets | ||
.map((item) => ({ | ||
...item, | ||
criteriaDisplay: item.criteria | ||
.sort(sortCriteria) | ||
.map((c) => c.number) | ||
.join(', '), | ||
})) | ||
.sort(sortComparator('name'))); | ||
}, [initialCodeSets]); | ||
|
||
const handleTableSort = (event, property, orderDirection) => { | ||
const descending = orderDirection === 'desc'; | ||
const updated = codeSets.sort(sortComparator(property, descending)); | ||
setOrderBy(property); | ||
setOrder(orderDirection); | ||
setCodeSets(updated); | ||
}; | ||
|
||
return ( | ||
<> | ||
<TableContainer className={classes.container} component={Paper}> | ||
<Table | ||
aria-label="Code Set table" | ||
> | ||
<ChplSortableHeaders | ||
headers={headers} | ||
onTableSort={handleTableSort} | ||
orderBy={orderBy} | ||
order={order} | ||
stickyHeader | ||
/> | ||
<TableBody> | ||
{ codeSets | ||
.map((item) => ( | ||
<TableRow key={`${item.id}`}> | ||
<TableCell className={classes.firstColumn}> | ||
{ item.name } | ||
</TableCell> | ||
<TableCell> | ||
{ getDisplayDateFormat(item.startDay) } | ||
</TableCell> | ||
<TableCell> | ||
{ getDisplayDateFormat(item.requiredDay) } | ||
</TableCell> | ||
<TableCell> | ||
{ item.criteriaDisplay } | ||
</TableCell> | ||
</TableRow> | ||
))} | ||
</TableBody> | ||
</Table> | ||
</TableContainer> | ||
</> | ||
); | ||
} | ||
|
||
export default ChplCodeSetsView; | ||
|
||
ChplCodeSetsView.propTypes = { | ||
codeSets: arrayOf(object).isRequired, | ||
}; |
60 changes: 60 additions & 0 deletions
60
src/app/components/system-maintenance/code-set/code-sets.jsx
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,60 @@ | ||
import React, { useContext, useEffect, useState } from 'react'; | ||
import { | ||
Button, | ||
Card, | ||
CardContent, | ||
CardHeader, | ||
CircularProgress, | ||
} from '@material-ui/core'; | ||
|
||
import ChplCodeSetsView from './code-sets-view'; | ||
|
||
import { useFetchCodeSets } from 'api/standards'; | ||
import { BreadcrumbContext } from 'shared/contexts'; | ||
|
||
function ChplCodeSets() { | ||
const { append, display } = useContext(BreadcrumbContext); | ||
const { data, isLoading, isSuccess } = useFetchCodeSets(); | ||
const [codeSets, setCodeSets] = useState([]); | ||
|
||
useEffect(() => { | ||
append( | ||
<Button | ||
key="codeSets.viewall.disabled" | ||
depth={1} | ||
variant="text" | ||
disabled | ||
> | ||
Code Sets | ||
</Button>, | ||
); | ||
display('codeSets.viewall.disabled'); | ||
}, []); | ||
|
||
useEffect(() => { | ||
if (isLoading || !isSuccess) { return; } | ||
setCodeSets(data); | ||
}, [data, isLoading, isSuccess]); | ||
|
||
if (isLoading) { | ||
return ( | ||
<CircularProgress /> | ||
); | ||
} | ||
|
||
return ( | ||
<Card> | ||
<CardHeader title="Code Sets" /> | ||
<CardContent> | ||
<ChplCodeSetsView | ||
codeSets={codeSets} | ||
/> | ||
</CardContent> | ||
</Card> | ||
); | ||
} | ||
|
||
export default ChplCodeSets; | ||
|
||
ChplCodeSets.propTypes = { | ||
}; |
99 changes: 99 additions & 0 deletions
99
src/app/components/system-maintenance/conformance-method/conformance-methods-view.jsx
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,99 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import { | ||
Paper, | ||
Table, | ||
TableBody, | ||
TableCell, | ||
TableContainer, | ||
TableRow, | ||
makeStyles, | ||
} from '@material-ui/core'; | ||
import { arrayOf, object } from 'prop-types'; | ||
|
||
import { ChplSortableHeaders, sortComparator } from 'components/util/sortable-headers'; | ||
import { sortCriteria } from 'services/criteria.service'; | ||
import { getDisplayDateFormat } from 'services/date-util'; | ||
import { utilStyles } from 'themes'; | ||
|
||
const headers = [ | ||
{ property: 'name', text: 'Name', sortable: true }, | ||
{ property: 'removalDate', text: 'Removal Date', sortable: true }, | ||
{ text: 'Applicable Criteria' }, | ||
]; | ||
|
||
const useStyles = makeStyles({ | ||
...utilStyles, | ||
}); | ||
|
||
function ChplConformanceMethodsView({ conformanceMethods: initialConformanceMethods }) { | ||
const [conformanceMethods, setConformanceMethods] = useState([]); | ||
const [order, setOrder] = useState('asc'); | ||
const [orderBy, setOrderBy] = useState('name'); | ||
const classes = useStyles(); | ||
|
||
useEffect(() => { | ||
setConformanceMethods(initialConformanceMethods | ||
.map((item) => ({ | ||
...item, | ||
criteriaDisplay: item.criteria | ||
.sort(sortCriteria) | ||
.map((c) => c.number) | ||
.join(', '), | ||
})) | ||
.sort(sortComparator('name'))); | ||
}, [initialConformanceMethods]); | ||
|
||
const handleTableSort = (event, property, orderDirection) => { | ||
const descending = orderDirection === 'desc'; | ||
const updated = conformanceMethods.sort(sortComparator(property, descending)); | ||
setOrderBy(property); | ||
setOrder(orderDirection); | ||
setConformanceMethods(updated); | ||
}; | ||
|
||
return ( | ||
<> | ||
<TableContainer className={classes.container} component={Paper}> | ||
<Table | ||
aria-label="Conformance Method table" | ||
> | ||
<ChplSortableHeaders | ||
headers={headers} | ||
onTableSort={handleTableSort} | ||
orderBy={orderBy} | ||
order={order} | ||
stickyHeader | ||
/> | ||
<TableBody> | ||
{ conformanceMethods | ||
.map((item) => ( | ||
<TableRow key={`${item.id}`}> | ||
<TableCell className={classes.firstColumn}> | ||
{ item.removed | ||
&& ( | ||
<> | ||
Removed | | ||
</> | ||
)} | ||
{ item.name } | ||
</TableCell> | ||
<TableCell> | ||
{ getDisplayDateFormat(item.removalDate) } | ||
</TableCell> | ||
<TableCell> | ||
{ item.criteriaDisplay } | ||
</TableCell> | ||
</TableRow> | ||
))} | ||
</TableBody> | ||
</Table> | ||
</TableContainer> | ||
</> | ||
); | ||
} | ||
|
||
export default ChplConformanceMethodsView; | ||
|
||
ChplConformanceMethodsView.propTypes = { | ||
conformanceMethods: arrayOf(object).isRequired, | ||
}; |
Oops, something went wrong.