-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* feature(OH2-276): Implement main menu + sidemenu navigation * update: Update routes paths * update: Apply requested/suggested changes * update: Add hospital infos * update: Update admin sidemenu responsiveness * styles: Update admin sidebar styles * styles: Update MenuItem styles * feature: Add ward list * styles: Update component styles * feature: Add ward edit/new form * feature: Implement ward crud operations * update: Update form field values formatting * feat(admin): exams list * fix: always display table header even if empty (review: @SteveGT96) Co-authored-by: Steve Tsala <[email protected]> --------- Co-authored-by: SteveGT96 <[email protected]> Co-authored-by: Steve Tsala <[email protected]>
- Loading branch information
1 parent
af57bc4
commit e0a4890
Showing
10 changed files
with
113 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import React from "react"; | ||
|
||
import ExamsTable from "./examsTable"; | ||
|
||
export const Exams = () => { | ||
return <ExamsTable />; | ||
}; |
4 changes: 4 additions & 0 deletions
4
src/components/accessories/admin/exams/examsTable/ExamsTable.module.scss
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,4 @@ | ||
.table { | ||
display: grid; | ||
margin-top: 50px; | ||
} |
80 changes: 80 additions & 0 deletions
80
src/components/accessories/admin/exams/examsTable/ExamsTable.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,80 @@ | ||
import React, { useEffect } from "react"; | ||
import Table from "../../../table/Table"; | ||
import { useTranslation } from "react-i18next"; | ||
import InfoBox from "../../../infoBox/InfoBox"; | ||
import { CircularProgress } from "@material-ui/core"; | ||
import { useDispatch, useSelector } from "react-redux"; | ||
import { getExams } from "../../../../../state/exams/actions"; | ||
import { IState } from "../../../../../types"; | ||
import { ExamDTO } from "../../../../../generated"; | ||
import { IApiResponse } from "../../../../../state/types"; | ||
import classes from "./ExamsTable.module.scss"; | ||
|
||
export const ExamsTable = () => { | ||
const dispatch = useDispatch(); | ||
const { t } = useTranslation(); | ||
|
||
useEffect(() => { | ||
dispatch(getExams()); | ||
}, [dispatch]); | ||
|
||
const header = ["code", "type", "description", "procedure", "defaultResult"]; | ||
|
||
const label = { | ||
code: t("exam.code"), | ||
type: t("exam.examtype"), | ||
description: t("exam.description"), | ||
procedure: t("exam.procedure"), | ||
defaultResult: t("exam.defaultResult"), | ||
}; | ||
const order = ["code", "type", "description", "procedure", "defaultResult"]; | ||
|
||
const { data, status, error } = useSelector<IState, IApiResponse<ExamDTO[]>>( | ||
(state) => state.exams.examList | ||
); | ||
|
||
const formatDataToDisplay = (data: ExamDTO[]) => { | ||
return data.map((item) => { | ||
return { | ||
code: item.code ?? "", | ||
type: item.examtype?.description ?? "", | ||
description: item.description ?? "", | ||
procedure: item.procedure ?? "", | ||
defaultResult: item.defaultResult ?? "", | ||
}; | ||
}); | ||
}; | ||
|
||
return ( | ||
<div className={classes.table}> | ||
{(() => { | ||
switch (status) { | ||
case "FAIL": | ||
return <InfoBox type="error" message={error?.message} />; | ||
case "LOADING": | ||
return ( | ||
<CircularProgress | ||
style={{ marginLeft: "50%", position: "relative" }} | ||
/> | ||
); | ||
|
||
case "SUCCESS": | ||
return ( | ||
<Table | ||
rowData={formatDataToDisplay(data ?? [])} | ||
tableHeader={header} | ||
labelData={label} | ||
columnsOrder={order} | ||
rowsPerPage={10} | ||
isCollapsabile={false} | ||
/> | ||
); | ||
case "SUCCESS_EMPTY": | ||
return <InfoBox type="info" message={t("common.emptydata")} />; | ||
default: | ||
return; | ||
} | ||
})()} | ||
</div> | ||
); | ||
}; |
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,3 @@ | ||
import { ExamsTable } from "./ExamsTable"; | ||
|
||
export default ExamsTable; |
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 @@ | ||
export * from "./Exams"; |
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