diff --git a/src/components/center/CreateCenterModal.tsx b/src/components/center/CreateCenterModal.tsx index 5e9d3c8c..7d5d7945 100644 --- a/src/components/center/CreateCenterModal.tsx +++ b/src/components/center/CreateCenterModal.tsx @@ -19,6 +19,7 @@ import { GenerateSchemaAndUiSchema } from '../GeneratedSchemas'; import { showToastMessage } from '../Toastify'; import FormButtons from '../FormButtons'; import useSubmittedButtonStore from '@/store/useSubmittedButtonStore'; +import { FormContext, FormContextType } from '@/utils/app.constant'; interface CreateBlockModalProps { open: boolean; @@ -63,7 +64,7 @@ const CreateCenterModal: React.FC = ({ useEffect(() => { const getForm = async () => { try { - const res = await getFormRead('cohorts', 'cohort'); + const res = await getFormRead(FormContext.COHORTS, FormContextType.COHORT); console.log(res); const { schema, uiSchema } = GenerateSchemaAndUiSchema(res, t); console.log(schema, uiSchema); diff --git a/src/pages/centers/index.tsx b/src/pages/centers/index.tsx index 373edd64..61877f11 100644 --- a/src/pages/centers/index.tsx +++ b/src/pages/centers/index.tsx @@ -1,6 +1,17 @@ +import CenterList from '@/components/center/centerList'; +import CreateCenterModal from '@/components/center/CreateCenterModal'; +import Header from '@/components/Header'; +import Loader from '@/components/Loader'; +import ManageUser from '@/components/ManageUser'; +import { showToastMessage } from '@/components/Toastify'; import { getCohortList } from '@/services/CohortServices'; +import useStore from '@/store/store'; +import { CenterType, Role } from '@/utils/app.constant'; import { accessGranted, toPascalCase } from '@/utils/Helper'; import { ICohort } from '@/utils/Interfaces'; +import { ArrowDropDown, Clear, Search } from '@mui/icons-material'; +import AddIcon from '@mui/icons-material/Add'; +import ChevronRightIcon from '@mui/icons-material/ChevronRight'; import { Box, Button, @@ -12,28 +23,16 @@ import { Tabs, TextField, } from '@mui/material'; -import React, { useEffect, useState } from 'react'; -import FilterModalCenter from '../blocks/components/FilterModalCenter'; -import CenterList from '@/components/center/centerList'; -import Header from '@/components/Header'; -import Loader from '@/components/Loader'; -import ManageUser from '@/components/ManageUser'; -import { showToastMessage } from '@/components/Toastify'; -import CreateCenterModal from '@/components/center/CreateCenterModal'; -import useStore from '@/store/store'; -import { CenterType, Role, Status } from '@/utils/app.constant'; -import { ArrowDropDown, Clear, Search } from '@mui/icons-material'; -import AddIcon from '@mui/icons-material/Add'; -import ChevronRightIcon from '@mui/icons-material/ChevronRight'; -import SmartDisplayOutlinedIcon from '@mui/icons-material/SmartDisplayOutlined'; import { useTheme } from '@mui/material/styles'; import { useTranslation } from 'next-i18next'; import { serverSideTranslations } from 'next-i18next/serverSideTranslations'; import Image from 'next/image'; import { useRouter } from 'next/router'; +import React, { useEffect, useState } from 'react'; import { setTimeout } from 'timers'; import { accessControl } from '../../../app.config'; import building from '../../assets/images/apartment.png'; +import FilterModalCenter from '../blocks/components/FilterModalCenter'; const CentersPage = () => { const [loading, setLoading] = useState(false); @@ -97,11 +96,10 @@ const CentersPage = () => { userId && accessGranted('showBlockLevelCohort', accessControl, userRole) ) { - let response = await getCohortList(userId, { + const response = await getCohortList(userId, { customField: 'true', }); - const blockData = response.map((block: any) => { const blockName = block.cohortName; const blockId = block.cohortId; @@ -391,11 +389,13 @@ const CentersPage = () => { )} - + {openCreateCenterModal && ( + + )} {accessGranted( 'showBlockLevelCenterData', diff --git a/src/pages/learner/[userId].tsx b/src/pages/learner/[userId].tsx index c1bdb75b..14025f07 100644 --- a/src/pages/learner/[userId].tsx +++ b/src/pages/learner/[userId].tsx @@ -216,9 +216,8 @@ const LearnerProfile: React.FC = ({ const fetchDataAndInitializeForm = async () => { try { - let formFields; const response = await getUserDetails(userId, true); - formFields = await getFormRead('USERS', 'STUDENT'); + const formFields = await getFormRead(FormContext.USERS, FormContextType.STUDENT); console.log('response', response); console.log('formFields', formFields); setFormData(mapFields(formFields, response?.result)); diff --git a/src/pages/user-profile/[userId].tsx b/src/pages/user-profile/[userId].tsx index 7abd317a..3f02ae2b 100644 --- a/src/pages/user-profile/[userId].tsx +++ b/src/pages/user-profile/[userId].tsx @@ -178,9 +178,8 @@ const TeacherProfile: React.FC = ({ const fetchDataAndInitializeForm = async () => { try { - let formFields; const response = await getUserDetails(userId, true); - formFields = await getFormRead('USERS', 'TEACHER'); + const formFields = await getFormRead(FormContext.USERS, FormContextType.TEACHER); console.log('response', response); console.log('formFields', formFields); setUserFormData(mapFields(formFields, response?.result)); diff --git a/src/utils/app.constant.ts b/src/utils/app.constant.ts index 88d6a1c9..353d94e3 100644 --- a/src/utils/app.constant.ts +++ b/src/utils/app.constant.ts @@ -72,12 +72,14 @@ export enum cohortPrivileges { export enum FormContext { USERS = 'USERS', + COHORTS = 'COHORTS', } export enum FormContextType { STUDENT = 'STUDENT', TEACHER = 'TEACHER', TEAM_LEADER = 'TEAM LEADER', + COHORT= 'COHORT', } export enum CenterType {