From 80158c5342421ee38aa36dcbe27d928cc12685f3 Mon Sep 17 00:00:00 2001 From: Rushikesh-Sonawane99 Date: Fri, 2 Aug 2024 00:03:03 +0530 Subject: [PATCH] Issue #PS-1275 chore: Fixed subject I teach field issue --- .env | 1 + src/components/LearnerModal.tsx | 2 +- src/pages/centers/[cohortId].tsx | 8 ++++---- src/pages/user-profile/[userId].tsx | 32 +++++++++++++++++++---------- 4 files changed, 27 insertions(+), 16 deletions(-) diff --git a/.env b/.env index 2d9004de..beec282d 100644 --- a/.env +++ b/.env @@ -1,4 +1,5 @@ NEXT_PUBLIC_BASE_URL=https://qa.prathamteacherapp.tekdinext.com/user/v1 +# NEXT_PUBLIC_BASE_URL=https://backend.prathamdigital.org/user/v1 NEXT_PUBLIC_EVENT_BASE_URL=http://3.109.46.84:4000/event/v1 NEXT_PUBLIC_TELEMETRY_URL=https://qa.prathamteacherapp.tekdinext.com NEXT_PUBLIC_MEASUREMENT_ID= G-GNMQZ8Z65Z diff --git a/src/components/LearnerModal.tsx b/src/components/LearnerModal.tsx index 275793cc..fc44cf7c 100644 --- a/src/components/LearnerModal.tsx +++ b/src/components/LearnerModal.tsx @@ -148,7 +148,7 @@ const LearnerModal = ({ > {item?.label ? t( - `FIELDS.${item.label.toUpperCase()}`, + `FORM.${item.label.toUpperCase()}`, item.label ) : item.label} diff --git a/src/pages/centers/[cohortId].tsx b/src/pages/centers/[cohortId].tsx index 0f1625e3..d5ff3146 100644 --- a/src/pages/centers/[cohortId].tsx +++ b/src/pages/centers/[cohortId].tsx @@ -133,14 +133,14 @@ const TeachingCenterDetails = () => { if (cohortData?.customField?.length) { const district = cohortData.customField.find( - (item: CustomField) => item.label === 'District' + (item: CustomField) => item.label === 'DISTRICTS' ); const districtCode = district?.code || ''; setDistrictCode(districtCode); const districtId = district?.fieldId || ''; // setDistrictId(districtId); const state = cohortData.customField.find( - (item: CustomField) => item.label === 'State' + (item: CustomField) => item.label === 'STATES' ); const stateCode = state?.code || ''; setStateCode(stateCode); @@ -148,7 +148,7 @@ const TeachingCenterDetails = () => { // setStateId(stateId); const blockField = cohortData?.customField.find( - (field: any) => field.label === 'Block' + (field: any) => field.label === 'BLOCKS' ); setBlockCode(blockField?.code); // setBlockId(blockField.fieldId); @@ -249,7 +249,7 @@ const TeachingCenterDetails = () => { /> - {cohortDetails?.name} + {toPascalCase(cohortDetails?.name)} {cohortDetails?.centerType && ( diff --git a/src/pages/user-profile/[userId].tsx b/src/pages/user-profile/[userId].tsx index 477adba6..d9b0060f 100644 --- a/src/pages/user-profile/[userId].tsx +++ b/src/pages/user-profile/[userId].tsx @@ -28,7 +28,7 @@ import withAccessControl from '@/utils/hoc/withAccessControl'; import { getFormRead } from '@/services/CreateUserService'; import { FormContext, FormContextType, Role } from '@/utils/app.constant'; import manageUserStore from '@/store/manageUserStore'; -import useStore from '@/store/store'; +// import useStore from '@/store/store'; import AddFacilitatorModal from '@/components/AddFacilitator'; interface UserData { @@ -41,10 +41,10 @@ const TeacherProfile = () => { const { t } = useTranslation(); const router = useRouter(); const { userId }: any = router.query; - const store = useStore(); - const userRole = store.userRole; + // const store = useStore(); + // const userRole = store?.userRole; const userStore = manageUserStore(); - const selfUserId = localStorage.getItem('userId'); + const theme = useTheme(); const [userData, setUserData] = useState(null); @@ -63,7 +63,17 @@ const TeacherProfile = () => { const [userFormData, setUserFormData] = useState<{ [key: string]: any }>({}); const [openAddLearnerModal, setOpenAddLearnerModal] = React.useState(false); const [reload, setReload] = React.useState(false); + const [selfUserId, setSelfUserId] = React.useState(null); + const [userRole, setUserRole] = React.useState(null); + useEffect(() => { + if (typeof window !== 'undefined' && window.localStorage) { + const userId = localStorage.getItem('userId'); + setSelfUserId(userId); + const role = localStorage.getItem('role'); + setUserRole(role); + } + }, []); const handleReload = () => { setReload((prev) => !prev); }; @@ -275,7 +285,7 @@ const TeacherProfile = () => { // Find fields for "Subjects I Teach" and "My Main Subjects" const teachSubjectsField = customFieldsData?.find( - (field) => field.name === 'subject_taught' + (field) => field.name === 'subject_teach' ); const mainSubjectsField: any = customFieldsData?.find( (field) => field.name === 'main_subject' @@ -292,8 +302,8 @@ const TeacherProfile = () => { const mutualSubjects = teachSubjects?.filter((subject) => mainSubjects?.includes(subject) ); - const remainingSubjects = teachSubjects?.filter( - (subject) => !mainSubjects?.includes(subject) + const remainingSubjects = mainSubjects?.filter( + (subject) => !teachSubjects?.includes(subject) ); const orderedSubjects = [...mutualSubjects, ...remainingSubjects]; @@ -522,7 +532,7 @@ const TeacherProfile = () => { // }, }} > - {userRole == Role.TEAM_LEADER && userId !== selfUserId ? ( + {userRole === Role.TEAM_LEADER && userId !== selfUserId ? (