Skip to content

Commit

Permalink
OH2-323 | OH2-313 | Test if error states are properly reset. Add fixe…
Browse files Browse the repository at this point in the history
…s if need (#618)

* chore:OH2-323 | display types in alphabetic order

* fix:OH2-313 | properly reset error states
  • Loading branch information
SilverD3 authored Jun 20, 2024
1 parent 5728b0a commit fe0af22
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 42 deletions.
5 changes: 5 additions & 0 deletions src/components/accessories/admin/operations/Operations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import classes from "./Operations.module.scss";
import { useDispatch } from "react-redux";
import {
deleteOperation,
deleteOperationReset,
getOperations,
} from "../../../../state/operations/actions";
import { OperationDTO } from "../../../../generated";
Expand All @@ -19,6 +20,10 @@ export const Operations = () => {

useEffect(() => {
dispatch(getOperations());

return () => {
dispatch(deleteOperationReset());
};
}, [dispatch]);

const handleEdit = (row: OperationDTO) => {
Expand Down
30 changes: 17 additions & 13 deletions src/components/accessories/admin/types/TypesAdmin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useSelector } from "react-redux";
import { IState } from "../../../../types";
import { TypeMode } from "../../../../state/types/config";
import SelectField from "../../selectField/SelectField";
import { sortBy } from "lodash";

type TypeOption = {
label: string;
Expand All @@ -24,19 +25,22 @@ const TypesAdmin = () => {
(state) => state.types.config.mode
);

const typeOptions: TypeOption[] = [
defaultTypeOption,
{ label: t("types.exams"), value: "exams" },
{ label: t("types.vaccines"), value: "vaccines" },
{ label: t("types.operations"), value: "operations" },
{ label: t("types.diseases"), value: "diseases" },
{ label: t("types.deliveries"), value: "deliveries" },
{ label: t("types.admissions"), value: "admissions" },
{ label: t("types.deliveryResultType"), value: "deliveryresulttypes" },
{ label: t("types.discharges"), value: "discharges" },
{ label: t("types.medicals"), value: "medicals" },
{ label: t("types.pregnantTreatment"), value: "pregnanttreatmenttypes" },
];
const typeOptions: TypeOption[] = sortBy(
[
defaultTypeOption,
{ label: t("types.exams"), value: "exams" },
{ label: t("types.vaccines"), value: "vaccines" },
{ label: t("types.operations"), value: "operations" },
{ label: t("types.diseases"), value: "diseases" },
{ label: t("types.deliveries"), value: "deliveries" },
{ label: t("types.admissions"), value: "admissions" },
{ label: t("types.deliveryResultType"), value: "deliveryresulttypes" },
{ label: t("types.discharges"), value: "discharges" },
{ label: t("types.medicals"), value: "medicals" },
{ label: t("types.pregnantTreatment"), value: "pregnanttreatmenttypes" },
],
(type) => type.label
);

useEffect(() => {
if (
Expand Down
10 changes: 9 additions & 1 deletion src/components/accessories/admin/wards/Wards.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import React, { useEffect } from "react";
import classes from "./Wards.module.scss";
import { useDispatch } from "react-redux";
import { deleteWard, getWards } from "../../../../state/ward/actions";
import {
deleteWard,
deleteWardReset,
getWards,
} from "../../../../state/ward/actions";
import { WardDTO } from "../../../../generated";
import WardTable from "./wardTable";
import Button from "../../button/Button";
Expand All @@ -16,6 +20,10 @@ export const Wards = () => {

useEffect(() => {
dispatch(getWards());

return () => {
dispatch(deleteWardReset());
};
}, [dispatch]);

const handleEdit = (row: WardDTO) => {
Expand Down
9 changes: 7 additions & 2 deletions src/components/accessories/laboratory/Exams.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ export const Exams: FC = () => {
const [canceledObjCode, setCanceledObjCode] = useState("");

const [showStatusChangeModal, setShowStatusChangeModal] = useState(false);
const [selectedExamRow, setSelectedExamRow] =
useState<LaboratoryDTO | undefined>(undefined);
const [selectedExamRow, setSelectedExamRow] = useState<
LaboratoryDTO | undefined
>(undefined);

const { data, pageInfo, page, handlePageChange } = useLaboratories();

Expand Down Expand Up @@ -77,6 +78,10 @@ export const Exams: FC = () => {
})
);
dispatch(getExams());

return () => {
dispatch(deleteLabReset());
};
}, []);

useEffect(() => {
Expand Down
14 changes: 5 additions & 9 deletions src/components/accessories/patientOPD/patientOPD.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import {
createOpdReset,
createOpdWithOperationsRows,
updateOpdWithOperationRows,
deleteOpd,
updateOpdReset,
deleteOpdReset,
} from "../../../state/opds/actions";
import { getDiseasesOpd } from "../../../state/diseases/actions";
import PatientOPDForm from "./patientOPDForm/PatientOPDForm";
Expand All @@ -22,8 +22,6 @@ import PatientOPDTable from "./patientOPDTable/PatientOPDTable";
import { updateOpdFields } from "../../../libraries/formDataHandling/functions";
import { PatientExtraData } from "../patientExtraData/patientExtraData";
import { Permission } from "../../../libraries/permissionUtils/Permission";

import { initialFields as operationFields } from "../patientOperation/consts";
import { deleteOperationRowReset } from "../../../state/operations/actions";

const PatientOPD: FunctionComponent = () => {
Expand Down Expand Up @@ -66,6 +64,10 @@ const PatientOPD: FunctionComponent = () => {
dispatch(createOpdReset());
dispatch(updateOpdReset());
dispatch(getDiseasesOpd());

return () => {
dispatch(deleteOpdReset());
};
}, [dispatch]);

const patient = useSelector(
Expand All @@ -75,7 +77,6 @@ const PatientOPD: FunctionComponent = () => {
const userId = useSelector(
(state: IState) => state.main.authentication.data?.username
);
const [deletedObjCode, setDeletedObjCode] = useState("");

useEffect(() => {
if (activityTransitionState === "TO_RESET") {
Expand Down Expand Up @@ -134,11 +135,6 @@ const PatientOPD: FunctionComponent = () => {
scrollToElement(null);
};

const onDelete = (code: number | undefined) => {
setDeletedObjCode(code?.toString() ?? "");
dispatch(deleteOpd(code));
};

return (
<div className="patientOpd">
<Permission require={creationMode ? "opds.create" : "opds.update"}>
Expand Down
10 changes: 7 additions & 3 deletions src/components/accessories/patientTherapy/PatientTherapy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,11 @@ const PatientTherapy: FC = () => {
);

useEffect(() => {
dispatch(deleteTherapyReset());
dispatch(deleteTherapyReset());
dispatch(getMedicals());

return () => {
dispatch(deleteTherapyReset());
};
}, [dispatch]);

useEffect(() => {
Expand Down Expand Up @@ -128,7 +130,9 @@ const PatientTherapy: FC = () => {

return (
<div className="patientTherapy">
<Permission require={creationMode ? "therapies.create" : "therapies.update"}>
<Permission
require={creationMode ? "therapies.create" : "therapies.update"}
>
<TherapyForm
fields={
creationMode
Expand Down
9 changes: 0 additions & 9 deletions src/components/accessories/patientVisit/patientVisit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ import checkIcon from "../../../assets/check-icon.png";
import PatientVisitTable from "./patientVisitTable/PatientVisitTable";
import { updateVisitFields } from "../../../libraries/formDataHandling/functions";
import { getWards } from "../../../state/ward/actions";
import PatientOperation from "../patientOperation/PatientOperation";
import { CustomDialog } from "../customDialog/CustomDialog";
import { Permission } from "../../../libraries/permissionUtils/Permission";

const PatientVisit: FunctionComponent = () => {
Expand All @@ -38,8 +36,6 @@ const PatientVisit: FunctionComponent = () => {

const [creationMode, setCreationMode] = useState(true);

const [selectedVisit, setSelectedVisit] = useState({} as VisitDTO);

const [showModal, setShowModal] = useState(false);

const changeStatus = useSelector<IState, string | undefined>((state) => {
Expand Down Expand Up @@ -123,11 +119,6 @@ const PatientVisit: FunctionComponent = () => {
scrollToElement(null);
};

const onOperationCreated: () => void = () => {
setSelectedVisit({} as VisitDTO);
setShowModal(false);
};

return (
<div className="patientVisit">
<Permission
Expand Down
10 changes: 5 additions & 5 deletions src/resources/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -842,16 +842,16 @@
},
"types": {
"selectAType": "Select a type",
"vaccines": "Type of vaccines",
"exams": "Type of exams",
"vaccines": "Types of vaccine",
"exams": "Types of exam",
"admissions": "Types of admission",
"diseases": "Type of diseases",
"diseases": "Types of disease",
"discharges": "Types of discharge",
"deliveries": "Types of delivery",
"operations": "Type of operations",
"operations": "Types of operation",
"medicals": "Types of medical",
"chooseATypeToStart": "Choose a type to start...",
"pregnantTreatment": "Type of pregnant treatment",
"pregnantTreatment": "Types of pregnant treatment",
"deliveryResultType": "Types of delivery result"
},
"vaccineTypes": {
Expand Down

0 comments on commit fe0af22

Please sign in to comment.