-
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 (#579) * 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 * styles: Update admin content width and remove unused import * update: Optimize import and sync permissionList fixtures * update: Remove unnecessary file and update ward table elements per page to 20
- Loading branch information
Showing
54 changed files
with
2,323 additions
and
559 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 @@ | ||
export * from "./wards"; |
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,8 @@ | ||
.wards { | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
.actions { | ||
display: flex; | ||
justify-content: end; | ||
} |
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,46 @@ | ||
import React, { useEffect } from "react"; | ||
import classes from "./Wards.module.scss"; | ||
import { useDispatch } from "react-redux"; | ||
import { deleteWard, getWards } from "../../../../state/ward/actions"; | ||
import { WardDTO } from "../../../../generated"; | ||
import WardTable from "./wardTable"; | ||
import Button from "../../button/Button"; | ||
import { useNavigate } from "react-router"; | ||
import { useTranslation } from "react-i18next"; | ||
import { PATHS } from "../../../../consts"; | ||
|
||
export const Wards = () => { | ||
const navigate = useNavigate(); | ||
const dispatch = useDispatch(); | ||
const { t } = useTranslation(); | ||
|
||
useEffect(() => { | ||
dispatch(getWards()); | ||
}, [dispatch]); | ||
|
||
const handleEdit = (row: WardDTO) => { | ||
navigate(PATHS.wards_edit.replace("#id", row.code!), { state: row }); | ||
}; | ||
|
||
const handleDelete = (row: WardDTO) => { | ||
dispatch(deleteWard(row.code ?? "")); | ||
}; | ||
|
||
return ( | ||
<div className={classes.wards}> | ||
<div className={classes.actions}> | ||
<Button | ||
onClick={() => { | ||
navigate("./new"); | ||
}} | ||
type="button" | ||
variant="contained" | ||
color="primary" | ||
> | ||
{t("ward.addWard")} | ||
</Button> | ||
</div> | ||
<WardTable onEdit={handleEdit} onDelete={handleDelete} /> | ||
</div> | ||
); | ||
}; |
40 changes: 40 additions & 0 deletions
40
src/components/accessories/admin/wards/editWard/EditWard.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,40 @@ | ||
import { useTranslation } from "react-i18next"; | ||
import WardForm from "../wardForm/WardForm"; | ||
import React from "react"; | ||
import { getInitialFields } from "../wardForm/consts"; | ||
import { useDispatch, useSelector } from "react-redux"; | ||
import { WardDTO } from "../../../../../generated"; | ||
import { IApiResponse } from "../../../../../state/types"; | ||
import { updateWard } from "../../../../../state/ward/actions"; | ||
import { IState } from "../../../../../types"; | ||
import { Navigate, useLocation, useParams } from "react-router"; | ||
import { PATHS } from "../../../../../consts"; | ||
|
||
export const EditWard = () => { | ||
const dispatch = useDispatch(); | ||
const { t } = useTranslation(); | ||
const { state }: { state: WardDTO | undefined } = useLocation(); | ||
const { id } = useParams(); | ||
const update = useSelector<IState, IApiResponse<WardDTO>>( | ||
(state) => state.wards.update | ||
); | ||
|
||
const handleSubmit = (value: WardDTO) => { | ||
dispatch(updateWard(value)); | ||
}; | ||
|
||
if (state?.code !== id) { | ||
return <Navigate to={PATHS.wards} />; | ||
} | ||
|
||
return ( | ||
<WardForm | ||
creationMode={false} | ||
onSubmit={handleSubmit} | ||
isLoading={!!update.isLoading} | ||
resetButtonLabel={t("common.reset")} | ||
submitButtonLabel={t("ward.updateWard")} | ||
fields={getInitialFields(state)} | ||
/> | ||
); | ||
}; |
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 "./EditWard"; |
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 @@ | ||
export * from "./Wards"; | ||
export * from "./newWard"; | ||
export * from "./editWard"; | ||
export * from "./wardForm"; |
32 changes: 32 additions & 0 deletions
32
src/components/accessories/admin/wards/newWard/NewWard.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,32 @@ | ||
import { useTranslation } from "react-i18next"; | ||
import WardForm from "../wardForm/WardForm"; | ||
import React from "react"; | ||
import { getInitialFields } from "../wardForm/consts"; | ||
import { useDispatch, useSelector } from "react-redux"; | ||
import { WardDTO } from "../../../../../generated"; | ||
import { createWard } from "../../../../../state/ward/actions"; | ||
import { IState } from "../../../../../types"; | ||
import { IApiResponse } from "../../../../../state/types"; | ||
|
||
export const NewWard = () => { | ||
const dispatch = useDispatch(); | ||
const { t } = useTranslation(); | ||
const create = useSelector<IState, IApiResponse<WardDTO>>( | ||
(state) => state.wards.create | ||
); | ||
|
||
const handleSubmit = (value: WardDTO) => { | ||
dispatch(createWard(value)); | ||
}; | ||
|
||
return ( | ||
<WardForm | ||
creationMode | ||
onSubmit={handleSubmit} | ||
isLoading={!!create.isLoading} | ||
resetButtonLabel={t("common.reset")} | ||
submitButtonLabel={t("ward.saveWard")} | ||
fields={getInitialFields(undefined)} | ||
/> | ||
); | ||
}; |
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 "./NewWard"; |
Oops, something went wrong.