From 849826a891ebc759a1967ce594b61feac44e11b2 Mon Sep 17 00:00:00 2001 From: NabeelAyubee Date: Fri, 25 Oct 2024 16:09:01 +0530 Subject: [PATCH] added loader in table and fix load issue --- .../src/components/RoleTableComposer.js | 133 +++++++++++------- 1 file changed, 86 insertions(+), 47 deletions(-) diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/RoleTableComposer.js b/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/RoleTableComposer.js index ac046b4e784..94a49c155e2 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/RoleTableComposer.js +++ b/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/RoleTableComposer.js @@ -7,15 +7,37 @@ import { useUserAccessContext } from "./UserAccessWrapper"; import { useMyContext } from "../utils/context"; import { useQueryClient } from "react-query"; import { tableCustomStyle } from "./tableCustomStyle"; +import styled, { keyframes } from "styled-components"; -function LoaderOverlay() { +const rotate360 = keyframes` + from { + transform: rotate(0deg); + } + + to { + transform: rotate(360deg); + } +`; +const Spinner = styled.div` + margin: 16px; + animation: ${rotate360} 1s linear infinite; + transform: translateZ(0); + border-top: 2px solid grey; + border-right: 2px solid grey; + border-bottom: 2px solid grey; + border-left: 4px solid black; + background: transparent; + width: 80px; + height: 80px; + border-radius: 50%; +`; +function CustomLoader() { return ( -
-
+
+
); } - function RoleTableComposer({ nationalRoles }) { const { t } = useTranslation(); const queryClient = useQueryClient(); @@ -141,7 +163,7 @@ function RoleTableComposer({ nationalRoles }) { ...i, selectedHierarchy: value, boundaryOptions, - selectedBoundaries: i.selectedBoundaries || [], // Keep existing selected boundaries + selectedBoundaries: [], // Keep existing selected boundaries } : i ); @@ -385,6 +407,9 @@ function RoleTableComposer({ nationalRoles }) { refetchHrms(); // Fetch the updated data with the new rows per page }; const handleSearchSubmit = (e) => { + if (number?.length > 0 && number?.length <= 10) { + setShowToast({ key: "error", label: t("INVALID_MOBILE_NUMBER_LENGTH") }); + } setFilters({ name: name, number: number, @@ -403,59 +428,73 @@ function RoleTableComposer({ nationalRoles }) { const closeToast = () => { setShowToast(null); }; - if (isHrmsLoading) { - return ; - } + return ( <> -
-
- - {t("Name")} - { - setName(e.target.value); - }} - // inputRef={ref} - errorStyle={""} - min={1} - minlength={1} - /> - - - {t("Number")} - { - setNumber(e.target.value); - }} - // inputRef={ref} - errorStyle={""} - min={10} - minlength={10} - /> - -
- - {t("Clear Search")} - - +
{ + e.preventDefault(); // Prevent default submission + e.stopPropagation(); // Stop the event from reaching the parent form + handleSearchSubmit(); + }} + onKeyDown={(e) => { + if (e.key === "Enter") { + e.stopPropagation(); + handleSearchSubmit(); + } + }} + > +
+
+ + {t("Name")} + { + setName(e.target.value); + }} + // inputRef={ref} + errorStyle={""} + min={1} + minlength={1} + /> + + + {t("Number")} + { + setNumber(e.target.value); + }} + // inputRef={ref} + errorStyle={""} + min={10} + minlength={10} + /> + +
+ + {t("Clear Search")} + + +
-
+
- {isLoading && } + {/* {isLoading || isHrmsLoading ? : null} */} } paginationServer paginationTotalRows={totalRows} customStyles={tableCustomStyle}