Skip to content

Commit

Permalink
fix:OH2-377 | Fix the dashboard (#661)
Browse files Browse the repository at this point in the history
  • Loading branch information
SilverD3 authored Sep 12, 2024
1 parent 0588806 commit 5c54372
Show file tree
Hide file tree
Showing 14 changed files with 32 additions and 36 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Skeleton } from "@mui/lab";
import { Skeleton } from "@mui/material";
import { useAppDispatch } from "libraries/hooks/redux";
import React, { FC, useEffect } from "react";
import { useTranslation } from "react-i18next";
Expand All @@ -25,10 +25,12 @@ export const Admissions: FC<IOwnProps> = ({ period }) => {
dispatch(getAgeTypes());
dispatch(getAdmissionTypes());
dispatch(getWards());
}, [dispatch]);
}, [dispatch, period]);

useEffect(() => {
dispatch(getAdmissions({ admissionrange: period }));
}, [period]);
}, [period, dispatch]);

const {
admissionStatus,
admissionTypeStatus,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Skeleton } from "@mui/lab";
import { useAppDispatch } from "libraries/hooks/redux";
import React, { FC, useEffect, useRef, useState } from "react";
import { useTranslation } from "react-i18next";
Expand All @@ -13,6 +12,7 @@ import { TDashboardComponentProps } from "../../layouts/types";
import { DataSummary } from "../../summary/DataSummary";
import { IOwnProps } from "../types";

import { Skeleton } from "@mui/material";
import "../../card/styles.scss";

export const AdmissionsByAgeType: FC<TDashboardComponentProps & IOwnProps> = ({
Expand All @@ -30,7 +30,7 @@ export const AdmissionsByAgeType: FC<TDashboardComponentProps & IOwnProps> = ({

useEffect(() => {
dispatch(getAdmissions({ admissionrange: period }));
}, [period]);
}, [period, dispatch]);

const { total, success, status, ageTypeStatus, data, csvData } =
useAdmByAgeTypeData();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Skeleton } from "@mui/lab";
import { Skeleton } from "@mui/material";
import { useAppDispatch } from "libraries/hooks/redux";
import React, { FC, useEffect, useRef, useState } from "react";
import { useTranslation } from "react-i18next";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Skeleton } from "@mui/lab";
import { Skeleton } from "@mui/material";
import { useAppDispatch } from "libraries/hooks/redux";
import React, { FC, useEffect, useRef, useState } from "react";
import { useTranslation } from "react-i18next";
Expand All @@ -25,13 +25,12 @@ export const AdmissionsByTypes: FC<TDashboardComponentProps & IOwnProps> = ({
const admtcardRef = useRef<HTMLDivElement>(null);

useEffect(() => {
//dispatch(getAdmissions({ admissionrange: period }));
dispatch(getAdmissionTypes());
}, [dispatch]);

useEffect(() => {
dispatch(getAdmissions({ admissionrange: period }));
}, [period]);
}, [period, dispatch]);

const { total, success, status, admissionTypeStatus, data, csvData } =
useAdmByAdmTypeData();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Skeleton } from "@mui/lab";
import { Skeleton } from "@mui/material";
import { useAppDispatch } from "libraries/hooks/redux";
import React, { FC, useEffect, useRef, useState } from "react";
import { useTranslation } from "react-i18next";
Expand All @@ -25,13 +25,12 @@ export const AdmissionsByWards: FC<TDashboardComponentProps & IOwnProps> = ({
const cardRef = useRef<HTMLDivElement>(null);

useEffect(() => {
//dispatch(getAdmissions({ admissionrange: period }));
dispatch(getWards());
}, [dispatch]);

useEffect(() => {
dispatch(getAdmissions({ admissionrange: period }));
}, [period]);
}, [period, dispatch]);

const { total, success, status, wardStatus, data, csvData } =
useAdmByAdmWardData();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Skeleton } from "@mui/lab";
import { Skeleton } from "@mui/material";
import { useAppDispatch } from "libraries/hooks/redux";
import React, { FC, useEffect } from "react";
import { useTranslation } from "react-i18next";
Expand Down Expand Up @@ -38,11 +38,11 @@ export const Discharges: FC<IOwnProps> = ({ period }) => {
dispatch(getAgeTypes());
dispatch(getDischargeTypes());
dispatch(getWards());
}, [dispatch]);
}, [dispatch, period]);

useEffect(() => {
dispatch(getDischarges({ dischargerange: period }));
}, [period]);
}, [period, dispatch]);

return (
<>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Skeleton } from "@mui/lab";
import { Skeleton } from "@mui/material";
import { useAppDispatch } from "libraries/hooks/redux";
import React, { FC, useEffect, useRef, useState } from "react";
import { useTranslation } from "react-i18next";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Skeleton } from "@mui/lab";
import { Skeleton } from "@mui/material";
import { useAppDispatch } from "libraries/hooks/redux";
import React, { FC, useEffect, useRef, useState } from "react";
import { useTranslation } from "react-i18next";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Skeleton } from "@mui/lab";
import { Skeleton } from "@mui/material";
import { useAppDispatch } from "libraries/hooks/redux";
import React, { FC, useEffect, useRef, useState } from "react";
import { useTranslation } from "react-i18next";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Skeleton } from "@mui/lab";
import { Skeleton } from "@mui/material";
import { useAppDispatch } from "libraries/hooks/redux";
import React, { FC, useEffect, useRef, useState } from "react";
import { useTranslation } from "react-i18next";
Expand Down Expand Up @@ -26,11 +26,11 @@ export const DischargesByWards: FC<TDashboardComponentProps & IOwnProps> = ({
useEffect(() => {
dispatch(getDischarges({ dischargerange: period }));
dispatch(getWards());
}, [dispatch]);
}, [dispatch, period]);

useEffect(() => {
dispatch(getDischarges({ dischargerange: period }));
}, [period]);
}, [period, dispatch]);

const { total, success, status, wardStatus, data, csvData } =
useDisByWardData();
Expand Down
13 changes: 3 additions & 10 deletions src/components/accessories/dashboard/opds/Opds.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Skeleton } from "@mui/lab";
import { Skeleton } from "@mui/material";
import { useAppDispatch } from "libraries/hooks/redux";
import React, { FC, useEffect } from "react";
import { useTranslation } from "react-i18next";
Expand All @@ -23,15 +23,8 @@ export const Opds: FC<IOwnProps> = ({ period }) => {
);
dispatch(getAgeTypes());
}, [dispatch, period]);
const {
ageTypeStatus,
opdStatus,
dataByAgeType,
dataBySex,
success,
total,
opds,
} = useData();
const { ageTypeStatus, opdStatus, dataByAgeType, dataBySex, success, total } =
useData();

return (
<>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Skeleton } from "@mui/lab";
import { Skeleton } from "@mui/material";
import { useAppDispatch } from "libraries/hooks/redux";
import React, { FC, useEffect, useRef, useState } from "react";
import { useTranslation } from "react-i18next";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Skeleton } from "@mui/lab";
import { Skeleton } from "@mui/material";
import { useAppDispatch } from "libraries/hooks/redux";
import React, { FC, useEffect, useRef, useState } from "react";
import { useTranslation } from "react-i18next";
Expand Down
9 changes: 6 additions & 3 deletions src/state/layouts/slice.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { PayloadAction, createSlice } from "@reduxjs/toolkit";
import { initial } from "./initial";
import * as thunks from "./thunk";
import { ApiResponse } from "state/types";
import { isEmpty } from "lodash";
import { Layouts } from "react-grid-layout";
import { ApiResponse } from "state/types";
import {
decodeLayoutConfig,
encodeLayout,
toolboxDashboards,
} from "../../components/accessories/dashboard/layouts/consts";
import { initial } from "./initial";
import * as thunks from "./thunk";

export const layoutSlice = createSlice({
name: "layouts",
Expand Down Expand Up @@ -72,6 +72,9 @@ export const layoutSlice = createSlice({
...payload,
configValue: encodeLayout({ layout, toolbox }),
};

state.layouts = layout;
state.toolbox = toolbox;
})
.addCase(thunks.getLayouts.rejected, (state, action) => {
state.getLayouts = ApiResponse.error(action.payload);
Expand Down

0 comments on commit 5c54372

Please sign in to comment.