Skip to content

Commit

Permalink
Merge pull request #37 from Rushikesh-Sonawane99/release-1.0.0
Browse files Browse the repository at this point in the history
Issue #PS-1254 chore: Stored stateCode and districtCode in zustand
  • Loading branch information
itsvick authored Jul 23, 2024
2 parents 4a5e905 + 5917843 commit 65c2615
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/pages/centers/[cohortId].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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);
Expand All @@ -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<any>();
const [selectedDate, setSelectedDate] =
Expand Down Expand Up @@ -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)}` ||
Expand Down
12 changes: 12 additions & 0 deletions src/store/manageUserStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 65c2615

Please sign in to comment.