diff --git a/src/pages/centers/[cohortId].tsx b/src/pages/centers/[cohortId].tsx index fbbf289d..74845cb1 100644 --- a/src/pages/centers/[cohortId].tsx +++ b/src/pages/centers/[cohortId].tsx @@ -14,7 +14,6 @@ import AddLearnerModal from '@/components/AddLeanerModal'; import ArrowForwardIcon from '@mui/icons-material/ArrowForward'; import Box from '@mui/material/Box'; import CenterSessionModal from '@/components/CenterSessionModal'; -import CohortFacilitatorList from '@/components/CohortFacilitatorList'; import CohortLearnerList from '@/components/CohortLearnerList'; import { CustomField } from '@/utils/Interfaces'; import DeleteCenterModal from '@/components/center/DeleteCenterModal'; @@ -40,6 +39,8 @@ import { serverSideTranslations } from 'next-i18next/serverSideTranslations'; import { useRouter } from 'next/router'; import { useTheme } from '@mui/material/styles'; import { useTranslation } from 'next-i18next'; +import CohortFacilitatorList from '@/components/CohortFacilitatorList'; +import manageUserStore from '@/store/manageUserStore'; const TeachingCenterDetails = () => { const [value, setValue] = React.useState(1); @@ -48,6 +49,16 @@ const TeachingCenterDetails = () => { const router = useRouter(); const { cohortId }: any = router.query; const { t } = useTranslation(); + const store = manageUserStore(); + const setDistrictCode = manageUserStore( + (state: { setDistrictCode: any }) => state.setDistrictCode + ); + const setDistrictId = manageUserStore( + (state: { setDistrictId: any }) => state.setDistrictId + ); + const setStateCode = manageUserStore((state: { setStateCode: any }) => state.setStateCode); + const setStateId = manageUserStore((state: { setStateId: any }) => state.setStateId); + const [open, setOpen] = React.useState(false); const theme = useTheme(); const [selectedDate, setSelectedDate] = @@ -100,9 +111,17 @@ const TeachingCenterDetails = () => { const district = cohortData.customField.find( (item: CustomField) => item.label === 'District' ); + const districtCode = district?.code || ''; + setDistrictCode(districtCode); + const districtId = district?.fieldId || ''; + setDistrictId(districtId); const state = cohortData.customField.find( (item: CustomField) => item.label === 'State' ); + const stateCode = state?.code || ''; + setStateCode(stateCode) + const stateId = state?.fieldId || ''; + setStateId(stateId); cohortData.address = `${toPascalCase(district?.value)}, ${toPascalCase(state?.value)}` || diff --git a/src/store/manageUserStore.js b/src/store/manageUserStore.js index d500dac2..524c4179 100644 --- a/src/store/manageUserStore.js +++ b/src/store/manageUserStore.js @@ -6,8 +6,20 @@ const manageUserStore = create( (set) => ({ deleteId: '', learnerDeleteId: '', + blockCode: '', + districtCode: '', + stateCode: '', + blockId: '', + districtId: '', + stateId: '', setCohortDeleteId: (newCohortDeleteId) => set((state) => ({ deleteId: newCohortDeleteId })), setCohortLearnerDeleteId: (newCohortLearnerDeleteId) => set((state) => ({ learnerDeleteId: newCohortLearnerDeleteId })), + setBlockCode: (newBlockCode) => set(() => ({ blockCode: newBlockCode })), + setDistrictCode: (newDistrictCode) => set(() => ({ districtCode: newDistrictCode })), + setStateCode: (newStateCode) => set(() => ({ stateCode: newStateCode })), + setBlockId: (newBlockId) => set(() => ({ blockId: newBlockId })), + setDistrictId: (newDistrictId) => set(() => ({ districtId: newDistrictId })), + setStateId: (newStateId) => set(() => ({ stateId: newStateId })) }), { name: 'teacherApp',