From 3775a0b6840dc2676de530a261409b1cb7b370db Mon Sep 17 00:00:00 2001 From: suvarnakale Date: Thu, 27 Jun 2024 19:12:00 +0530 Subject: [PATCH] Issue #000 chore: build issue fixes --- src/components/ManageCentersModal.tsx | 10 +++++++--- src/pages/manageUser.tsx | 11 ++++++++--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/components/ManageCentersModal.tsx b/src/components/ManageCentersModal.tsx index 97165668..aad58b36 100644 --- a/src/components/ManageCentersModal.tsx +++ b/src/components/ManageCentersModal.tsx @@ -29,7 +29,7 @@ const ManageCentersModal: React.FC = ({ }) => { const theme = useTheme(); const { t } = useTranslation(); - const [checkedCenters, setCheckedCenters] = React.useState([]); + const [checkedCenters, setCheckedCenters] = React.useState([]); const style = { position: 'absolute', @@ -47,7 +47,9 @@ const ManageCentersModal: React.FC = ({ }; React.useEffect(() => { - setCheckedCenters(centers); + if (centers) { + setCheckedCenters(centers as never[]); + } }, [centers]); const handleToggle = (name: string) => { @@ -67,7 +69,9 @@ const ManageCentersModal: React.FC = ({ }; const handleAssign = () => { - onAssign(checkedCenters); + if (onAssign) { + onAssign(checkedCenters); + } }; return ( diff --git a/src/pages/manageUser.tsx b/src/pages/manageUser.tsx index 21ecfd2d..b3744bd4 100644 --- a/src/pages/manageUser.tsx +++ b/src/pages/manageUser.tsx @@ -39,6 +39,11 @@ interface Cohort { name: string; } +interface User { + name: string; + userId: string; +} + type CohortsData = { [userId: string]: Cohort[]; }; @@ -58,7 +63,7 @@ const manageUsers = () => { const [centersData, setCentersData] = useState([]); const [open, setOpen] = React.useState(false); const [openCentersModal, setOpenCentersModal] = React.useState(false); - const [selectedUser, setSelectedUser] = useState(null); + const [selectedUser, setSelectedUser] = useState(null); const [selectedUserName, setSelectedUserName] = useState(null); const [centers, setCenters] = useState([]); const [centerList, setCenterList] = useState([]); @@ -245,10 +250,10 @@ const manageUsers = () => { } }; - const handleAssignCenters = async (selectedCenters) => { + const handleAssignCenters = async (selectedCenters: any) => { console.log('selectedUser', selectedUser); try { - const selectedUserIds = [selectedUser.userId]; + const selectedUserIds = [selectedUser?.userId]; const matchedCohortIdsFromCohortsData = Object.values(cohortsData) .flatMap((cohorts) => cohorts)