From a751f4d053336df47c85d2015968f032327fc492 Mon Sep 17 00:00:00 2001 From: Akshata Katwal Date: Fri, 13 Sep 2024 20:28:28 +0530 Subject: [PATCH 01/40] Issue feat:PS-1502 Reassign center to leaner and facilitator and reassign block to team leader --- src/components/AreaSelection.tsx | 61 +++--- src/components/CustomModal.tsx | 12 +- src/components/ReassignCenterModal.tsx | 246 +++++++++++++++++++++---- src/components/UserTable.tsx | 63 +++++-- src/services/CreateUserService.ts | 3 +- src/utils/Helper.ts | 43 ++++- src/utils/useLocationState.tsx | 142 ++++++++++---- 7 files changed, 462 insertions(+), 108 deletions(-) diff --git a/src/components/AreaSelection.tsx b/src/components/AreaSelection.tsx index c0735459..01ae8c00 100644 --- a/src/components/AreaSelection.tsx +++ b/src/components/AreaSelection.tsx @@ -3,8 +3,9 @@ import { useTheme } from "@mui/material/styles"; import { useTranslation } from "next-i18next"; import React, { useEffect, useState } from "react"; import MultipleSelectCheckmarks from "./FormControl"; -import { capitalizeFirstLetterOfEachWordInArray } from "@/utils/Helper"; -import { useMediaQuery } from "@mui/material"; +import { capitalizeFirstLetterOfEachWordInArray} from "@/utils/Helper"; +import { useMediaQuery } from "@mui/material"; +import { Role } from "@/utils/app.constant"; interface State { value: string; @@ -54,8 +55,11 @@ interface DropdownBoxProps { isMobile: boolean; isMediumScreen: boolean; isCenterSelection?: boolean; - stateDefaultValue?: string; + stateDefaultValue?:string; userType?: string; + reAssignModal?:boolean; + blockDefaultValue?:string; + districtDefaultValue?:string } const AreaSelection: React.FC = ({ @@ -76,17 +80,26 @@ const AreaSelection: React.FC = ({ inModal = false, handleCenterChangeWrapper = () => {}, stateDefaultValue, + blockDefaultValue, + districtDefaultValue, + userType, + reAssignModal=false }) => { + +console.log(selectedState.length) const { t } = useTranslation(); const theme = useTheme(); - const [singleState, setSingleState] = useState(true); - const [stateValue, setStateValue] = useState(""); - const [stateCode, setStateCode] = useState(""); - const isSmallScreen = useMediaQuery((theme: any) => - theme.breakpoints.down("sm") - ); - +const [singleState, setSingleState] = useState (true); +const [stateValue, setStateValue] = useState (""); +const [stateCode, setStateCode] = useState (""); +let isSmallScreen = useMediaQuery((theme: any) => +theme.breakpoints.down("sm"), +); +// isSmallScreen=isMobile?true: false; +const blockDisable= districtDefaultValue?false: true +const shouldRenderSelectCheckmarks = +!(reAssignModal && userType === Role.TEAM_LEADERS); return ( = ({ // boxShadow: "0px 0px 10px rgba(0, 0, 0, 0.1)", }} > - - {userType && ( + {userType && !reAssignModal && ( {userType} @@ -156,12 +170,14 @@ const AreaSelection: React.FC = ({ } overall={!inModal} defaultValue={ - selectedState.length > 0 && districts?.length <= 0 + reAssignModal + ? districtDefaultValue + : selectedState.length > 0 && districts?.length === 0 ? t("COMMON.NO_DISTRICTS") : t("COMMON.ALL_DISTRICTS") } /> - blocks.label) )} @@ -170,23 +186,26 @@ const AreaSelection: React.FC = ({ selectedCategories={capitalizeFirstLetterOfEachWordInArray(selectedBlock)} onCategoryChange={handleBlockChangeWrapper} disabled={ + blockDefaultValue? false: + blocks?.length <= 0 || selectedDistrict?.length === 0 || (selectedDistrict && selectedDistrict[0] === "") || selectedDistrict[0] === t("COMMON.ALL_DISTRICTS") } overall={!inModal} - defaultValue={ + defaultValue={ + // blockDefaultValue? blockDefaultValue: selectedDistrict?.length > 0 && blocks?.length <= 0 ? t("COMMON.NO_BLOCKS") : t("COMMON.ALL_BLOCKS") } - /> - {isCenterSelection && ( - centers.name) - )} + />) +} + + + { isCenterSelection && ( centers.name))} codes={allCenters?.map((centers) => centers.cohortId)} tagName={t("CENTERS.CENTERS")} selectedCategories={selectedCenter} diff --git a/src/components/CustomModal.tsx b/src/components/CustomModal.tsx index bb554afa..18f00c94 100644 --- a/src/components/CustomModal.tsx +++ b/src/components/CustomModal.tsx @@ -8,6 +8,7 @@ import { Divider, useMediaQuery, Theme, + useTheme } from "@mui/material"; import CloseIcon from "@mui/icons-material/Close"; @@ -40,10 +41,13 @@ const CustomModal: React.FC = ({ primaryBtnDisabled = true, children, }) => { - const isSmallScreen = useMediaQuery((theme: Theme) => - theme.breakpoints.down("sm"), - ); + // const isSmallScreen = useMediaQuery((theme: Theme) => + // theme.breakpoints.down("sm"), + // ); + const theme = useTheme(); + const isSmallScreen = useMediaQuery(theme.breakpoints.down("sm")); + const isLargeScreen = useMediaQuery(theme.breakpoints.up("lg")); return ( = ({ top: "50%", left: "50%", transform: "translate(-50%, -50%)", - width: isSmallScreen ? "90%" : 400, + width: isSmallScreen ? "90%" : isLargeScreen ? "65%" : "85%", maxWidth: "90%", bgcolor: "background.paper", boxShadow: 24, diff --git a/src/components/ReassignCenterModal.tsx b/src/components/ReassignCenterModal.tsx index f32abbf1..74829f8d 100644 --- a/src/components/ReassignCenterModal.tsx +++ b/src/components/ReassignCenterModal.tsx @@ -5,7 +5,7 @@ import { InputAdornment, TextField, } from "@mui/material"; -import React, { useState } from "react"; +import React, { useEffect, useState } from "react"; import { useTheme } from "@mui/material/styles"; import { useTranslation } from "next-i18next"; import { showToastMessage } from "./Toastify"; @@ -16,6 +16,9 @@ import { bulkCreateCohortMembers } from "@/services/CohortService/cohortService" import { getCenterList } from "@/services/MasterDataService"; import { getUserDetailsInfo } from "@/services/UserList"; import { updateUser } from "@/services/CreateUserService"; +import { useLocationState } from "@/utils/useLocationState"; +import AreaSelection from "./AreaSelection"; +import { transformArray } from "../utils/Helper"; interface ReassignCohortModalProps { open: boolean; @@ -23,14 +26,19 @@ interface ReassignCohortModalProps { cohortData?: any; userId?: string; userType?: string; - blocks?:any, - blockName?: any + blockList?:any, + blockName?: any, + blockCode?:any, + districtName?: any, + districtCode?:any, + cohortId?:any + centers: any } interface Cohort { - id: any; - cohortId: string; - name: string; + id?: any; + cohortId?: string; + name?: string; } const ReassignCenterModal: React.FC = ({ @@ -39,25 +47,73 @@ const ReassignCenterModal: React.FC = ({ cohortData, userId, userType, - blocks, - blockName -}) => { - console.log(blocks) + blockList, + blockName, + cohortId, + blockCode, + districtName, + districtCode, + centers + +}) => { const { t } = useTranslation(); const theme = useTheme(); + const roleType = userType; + const defaultBlock=blockName; - const cohorts: Cohort[] = cohortData?.map( +const { + states, + districts, + blocks, + allCenters, + isMobile, + isMediumScreen, + selectedState, + selectedStateCode, + selectedDistrict, + selectedDistrictCode, + selectedCenter, + dynamicForm, + selectedBlock, + selectedBlockCode, + handleStateChangeWrapper, + handleDistrictChangeWrapper, + handleBlockChangeWrapper, + handleCenterChangeWrapper, + selectedCenterCode, + selectedBlockCohortId, + blockFieldId, + districtFieldId, + stateFieldId, + dynamicFormForBlock, + stateDefaultValue, + setSelectedBlock, + setSelectedDistrict, + setSelectedDistrictCode, + setSelectedBlockCode + } =useLocationState(open, onClose, roleType, true) + + let cohorts: Cohort[] = allCenters?.map( (cohort: { cohortId: any; name: string }) => ({ name: cohort.name, id: cohort.cohortId, }) ); - const [searchInput, setSearchInput] = useState(""); - const [selectedBlockId, setselectedBlockId] = useState(""); + console.log(centers?.split(',').map((center :any)=> center.trim())) + console.log(blockCode) + const names = cohortData.map((item : any)=> item.name); + + console.log(names); + + const [searchInput, setSearchInput] = useState(""); + //const [selectedBlockId, setselectedBlockId] = useState(blockName); + + // const [checkedCenters, setCheckedCenters] = useState([blockCode]); const [checkedCenters, setCheckedCenters] = useState([]); + const handleSearchInputChange = ( event: React.ChangeEvent ) => { @@ -65,6 +121,7 @@ const ReassignCenterModal: React.FC = ({ }; const handleClose = () => { + setCheckedCenters([]); onClose(); }; @@ -76,28 +133,105 @@ const ReassignCenterModal: React.FC = ({ : [...prev, name] ); }; + console.log(checkedCenters) + + console.log(userType) const handleReassign = async () => { try { - const selectedData = cohorts - .filter((center) => checkedCenters.includes(center.name)) - .map((center) => center.id); - const unSelectedData = cohorts - .filter((center) => !checkedCenters.includes(center.name)) - .map((center) => center.id); - + let selectedData; + let unSelectedData: string[]; + if(userType!== Role.TEAM_LEADERS) + { + selectedData = cohorts + .filter((center) => center?.name && checkedCenters.includes(center.name)) + .map((center) => center!.id); + + unSelectedData = cohorts + .filter((center) => center?.name && !checkedCenters.includes(center.name)) + .map((center) => center!.id); + + } + else + { + selectedData = blocks + .filter((center) => center?.value && checkedCenters.includes(center.value)) + .map((center) => center!.value); + + unSelectedData= blocks + .filter((center) => center?.value && !checkedCenters.includes(center.value)) + .map((center) => center!.value); + } + console.log(unSelectedData) + +const labelArray = filteredCBlocks + ?.filter((block: any) => unSelectedData?.includes(block.value)) + .map((block: any) => block.label); + + console.log(blocks) + console.log(selectedData) + let payload; - if (userType !== Role.TEAM_LEADERS) { payload = { userId: [userId], cohortId: selectedData, - removeCohortId: unSelectedData, + removeCohortId: unSelectedData.length===0?cohortId:unSelectedData, }; await bulkCreateCohortMembers(payload); + let customFields; + + if(selectedBlock[0]!==blockName) + { + + const userDetails = await getUserDetailsInfo(userId); + const blockField = userDetails?.userData?.customFields.find( + (field: any) => field.label === "BLOCKS" + ); + customFields = [ + + { + fieldId: blockField.fieldId, + value: selectedBlockCode, + }, + + ]; + + + if(selectedDistrict[0]!==districtName) + { + const userDetails = await getUserDetailsInfo(userId); + const blockField = userDetails?.userData?.customFields.find( + (field: any) => field.label === "BLOCKS" + ); + customFields = [ + { + fieldId: districtFieldId, + value: selectedDistrictCode, + }, + { + fieldId: blockField.fieldId, + value: selectedBlockCode, + }, + + ]; + + } + } + + + const updateObject = { + userData: {}, + customFields: customFields, + }; + if (userId) { + await updateUser(userId, updateObject); + } handleClose(); + + showToastMessage( t( userType === Role.TEAM_LEADERS @@ -159,19 +293,31 @@ const ReassignCenterModal: React.FC = ({ (field: any) => field.label === "BLOCKS" ); - const customFields = [ + let customFields = [ { fieldId: blockField.fieldId, value: checkedCenters[0], }, ]; - + if(selectedDistrict[0]!==districtName) + { + customFields = [ + { + fieldId: blockField.fieldId, + value: checkedCenters[0], + }, + { + fieldId: districtFieldId, + value: selectedDistrictCode, + }, + ]; + } const updateObject = { userData: {}, customFields: customFields, }; - if (userId) { + await updateUser(userId, updateObject); } @@ -191,15 +337,16 @@ const ReassignCenterModal: React.FC = ({ ); } }; - - const filteredCohorts = cohorts?.filter((cohort) => - cohort.name.toLowerCase().includes(searchInput) + + let filteredCohorts = cohorts?.filter((cohort) => + cohort?.name?.toLowerCase().includes(searchInput) ); + console.log(filteredCohorts) // const filteredCBlocks = blocks?.filter((cohort: any) => // cohort.label.toLowerCase().includes(searchInput) // ); - const filteredCBlocks = blocks?.filter((cohort: any) => + let filteredCBlocks = blocks?.filter((cohort: any) => cohort.label.toLowerCase().includes(searchInput) ).map((cohort: any) => ({ label: cohort.label, @@ -214,6 +361,8 @@ const ReassignCenterModal: React.FC = ({ setCheckedCenters([centerName]); } }; + + return ( <> = ({ primaryBtnClick={handleReassign} primaryBtnDisabled={checkedCenters.length === 0} > + = ({ }} /> + - { userType!==Role.TEAM_LEADERS? (filteredCohorts?.map((center) => ( + { + + userType!==Role.TEAM_LEADERS? (filteredCohorts?.map((center) => + ( {center.name} handleToggle(center.name)} + checked={center?.name ? checkedCenters.includes(center.name) : false} + onChange={() => center?.name && handleToggle(center.name)} + sx={{ color: theme.palette.text.primary, "&.Mui-checked": { @@ -267,7 +446,8 @@ const ReassignCenterModal: React.FC = ({ - ))): + ) + )): (filteredCBlocks?.map((center: any) => ( = ({ const [centers, setCenters] = useState([]); const [userName, setUserName] = useState(""); const [blocks, setBlocks] = useState([]); - const [userCohort, setUserCohorts] = useState ("") + const [userCohort, setUserCohorts] = useState (""); + const [assignedCenters, setAssignedCenters] = useState(); + const [selectedUserId, setSelectedUserId] = useState(""); + const [cohortId, setCohortId] = useState([]); + const [block, setBlock] = useState(""); + const [district, setDistrict] = useState(""); + + const [blockCode, setBlockCode] = useState(""); + const [districtCode, setDistrictCode] = useState(""); + const [selectedReason, setSelectedReason] = useState(""); const [otherReason, setOtherReason] = useState(""); @@ -534,8 +545,22 @@ const UserTable: React.FC = ({ const handleReassignCohort = async(rowData: any) => { // setIsDeleteModalOpen(true); console.log(rowData) - setSelectedUserId(rowData.userId ); - setBlock(rowData.blocks) + setSelectedUserId(rowData?.userId ); + setCohortId(rowData?.cohortIds); + setBlock(rowData?.blocks) + console.log(rowData?.districtValue) + setDistrict(rowData?.districtValue) + setDistrictCode(rowData?.districtCode) + setBlockCode(rowData?.blockCode) + setAssignedCenters(rowData?.centers) + const reassignUserInfo = { + blocks: rowData?.blocks || [], + districtValue: rowData?.districtValue || '', + districtCode: rowData?.districtCode || '', + blockCode: rowData?.blockCode || '' + }; + + localStorage.setItem('reassignuserInfo', JSON.stringify(reassignUserInfo)); setIsReassignCohortModalOpen(true) //const userData=""; @@ -734,7 +759,9 @@ const UserTable: React.FC = ({ updatedBy: user.updatedBy, stateCode:stateField?.code, districtCode:districtField?.code, - blockCode:blockField?.code + blockCode:blockField?.code, + districtValue:districtField? districtField?.value: "-" + // centers: null, // Programs: null, }; @@ -795,17 +822,21 @@ const UserTable: React.FC = ({ // (cohort: Cohort) => cohort.name, // ); const cohortNames = response?.result?.cohortData - ?.filter((cohort: Cohort) => cohort.type !== "BLOCK" && cohort?.cohortMemberStatus!=="archived") // Filter out cohorts with type 'block' - .map((cohort: Cohort) => cohort.name); + ?.filter((cohort: Cohort) => cohort.type !== "BLOCK" && cohort?.cohortMemberStatus!=="archived") + .map((cohort: Cohort) => cohort.name); + const cohortIds = response?.result?.cohortData + ?.filter((cohort: Cohort) => cohort.type !== "BLOCK" && cohort?.cohortMemberStatus!=="archived") + .map((cohort: Cohort) => cohort.cohortId); + const centerMembershipIdList = response?.result?.cohortData - ?.filter((cohort: Cohort) => cohort.type !== "BLOCK" && cohort?.cohortMemberStatus!=="archived") // Filter out cohorts with type 'block' + ?.filter((cohort: Cohort) => cohort.type !== "BLOCK" && cohort?.cohortMemberStatus!=="archived") .map((cohort: Cohort) => cohort.cohortMembershipId); const blockMembershipIdList = response?.result?.cohortData - ?.filter((cohort: Cohort) => cohort.type === "BLOCK" && cohort?.cohortMemberStatus!=="archived") // Filter out cohorts with type 'block' + ?.filter((cohort: Cohort) => cohort.type === "BLOCK" && cohort?.cohortMemberStatus!=="archived") .map((cohort: Cohort) => cohort.cohortMembershipId); // const cohortMembershipId=response?.result?.cohortData?.cohortMembershipId; console.log(blockMembershipIdList) - console.log(centerMembershipIdList) + console.log(cohortIds) let finalArray; @@ -813,12 +844,12 @@ const UserTable: React.FC = ({ finalArray = capitalizeFirstLetterOfEachWordInArray(cohortNames); } // const finalArray=capitalizeFirstLetterOfEachWordInArray(cohortNames) - // console.log(finalArray) + console.log(finalArray) return { ...user, centerMembershipIdList: centerMembershipIdList, blockMembershipIdList: blockMembershipIdList, - + cohortIds:cohortIds, centers: finalArray ? finalArray?.join(" , ") : "-", }; }) @@ -1096,9 +1127,15 @@ const UserTable: React.FC = ({ onClose={handleCloseReassignModal} userType={userType} cohortData={centers} - blocks={blocks} + blockList={blocks} userId={selectedUserId} blockName={block} + districtName={district} + blockCode={blockCode} + districtCode={districtCode} + cohortId={cohortId} + centers={assignedCenters} + /> => { const apiUrl: string = `${process.env.NEXT_PUBLIC_BASE_URL}/create`; try { const response = await post(apiUrl, userData); return response?.data?.result; } catch (error) { - console.error("error in getting cohort list", error); + console.error('error in getting cohort list', error); // throw error; } }; diff --git a/src/utils/Helper.ts b/src/utils/Helper.ts index bf1c82c2..02688112 100644 --- a/src/utils/Helper.ts +++ b/src/utils/Helper.ts @@ -4,6 +4,24 @@ import { Role, FormContextType, FormValues, InputTypes } from "./app.constant"; import { State } from "./Interfaces"; import { useQueryClient } from '@tanstack/react-query'; +interface Value { + value: string; + label: string; + createdAt: string; + updatedAt: string; + createdBy: string | null; + updatedBy: string | null; + cohortId?: string; +} + +interface CohortDetail { + cohortId: string; + name: string; + createdAt: string; + updatedAt: string; + createdBy: string | null; + updatedBy: string | null; +} export const generateUUID = () => { let d = new Date().getTime(); let d2 = @@ -106,7 +124,7 @@ export const capitalizeFirstLetterOfEachWordInArray = ( return arr; } console.log(arr); - return arr.map((str) => + return arr?.map((str) => str.replace(/\b[a-z]/g, (char) => char.toUpperCase()) ); }; @@ -243,3 +261,26 @@ export const findCommonAssociations = (data1: any[], data2: any[]) => { return null; }).filter(Boolean); }; + +export function mergeCohortDetails(values: Value[], cohortDetails: CohortDetail[]): Value[] { + const filteredValues = values.map(value => ({ + value: value.value, + label: value.label, + createdAt: value.createdAt, + updatedAt: value.updatedAt, + createdBy: value.createdBy, + updatedBy: value.updatedBy, + })); + + const newValues = cohortDetails.map(cohort => ({ + value: cohort.name, + label: cohort.name, + createdAt: cohort.createdAt, + updatedAt: cohort.updatedAt, + createdBy: cohort.createdBy, + updatedBy: cohort.updatedBy, + cohortId: cohort.cohortId, + })); + + return [...filteredValues, ...newValues]; +} diff --git a/src/utils/useLocationState.tsx b/src/utils/useLocationState.tsx index 29afadf7..0ed67d8f 100644 --- a/src/utils/useLocationState.tsx +++ b/src/utils/useLocationState.tsx @@ -8,6 +8,7 @@ import { getCohortList } from "@/services/CohortService/cohortService"; import { FormContextType, QueryKeys } from "./app.constant"; import { useTranslation } from "react-i18next"; import { useQueryClient } from "@tanstack/react-query"; + interface FieldProp { value: string; label: string; @@ -19,8 +20,11 @@ interface CenterProp { export const useLocationState = ( open: boolean, onClose: () => void, - userType?: any + userType?: any, + reAssignModal?:boolean ) => { + console.log(reAssignModal) + const [states, setStates] = useState([]); const [districts, setDistricts] = useState([]); const [blocks, setBlocks] = useState([]); @@ -29,13 +33,13 @@ export const useLocationState = ( const isMediumScreen = useMediaQuery("(max-width:986px)"); const [selectedState, setSelectedState] = useState([]); const [selectedStateCode, setSelectedStateCode] = useState(""); - const [selectedDistrict, setSelectedDistrict] = useState([]); + const [selectedDistrict, setSelectedDistrict] = useState( []); const [selectedDistrictCode, setSelectedDistrictCode] = useState(""); const [selectedCenter, setSelectedCenter] = useState([]); const [dynamicForm, setDynamicForm] = useState(false); const [dynamicFormForBlock, setdynamicFormForBlock] = useState(false); - const [selectedBlock, setSelectedBlock] = useState([]); + const [selectedBlock, setSelectedBlock] = useState( []); const [selectedBlockCode, setSelectedBlockCode] = useState(""); const [selectedCenterCode, setSelectedCenterCode] = useState(""); const [selectedBlockCohortId, setSelectedBlockCohortId] = useState(""); @@ -91,8 +95,14 @@ export const useLocationState = ( handleBlockChange([], []); } try { - setBlocks([]); - setAllCenters([]); + console.log(reAssignModal) + + // if(!reAssignModal) + // { + setBlocks([]); + setAllCenters([]); + + setSelectedDistrictCode(selectedCodes[0]); setSelectedBlockCohortId(""); const object = { @@ -260,7 +270,7 @@ export const useLocationState = ( setdynamicFormForBlock(false); } }, [onClose, open]); - + useEffect(() => { const fetchData = async () => { try { @@ -316,33 +326,78 @@ export const useLocationState = ( setStateDefaultValue(stateField.value); localStorage.setItem('userStateName',stateField?.value ) - setSelectedState([stateField.value]); - setSelectedStateCode(stateField.code); - const response = await queryClient.fetchQuery({ - queryKey: [ - QueryKeys.FIELD_OPTION_READ, - stateField.code, - "districts", - ], - queryFn: () => - getStateBlockDistrictList({ - controllingfieldfk: stateField.code, - fieldName: "districts", - }), - }); - const result = response?.result?.values; - console.log(result); - setDistricts(result); - } else { - setStateDefaultValue(t("COMMON.ALL_STATES")); - } - const object2 = [ - { - value: stateField.code, - label: stateField.value, - }, - ]; - setStates(object2); + setSelectedState([stateField.value]); + setSelectedStateCode(stateField.code) + const object = { + controllingfieldfk: stateField.code, + + fieldName: "districts", + }; + console.log(object); + const response = await getStateBlockDistrictList(object); + const result = response?.result?.values; + console.log(result) + setDistricts(result); + if(reAssignModal) + { + const data = getStoredData(); + console.log(data) + setSelectedBlock([data.blocks]); + setSelectedDistrict([data.districtValue] ); + setSelectedDistrictCode(data.districtCode); + setSelectedBlockCode(data.blockCode); + // if(selectedDistrict.length!==0) + { + // setSelectedDistrictCode(selectedCodes[0]); + // setSelectedBlockCohortId(""); + const object = { + controllingfieldfk: selectedDistrictCode, + fieldName: "blocks", + }; + const response = await getStateBlockDistrictList(object); + setBlockFieldId(response?.result?.fieldId); + //console.log(blockFieldId) + const result = response?.result?.values; + setBlocks(result); + const getCentersObject = { + limit: 0, + offset: 0, + filters: { + // "type":"COHORT", + status: ["active"], + states: stateField.code, + districts: data.districtCode, + blocks: data.blockCode + // "name": selected[0] + }, + }; + const centerResponse = await getCenterList(getCentersObject); + + // const result = response?.result?.cohortDetails; + const dataArray = centerResponse?.result?.results?.cohortDetails; + + const cohortInfo = dataArray + ?.filter((cohort: any) => cohort.type !== "BLOCK") + .map((item: any) => ({ + cohortId: item?.cohortId, + name: item?.name, + })); + console.log(dataArray); + setAllCenters(cohortInfo); + } + } + + } + else{ + setStateDefaultValue(t("COMMON.ALL_STATES")) + + } + const object2=[{ + value:stateField.code, + label:stateField.value + }] + setStates(object2); + } //console.log(JSON.parse(admin)?.customFields) // setAdminInfo(JSON.parse(admin)) @@ -357,8 +412,20 @@ export const useLocationState = ( }; fetchData(); - }, []); - console.log(stateDefaultValue); + }, [open]); + const getStoredData = () => { + const storedData = localStorage.getItem('reassignuserInfo'); + if (storedData) { + try { + return JSON.parse(storedData); + } catch (error) { + console.error('Failed to parse localStorage data:', error); + return {}; // Return default if parsing fails + } + } + return {}; // Return default if no data is found + }; + console.log(stateDefaultValue) return { states, districts, @@ -385,5 +452,10 @@ export const useLocationState = ( selectedCenterCode, selectedBlockCohortId, stateDefaultValue, + setSelectedBlock, + setSelectedDistrict, + setSelectedDistrictCode, + setSelectedBlockCode + }; }; From d6bf3e3989142e38e98982327f56fd69284d9260 Mon Sep 17 00:00:00 2001 From: Akshata Katwal Date: Mon, 16 Sep 2024 13:11:28 +0530 Subject: [PATCH 02/40] update pr --- src/components/ReassignCenterModal.tsx | 243 ++++++++++++++++--------- src/utils/useLocationState.tsx | 2 +- 2 files changed, 156 insertions(+), 89 deletions(-) diff --git a/src/components/ReassignCenterModal.tsx b/src/components/ReassignCenterModal.tsx index 74829f8d..88b32169 100644 --- a/src/components/ReassignCenterModal.tsx +++ b/src/components/ReassignCenterModal.tsx @@ -4,6 +4,7 @@ import { Divider, InputAdornment, TextField, + Typography, } from "@mui/material"; import React, { useEffect, useState } from "react"; import { useTheme } from "@mui/material/styles"; @@ -19,6 +20,7 @@ import { updateUser } from "@/services/CreateUserService"; import { useLocationState } from "@/utils/useLocationState"; import AreaSelection from "./AreaSelection"; import { transformArray } from "../utils/Helper"; +import { firstLetterInUpperCase } from "./../utils/Helper"; interface ReassignCohortModalProps { open: boolean; @@ -100,8 +102,8 @@ const { }) ); - console.log(centers?.split(',').map((center :any)=> center.trim())) - console.log(blockCode) + console.log(centers) + console.log(selectedBlock) const names = cohortData.map((item : any)=> item.name); console.log(names); @@ -110,9 +112,8 @@ const { //const [selectedBlockId, setselectedBlockId] = useState(blockName); - // const [checkedCenters, setCheckedCenters] = useState([blockCode]); - const [checkedCenters, setCheckedCenters] = useState([]); - + const [checkedCenters, setCheckedCenters] = useState([]); + //const [checkedCenters, setCheckedCenters] = useState([]); const handleSearchInputChange = ( event: React.ChangeEvent @@ -133,9 +134,21 @@ const { : [...prev, name] ); }; - console.log(checkedCenters) - console.log(userType) + useEffect(() => { + if (blockName) { + if(userType===Role.TEAM_LEADERS) + setCheckedCenters([blockName]); + } + if(centers) + { + if(userType!==Role.TEAM_LEADERS) + setCheckedCenters(centers?.split(',').map((center :any)=> center.trim())) + + } + }, [blockName, centers, open]); + console.log(checkedCenters) + console.log(centers) const handleReassign = async () => { try { @@ -159,14 +172,10 @@ const { .map((center) => center!.value); unSelectedData= blocks - .filter((center) => center?.value && !checkedCenters.includes(center.value)) - .map((center) => center!.value); + .filter((center) => center?.label && !checkedCenters.includes(center.label)) + .map((center) => center!.label); } - console.log(unSelectedData) -const labelArray = filteredCBlocks - ?.filter((block: any) => unSelectedData?.includes(block.value)) - .map((block: any) => block.label); console.log(blocks) console.log(selectedData) @@ -278,11 +287,34 @@ const labelArray = filteredCBlocks const previousBlockId = previousCohortDetails?.find( (item: any) => item?.type === "BLOCK" )?.cohortId; - + + let unSelectedBlockCohortIds: string[] = []; + + for (const code of unSelectedData) { + const reassignBlockObject = { + limit: 200, + offset: 0, + filters: { + status: ['active'], + name: code, + }, + } + const centerResponse = await getCenterList(reassignBlockObject); + const cohortDetailsInfo = centerResponse?.result?.results?.cohortDetails; + const unSelectedBlockCohortIdValue = cohortDetailsInfo?.find( + (item: any) => item?.type === 'BLOCK' + )?.cohortId; + + if (unSelectedBlockCohortIdValue) { + unSelectedBlockCohortIds.push(unSelectedBlockCohortIdValue); + } + unSelectedBlockCohortIds.push(previousBlockId); + + } payload = { userId: [userId], cohortId: [selectedBlockCohortId], - removeCohortId: [previousBlockId], + removeCohortId:unSelectedBlockCohortIds, }; await bulkCreateCohortMembers(payload); @@ -342,7 +374,17 @@ const labelArray = filteredCBlocks let filteredCohorts = cohorts?.filter((cohort) => cohort?.name?.toLowerCase().includes(searchInput) ); - console.log(filteredCohorts) + + + const formattedCohorts = filteredCohorts?.map(location => ({ + ...location, + name: location.name + ? location.name.split(' ') + .map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()) + .join(' ') + : '' + })); + // const filteredCBlocks = blocks?.filter((cohort: any) => // cohort.label.toLowerCase().includes(searchInput) // ); @@ -352,6 +394,18 @@ const labelArray = filteredCBlocks label: cohort.label, value: cohort.value, })); + +const formattedBlocks = filteredCBlocks.map(location => ({ + ...location, + label: location.label + ? location.label.split(' ') + .map((word: any) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()) + .join(' ') + : '' +})); +console.log(filteredCBlocks) +console.log(formattedBlocks) + const handleToggle2 = (centerName: string) => { // If the selected center is already checked, uncheck it if (checkedCenters.includes(centerName)) { @@ -362,7 +416,8 @@ const labelArray = filteredCBlocks } }; - + console.log(filteredCohorts) + return ( <> - - + + please select block from block list + + + ): + (<> + + + + ), + }} + /> + + + + {userType !== Role.TEAM_LEADERS ? ( + formattedCohorts && formattedCohorts.length > 0 ? ( + formattedCohorts.map((center) => ( + + + {center.name} + center?.name && handleToggle(center.name)} + sx={{ + color: theme.palette.text.primary, + "&.Mui-checked": { + color: "black", + }, + verticalAlign: "middle", + marginTop: "-10px", + }} + /> + + + + )) + ) : ( + No centers available + ) + ) : formattedBlocks && formattedBlocks.length > 0 ? ( + formattedBlocks.map((center: any) => ( + + + {center.label} + handleToggle2(center.label)} sx={{ - backgroundColor: theme.palette.warning["A700"], - borderRadius: 8, - "& .MuiOutlinedInput-root fieldset": { border: "none" }, - "& .MuiOutlinedInput-input": { borderRadius: 8 }, - }} - placeholder={ userType===Role.TEAM_LEADERS?t("MASTER.SEARCHBAR_PLACEHOLDER_BLOCK"): t("CENTERS.SEARCHBAR_PLACEHOLDER")} - value={searchInput} - onChange={handleSearchInputChange} - fullWidth - InputProps={{ - endAdornment: ( - - - - ), + color: theme.palette.text.primary, + "&.Mui-checked": { + color: "black", + }, + verticalAlign: "middle", + marginTop: "-10px", }} /> - - - { - - userType!==Role.TEAM_LEADERS? (filteredCohorts?.map((center) => - ( - - - {center.name} - center?.name && handleToggle(center.name)} - - sx={{ - color: theme.palette.text.primary, - "&.Mui-checked": { - color: "black", - }, - verticalAlign: "middle", - marginTop: "-10px", - }} - /> - - - - ) - )): - (filteredCBlocks?.map((center: any) => ( - - - {center.label} - handleToggle2(center.value)} - sx={{ - color: theme.palette.text.primary, - "&.Mui-checked": { - color: "black", - }, - verticalAlign: "middle", - marginTop: "-10px", - }} - /> - - - - ))) - } - + + + )) + ) : ( + No blocks available + )} + - + + + )} + diff --git a/src/utils/useLocationState.tsx b/src/utils/useLocationState.tsx index 0ed67d8f..8126d17e 100644 --- a/src/utils/useLocationState.tsx +++ b/src/utils/useLocationState.tsx @@ -351,7 +351,7 @@ export const useLocationState = ( // setSelectedDistrictCode(selectedCodes[0]); // setSelectedBlockCohortId(""); const object = { - controllingfieldfk: selectedDistrictCode, + controllingfieldfk:data.districtCode, fieldName: "blocks", }; const response = await getStateBlockDistrictList(object); From 1ffbec450da701ffbd68b65d0740048c892579df Mon Sep 17 00:00:00 2001 From: Akshata Katwal Date: Mon, 16 Sep 2024 15:11:05 +0530 Subject: [PATCH 03/40] add translations --- public/locales/en/common.json | 8 +++++++- src/components/ReassignCenterModal.tsx | 9 +++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/public/locales/en/common.json b/public/locales/en/common.json index 8881ce12..5fb9a256 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -122,7 +122,13 @@ "CENTERS_REASSIGN_FAILED": "Center Reassignment fails", "BLOCKS_REASSIGN_FAILED": "Block Reassignment fails", "USER_COHORTS": "{{name}} belongs to below cohorts", - "DELETE_COHORT_WARNING": "Do you want to delete user from cohort?" + "DELETE_COHORT_WARNING": "Do you want to delete user from cohort?", + "NO_CENTER_AVAILABLE": "No centers available", + "NO_BLOCK_AVAILABLE": "No blocks available", + "PLEASE_SELECT_BLOCK_LIST":"Please select block from block list" + + + }, "LOGIN_PAGE": { "USERNAME": "Username", diff --git a/src/components/ReassignCenterModal.tsx b/src/components/ReassignCenterModal.tsx index 88b32169..ff2e28a7 100644 --- a/src/components/ReassignCenterModal.tsx +++ b/src/components/ReassignCenterModal.tsx @@ -455,9 +455,9 @@ console.log(formattedBlocks) /> {(selectedBlock.length===0 && userType!==Role.TEAM_LEADERS)? (<> - please select block from block list + { t("COMMON.PLEASE_SELECT_BLOCK_LIST")} ): @@ -509,7 +509,8 @@ console.log(formattedBlocks) )) ) : ( - No centers available + { t("COMMON.NO_CENTER_AVAILABLE")} + ) ) : formattedBlocks && formattedBlocks.length > 0 ? ( formattedBlocks.map((center: any) => ( @@ -533,7 +534,7 @@ console.log(formattedBlocks) )) ) : ( - No blocks available + { t("COMMON.NO_BLOCK_AVAILABLE")} )} From e97b274f2395015ec07847b047b03cb3d93eafd5 Mon Sep 17 00:00:00 2001 From: Akshata Katwal Date: Mon, 16 Sep 2024 18:31:43 +0530 Subject: [PATCH 04/40] Issue feat: Add filtered districts from cohort search and read option --- src/services/formatedDistrict.ts | 52 ++++++++++++++++++++++++++++++++ src/utils/useLocationState.tsx | 7 +++-- 2 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 src/services/formatedDistrict.ts diff --git a/src/services/formatedDistrict.ts b/src/services/formatedDistrict.ts new file mode 100644 index 00000000..5b8c97c4 --- /dev/null +++ b/src/services/formatedDistrict.ts @@ -0,0 +1,52 @@ + +import { + getCohortList, + } from "@/services/CohortService/cohortService"; +import { + CohortTypes, + + } from "@/utils/app.constant"; +import { getStateBlockDistrictList } from "./MasterDataService"; + +export const formatedDistricts = async () => { + const adminState = JSON.parse( + localStorage.getItem("adminInfo") || "{}" + ).customFields.find( + (field: any) => field.label === "STATES" + );; + try { + const reqParams = { + limit: 0, + offset: 0, + filters: { + // name: searchKeyword, + states: adminState.code, + type: CohortTypes.DISTRICT, + }, + sort: ["name", "asc"], + }; + + const response = await getCohortList(reqParams); + + const cohortDetails = response?.results?.cohortDetails || []; + const object = { + controllingfieldfk: adminState.code, + fieldName: "districts", + }; + const optionReadResponse = await getStateBlockDistrictList(object); + //console.log(blockFieldId) + const result = optionReadResponse?.result?.values; + console.log(cohortDetails) + console.log(result) + const matchedCohorts = result?.map((value: any) => { + const cohortMatch = cohortDetails.find((cohort: any )=> cohort.name === value.label); + return cohortMatch ? { ...value } : null; + }).filter(Boolean); + return matchedCohorts; + // console.log(matchedCohorts); + + } catch (error) { + console.log('Error in getting Channel Details', error); + return error; + } +}; diff --git a/src/utils/useLocationState.tsx b/src/utils/useLocationState.tsx index 8126d17e..d0ce20c8 100644 --- a/src/utils/useLocationState.tsx +++ b/src/utils/useLocationState.tsx @@ -8,6 +8,7 @@ import { getCohortList } from "@/services/CohortService/cohortService"; import { FormContextType, QueryKeys } from "./app.constant"; import { useTranslation } from "react-i18next"; import { useQueryClient } from "@tanstack/react-query"; +import { formatedDistricts } from "@/services/formatedDistrict"; interface FieldProp { value: string; @@ -336,8 +337,10 @@ export const useLocationState = ( console.log(object); const response = await getStateBlockDistrictList(object); const result = response?.result?.values; - console.log(result) - setDistricts(result); + const districtResult= await formatedDistricts(); + + console.log(districtResult) + setDistricts(districtResult); if(reAssignModal) { const data = getStoredData(); From 7fda69b7844aa83e0abfdaabc193bb5ddbd194a6 Mon Sep 17 00:00:00 2001 From: Arif Date: Tue, 17 Sep 2024 14:05:07 +0530 Subject: [PATCH 05/40] Issue #PS-1959 feat: Pre-requisite and Post-requisite UI [Teacher and Admin] --- public/locales/en/common.json | 8 +- public/placeholderImage.png | Bin 0 -> 14568 bytes src/components/ResourceCard.tsx | 41 ++++++++++ src/pages/importCsv.tsx | 12 ++- src/pages/resourceList.tsx | 130 ++++++++++++++++++++++++++++++++ src/store/tanonomyStore.js | 3 + src/utils/app.constant.ts | 7 +- 7 files changed, 198 insertions(+), 3 deletions(-) create mode 100644 public/placeholderImage.png create mode 100644 src/components/ResourceCard.tsx create mode 100644 src/pages/resourceList.tsx diff --git a/public/locales/en/common.json b/public/locales/en/common.json index 8881ce12..19214fc9 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -212,7 +212,13 @@ "SUBTOPICS":"Sub-Topics", "RESOURCES": "Resources", "TOPIC": "Topic", - "DURATION/MONTH": "Duration/Month" + "DURATION/MONTH": "Duration/Month", + "LEARNERS_PREREQISITE":"Learners Pre-requisites", + "NO_DATA_PRE":"No data available for Learners Pre-requisites", + "LEARNERS_POSTREQISITE":"Learners Post-requisites", + "NO_DATA_POST":"No data available for Learners Post-requisites", + "FACILITATORS":"Facilitators Requisites", + "NO_DATA":"No data available for Facilitators Requisites" }, "MASTER": { diff --git a/public/placeholderImage.png b/public/placeholderImage.png new file mode 100644 index 0000000000000000000000000000000000000000..c342af7bc5d286e048c523f81d1cf437f88fb141 GIT binary patch literal 14568 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 Sy+jcJ0000 = ({ title, type, resource }) => { + return ( + + + + Resource Placeholder + + + {title} + + + {type} + + + + ); +}; + +export default ResourceCard; diff --git a/src/pages/importCsv.tsx b/src/pages/importCsv.tsx index 5270ab9f..b8227933 100644 --- a/src/pages/importCsv.tsx +++ b/src/pages/importCsv.tsx @@ -67,6 +67,7 @@ const ImportCsv = () => { const [subTopics, setSubTopics] = useState(0); const theme = useTheme(); const isSmallScreen = useMediaQuery(theme.breakpoints.down("sm")); + const setResources = taxonomyStore((state) => state.setResources); useEffect(() => { const fetchData = async () => { @@ -305,6 +306,13 @@ const ImportCsv = () => { return months[date.getMonth()]; }; + const handleResources = (subTopic: any) => { + setResources(subTopic); + router.push({ + pathname: "/resourceList", + }); + }; + return ( { sx={{ display: "flex", gap: "10px", - alignItems: "center", + alignItems: "center", }} > { {topic.children.map((subTopic: any) => ( handleResources(subTopic) } sx={{ border: `1px solid #E0E0E0`, padding: "10px", backgroundColor: "white", marginBottom: "20px", + cursor: "pointer" }} > { + const [learnersPreReq, setLearnersPreReq] = useState([]); + const [learnersPostReq, setLearnersPostReq] = useState([]); + const [facilitatorsPreReq, setFacilitatorsPreReq] = useState([]); + + const tstore = taxonomyStore(); + const { t } = useTranslation(); + + useEffect(() => { + const fetchData = async () => { + const resources = tstore.resources; + + const fetchedLearningResources = resources.learningResources || []; + + const preReqs = fetchedLearningResources.filter( + (item: any) => item.type === ResourceType.PREREQUISITE + ); + const postReqs = fetchedLearningResources.filter( + (item: any) => item.type === ResourceType.POSTREQUISITE + ); + const facilitatorsReqs = fetchedLearningResources.filter( + (item: any) => !item.type + ); + + setLearnersPreReq(preReqs); + setLearnersPostReq(postReqs); + setFacilitatorsPreReq(facilitatorsReqs); + }; + + fetchData(); + }, [tstore.resources]); + + return ( + + {tstore.taxonomyType} + + window.history.back()}> + + + + {/* Course Name */} + + {tstore?.resources?.name} + + + + + + {t("COURSE_PLANNER.LEARNERS_PREREQISITE")} + + {learnersPreReq.length > 0 ? ( + + {learnersPreReq.map((item, index) => ( + + + + ))} + + ) : ( + + {t("COURSE_PLANNER.NO_DATA_PRE")} + + )} + + + {t("COURSE_PLANNER.LEARNERS_POSTREQISITE")} + + {learnersPostReq.length > 0 ? ( + + {learnersPostReq.map((item, index) => ( + + + + ))} + + ) : ( + + {t("COURSE_PLANNER.NO_DATA_POST")} + + )} + + + {t("COURSE_PLANNER.FACILITATORS")} + + {facilitatorsPreReq.length > 0 ? ( + + {facilitatorsPreReq.map((item, index) => ( + + + + ))} + + ) : ( + {t("COURSE_PLANNER.NO_DATA")} + )} + + + ); +}; + +export default ResourceList; + +export async function getStaticProps({ locale }: { locale: string }) { + return { + props: { + ...(await serverSideTranslations(locale, ["common"])), + }, + }; +} diff --git a/src/store/tanonomyStore.js b/src/store/tanonomyStore.js index 52450ef4..5d114d75 100644 --- a/src/store/tanonomyStore.js +++ b/src/store/tanonomyStore.js @@ -11,6 +11,7 @@ const taxonomyStore = create( taxonomyGrade: "", taxonomyType: "", taxonomySubject: "", + resources:"", setState: (newState) => set((state) => ({ state: newState})), setBoard: (newBoard) => @@ -23,6 +24,8 @@ const taxonomyStore = create( set((state) => ({ taxonomyType: newTaxonomyType})), setTaxonomySubject: (newTaxonomySubject) => set((state) => ({ taxonomySubject: newTaxonomySubject})), + setResources: (newResources) => + set((state) => ({ resources: newResources})), }), { name: "taxonomy", diff --git a/src/utils/app.constant.ts b/src/utils/app.constant.ts index f7774ced..0c4b96a0 100644 --- a/src/utils/app.constant.ts +++ b/src/utils/app.constant.ts @@ -113,4 +113,9 @@ export const monthColors:any = { "Oct": "#FFD6D6", "Nov": "#FFD6D6", "Dec": "#FFD6D6" -}; \ No newline at end of file +}; + +export enum ResourceType { + PREREQUISITE = "prerequisite", + POSTREQUISITE = "postrequisite", +} \ No newline at end of file From 2effaaf0ad6971084923838e492beedd3fb4d2eb Mon Sep 17 00:00:00 2001 From: Akshata Katwal Date: Tue, 17 Sep 2024 20:19:01 +0530 Subject: [PATCH 06/40] Issue feat: update block list --- src/components/ReassignCenterModal.tsx | 14 +-- src/services/formatedCohorts.ts | 115 +++++++++++++++++++++++++ src/services/formatedDistrict.ts | 52 ----------- src/utils/useLocationState.tsx | 9 +- 4 files changed, 129 insertions(+), 61 deletions(-) create mode 100644 src/services/formatedCohorts.ts delete mode 100644 src/services/formatedDistrict.ts diff --git a/src/components/ReassignCenterModal.tsx b/src/components/ReassignCenterModal.tsx index ff2e28a7..0612614f 100644 --- a/src/components/ReassignCenterModal.tsx +++ b/src/components/ReassignCenterModal.tsx @@ -94,7 +94,6 @@ const { setSelectedDistrictCode, setSelectedBlockCode } =useLocationState(open, onClose, roleType, true) - let cohorts: Cohort[] = allCenters?.map( (cohort: { cohortId: any; name: string }) => ({ name: cohort.name, @@ -102,7 +101,7 @@ const { }) ); - console.log(centers) + console.log(blockCode) console.log(selectedBlock) const names = cohortData.map((item : any)=> item.name); @@ -198,6 +197,7 @@ const { const blockField = userDetails?.userData?.customFields.find( (field: any) => field.label === "BLOCKS" ); + console.log(checkedCenters) customFields = [ { @@ -308,9 +308,10 @@ const { if (unSelectedBlockCohortIdValue) { unSelectedBlockCohortIds.push(unSelectedBlockCohortIdValue); } - unSelectedBlockCohortIds.push(previousBlockId); } + unSelectedBlockCohortIds.push(previousBlockId); + payload = { userId: [userId], cohortId: [selectedBlockCohortId], @@ -324,19 +325,20 @@ const { const blockField = userDetails?.userData?.customFields.find( (field: any) => field.label === "BLOCKS" ); - + const selectedCenterCode = filteredCBlocks.find(location => location.label === checkedCenters[0])?.value; let customFields = [ { fieldId: blockField.fieldId, - value: checkedCenters[0], + value: selectedCenterCode, }, ]; + console.log(selectedBlockCode,checkedCenters[0]) if(selectedDistrict[0]!==districtName) { customFields = [ { fieldId: blockField.fieldId, - value: checkedCenters[0], + value: selectedCenterCode, }, { fieldId: districtFieldId, diff --git a/src/services/formatedCohorts.ts b/src/services/formatedCohorts.ts new file mode 100644 index 00000000..1149b172 --- /dev/null +++ b/src/services/formatedCohorts.ts @@ -0,0 +1,115 @@ + +import { + getCohortList, + } from "@/services/CohortService/cohortService"; +import { + CohortTypes, + + } from "@/utils/app.constant"; +import { getStateBlockDistrictList } from "./MasterDataService"; +interface Cohort { + name: string; + [key: string]: any; +} + +interface BlockValue { + label: string; + [key: string]: any; +} + +interface FormattedBlocksResult { + cohortDetails: Cohort[]; + matchedCohorts: BlockValue[]; +} +export const formatedDistricts = async () => { + const adminState = JSON.parse( + localStorage.getItem("adminInfo") || "{}" + ).customFields.find( + (field: any) => field.label === "STATES" + );; + try { + const reqParams = { + limit: 0, + offset: 0, + filters: { + // name: searchKeyword, + states: adminState.code, + type: CohortTypes.DISTRICT, + status: ["active"] + + }, + sort: ["name", "asc"], + }; + + const response = await getCohortList(reqParams); + + const cohortDetails = response?.results?.cohortDetails || []; + const object = { + controllingfieldfk: adminState.code, + fieldName: "districts", + }; + const optionReadResponse = await getStateBlockDistrictList(object); + //console.log(blockFieldId) + const result = optionReadResponse?.result?.values; + console.log(cohortDetails) + console.log(result) + const matchedCohorts = result?.map((value: any) => { + const cohortMatch = cohortDetails.find((cohort: any )=> cohort.name === value.label); + return cohortMatch ? { ...value } : null; + }).filter(Boolean); + return matchedCohorts; + // console.log(matchedCohorts); + + } catch (error) { + console.log('Error in getting Channel Details', error); + return error; + } +}; + + +export const formatedBlocks = async (districtCode: string) => { + const adminState = JSON.parse( + localStorage.getItem("adminInfo") || "{}" + ).customFields.find( + (field: any) => field.label === "STATES" + );; +try { + const reqParams = { + limit: 0, + offset: 0, + filters: { + // name: searchKeyword, + states: adminState.code, + districts:districtCode, + + type: CohortTypes.BLOCK, + status: ["active"] + }, + sort: ["name", "asc"], + }; + + const response = await getCohortList(reqParams); + + const cohortDetails = response?.results?.cohortDetails || []; + const object = { + controllingfieldfk:districtCode, + fieldName: "blocks", + }; + const optionReadResponse = await getStateBlockDistrictList(object); + //console.log(blockFieldId) + const result = optionReadResponse?.result?.values; + console.log(cohortDetails) + console.log(result) + const matchedCohorts = result?.map((value: any) => { + const cohortMatch = cohortDetails.find((cohort: any )=> cohort.name === value.label); + return cohortMatch ? { ...value } : null; + }).filter(Boolean); + console.log(matchedCohorts); + + return matchedCohorts; + +} catch (error) { + console.log('Error in getting Channel Details', error); + return error; +} +}; diff --git a/src/services/formatedDistrict.ts b/src/services/formatedDistrict.ts deleted file mode 100644 index 5b8c97c4..00000000 --- a/src/services/formatedDistrict.ts +++ /dev/null @@ -1,52 +0,0 @@ - -import { - getCohortList, - } from "@/services/CohortService/cohortService"; -import { - CohortTypes, - - } from "@/utils/app.constant"; -import { getStateBlockDistrictList } from "./MasterDataService"; - -export const formatedDistricts = async () => { - const adminState = JSON.parse( - localStorage.getItem("adminInfo") || "{}" - ).customFields.find( - (field: any) => field.label === "STATES" - );; - try { - const reqParams = { - limit: 0, - offset: 0, - filters: { - // name: searchKeyword, - states: adminState.code, - type: CohortTypes.DISTRICT, - }, - sort: ["name", "asc"], - }; - - const response = await getCohortList(reqParams); - - const cohortDetails = response?.results?.cohortDetails || []; - const object = { - controllingfieldfk: adminState.code, - fieldName: "districts", - }; - const optionReadResponse = await getStateBlockDistrictList(object); - //console.log(blockFieldId) - const result = optionReadResponse?.result?.values; - console.log(cohortDetails) - console.log(result) - const matchedCohorts = result?.map((value: any) => { - const cohortMatch = cohortDetails.find((cohort: any )=> cohort.name === value.label); - return cohortMatch ? { ...value } : null; - }).filter(Boolean); - return matchedCohorts; - // console.log(matchedCohorts); - - } catch (error) { - console.log('Error in getting Channel Details', error); - return error; - } -}; diff --git a/src/utils/useLocationState.tsx b/src/utils/useLocationState.tsx index d0ce20c8..41570963 100644 --- a/src/utils/useLocationState.tsx +++ b/src/utils/useLocationState.tsx @@ -8,7 +8,7 @@ import { getCohortList } from "@/services/CohortService/cohortService"; import { FormContextType, QueryKeys } from "./app.constant"; import { useTranslation } from "react-i18next"; import { useQueryClient } from "@tanstack/react-query"; -import { formatedDistricts } from "@/services/formatedDistrict"; +import { formatedBlocks, formatedDistricts } from "@/services/formatedCohorts"; interface FieldProp { value: string; @@ -114,7 +114,9 @@ export const useLocationState = ( setBlockFieldId(response?.result?.fieldId); //console.log(blockFieldId) const result = response?.result?.values; - setBlocks(result); + const blockResult=await formatedBlocks(selectedCodes[0]) + setBlocks(blockResult); + //setBlocks(result); } catch (error) { console.log(error); } @@ -361,7 +363,8 @@ export const useLocationState = ( setBlockFieldId(response?.result?.fieldId); //console.log(blockFieldId) const result = response?.result?.values; - setBlocks(result); + const blockResult=await formatedBlocks(data.districtCode) + setBlocks(blockResult); const getCentersObject = { limit: 0, offset: 0, From 3f4c30391d6ca9c0561d9459a3a400662b4782e7 Mon Sep 17 00:00:00 2001 From: Akshata Katwal Date: Wed, 18 Sep 2024 10:41:48 +0530 Subject: [PATCH 07/40] Issue feat: Add cohort ids in combine response for option reacd and cohort search --- src/components/ReassignCenterModal.tsx | 28 +++------- src/services/formatedCohorts.ts | 71 ++++++++++++++------------ 2 files changed, 44 insertions(+), 55 deletions(-) diff --git a/src/components/ReassignCenterModal.tsx b/src/components/ReassignCenterModal.tsx index 0612614f..a54a667f 100644 --- a/src/components/ReassignCenterModal.tsx +++ b/src/components/ReassignCenterModal.tsx @@ -290,32 +290,16 @@ const { let unSelectedBlockCohortIds: string[] = []; - for (const code of unSelectedData) { - const reassignBlockObject = { - limit: 200, - offset: 0, - filters: { - status: ['active'], - name: code, - }, - } - const centerResponse = await getCenterList(reassignBlockObject); - const cohortDetailsInfo = centerResponse?.result?.results?.cohortDetails; - const unSelectedBlockCohortIdValue = cohortDetailsInfo?.find( - (item: any) => item?.type === 'BLOCK' - )?.cohortId; - - if (unSelectedBlockCohortIdValue) { - unSelectedBlockCohortIds.push(unSelectedBlockCohortIdValue); - } - - } + unSelectedBlockCohortIds.push(previousBlockId); - + let cohortIds = blocks + .filter((item:any) => item.label !== checkedCenters[0]) + .map((item:any) => item.cohortId); + cohortIds.push(previousBlockId) payload = { userId: [userId], cohortId: [selectedBlockCohortId], - removeCohortId:unSelectedBlockCohortIds, + removeCohortId:cohortIds, }; await bulkCreateCohortMembers(payload); diff --git a/src/services/formatedCohorts.ts b/src/services/formatedCohorts.ts index 1149b172..ec678d13 100644 --- a/src/services/formatedCohorts.ts +++ b/src/services/formatedCohorts.ts @@ -69,47 +69,52 @@ export const formatedDistricts = async () => { export const formatedBlocks = async (districtCode: string) => { const adminState = JSON.parse( - localStorage.getItem("adminInfo") || "{}" - ).customFields.find( - (field: any) => field.label === "STATES" - );; -try { - const reqParams = { + localStorage.getItem("adminInfo") || "{}" + ).customFields.find( + (field: any) => field.label === "STATES" + ); + try { + const reqParams = { limit: 0, offset: 0, filters: { - // name: searchKeyword, + // name: searchKeyword, states: adminState.code, - districts:districtCode, - + districts: districtCode, type: CohortTypes.BLOCK, - status: ["active"] + status: ["active"], }, - sort: ["name", "asc"], + sort: ["name", "asc"], }; const response = await getCohortList(reqParams); + const cohortDetails = response?.results?.cohortDetails || []; - const cohortDetails = response?.results?.cohortDetails || []; - const object = { - controllingfieldfk:districtCode, - fieldName: "blocks", - }; - const optionReadResponse = await getStateBlockDistrictList(object); - //console.log(blockFieldId) - const result = optionReadResponse?.result?.values; - console.log(cohortDetails) - console.log(result) - const matchedCohorts = result?.map((value: any) => { - const cohortMatch = cohortDetails.find((cohort: any )=> cohort.name === value.label); - return cohortMatch ? { ...value } : null; - }).filter(Boolean); - console.log(matchedCohorts); - - return matchedCohorts; - -} catch (error) { - console.log('Error in getting Channel Details', error); - return error; -} + const object = { + controllingfieldfk: districtCode, + fieldName: "blocks", + }; + const optionReadResponse = await getStateBlockDistrictList(object); + const result = optionReadResponse?.result?.values; + + console.log(cohortDetails); + console.log(result); + + const matchedCohorts = result + ?.map((value: any) => { + const cohortMatch = cohortDetails.find( + (cohort: any) => cohort.name === value.label + ); + // Include cohortId if the match is found + return cohortMatch ? { ...value, cohortId: cohortMatch.cohortId } : null; + }) + .filter(Boolean); + + + return matchedCohorts; + } catch (error) { + console.log("Error in getting Channel Details", error); + return error; + } }; + From 0921f0833e0274a9a7efa059854a5107348406c0 Mon Sep 17 00:00:00 2001 From: Akshata Katwal Date: Wed, 18 Sep 2024 12:14:28 +0530 Subject: [PATCH 08/40] update pr --- src/components/ReassignCenterModal.tsx | 8 +++++++- src/components/UserTable.tsx | 7 ++++++- src/utils/useLocationState.tsx | 3 ++- src/utils/useSharedState.ts | 3 +++ 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/components/ReassignCenterModal.tsx b/src/components/ReassignCenterModal.tsx index a54a667f..c5130f84 100644 --- a/src/components/ReassignCenterModal.tsx +++ b/src/components/ReassignCenterModal.tsx @@ -21,6 +21,7 @@ import { useLocationState } from "@/utils/useLocationState"; import AreaSelection from "./AreaSelection"; import { transformArray } from "../utils/Helper"; import { firstLetterInUpperCase } from "./../utils/Helper"; +import useSubmittedButtonStore from "@/utils/useSharedState"; interface ReassignCohortModalProps { open: boolean; @@ -104,7 +105,10 @@ const { console.log(blockCode) console.log(selectedBlock) const names = cohortData.map((item : any)=> item.name); - + const setReassignButtonStatus = useSubmittedButtonStore((state:any) => state.setReassignButtonStatus); + const reassignButtonStatus = useSubmittedButtonStore( + (state: any) => state.reassignButtonStatus + ); console.log(names); const [searchInput, setSearchInput] = useState(""); @@ -343,6 +347,8 @@ const { t("COMMON.BLOCKS_REASSIGN_SUCCESSFULLY"), "success" ); + reassignButtonStatus ? setReassignButtonStatus(false) : setReassignButtonStatus(true); + } } catch (error) { showToastMessage( diff --git a/src/components/UserTable.tsx b/src/components/UserTable.tsx index 39cc4144..ebc059d1 100644 --- a/src/components/UserTable.tsx +++ b/src/components/UserTable.tsx @@ -31,6 +31,7 @@ import { useQuery } from "@tanstack/react-query"; import ReassignCenterModal from "./ReassignCenterModal"; import { getCenterList, getStateBlockDistrictList } from "@/services/MasterDataService"; import { updateCohortMemberStatus } from "@/services/CohortService/cohortService"; +import useSubmittedButtonStore from "@/utils/useSharedState"; type UserDetails = { userId: any; username: any; @@ -153,6 +154,9 @@ const UserTable: React.FC = ({ const [openAddLearnerModal, setOpenAddLearnerModal] = React.useState(false); const [userId, setUserId] = useState(); const [submitValue, setSubmitValue] = useState(false); + const reassignButtonStatus = useSubmittedButtonStore( + (state: any) => state.reassignButtonStatus + ); const { data:teacherFormData ,isLoading: teacherFormDataLoading, error :teacherFormDataErrror } = useQuery({ queryKey: ["teacherFormData"], queryFn: () => Promise.resolve([]), @@ -806,7 +810,8 @@ const UserTable: React.FC = ({ filters, parentState, deleteUserState, - sortByForCohortMemberList + sortByForCohortMemberList, + reassignButtonStatus ]); useEffect(() => { diff --git a/src/utils/useLocationState.tsx b/src/utils/useLocationState.tsx index 41570963..07a51343 100644 --- a/src/utils/useLocationState.tsx +++ b/src/utils/useLocationState.tsx @@ -277,6 +277,7 @@ export const useLocationState = ( useEffect(() => { const fetchData = async () => { try { + if(open){ const response = await queryClient.fetchQuery({ queryKey: [ QueryKeys.FIELD_OPTION_READ, @@ -412,7 +413,7 @@ export const useLocationState = ( //console.log(result) // setStates(result); console.log(typeof states); - } catch (error) { + }} catch (error) { console.log(error); } }; diff --git a/src/utils/useSharedState.ts b/src/utils/useSharedState.ts index eb68c385..6ca09a24 100644 --- a/src/utils/useSharedState.ts +++ b/src/utils/useSharedState.ts @@ -4,6 +4,9 @@ const useSubmittedButtonStore = create((set) => ({ submittedButtonStatus: false, setSubmittedButtonStatus: (status: boolean) => set({ submittedButtonStatus: status }), + reassignButtonStatus: false, + setReassignButtonStatus: (status: boolean) => + set({ reassignButtonStatus: status }), adminInformation: {}, setAdminInformation: (data: any) => set({ adminInformation: data }), // setSubmittedButtonStatus: (status: boolean) => set({ submittedButtonStatus: status }), From fba9659247de6fabcaf41adcf9c17649ed03127d Mon Sep 17 00:00:00 2001 From: Arif Date: Wed, 18 Sep 2024 21:39:05 +0530 Subject: [PATCH 09/40] Issue #1817 feat: View course planner on admin app UI development --- src/components/layouts/sidebar/MenuItems.js | 10 --- src/pages/course-planner/index.tsx | 17 +---- src/pages/importCsv.tsx | 70 +++++++-------------- src/pages/stateDetails.tsx | 55 ++-------------- src/pages/subjectDetails.tsx | 40 ++++++++---- 5 files changed, 58 insertions(+), 134 deletions(-) diff --git a/src/components/layouts/sidebar/MenuItems.js b/src/components/layouts/sidebar/MenuItems.js index 51939106..c63407c8 100644 --- a/src/components/layouts/sidebar/MenuItems.js +++ b/src/components/layouts/sidebar/MenuItems.js @@ -65,16 +65,6 @@ const Menuitems = [ title: "SIDEBAR.COURSE_PLANNER", icon: coursePannerIcon, href: "/course-planner", - subOptions: [ - { - title: "SIDEBAR.FOUNDATION_COURSE", - href: "/course-planner", - }, - // { - // title: "SIDEBAR.MAIN_COURSE", - // href: "/mainCourse", - // }, - ], }, ]; diff --git a/src/pages/course-planner/index.tsx b/src/pages/course-planner/index.tsx index 8e6539f0..7602a9e3 100644 --- a/src/pages/course-planner/index.tsx +++ b/src/pages/course-planner/index.tsx @@ -154,24 +154,10 @@ const Foundation = () => { return ( <> - handleFilter(event.target.value)} - card={undefined} - selectFilter={selectFilter} - onBackClick={undefined} - /> - {loading ? ( ) : ( - + {/* { }} sx={{ minWidth: "auto", padding: 0 }} > - diff --git a/src/pages/importCsv.tsx b/src/pages/importCsv.tsx index b8227933..df996c72 100644 --- a/src/pages/importCsv.tsx +++ b/src/pages/importCsv.tsx @@ -154,18 +154,9 @@ const ImportCsv = () => { const userProjectDetailsResponse = await getUserProjectDetails({ id: courseId, }); - setUserProjectDetails(userProjectDetailsResponse.result.tasks); + setUserProjectDetails(userProjectDetailsResponse?.result?.tasks); if (userProjectDetails?.length) { - const totalChildren = userProjectDetails.reduce( - (acc: number, project: any) => { - return acc + (project?.children?.length || 0); - }, - 0 - ); - - if (totalChildren !== subTopics) { - setSubTopics(totalChildren); - } + } setLoading(false); } catch (error) { @@ -313,6 +304,19 @@ const ImportCsv = () => { }); }; + + + const totalChildren = userProjectDetails?.reduce( + (acc: number, project: any) => { + return acc + (project?.children?.length || 0); + }, + 0 + ); + + if (totalChildren !== subTopics) { + setSubTopics(totalChildren); + } + return ( { - - {subjectDetails?.subject} + + {tstore.taxonomySubject} @@ -375,27 +379,11 @@ const ImportCsv = () => { }} onClick={handleCopyLink} > - + {/* */} - {}} - handleMediumChange={() => {}} - handleSearchChange={() => {}} - selectedOption="" - handleDropdownChange={() => {}} - card={undefined} - selectFilter={undefined} - onBackClick={() => {}} - showGradeMedium={false} - showFoundaitonCourse={false} - /> - {loading ? ( @@ -479,7 +467,7 @@ const ImportCsv = () => { sx={{ display: "flex", gap: "10px", - alignItems: "center", + alignItems: "center", }} > { display: "flex", flexDirection: "row", justifyContent: "space-between", - padding: "10px 25px 0px 25px ", + padding: "10px 25px 0px 25px", borderRadius: "8px", }} > @@ -518,10 +506,8 @@ const ImportCsv = () => { {t("COURSE_PLANNER.DURATION/MONTH")} - - {t("COURSE_PLANNER.COPY_LINK")} - + { {topic.children.map((subTopic: any) => ( handleResources(subTopic) } + onClick={() => handleResources(subTopic)} sx={{ border: `1px solid #E0E0E0`, padding: "10px", backgroundColor: "white", marginBottom: "20px", - cursor: "pointer" + cursor: "pointer", }} > { )} - - - diff --git a/src/pages/stateDetails.tsx b/src/pages/stateDetails.tsx index 7c01464b..8a101352 100644 --- a/src/pages/stateDetails.tsx +++ b/src/pages/stateDetails.tsx @@ -107,38 +107,16 @@ const StateDetails = () => { return ( - {}} - /> - + + {card.state} - - - ({card.boardsUploaded}/{card.totalBoards} - {t("COURSE_PLANNER.BOARDS_FULLY_UPLOADED")}) - - + {boards.map((board: any, index: number) => ( { {board?.name} - - - - - - {card.boardsUploaded} / {card.totalBoards}{" "} - {t("COURSE_PLANNER.SUBJECTS_UPLOADED")} - - + + diff --git a/src/pages/subjectDetails.tsx b/src/pages/subjectDetails.tsx index 90778271..d23a14c5 100644 --- a/src/pages/subjectDetails.tsx +++ b/src/pages/subjectDetails.tsx @@ -358,11 +358,16 @@ const SubjectDetails = () => { sx={{ "& .MuiSelect-select": { padding: "8px 16px", + textAlign: "left", }, - border: "1px solid black", - borderRadius: "10px", + "& fieldset": { + border: "none", + }, + border: "1px solid #3C3C3C", + borderRadius: "8px", marginRight: "16px", - height: 30, + height: 40, + width: "170px", }} > @@ -384,15 +389,20 @@ const SubjectDetails = () => { sx={{ "& .MuiSelect-select": { padding: "8px 16px", + textAlign: "left", + }, + "& fieldset": { + border: "none", }, - border: "1px solid black", - borderRadius: "10px", + border: "1px solid #3C3C3C", + borderRadius: "8px", marginRight: "16px", - height: 30, + height: 40, + width: "170px", }} > - Select Grade + Select Grade {grade.map((item: any) => ( @@ -401,6 +411,7 @@ const SubjectDetails = () => { ))} + + { - {subject && subject.length > 0 ? ( + {subject && subject.length > 1 ? ( subject.map((subj: any, index: any) => ( { }} sx={{ minWidth: "auto", padding: 0 }} > - From 7f79c86d178d6e2d2b1364fcaa598cd6c6940a5e Mon Sep 17 00:00:00 2001 From: Arif Date: Wed, 18 Sep 2024 21:54:19 +0530 Subject: [PATCH 10/40] updates --- src/pages/importCsv.tsx | 2 -- src/pages/stateDetails.tsx | 2 +- src/pages/subjectDetails.tsx | 19 +++++++++++++++++++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/pages/importCsv.tsx b/src/pages/importCsv.tsx index df996c72..3cb17426 100644 --- a/src/pages/importCsv.tsx +++ b/src/pages/importCsv.tsx @@ -304,8 +304,6 @@ const ImportCsv = () => { }); }; - - const totalChildren = userProjectDetails?.reduce( (acc: number, project: any) => { return acc + (project?.children?.length || 0); diff --git a/src/pages/stateDetails.tsx b/src/pages/stateDetails.tsx index 8a101352..26dbf323 100644 --- a/src/pages/stateDetails.tsx +++ b/src/pages/stateDetails.tsx @@ -49,7 +49,7 @@ const StateDetails = () => { const channel = store?.boards; setBoards(channel); - + localStorage.removeItem("overallCommonSubjects") setLoading(false); }, 1000); }; diff --git a/src/pages/subjectDetails.tsx b/src/pages/subjectDetails.tsx index d23a14c5..abd73e7b 100644 --- a/src/pages/subjectDetails.tsx +++ b/src/pages/subjectDetails.tsx @@ -80,6 +80,24 @@ const SubjectDetails = () => { const setTaxonomyType = taxonomyStore((state) => state.setTaxonomyType); const setTaxonomySubject = taxonomyStore((state) => state.setTaxonomySubject); + useEffect(() => { + const subjects = localStorage.getItem('overallCommonSubjects'); + + if (subjects) { + try { + const parsedData = JSON.parse(subjects); + setSubject(parsedData); + } catch (error) { + console.error("Failed to parse subjects from localStorage:", error); + } + } else { + console.log("No subjects found in localStorage."); + setSubject([]); + } + }, []); + + + useEffect(() => { const fetchFrameworkDetails = async () => { if (typeof boardDetails === "string") { @@ -343,6 +361,7 @@ const SubjectDetails = () => { const overallCommonSubjects = findOverallCommonSubjects(arrays); setSubject(overallCommonSubjects); + localStorage.setItem("overallCommonSubjects", JSON.stringify(overallCommonSubjects)) } }; From 1f35551dec3dbd7b42d86ebc494ce2fc5fc8e7af Mon Sep 17 00:00:00 2001 From: Akshata Katwal Date: Thu, 19 Sep 2024 11:12:08 +0530 Subject: [PATCH 11/40] Issue feat: Learner can reassign to only one center --- src/components/ReassignCenterModal.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/components/ReassignCenterModal.tsx b/src/components/ReassignCenterModal.tsx index c5130f84..f50a27bf 100644 --- a/src/components/ReassignCenterModal.tsx +++ b/src/components/ReassignCenterModal.tsx @@ -131,11 +131,18 @@ const { }; const handleToggle = (name: string) => { - setCheckedCenters((prev) => + if(userType===Role.LEARNERS) + { + setCheckedCenters([name]); + } + else{ + setCheckedCenters((prev) => prev.includes(name) ? prev.filter((center) => center !== name) : [...prev, name] ); + } + }; useEffect(() => { From cc3c9898d04477ffd9f263f746ad4becbf544a42 Mon Sep 17 00:00:00 2001 From: Akshata Katwal Date: Thu, 19 Sep 2024 15:58:17 +0530 Subject: [PATCH 12/40] Issue feat:PS-2011 update mr, or, hi json files as per translation sheet values --- public/locales/hi/common.json | 166 ++++++++++++++++++++-------- public/locales/mr/common.json | 175 ++++++++++++++++++++--------- public/locales/or/common.json | 201 +++++++++++++++++++++++----------- 3 files changed, 385 insertions(+), 157 deletions(-) diff --git a/public/locales/hi/common.json b/public/locales/hi/common.json index 6ec1a9d4..c45dc088 100644 --- a/public/locales/hi/common.json +++ b/public/locales/hi/common.json @@ -1,66 +1,87 @@ { "COMMON": { "LANGUAGE": "भाषा", - "LOADING": "लोडिंग", + "LOADING": "लोड हो रहा है", + "ADD_NEW": "नया जोड़ें", + "PAGE_SIZE": "पृष्ठ आकार", + "DELETE_USER": "उपयोगकर्ता को स्थायी रूप से हटाएं", + "DELETE_USER_WITH_REASON": "उपयोगकर्ता को हटाएं", + "USER_DELETED_PERMANENTLY": "उपयोगकर्ता सफलतापूर्वक हटाया गया!", + "OTHER_REASON": "अन्य कारण", + "OTHER_REASON_PLACEHOLDER": "अन्य कारण दर्ज करें", + "REASON_FOR_DELETION": "हटाने का कारण", + "INCORRECT_DATA_ENTRY": "गलत डेटा प्रविष्टि", + "DUPLICATED_USER": "डुप्लिकेट उपयोगकर्ता", + "NO_USER_FOUND": "उपयोगकर्ता नहीं मिला", + "ALL": "सभी", + "NO_GO_BACK": "नहीं, वापस जाएं", + "YES": "हाँ", + "SURE_REASSIGN_CENTER": "क्या आप सुनिश्चित हैं कि आप इस उपयोगकर्ता को केंद्र पुनः आवंटित करना चाहते हैं?", + "OTHER": "अन्य", + "SORT": "छाँटें", + "EDIT_COHORT_NAME": "समूह संपादित करें", + "NAME": "नाम", + "UPDATE_COHORT": "समूह अपडेट करें", "EDIT": "संपादित करें", - "DELETE": "हटाएं" + "DELETE": "हटाएं", + "NO_DATA_FOUND": "कोई डेटा नहीं मिला", + "SUBMIT": "जमा करें", + "BACK": "वापस" }, "LOGIN_PAGE": { "USERNAME": "उपयोगकर्ता नाम", "PASSWORD": "पासवर्ड", - "LOGIN": "लॉग इन करें", + "LOGIN": "लॉगिन", "USERNAME_PLACEHOLDER": "उपयोगकर्ता नाम दर्ज करें", "PASSWORD_PLACEHOLDER": "पासवर्ड दर्ज करें", - "USERNAME_PASSWORD_NOT_CORRECT": "आपका यूजरनेम या पासवर्ड गलत है", + "USERNAME_PASSWORD_NOT_CORRECT": "आपके द्वारा दर्ज किया गया उपयोगकर्ता नाम या पासवर्ड गलत है", "FORGOT_PASSWORD": "पासवर्ड भूल गए?", - "REMEMBER_ME": "मुझे याद रखें", - "NO_GO_BACK": "नहीं, वापस जाओ", - "YES": "हाँ", - "OTHER": "अन्य", - "SORT": "क्रमबद्ध करें", - "EDIT_COHORT_NAME": "समूह संपादित करें", - "UPDATE_COHORT": "अद्यतन समूह" + "REMEMBER_ME": "मुझे याद रखें" }, - "COHORTS": { - "SEARCHBAR_PLACEHOLDER": "कोहॉर्ट्स खोजें.." + "SIDEBAR": { + "HI": "नमस्ते", + "DASHBOARD": "डैशबोर्ड", + "MANAGE_USERS": "उपयोगकर्ताओं का प्रबंधन करें", + "COURSE_PLANNER": "पाठ्यक्रम योजनाकार", + "COHORTS": "समूह", + "FACILITATORS": "सुविधा प्रदाता", + "LEARNERS": "शिक्षार्थी", + "TEAM_LEADERS": "टीम लीडर", + "CREATE_PLAN": "योजना बनाएं", + "VIEW_PLANS": "योजनाएँ देखें" }, - "ACTIONBUTONS": { - "EDIT": "संपादित करें", - "DELETE": "हटाएं" + "FACILITATORS": { + "ALL_STATES": "सभी राज्य", + "ALL_DISTRICTS": "सभी जिले", + "ALL_BLOCKS": "सभी ब्लॉक", + "SEARCHBAR_PLACEHOLDER": "सुविधा प्रदाता खोजें.." }, - "SIDEBAR": { - "FOUNDATION_COURSE": "आधार पाठ्यक्रम", - "MAIN_COURSE": "मुख्य पाठ्यक्रम" + "NAVBAR": { + "SEARCHBAR_PLACEHOLDER": "पाठ्यक्रम, विषय, छात्र, पीडीएफ आदि खोजें.." + }, + "LEARNERS": { + "SEARCHBAR_PLACEHOLDER": "शिक्षार्थियों को खोजें..", + "NEW_LEARNER": "नया शिक्षार्थी", + "FIRST_SELECT_REQUIRED_FIELDS": "पहले आवश्यक फ़ील्ड चुनें" }, - - "COURSE_PLANNER": { - "GRADE": "कक्षा", - "MEDIUM": "माध्यम", - "FILTER": "फिल्टर", - "BOARDS_FULLY_UPLOADED": "बोर्ड्स पूरी तरह से अपलोड हुए", - "ACTIVITY": "गतिविधि", - "COPY_LINK": "लिंक कॉपी करें", - "SEARCH": "खोजें", - "DATA_NOT_FOUND": "डेटा नहीं मिला", - "SUBJECTS_UPLOADED": "विषय अपलोड किए गए", - "IMPORT_PLANNER": "आयात नियोजक", - "REMOVE_FILE": "फाइल हटाएं", - "IMPORT_PLANNER_TO_UPLOADING": "अपलोड शुरू करने के लिए 'आयात नियोजक' पर क्लिक करें", - "TOPIC_DETAILS": "विषय विवरण" + "TEAM_LEADERS": { + "SEARCHBAR_PLACEHOLDER": "टीम लीडर्स को खोजें.." + }, + "COHORTS": { + "SEARCHBAR_PLACEHOLDER": "समूहों को खोजें.." }, "MASTER": { "STATE": "राज्य", - "SORT": "क्रमबद्ध करें", - "DISTRICT_NAMES": "जिला नाम", - "ACTIONS": "क्रियाएँ", + "STATE_NAMES": "राज्य के नाम", + "SORT": "छाँटें", + "DISTRICT_NAMES": "जिलों के नाम", + "BLOCK_NAMES": "ब्लॉक के नाम", + "ACTIONS": "कार्य", "DISTRICTS": "जिले", "SEARCHBAR_PLACEHOLDER_STATE": "राज्यों को खोजें", "SEARCHBAR_PLACEHOLDER_DISTRICT": "जिलों को खोजें", - "SEARCHBAR_PLACEHOLDER_BLOCK": "ब्लॉकों को खोजें", - "BLOCKS": "ब्लॉक", - "BLOCK_NAMES": "ब्लॉक के नाम", - "ALL_DISTRICTS": "सभी जिले", - "ALL_BLOCKS": "सभी ब्लॉक" + "SEARCHBAR_PLACEHOLDER_BLOCK": "ब्लॉक्स को खोजें", + "BLOCKS": "ब्लॉक्स" }, "CENTERS": { "CENTERS": "केंद्र", @@ -69,8 +90,8 @@ "REMOTE_CENTER": "दूरस्थ केंद्र", "REGULAR": "नियमित", "REMOTE": "दूरस्थ", - "SEARCH_BLOCKS": "ब्लॉक खोजें", - "BLOCK_REQUEST": "आप इस उपयोगकर्ता को ब्लॉक पुनः असाइन करने के लिए राज्य टीम लीडर को अनुरोध भेज रहे हैं", + "SEARCH_BLOCKS": "ब्लॉक्स को खोजें", + "BLOCK_REQUEST": "आप इस उपयोगकर्ता को ब्लॉक पुनः आवंटित करने के लिए राज्य टीम लीडर को अनुरोध भेज रहे हैं", "NEW_CENTER": "नया केंद्र", "CENTER_TYPE": "केंद्र प्रकार", "UNIT_NAME": "इकाई का नाम", @@ -82,5 +103,60 @@ "CENTER_RENAMED": "केंद्र का नाम सफलतापूर्वक बदला गया!", "SEND_REQUEST": "अनुरोध भेजें", "REQUEST_TO_DELETE_HAS_BEEN_SENT": "हटाने का अनुरोध भेजा गया है" + }, + "FORM": { + "FULL_NAME": "पूरा नाम", + "ENTER_FULL_NAME": "पूरा नाम दर्ज करें", + "CONTACT_NUMBER": "संपर्क नंबर", + "ENTER_CONTACT_NUMBER": "संपर्क नंबर दर्ज करें", + "HOW_WAS_LEARNER_MOBILISED": "शिक्षार्थी को कैसे जुटाया गया?", + "SECOND_CHANCE_ALUMNI": "सेकंड चांस पूर्व छात्र", + "PRATHAM_TEAM_MEMBER": "प्रथम टीम सदस्य", + "OTHER": "अन्य", + "AGE": "आयु", + "GENDER": "लिंग", + "MALE": "पुरुष", + "FEMALE": "महिला", + "LEARNERS_PRIMARY_WORK": "शिक्षार्थी का प्राथमिक कार्य", + "ENROLLED_IN_EDUCATIONAL_INSTITUTE": "शैक्षिक संस्थान में नामांकित", + "OWN_FARMING": "स्वयं की खेती", + "AGRICULTURAL_FARM_LABORER": "कृषि खेत मजदूर", + "NON_AGRICULTURAL_LABORER": "गैर-कृषि मजदूर", + "SALARIED_WORK": "वेतनभोगी कार्य", + "SELF_EMPLOYMENT": "स्व-रोजगार", + "UNEMPLOYED": "बेरोज़गार", + "INVOLVED_IN_DOMESTIC_WORK": "घरेलू कार्यों में शामिल", + "FATHER_NAME": "पिता का नाम", + "ENTER_YOUR_FATHER_NAME": "अपने पिता का नाम दर्ज करें", + "CLASS_OR_LAST_PASSED_GRADE": "कक्षा (अंतिम उत्तीर्ण ग्रेड)", + "NO_SCHOOLING": "कोई स्कूली शिक्षा नहीं", + "REASON_FOR_DROPOUT_FROM_SCHOOL": "स्कूल से बाहर होने का कारण", + "SCHOOL_INACCESSIBLE": "स्कूल पहुंच से बाहर", + "FINANCIAL_CONSTRAINTS": "वित्तीय सीमाएँ", + "LACK_OF_INTEREST": "रुचि की कमी", + "FAMILY_RESPONSIBILITIES": "पारिवारिक ज़िम्मेदारियाँ", + "FAILED": "असफल", + "ILLNESS": "बीमारी", + "MARRIAGE": "विवाह", + "MIGRATION": "प्रवास", + "STARTED_VOCATIONAL_COURSE": "व्यावसायिक पाठ्यक्रम शुरू किया", + "STARTED_A_JOB": "नौकरी शुरू की", + "SCHOOL_CLOSURE_DUE_TO_COVID": "कोविड के कारण स्कूल बंद", + "MARITAL_STATUS": "वैवाहिक स्थिति", + "UNMARRIED": "अविवाहित", + "MARRIED": "विवाहित", + "DIVORCED": "तलाकशुदा", + "PHONE_TYPE_AVAILABLE": "उपलब्ध फ़ोन का प्रकार", + "SMARTPHONE": "स्मार्टफोन", + "KEYPAD": "कीपैड", + "NO_PHONE": "कोई फोन नहीं", + "IS_IT_YOUR_OWN_PHONE": "क्या यह आपका खुद का फोन है?", + "YES": "हाँ", + "NO": "नहीं", + "TYPE_OF_PHONE_AVAILABLE": "उपलब्ध फ़ोन का प्रकार", + "REASON_FOR_DROP_OUT_FROM_SCHOOL": "स्कूल से बाहर होने का कारण", + "EMAIL": "ईमेल", + "YEAR_OF_ JOINING_SCP": "एससीपी में शामिल होने का वर्ष", + "ASSIGN_CENTERS": "केंद्र आवंटित करें" } -} +} \ No newline at end of file diff --git a/public/locales/mr/common.json b/public/locales/mr/common.json index b08edf2a..31789647 100644 --- a/public/locales/mr/common.json +++ b/public/locales/mr/common.json @@ -1,67 +1,87 @@ { "COMMON": { "LANGUAGE": "भाषा", - "LOADING": "लोड होत आहे", + "LOADING": "लोड करत आहे", + "ADD_NEW": "नवीन जोडा", + "PAGE_SIZE": "पृष्ठ आकार", + "DELETE_USER": "वापरकर्त्याला कायमस्वरूपी हटवा", + "DELETE_USER_WITH_REASON": "वापरकर्त्याला हटवा", + "USER_DELETED_PERMANENTLY": "वापरकर्ता यशस्वीरित्या हटविला गेला!", + "OTHER_REASON": "इतर कारण", + "OTHER_REASON_PLACEHOLDER": "इतर कारण प्रविष्ट करा", + "REASON_FOR_DELETION": "हटवण्याचे कारण", + "INCORRECT_DATA_ENTRY": "चुकीची डेटा नोंद", + "DUPLICATED_USER": "डुप्लिकेट वापरकर्ता", + "NO_USER_FOUND": "वापरकर्ता सापडला नाही", + "ALL": "सर्व", + "NO_GO_BACK": "नाही, परत जा", + "YES": "होय", + "SURE_REASSIGN_CENTER": "तुम्ही खात्री आहात की तुम्हाला या वापरकर्त्यास केंद्र पुन्हा नियुक्त करायचे आहे?", "OTHER": "इतर", "SORT": "क्रमवारी लावा", - "EDIT_COHORT_NAME": "समूह संपादित करा", + "EDIT_COHORT_NAME": "गट संपादित करा", "NAME": "नाव", - "UPDATE_COHORT": "कोहॉर्ट अपडेट करा", + "UPDATE_COHORT": "गट अद्यतनित करा", "EDIT": "संपादित करा", - "DELETE": "हटवा" + "DELETE": "हटवा", + "NO_DATA_FOUND": "डेटा सापडला नाही", + "SUBMIT": "सबमिट करा", + "BACK": "परत जा" }, "LOGIN_PAGE": { - "USERNAME": "वापरकर्तानाव", + "USERNAME": "वापरकर्ता नाव", "PASSWORD": "पासवर्ड", - "LOGIN": "लॉग इन करा", - "USERNAME_PLACEHOLDER": "वापरकर्तानाव प्रविष्ट करा", - "PASSWORD_PLACEHOLDER": "पासवर्ड टाका", - "USERNAME_PASSWORD_NOT_CORRECT": "आपलं वापरकर्तानाव किंवा संकेतशब्द चुकीचं आहे", - "FORGOT_PASSWORD": "पासवर्ड विसरलात?", - "REMEMBER_ME": "मला लक्षात ठेवा", - "NO_GO_BACK": "नाही, परत जा", - "YES": "होय" + "LOGIN": "लॉगिन", + "USERNAME_PLACEHOLDER": "वापरकर्ता नाव प्रविष्ट करा", + "PASSWORD_PLACEHOLDER": "पासवर्ड प्रविष्ट करा", + "USERNAME_PASSWORD_NOT_CORRECT": "तुम्ही प्रविष्ट केलेले वापरकर्ता नाव किंवा पासवर्ड चुकीचा आहे", + "FORGOT_PASSWORD": "पासवर्ड विसरलात का?", + "REMEMBER_ME": "मला लक्षात ठेवा" }, - "COHORTS": { - "SEARCHBAR_PLACEHOLDER": "कोहॉर्ट्स शोधा.." + "SIDEBAR": { + "HI": "नमस्कार", + "DASHBOARD": "डॅशबोर्ड", + "MANAGE_USERS": "वापरकर्त्यांचे व्यवस्थापन करा", + "COURSE_PLANNER": "अभ्यासक्रम नियोजक", + "COHORTS": "गट", + "FACILITATORS": "प्रशिक्षक", + "LEARNERS": "शिकणारे", + "TEAM_LEADERS": "टीम लीडर", + "CREATE_PLAN": "योजना तयार करा", + "VIEW_PLANS": "योजना पहा" }, - "ACTIONBUTONS": { - "EDIT": "संपादित करा", - "DELETE": "हटवा" + "FACILITATORS": { + "ALL_STATES": "सर्व राज्ये", + "ALL_DISTRICTS": "सर्व जिल्हे", + "ALL_BLOCKS": "सर्व ब्लॉक्स", + "SEARCHBAR_PLACEHOLDER": "प्रशिक्षक शोधा.." }, - "SIDEBAR": { - "FOUNDATION_COURSE": "मूलभूत अभ्यासक्रम", - "MAIN_COURSE": "मुख्य अभ्यासक्रम" + "NAVBAR": { + "SEARCHBAR_PLACEHOLDER": "अभ्यासक्रम, विषय, विद्यार्थी, पीडीएफ इत्यादी शोधा.." }, - "COURSE_PLANNER": { - "GRADE": "इयत्ता", - "MEDIUM": "माध्यम", - "FILTER": "फिल्टर", - "BOARDS_FULLY_UPLOADED": "बोर्ड्स पूर्णपणे अपलोड केले", - "ACTIVITY": "क्रियाकलाप", - "COPY_LINK": "लिंक कॉपी करा", - "SEARCH": "शोधा", - "DATA_NOT_FOUND": "डेटा आढळला नाही", - "SUBJECTS_UPLOADED": "विषय अपलोड केले", - "IMPORT_PLANNER": "आयात नियोजक", - "REMOVE_FILE": "फाईल काढा", - "IMPORT_PLANNER_TO_UPLOADING": "अपलोड करण्यास सुरुवात करण्यासाठी 'आयात नियोजक' वर क्लिक करा", - "TOPIC_DETAILS": "विषय तपशील" + "LEARNERS": { + "SEARCHBAR_PLACEHOLDER": "शिकणारे शोधा..", + "NEW_LEARNER": "नवीन शिकणारा", + "FIRST_SELECT_REQUIRED_FIELDS": "प्रथम आवश्यक फील्ड निवडा" + }, + "TEAM_LEADERS": { + "SEARCHBAR_PLACEHOLDER": "टीम लीडर शोधा.." + }, + "COHORTS": { + "SEARCHBAR_PLACEHOLDER": "गट शोधा.." }, - "MASTER": { "STATE": "राज्य", + "STATE_NAMES": "राज्याची नावे", "SORT": "क्रमवारी लावा", "DISTRICT_NAMES": "जिल्ह्यांची नावे", + "BLOCK_NAMES": "ब्लॉकची नावे", "ACTIONS": "कृती", "DISTRICTS": "जिल्हे", - "SEARCHBAR_PLACEHOLDER_STATE": "राज्य शोधा", + "SEARCHBAR_PLACEHOLDER_STATE": "राज्ये शोधा", "SEARCHBAR_PLACEHOLDER_DISTRICT": "जिल्हे शोधा", - "SEARCHBAR_PLACEHOLDER_BLOCK": "ब्लॉक शोधा", - "BLOCKS": "ब्लॉक", - "BLOCK_NAMES": "ब्लॉकचे नावे", - "ALL_DISTRICTS": "सर्व जिल्हे", - "ALL_BLOCKS": "सर्व ब्लॉक" + "SEARCHBAR_PLACEHOLDER_BLOCK": "ब्लॉक्स शोधा", + "BLOCKS": "ब्लॉक्स" }, "CENTERS": { "CENTERS": "केंद्रे", @@ -70,18 +90,73 @@ "REMOTE_CENTER": "दूरस्थ केंद्र", "REGULAR": "नियमित", "REMOTE": "दूरस्थ", - "SEARCH_BLOCKS": "ब्लॉक शोधा", - "BLOCK_REQUEST": "आपण या वापरकर्त्यास ब्लॉक पुन्हा नियुक्त करण्यासाठी राज्य टीम लीडरला विनंती पाठवत आहात", + "SEARCH_BLOCKS": "ब्लॉक्स शोधा", + "BLOCK_REQUEST": "तुम्ही या वापरकर्त्यास ब्लॉक पुन्हा नियुक्त करण्यासाठी राज्य टीम लीडरला विनंती पाठवत आहात", "NEW_CENTER": "नवीन केंद्र", "CENTER_TYPE": "केंद्र प्रकार", "UNIT_NAME": "युनिटचे नाव", - "NOTE": "टीप: हे केंद्राचे नाव असेल", - "CENTER_CREATED": "केंद्र यशस्वीरित्या तयार झाले!", + "NOTE": "लक्षात घ्या: हे केंद्राचे नाव असेल", + "CENTER_CREATED": "केंद्र यशस्वीरित्या तयार केले गेले!", "RENAME_CENTER": "केंद्राचे नाव बदला", - "REQUEST_TO_DELETE": "हटविण्याची विनंती", + "REQUEST_TO_DELETE": "हटवण्याची विनंती", "RENAME": "नाव बदला", - "CENTER_RENAMED": "केंद्राचे नाव यशस्वीरित्या बदलले!", + "CENTER_RENAMED": "केंद्राचे नाव यशस्वीरित्या बदलले गेले!", "SEND_REQUEST": "विनंती पाठवा", - "REQUEST_TO_DELETE_HAS_BEEN_SENT": "हटविण्याची विनंती पाठविण्यात आली आहे" + "REQUEST_TO_DELETE_HAS_BEEN_SENT": "हटवण्याची विनंती पाठवली गेली आहे" + }, + "FORM": { + "FULL_NAME": "पूर्ण नाव", + "ENTER_FULL_NAME": "पूर्ण नाव प्रविष्ट करा", + "CONTACT_NUMBER": "संपर्क क्रमांक", + "ENTER_CONTACT_NUMBER": "संपर्क क्रमांक प्रविष्ट करा", + "HOW_WAS_LEARNER_MOBILISED": "शिकणार्‍यास कसे एकत्रित केले?", + "SECOND_CHANCE_ALUMNI": "सेकंड चान्स माजी विद्यार्थी", + "PRATHAM_TEAM_MEMBER": "प्रथम टीम सदस्य", + "OTHER": "इतर", + "AGE": "वय", + "GENDER": "लिंग", + "MALE": "पुरुष", + "FEMALE": "महिला", + "LEARNERS_PRIMARY_WORK": "शिकणार्‍याचे प्राथमिक कार्य", + "ENROLLED_IN_EDUCATIONAL_INSTITUTE": "शैक्षणिक संस्थेत नावनोंदणी केली", + "OWN_FARMING": "स्वत:ची शेती", + "AGRICULTURAL_FARM_LABORER": "कृषी शेतमजूर", + "NON_AGRICULTURAL_LABORER": "गैर-कृषी मजूर", + "SALARIED_WORK": "पगारी काम", + "SELF_EMPLOYMENT": "स्वयंरोजगार", + "UNEMPLOYED": "बेरोजगार", + "INVOLVED_IN_DOMESTIC_WORK": "घरगुती कामात गुंतलेले", + "FATHER_NAME": "वडिलांचे नाव", + "ENTER_YOUR_FATHER_NAME": "तुमचे वडिलांचे नाव प्रविष्ट करा", + "CLASS_OR_LAST_PASSED_GRADE": "वर्ग (शेवटचा उत्तीर्ण ग्रेड)", + "NO_SCHOOLING": "शालेय शिक्षण नाही", + "REASON_FOR_DROPOUT_FROM_SCHOOL": "शाळा सोडण्याचे कारण", + "SCHOOL_INACCESSIBLE": "शाळा उपलब्ध नाही", + "FINANCIAL_CONSTRAINTS": "आर्थिक मर्यादा", + "LACK_OF_INTEREST": "आवडीचा अभाव", + "FAMILY_RESPONSIBILITIES": "कौटुंबिक जबाबदाऱ्या", + "FAILED": "अयशस्वी", + "ILLNESS": "आजारपण", + "MARRIAGE": "लग्न", + "MIGRATION": "स्थलांतर", + "STARTED_VOCATIONAL_COURSE": "व्यावसायिक कोर्स सुरू केला", + "STARTED_A_JOB": "नोकरी सुरू केली", + "SCHOOL_CLOSURE_DUE_TO_COVID": "कोविडमुळे शाळा बंद", + "MARITAL_STATUS": "वैवाहिक स्थिती", + "UNMARRIED": "अविवाहित", + "MARRIED": "विवाहित", + "DIVORCED": "घटस्फोटीत", + "PHONE_TYPE_AVAILABLE": "उपलब्ध फोनचा प्रकार", + "SMARTPHONE": "स्मार्टफोन", + "KEYPAD": "कीपॅड", + "NO_PHONE": "फोन नाही", + "IS_IT_YOUR_OWN_PHONE": "हा तुमचा स्वत:चा फोन आहे का?", + "YES": "होय", + "NO": "नाही", + "TYPE_OF_PHONE_AVAILABLE": "उपलब्ध फोनचा प्रकार", + "REASON_FOR_DROP_OUT_FROM_SCHOOL": "शाळा सोडण्याचे कारण", + "EMAIL": "ईमेल", + "YEAR_OF_ JOINING_SCP": "एससीपीमध्ये सामील होण्याचे वर्ष", + "ASSIGN_CENTERS": "केंद्रे नियुक्त करा" } -} +} \ No newline at end of file diff --git a/public/locales/or/common.json b/public/locales/or/common.json index fcba4fdf..fd989feb 100644 --- a/public/locales/or/common.json +++ b/public/locales/or/common.json @@ -1,85 +1,162 @@ { "COMMON": { "LANGUAGE": "ଭାଷା", - "LOADING": "ଲୋଡ୍ ହେଉଛି (Loading)", - "UPDATE_COHORT": "କୋହୋର୍ଟ୍ ଅଦ୍ୟତନ କରନ୍ତୁ", - "SORT": "ସର୍ଟ", - "OTHER": "ଅନ୍ୟ", + "LOADING": "ଲୋଡ୍ ହେଉଛି", + "ADD_NEW": "ନୂତନ ଯୋଡନ୍ତୁ", + "PAGE_SIZE": "ପୃଷ୍ଠା ଆକାର", + "DELETE_USER": "ଉପଭୋକ୍ତାକୁ ଶାଶ୍ଵତ ଭାବରେ ହଟାନ୍ତୁ", + "DELETE_USER_WITH_REASON": "ଉପଭୋକ୍ତାକୁ ହଟାନ୍ତୁ", + "USER_DELETED_PERMANENTLY": "ଉପଭୋକ୍ତାକୁ ସଫଳତାର ସହ ହଟାଯାଇଛି!", + "OTHER_REASON": "ଅନ୍ୟାନ୍ୟ କାରଣ", + "OTHER_REASON_PLACEHOLDER": "ଅନ୍ୟାନ୍ୟ କାରଣ ଲେଖନ୍ତୁ", + "REASON_FOR_DELETION": "ହଟାଇବାର କାରଣ", + "INCORRECT_DATA_ENTRY": "ତ୍ରୁଟିପୂର୍ଣ୍ଣ ତଥ୍ୟ ଆବେଶ", + "DUPLICATED_USER": "ଡୁପ୍ଲିକେଟ୍ ଉପଭୋକ୍ତା", + "NO_USER_FOUND": "ଉପଭୋକ୍ତାକୁ ପାଇଁ ହେବନାହିଁ", + "ALL": "ସମସ୍ତ", + "NO_GO_BACK": "ନାହିଁ, ପଛକୁ ଯାଆନ୍ତୁ", + "YES": "ହଁ", + "SURE_REASSIGN_CENTER": "ଆପଣ ନିଶ୍ଚିତ କି ଏହି ଉପଭୋକ୍ତାଙ୍କୁ କେନ୍ଦ୍ର ପୁନର୍ନିୟୁକ୍ତ କରିବାକୁ ଚାହୁଁଛନ୍ତି?", + "OTHER": "ଅନ୍ୟାନ୍ୟ", + "SORT": "ବିନ୍ୟାସ", + "EDIT_COHORT_NAME": "ଗୋଷ୍ଠୀ ସମ୍ପାଦନା", "NAME": "ନାମ", - "EDIT": "ସଂପାଦନା", - "DELETE": "ବିଲୋପ" + "UPDATE_COHORT": "ଗୋଷ୍ଠୀ ଅଦ୍ୟତନ କରନ୍ତୁ", + "EDIT": "ସମ୍ପାଦନା", + "DELETE": "ହଟାନ୍ତୁ", + "NO_DATA_FOUND": "ତଥ୍ୟ ମିଳିଲା ନାହିଁ", + "SUBMIT": "ଦାଖଲ କରନ୍ତୁ", + "BACK": "ପଛକୁ ଯାଆନ୍ତୁ" }, "LOGIN_PAGE": { - "USERNAME": "ଉପଯୋଗକର୍ତା ନାମ", - "PASSWORD": "ପାସୱାର୍ଡ", + "USERNAME": "ଉପଭୋକ୍ତା ନାମ", + "PASSWORD": "ପ୍ରବେଶ କୋଡ଼", "LOGIN": "ପ୍ରବେଶ", - "USERNAME_PLACEHOLDER": "ଉପଯୋଗକର୍ତା ନାମ ଏଣ୍ଟର କର", - "PASSWORD_PLACEHOLDER": "ପାସୱାର୍ଡ ଏଣ୍ଟର କର", - "USERNAME_PASSWORD_NOT_CORRECT": "ଆପଣଙ୍କ ବ୍ୟବହାରକୃତ ନାମ କିମ୍ବା ପାସ୍‌ୱାର୍ଡ ଭୁଲ ଅଛି", - "FORGOT_PASSWORD": "ପାସ୍‌ୱାର୍ଡ ଭୁଲିଛନ୍ତି?", - "REMEMBER_ME": "ମୋତେ ମନ ରଖ", - "NO_GO_BACK": "ନାହିଁ, ପଛକୁ ଯାଆନ୍ତୁ", - "YES": "ହଁ" + "USERNAME_PLACEHOLDER": "ଉପଭୋକ୍ତା ନାମ ଲେଖନ୍ତୁ", + "PASSWORD_PLACEHOLDER": "ପ୍ରବେଶ କୋଡ଼ ଲେଖନ୍ତୁ", + "USERNAME_PASSWORD_NOT_CORRECT": "ଆପଣ ଲେଖିଥିବା ଉପଭୋକ୍ତା ନାମ କିମ୍ବା ପ୍ରବେଶ କୋଡ଼ ତ୍ରୁଟିପୂର୍ଣ୍ଣ", + "FORGOT_PASSWORD": "ପ୍ରବେଶ କୋଡ଼କୁ ଭୁଲିଗଲେ?", + "REMEMBER_ME": "ମୋତେ ମନେ ରଖନ୍ତୁ" }, - "ACTIONBUTONS": { - "EDIT": "ସଂପାଦନା", - "DELETE": "ବିଲୋପ" + "SIDEBAR": { + "HI": "ନମସ୍କାର", + "DASHBOARD": "ଡ୍ୟାସବୋର୍ଡ", + "MANAGE_USERS": "ଉପଭୋକ୍ତାମାନଙ୍କୁ ପରିଚାଳନା କରନ୍ତୁ", + "COURSE_PLANNER": "ପାଠ୍ୟକ୍ରମ ପ୍ରଣାଳୀକାରୀ", + "COHORTS": "ଗୋଷ୍ଠୀମାନେ", + "FACILITATORS": "ସହଜକାରୀମାନେ", + "LEARNERS": "ଶିକ୍ଷାର୍ଥୀମାନେ", + "TEAM_LEADERS": "ଦଳ ନେତାମାନେ", + "CREATE_PLAN": "ଯୋଜନା ସୃଷ୍ଟି କରନ୍ତୁ", + "VIEW_PLANS": "ଯୋଜନାଗୁଡ଼ିକୁ ଦେଖନ୍ତୁ" }, - "COHORTS": { - "SEARCHBAR_PLACEHOLDER": "କୋହର୍ଟସ୍ ସନ୍ଧାନ କରନ୍ତୁ.." + "FACILITATORS": { + "ALL_STATES": "ସମସ୍ତ ରାଜ୍ୟ", + "ALL_DISTRICTS": "ସମସ୍ତ ଜିଲ୍ଲା", + "ALL_BLOCKS": "ସମସ୍ତ ବ୍ଲକ୍", + "SEARCHBAR_PLACEHOLDER": "ସହଜକାରୀମାନଙ୍କୁ ଖୋଜନ୍ତୁ.." }, - "SIDEBAR": { - "FOUNDATION_COURSE": "ମୂଳ ପାଠ୍ୟକ୍ରମ", - "MAIN_COURSE": "ମୁଖ୍ୟ ପାଠ୍ୟକ୍ରମ" + "NAVBAR": { + "SEARCHBAR_PLACEHOLDER": "ପାଠ୍ୟକ୍ରମ, ବିଷୟ, ଛାତ୍ର, ପିଡ଼ଏଫ୍ ଇତ୍ୟାଦି ଖୋଜନ୍ତୁ.." }, - "COURSE_PLANNER": { - "GRADE": "ଶ୍ରେଣୀ", - "MEDIUM": "ମାଧ୍ୟମ", - "FILTER": "ଫିଲ୍ଟର", - "BOARDS_FULLY_UPLOADED": "ବୋର୍ଡ୍ସ ସମ୍ପୂର୍ଣ୍ଣ ଅପଲୋଡ୍ ହେଲା", - "ACTIVITY": "କାର୍ଯ୍ୟକଳାପ", - "COPY_LINK": "ଲିଙ୍କ କପି କରନ୍ତୁ", - "SEARCH": "ସନ୍ଧାନ", - "DATA_NOT_FOUND": "ଡାଟା ମିଳିଲା ନାହିଁ", - "SUBJECTS_UPLOADED": "ବିଷୟ ଅପଲୋଡ୍ ହେଲା", - "IMPORT_PLANNER": "ଆୟାତ ପ୍ଲାନର", - "REMOVE_FILE": "ଫାଇଲ୍ ବାହାର କରନ୍ତୁ", - "IMPORT_PLANNER_TO_UPLOADING": "ଅପଲୋଡ୍ ଆରମ୍ଭ କରିବାକୁ ‘ଆୟାତ ପ୍ଲାନର’ ଉପରେ କ୍ଲିକ୍ କରନ୍ତୁ", - "TOPIC_DETAILS": "ବିଷୟ ବିବରଣୀ" + "LEARNERS": { + "SEARCHBAR_PLACEHOLDER": "ଶିକ୍ଷାର୍ଥୀମାନଙ୍କୁ ଖୋଜନ୍ତୁ..", + "NEW_LEARNER": "ନୂତନ ଶିକ୍ଷାର୍ଥୀ", + "FIRST_SELECT_REQUIRED_FIELDS": "ପ୍ରଥମେ ଆବଶ୍ୟକ ତଥ୍ୟଗୁଡ଼ିକୁ ଚୟନ କରନ୍ତୁ" + }, + "TEAM_LEADERS": { + "SEARCHBAR_PLACEHOLDER": "ଦଳ ନେତାମାନଙ୍କୁ ଖୋଜନ୍ତୁ.." + }, + "COHORTS": { + "SEARCHBAR_PLACEHOLDER": "ଗୋଷ୍ଠୀମାନଙ୍କୁ ଖୋଜନ୍ତୁ.." }, "MASTER": { "STATE": "ରାଜ୍ୟ", - "SORT": "ଛାଟାନ୍ତୁ", - "DISTRICT_NAMES": "ଜିଲ୍ଲା ନାମ", + "STATE_NAMES": "ରାଜ୍ୟ ନାମଗୁଡ଼ିକ", + "SORT": "ବିନ୍ୟାସ", + "DISTRICT_NAMES": "ଜିଲ୍ଲା ନାମଗୁଡ଼ିକ", + "BLOCK_NAMES": "ବ୍ଲକ୍ ନାମଗୁଡ଼ିକ", "ACTIONS": "କାର୍ଯ୍ୟ", - "DISTRICTS": "ଜିଲ୍ଲା", - "SEARCHBAR_PLACEHOLDER_STATE": "ରାଜ୍ୟ ଖୋଜନ୍ତୁ", - "SEARCHBAR_PLACEHOLDER_DISTRICT": "ଜିଲ୍ଲା ଖୋଜନ୍ତୁ", - "SEARCHBAR_PLACEHOLDER_BLOCK": "ବ୍ଲକ୍ ଖୋଜନ୍ତୁ", - "BLOCKS": "ବ୍ଲକ୍", - "BLOCK_NAMES": "ବ୍ଲକ୍ ନାମ", - "ALL_DISTRICTS": "ସମସ୍ତ ଜିଲ୍ଲା", - "ALL_BLOCKS": "ସମସ୍ତ ବ୍ଲକ୍‌" + "DISTRICTS": "ଜିଲ୍ଲାମାନେ", + "SEARCHBAR_PLACEHOLDER_STATE": "ରାଜ୍ୟଗୁଡ଼ିକୁ ଖୋଜନ୍ତୁ", + "SEARCHBAR_PLACEHOLDER_DISTRICT": "ଜିଲ୍ଲାମାନଙ୍କୁ ଖୋଜନ୍ତୁ", + "SEARCHBAR_PLACEHOLDER_BLOCK": "ବ୍ଲକ୍ ଗୁଡ଼ିକୁ ଖୋଜନ୍ତୁ", + "BLOCKS": "ବ୍ଲକ୍ମାନେ" }, "CENTERS": { - "CENTERS": "କେନ୍ଦ୍ରଗୁଡିକ", - "REGULAR_CENTERS": "ନିୟମିତ କେନ୍ଦ୍ରଗୁଡିକ", - "REMOTE_CENTERS": "ଦୂରସ୍ଥ କେନ୍ଦ୍ରଗୁଡିକ", + "CENTERS": "କେନ୍ଦ୍ରଗୁଡ଼ିକ", + "REGULAR_CENTERS": "ନିୟମିତ କେନ୍ଦ୍ରଗୁଡ଼ିକ", + "REMOTE_CENTERS": "ଦୂରସ୍ଥ କେନ୍ଦ୍ରଗୁଡ଼ିକ", "REMOTE_CENTER": "ଦୂରସ୍ଥ କେନ୍ଦ୍ର", "REGULAR": "ନିୟମିତ", "REMOTE": "ଦୂରସ୍ଥ", - "SEARCH_BLOCKS": "ବ୍ଲକଗୁଡ଼ିକୁ ଖୋଜନ୍ତୁ", - "BLOCK_REQUEST": "ଆପଣ ଏହି ବ୍ୟବହାରକାରୀଙ୍କୁ ବ୍ଲକ ପୁନଃ ନିଯୁକ୍ତ କରିବା ପାଇଁ ରାଜ୍ୟ ଟିମ୍ ଲିଡରକୁ ଅନୁରୋଧ ପଠାଉଛନ୍ତି", + "SEARCH_BLOCKS": "ବ୍ଲକ୍ଗୁଡ଼ିକୁ ଖୋଜନ୍ତୁ", + "BLOCK_REQUEST": "ଆପଣ ଏହି ଉପଭୋକ୍ତାଙ୍କୁ ବ୍ଲକ୍ ପୁନର୍ନିୟୁକ୍ତ କରିବା ପାଇଁ ରାଜ୍ୟ ଟିମ୍ ଲିଡର୍କୁ ଅନୁରୋଧ ପଠାଉଛନ୍ତି", "NEW_CENTER": "ନୂତନ କେନ୍ଦ୍ର", "CENTER_TYPE": "କେନ୍ଦ୍ର ପ୍ରକାର", - "UNIT_NAME": "ଅଂଶର ନାମ", - "NOTE": "ଟିପ୍ପଣୀ: ଏହା ହେବ କେନ୍ଦ୍ରର ନାମ", - "CENTER_CREATED": "କେନ୍ଦ୍ର ସଫଳତାପୂର୍ଣ୍ଣ ଭାବରେ ସୃଷ୍ଟି ହେଲା!", - "RENAME_CENTER": "କେନ୍ଦ୍ରର ନାମ ପରିବର୍ତ୍ତନ କରନ୍ତୁ", - "REQUEST_TO_DELETE": "ମିଟାଇବାକୁ ଅନୁରୋଧ", - "RENAME": "ନାମ ପରିବର୍ତ୍ତନ କରନ୍ତୁ", - "CENTER_RENAMED": "କେନ୍ଦ୍ରର ନାମ ସଫଳତାପୂର୍ଣ୍ଣ ଭାବରେ ପରିବର୍ତ୍ତିତ ହେଲା!", - "SEND_REQUEST": "ଅନୁରୋଧ ପଠାଅନ୍ତୁ", - "REQUEST_TO_DELETE_HAS_BEEN_SENT": "ମିଟାଇବା ପାଇଁ ଅନୁରୋଧ ପଠାଯାଇଛି" + "UNIT_NAME": "ଏକକ ନାମ", + "NOTE": "ଦୟାକରି ଲକ୍ଷ୍ୟ କରନ୍ତୁ: ଏହା କେନ୍ଦ୍ରର ନାମ ହେବ", + "CENTER_CREATED": "କେନ୍ଦ୍ର ସଫଳତାର ସହ ସୃଷ୍ଟି ହେଲା!", + "RENAME_CENTER": "କେନ୍ଦ୍ରର ନାମ ପରିବର", + "REQUEST_TO_DELETE": "ମିଟିବା ପାଇଁ ଅନୁରୋଧ", + "RENAME": "ପୁନର୍ନାମକରଣ", + "CENTER_RENAMED": "କେନ୍ଦ୍ର ଶୁଭକାମନାର ସହିତ ପୁନର୍ନାମ କରାଯାଇଛି!", + "SEND_REQUEST": "ଅନୁରୋଧ ପଠାନ୍ତୁ", + "REQUEST_TO_DELETE_HAS_BEEN_SENT": "ମିଟିବା ପାଇଁ ଅନୁରୋଧ ପଠାଇ ଦିଆଯାଇଛି" + }, + "FORM": { + "FULL_NAME": "ପୂର୍ଣ୍ଣ ନାମ", + "ENTER_FULL_NAME": "ପୂର୍ଣ୍ଣ ନାମ ଭରନ୍ତୁ", + "CONTACT_NUMBER": "ସମ୍ପର୍କ ସଂଖ୍ୟା", + "ENTER_CONTACT_NUMBER": "ସମ୍ପର୍କ ସଂଖ୍ୟା ଭରନ୍ତୁ", + "HOW_WAS_LEARNER_MOBILISED": "ଶିକ୍ଷାର୍ଥୀ କିପରି ସଙ୍ଗଠିତ ହେଲେ?", + "SECOND_CHANCE_ALUMNI": "ଦ୍ବିତୀୟ ସୁଯୋଗ ପାଠଶାଳୀ", + "PRATHAM_TEAM_MEMBER": "ପ୍ରଥମ ଟିମ୍ ସଦସ୍ୟ", + "OTHER": "ଅନ୍ୟ", + "AGE": "ବୟସ", + "GENDER": "ଲିଙ୍ଗ", + "MALE": "ପୁରୁଷ", + "FEMALE": "ସ୍ତ୍ରୀ", + "LEARNERS_PRIMARY_WORK": "ଶିକ୍ଷାର୍ଥୀର ପ୍ରାଥମିକ କାମ", + "ENROLLED_IN_EDUCATIONAL_INSTITUTE": "ଶିକ୍ଷା ସଂସ୍ଥାରେ ଭର୍ତ୍ତି ହୋଇଛନ୍ତି", + "OWN_FARMING": "ନିଜର କୃଷି", + "AGRICULTURAL_FARM_LABORER": "କୃଷି କଷ୍ଟକର୍ମୀ", + "NON_AGRICULTURAL_LABORER": "ଅକୃଷି କଷ୍ଟକର୍ମୀ", + "SALARIED_WORK": "ଶାଳୀତ କାମ", + "SELF_EMPLOYMENT": "ସ୍ୱୟଂ ସେବା", + "UNEMPLOYED": "ବେକାର", + "INVOLVED_IN_DOMESTIC_WORK": "ଘରୋଇ କାମରେ ଲିପ୍ତ", + "FATHER_NAME": "ବାପାଙ୍କ ନାମ", + "ENTER_YOUR_FATHER_NAME": "ଆପଣଙ୍କ ବାପାଙ୍କ ନାମ ଭରନ୍ତୁ", + "CLASS_OR_LAST_PASSED_GRADE": "କ୍ଲାସ୍ (ଶେଷ ପାଠାଗତ ଶ୍ରେଣୀ)", + "NO_SCHOOLING": "କୌଣସି ଶିକ୍ଷା ନାହିଁ", + "REASON_FOR_DROPOUT_FROM_SCHOOL": "ପାଠଶାଳାରୁ ତ୍ୟାଗ କରିବାର କାରଣ", + "SCHOOL_INACCESSIBLE": "ପାଠଶାଳା ଅପହେଲିତ", + "FINANCIAL_CONSTRAINTS": "ଆର୍ଥିକ ଅସୁବିଧା", + "LACK_OF_INTEREST": "ରୁଚିର ଅଭାବ", + "FAMILY_RESPONSIBILITIES": "ପରିବାରିକ ଦାୟିତ୍ୱ", + "FAILED": "ବିଫଳ", + "ILLNESS": "ରୋଗ", + "MARRIAGE": "ବିବାହ", + "MIGRATION": "ପରିବର୍ତ୍ତନ", + "STARTED_VOCATIONAL_COURSE": "ପେଶାଗତ ପାଠ୍ୟକ୍ରମ ଆରମ୍ଭ କରିଛନ୍ତି", + "STARTED_A_JOB": "ଏକ କାମ ଆରମ୍ଭ କରିଛନ୍ତି", + "SCHOOL_CLOSURE_DUE_TO_COVID": "କୋଭିଡ୍ ଦ୍ବାରା ପାଠଶାଳା ବନ୍ଦ", + "MARITAL_STATUS": "ବିବାହିତ ଅବସ୍ଥା", + "UNMARRIED": "ବିବାହିତ ନୁହେଁ", + "MARRIED": "ବିବାହିତ", + "DIVORCED": "ବିବାହ ବିଚ୍ଛିନ୍ନ", + "PHONE_TYPE_AVAILABLE": "ଉପଲବ୍ଧ ଫୋନର ପ୍ରକାର", + "SMARTPHONE": "ସ୍ମାର୍ଟଫୋନ୍", + "KEYPAD": "କୀପ୍ୟାଡ୍", + "NO_PHONE": "କୌଣସି ଫୋନ୍ ନାହିଁ", + "IS_IT_YOUR_OWN_PHONE": "ଏହା ଆପଣଙ୍କ ନିଜର ଫୋନ୍ କି?", + "YES": "ହଁ", + "NO": "ନାହିଁ", + "TYPE_OF_PHONE_AVAILABLE": "ଉପଲବ୍ଧ ଫୋନର ପ୍ରକାର", + "REASON_FOR_DROP_OUT_FROM_SCHOOL": "ପାଠଶାଳାରୁ ତ୍ୟାଗ କରିବାର କାରଣ", + "EMAIL": "ଇମେଲ୍", + "YEAR_OF_ JOINING_SCP": "SCP ମଧ୍ୟରେ ସାମିଲ ହେବାର ବର୍ଷ", + "ASSIGN_CENTERS": "କେନ୍ଦ୍ର ସୁପର୍ଦ୍ଦ କରନ୍ତୁ" } -} +} \ No newline at end of file From 18c6e769754b9892778dbc502b537411d5433067 Mon Sep 17 00:00:00 2001 From: Akshata Katwal Date: Thu, 19 Sep 2024 16:05:46 +0530 Subject: [PATCH 13/40] update pr :update cohortmember list api as per new response --- src/components/UserTable.tsx | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/components/UserTable.tsx b/src/components/UserTable.tsx index ebc059d1..12d7687a 100644 --- a/src/components/UserTable.tsx +++ b/src/components/UserTable.tsx @@ -677,19 +677,19 @@ const UserTable: React.FC = ({ { finalResult = result?.map((user: any) => { const ageField = user?.customField?.find( - (field: any) => field?.fieldname === "AGE" + (field: any) => field?.label === "AGE" ); const genderField = user?.customField?.find( - (field: any) => field?.fieldname === "GENDER" + (field: any) => field?.label === "GENDER" ); const blockField = user?.customField?.find( - (field: any) => field?.fieldname === "BLOCKS" + (field: any) => field?.label === "BLOCKS" ); const districtField = user?.customField?.find( - (field: any) => field?.fieldname === "DISTRICTS" + (field: any) => field?.label === "DISTRICTS" ); const stateField = user?.customField?.find( - (field: any) => field?.fieldname === "STATES" + (field: any) => field?.label === "STATES" ); return { userId: user?.userId, @@ -701,13 +701,13 @@ const UserTable: React.FC = ({ role: user.role, // gender: user.gender, mobile: user.mobile === "NaN" ? "-" : user.mobile, - age: ageField ? ageField?.fieldvalues : "-", - district: districtField ? districtField?.fieldvalues+" , "+blockField?.fieldvalues : "-", - state: stateField ? stateField?.fieldvalues : "-", - blocks: blockField ? blockField?.fieldvalues : "-", + age: ageField ? ageField?.value : "-", + district: districtField ? districtField?.value+" , "+blockField?.value : "-", + state: stateField ? stateField?.value : "-", + blocks: blockField ? blockField?.value : "-", gender: genderField - ? genderField.fieldvalues?.charAt(0)?.toUpperCase() + - genderField.fieldvalues.slice(1).toLowerCase() + ? genderField.value?.charAt(0)?.toUpperCase() + + genderField.value.slice(1).toLowerCase() : "-", // createdAt: user?.createdAt, // updatedAt: user?.updatedAt, From e47210332a5b505936e3458de0f65cfac15824bc Mon Sep 17 00:00:00 2001 From: Akshata Katwal Date: Thu, 19 Sep 2024 19:54:35 +0530 Subject: [PATCH 14/40] Issue feat:PS-2028 Add bydefault state district block and center selection and change route path according to that --- public/locales/en/common.json | 19 +- src/components/AreaSelection.tsx | 10 +- src/components/FormControl.tsx | 2 +- src/components/HeaderComponent.tsx | 66 ++++++- src/components/UserTable.tsx | 278 +++++++++++++++++++++++++---- 5 files changed, 324 insertions(+), 51 deletions(-) diff --git a/public/locales/en/common.json b/public/locales/en/common.json index 5fb9a256..3fb48589 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -112,7 +112,6 @@ "NEW": "New {{role}}", "USER_CREDENTIAL_SEND_SUCCESSFULLY": "User credentials sent successfully!", "USER_CREDENTIALS_WILL_BE_SEND_SOON": "User credentials will be sent soon", - "REASSIGN_CENTERS": "Re-assign Center", "REASSIGN_BLOCKS": "Re-assign Blocks", "REASSIGN": "Reassign", @@ -125,10 +124,9 @@ "DELETE_COHORT_WARNING": "Do you want to delete user from cohort?", "NO_CENTER_AVAILABLE": "No centers available", "NO_BLOCK_AVAILABLE": "No blocks available", - "PLEASE_SELECT_BLOCK_LIST":"Please select block from block list" - - - + "PLEASE_SELECT_BLOCK_LIST": "Please select block from block list", + "ALL_CENTERS": "All centers", + "NO_CENTERS": "No centers" }, "LOGIN_PAGE": { "USERNAME": "Username", @@ -162,7 +160,6 @@ "SEARCHBAR_PLACEHOLDER": "Search Facilitators..", "FACILITATOR_CREATED_SUCCESSFULLY": "Teacher is created, and credentials sent successfully!", "USER_CREDENTIALS_WILL_BE_SEND_SOON": "Teacher is created ,credentials will be sent soon", - "FACILITATOR_UPDATED_SUCCESSFULLY": "Teacher has been successfully updated!", "EDIT_FACILITATOR": "Edit Facilitator" }, @@ -175,7 +172,6 @@ "FIRST_SELECT_REQUIRED_FIELDS": "First select required fields", "LEARNER_CREATED_SUCCESSFULLY": "Learner has been successfully created!", "USER_CREDENTIALS_WILL_BE_SEND_SOON": "Learner is created, credentials will be sent soon", - "LEARNER_UPDATED_SUCCESSFULLY": "Learner has been successfully updated!", "EDIT_LEARNER": "Edit Learner" }, @@ -185,14 +181,12 @@ "FIRST_SELECT_REQUIRED_FIELDS": "First select required fields", "TEAM_LEADER_CREATED_SUCCESSFULLY": "Team Leader is created, and credentials sent successfully!", "USER_CREDENTIALS_WILL_BE_SEND_SOON": "Team Leader is created ,credentials will be sent soon", - "TEAM_LEADER_UPDATED_SUCCESSFULLY": "Team Leader has been successfully updated!", "EDIT_TEAM_LEADER": "Edit Team Leader" }, "ADMIN": { "ADMIN_UPDATED_SUCCESSFULLY": "Admin has been successfully updated!" }, - "COHORTS": { "SEARCHBAR_PLACEHOLDER": "Search Center.." }, @@ -214,12 +208,11 @@ "UPLOAD": "Upload", "COURSE_CREATED_SUCCESSFULLY": "Course created successfully", "COURSE_NOT_CREATED": "Course not created", - "SUB-TOPIC":"Sub-topic", - "SUBTOPICS":"Sub-Topics", + "SUB-TOPIC": "Sub-topic", + "SUBTOPICS": "Sub-Topics", "RESOURCES": "Resources", "TOPIC": "Topic", "DURATION/MONTH": "Duration/Month" - }, "MASTER": { "STATE": "States", @@ -391,4 +384,4 @@ "CODE": "Code", "DISTRICT": "District" } -} +} \ No newline at end of file diff --git a/src/components/AreaSelection.tsx b/src/components/AreaSelection.tsx index 01ae8c00..2aa4e7e1 100644 --- a/src/components/AreaSelection.tsx +++ b/src/components/AreaSelection.tsx @@ -170,6 +170,8 @@ const shouldRenderSelectCheckmarks = } overall={!inModal} defaultValue={ + //districtDefaultValue? districtDefaultValue: + reAssignModal ? districtDefaultValue : selectedState.length > 0 && districts?.length === 0 @@ -186,7 +188,7 @@ const shouldRenderSelectCheckmarks = selectedCategories={capitalizeFirstLetterOfEachWordInArray(selectedBlock)} onCategoryChange={handleBlockChangeWrapper} disabled={ - blockDefaultValue? false: + // blockDefaultValue? false: blocks?.length <= 0 || selectedDistrict?.length === 0 || @@ -212,6 +214,12 @@ const shouldRenderSelectCheckmarks = onCategoryChange={handleCenterChangeWrapper} disabled={selectedBlock.length === 0 || selectedCenter[0] === ""} overall={!inModal} + defaultValue={ + // blockDefaultValue? blockDefaultValue: + selectedBlock?.length > 0 && blocks?.length <= 0 + ? t("COMMON.NO_CENTERS") + : t("COMMON.ALL_CENTERS") + } /> )} diff --git a/src/components/FormControl.tsx b/src/components/FormControl.tsx index b5cad019..ac5ee06d 100644 --- a/src/components/FormControl.tsx +++ b/src/components/FormControl.tsx @@ -85,7 +85,7 @@ const MultipleSelectCheckmarks: React.FC = ({ } onChange={handleChange} input={} - renderValue={(selected) => selected.join(", ")} + renderValue={(selected) => selected?.join(", ")} MenuProps={MenuProps} > {overall && ( diff --git a/src/components/HeaderComponent.tsx b/src/components/HeaderComponent.tsx index 89daf7e7..684f7066 100644 --- a/src/components/HeaderComponent.tsx +++ b/src/components/HeaderComponent.tsx @@ -24,6 +24,7 @@ import { transformArray } from "../utils/Helper"; import Tab from "@mui/material/Tab"; import Tabs from "@mui/material/Tabs"; import { useQueryClient } from "@tanstack/react-query"; +import { formatedBlocks, formatedDistricts } from "@/services/formatedCohorts"; interface State { value: string; @@ -73,7 +74,15 @@ const HeaderComponent = ({ statusValue, shouldFetchDistricts = true, setStatusValue, + setSelectedDistrictCode, + setSelectedDistrict, + setSelectedBlockCode, + setSelectedBlock, + setSelectedCenter, + selectedCenterCode, + setSelectedCenterCode }: any) => { + const { t } = useTranslation(); const queryClient = useQueryClient(); @@ -118,6 +127,7 @@ const HeaderComponent = ({ // console.log(object); // const response = await getStateBlockDistrictList(object); const result = response?.result?.values; + setDistricts(result); } catch (error) { console.log(error); @@ -150,7 +160,9 @@ const HeaderComponent = ({ // }; // const response = await getStateBlockDistrictList(object); const result = response?.result?.values; - setBlocks(result); + const blockResult=await formatedBlocks(selectedCodes[0]) + + setBlocks(blockResult); } catch (error) { console.log(error); } @@ -251,7 +263,57 @@ const HeaderComponent = ({ // console.log(object); // const response = await getStateBlockDistrictList(object); const result = response?.result?.values; - setDistricts(result); + const districtResult= await formatedDistricts(); + + setDistricts(districtResult); + setSelectedDistrict([districtResult[0]?.label]) + setSelectedDistrictCode(districtResult[0]?.value) + const blockResult=await formatedBlocks(districtResult[0]?.value) + setBlocks(blockResult); + + setSelectedBlock([blockResult[0]?.label]) + setSelectedBlockCode(blockResult[0]?.value) + const getCentersObject = { + limit: 0, + offset: 0, + filters: { + // "type":"COHORT", + status: ["active"], + states: stateField.code, + districts: districtResult[0]?.value, + blocks: blockResult[0]?.value, + // "name": selected[0] + }, + }; + const centerResponse = await queryClient.fetchQuery({ + queryKey: [ + QueryKeys.FIELD_OPTION_READ, + getCentersObject.limit, + getCentersObject.offset, + getCentersObject.filters, + ], + queryFn: () => getCenterList(getCentersObject), + }); + // const response = await getCenterList(getCentersObject); + console.log(centerResponse); + // setSelectedBlockCohortId( + // response?.result?.results?.cohortDetails[0].cohortId + // ); + // const result = response?.result?.cohortDetails; + const dataArray = centerResponse?.result?.results?.cohortDetails; + console.log(dataArray); + + const cohortInfo = dataArray + ?.filter((cohort: any) => cohort.type !== "BLOCK") + .map((item: any) => ({ + cohortId: item?.cohortId, + name: item?.name, + })); + console.log(dataArray); + setAllCenters(cohortInfo); + setSelectedCenter([cohortInfo[0]?.name]) + setSelectedCenterCode(cohortInfo[0]?.cohortId) + console.log(cohortInfo) } const object = [ diff --git a/src/components/UserTable.tsx b/src/components/UserTable.tsx index 12d7687a..c8f879a3 100644 --- a/src/components/UserTable.tsx +++ b/src/components/UserTable.tsx @@ -32,6 +32,7 @@ import ReassignCenterModal from "./ReassignCenterModal"; import { getCenterList, getStateBlockDistrictList } from "@/services/MasterDataService"; import { updateCohortMemberStatus } from "@/services/CohortService/cohortService"; import useSubmittedButtonStore from "@/utils/useSharedState"; +import { useRouter } from "next/router"; type UserDetails = { userId: any; username: any; @@ -96,6 +97,7 @@ const UserTable: React.FC = ({ const [selectedState, setSelectedState] = React.useState([]); const [blockMembershipIdList, setBlockMembershipIdList] = React.useState([]); const [centerMembershipIdList, setCenterMembershipIdList] = React.useState([]); + const router = useRouter(); const [selectedStateCode, setSelectedStateCode] = useState(""); @@ -138,6 +140,8 @@ const UserTable: React.FC = ({ const [otherReason, setOtherReason] = useState(""); const [deleteUserState, setDeleteUserState] = useState(false); const [selectedCenter, setSelectedCenter] = useState([]); + const [selectedCenterCode, setSelectedCenterCode] = useState([]); + const [enableCenterFilter, setEnableCenterFilter] = useState(false); @@ -154,6 +158,7 @@ const UserTable: React.FC = ({ const [openAddLearnerModal, setOpenAddLearnerModal] = React.useState(false); const [userId, setUserId] = useState(); const [submitValue, setSubmitValue] = useState(false); + console.log(selectedBlockCode) const reassignButtonStatus = useSubmittedButtonStore( (state: any) => state.reassignButtonStatus ); @@ -251,11 +256,22 @@ const UserTable: React.FC = ({ /> ); const handleStateChange = async (selected: string[], code: string[]) => { + setSelectedCenterCode([]) + setEnableCenterFilter(false) setSelectedDistrict([]); - setSelectedBlock([]); + setSelectedCenter([]); + setSelectedBlock([]); + setSelectedBlockCode(""); + setSelectedDistrictCode(""); setSelectedState(selected); + const updatedQuery = { ...router.query }; + delete updatedQuery.districtCode; + delete updatedQuery.blockCode; + delete updatedQuery.center; + + console.log(selected[0]) if (selected[0] === "" || selected[0] === t("COMMON.ALL_STATES")) { if (filters.status) setFilters({ status: [filters.status], role: role }); @@ -302,12 +318,19 @@ const UserTable: React.FC = ({ }; const handleDistrictChange = (selected: string[], code: string[]) => { + setSelectedCenterCode([]) + setEnableCenterFilter(false) + setSelectedCenter([]); setSelectedBlock([]); setSelectedDistrict(selected); +setSelectedBlockCode(""); - +router.replace({ + pathname: router.pathname, + query: { ...router.query, stateCode: selectedStateCode ,districtCode: selected[0] } +}); if (selected[0] === "" || selected[0] === t("COMMON.ALL_DISTRICTS")) { if (filters.status) { setFilters({ @@ -344,8 +367,10 @@ const UserTable: React.FC = ({ console.log("Selected categories:", selected); }; const handleBlockChange = (selected: string[], code: string[]) => { - setEnableCenterFilter(false) + setSelectedCenterCode([]) + setEnableCenterFilter(false) + setSelectedCenter([]); setSelectedBlock(selected); if (selected[0] === "" || selected[0] === t("COMMON.ALL_BLOCKS")) { if (filters.status) { @@ -387,17 +412,47 @@ const UserTable: React.FC = ({ console.log("Selected categories:", selected); }; const handleCenterChange = async(selected: string[], code: string[]) => { + setSelectedCenterCode([code[0]]) + setSelectedCenter(selected) + console.log(selected[0]) + if (selected[0] === "" || selected[0] === t("COMMON.ALL_CENTERS")) { + setEnableCenterFilter(false) - setEnableCenterFilter(true) - setFilters({ - // states: selectedStateCode, - // districts: selectedDistrictCode, - // blocks: blocks, - cohortId:code[0], - role: role, - status:[statusValue] - }); + if (filters.status) { + setFilters({ + states: selectedStateCode, + districts: selectedDistrictCode, + blocks: selectedBlockCode, + role: role, + status: filters.status, + + }); + } else { + setFilters({ + states: selectedStateCode, + districts: selectedDistrictCode, + blocks: selectedBlockCode, + role: role, + }); + } + } + else + { + setEnableCenterFilter(true) + + setFilters({ + // states: selectedStateCode, + // districts: selectedDistrictCode, + // blocks: blocks, + cohortId:code[0], + role: role, + status:[statusValue] + }); + + } + + }; const handleSortChange = async (event: SelectChangeEvent) => { @@ -706,8 +761,8 @@ const UserTable: React.FC = ({ state: stateField ? stateField?.value : "-", blocks: blockField ? blockField?.value : "-", gender: genderField - ? genderField.value?.charAt(0)?.toUpperCase() + - genderField.value.slice(1).toLowerCase() + ? genderField?.value?.charAt(0)?.toUpperCase() + + genderField?.value?.slice(1).toLowerCase() : "-", // createdAt: user?.createdAt, // updatedAt: user?.updatedAt, @@ -726,7 +781,7 @@ const UserTable: React.FC = ({ (field: any) => field?.label === "AGE" ); const genderField = user?.customFields?.find( - (field: any) => field?.label === "GENDER" + (field: any) => field?.label === "GENDER" ); const blockField = user?.customFields?.find( (field: any) => field?.label === "BLOCKS" @@ -748,11 +803,11 @@ const UserTable: React.FC = ({ user.name.slice(1).toLowerCase(), role: user.role, // gender: user.gender, - mobile: user.mobile === "NaN" ? "-" : user.mobile, - age: ageField ? ageField.value : "-", - district: districtField ? districtField.value+" , "+blockField.value : "-", - state: stateField ? stateField.value : "-", - blocks: blockField ? blockField.value : "-", + mobile: user.mobile === "NaN" ? "-" : user?.mobile, + age: ageField ? ageField?.value : "-", + district: districtField ? districtField?.value+" , "+blockField?.value : "-", + state: stateField ? stateField?.value : "-", + blocks: blockField ? blockField?.value : "-", gender: genderField ? genderField.value?.charAt(0)?.toUpperCase() + genderField.value.slice(1).toLowerCase() @@ -801,7 +856,12 @@ const UserTable: React.FC = ({ console.log(error); } }; - fetchUserList(); + console.log(data ) + if (selectedBlockCode !== "" || (selectedDistrictCode !== "" && selectedBlockCode === "")) { + fetchUserList(); + } + // fetchUserList(); + }, [ pageOffset, submitValue, @@ -811,7 +871,8 @@ const UserTable: React.FC = ({ parentState, deleteUserState, sortByForCohortMemberList, - reassignButtonStatus + reassignButtonStatus, + enableCenterFilter ]); useEffect(() => { @@ -889,19 +950,32 @@ const UserTable: React.FC = ({ if (!stateField.value.includes(',')) { setSelectedState([stateField.value]); setSelectedStateCode(stateField.code) - setFilters({ - states: stateField.code, - role: role, - status:[statusValue], - } + + + // setFilters({ + // states: stateField.code, + // //districts:selectedDistrictCode, + // // blocks:selectedBlockCode, + // role: role, + // status:[statusValue], + // } - ) + // ) + if(selectedBlockCode && selectedDistrictCode) + { + setFilters({ + states: stateField.code, + districts:selectedDistrictCode, + blocks:selectedBlockCode, + role: role, + status:[statusValue], + }) + } + + } - const object=[{ - value:stateField.code, - label:stateField.value - }] + // setStates(object); } @@ -913,12 +987,140 @@ const UserTable: React.FC = ({ }; fetchData(); - }, []); + }, [selectedBlockCode, selectedDistrictCode]); + useEffect(() => { + const fetchData = () => { + console.log(selectedCenter.length) + if(userType===Role.TEAM_LEADERS) + { + setEnableCenterFilter(false); + + } + else{ + if(selectedCenter.length!==0) + { + if (selectedCenter[0] === "" || selectedCenter[0] === t("COMMON.ALL_CENTERS")) { + setEnableCenterFilter(false); + + } + else + { + setEnableCenterFilter(true); + + } + //setEnableCenterFilter(true); + if(selectedCenterCode.length!==0) + { setFilters({ + // states: selectedStateCode, + // districts: selectedDistrictCode, + // blocks: blocks, + cohortId:selectedCenterCode, + role: role, + status:[statusValue] + });} + + + } + else{ + setEnableCenterFilter(false) + setSelectedCenterCode([]) + } + } + + + + }; + + fetchData(); + }, [selectedCenter, selectedCenterCode]); + +useEffect(() => { + // Handle replacement when only state and district codes are available + if (selectedStateCode!=="" && selectedDistrictCode==="" && selectedBlockCode==="") { + const newQuery = { ...router.query }; + console.log(newQuery) + + if (newQuery.center) { + delete newQuery.center; + } + if (newQuery.district) { + delete newQuery.district; + } + if (newQuery.block) { + delete newQuery.block; + } + router.replace({ + pathname: router.pathname, + query: { + ...newQuery, + state: selectedStateCode, + } + }); + } + if (selectedStateCode!=="" && selectedDistrictCode!=="" && selectedBlockCode==="") { + const newQuery = { ...router.query }; + console.log(newQuery) + + if (newQuery.center) { + delete newQuery.center; + } + if (newQuery.block) { + delete newQuery.block; + } + router.replace({ + pathname: router.pathname, + query: { + ...newQuery, + state: selectedStateCode, + district: selectedDistrictCode + } + }); + } + // Handle replacement when state, district, and block codes are available + if (selectedStateCode!=="" && selectedDistrictCode!=="" && selectedBlockCode!=="" && selectedCenter.length === 0) { + console.log("heyyy") + const newQuery = { ...router.query }; + if (newQuery.center) { + delete newQuery.center; + } + if (newQuery.block) { + delete newQuery.block; + } + router.replace({ + pathname: router.pathname, + query: { + ...newQuery, + state: selectedStateCode, + district: selectedDistrictCode, + block: selectedBlockCode + } + }); + } + + // Handle replacement when state, district, block, and center are all selected + if (selectedStateCode !==""&& selectedDistrictCode!=="" && selectedBlockCode!=="" && selectedCenter.length !== 0) { + console.log("heyyy") + + console.log(selectedCenter); + if (userType !== Role.TEAM_LEADERS) { + router.replace({ + pathname: router.pathname, + query: { + ...router.query, + state: selectedStateCode, + district: selectedDistrictCode, + block: selectedBlockCode, + center: selectedCenter + } + }); + } + } +}, [selectedStateCode, selectedDistrictCode, selectedBlockCode, selectedCenter]); @@ -1024,7 +1226,9 @@ const UserTable: React.FC = ({ searchPlaceHolder: searchPlaceholder, selectedState: selectedState, selectedDistrict: selectedDistrict, + setSelectedDistrict:setSelectedDistrict, selectedBlock: selectedBlock, + setSelectedBlock:setSelectedBlock, selectedSort: selectedSort, statusValue:statusValue, setStatusValue:setStatusValue, @@ -1037,11 +1241,17 @@ const UserTable: React.FC = ({ handleSearch: handleSearch, handleAddUserClick: handleAddUserClick, selectedBlockCode: selectedBlockCode, + setSelectedBlockCode:setSelectedBlockCode, selectedDistrictCode: selectedDistrictCode, + setSelectedDistrictCode:setSelectedDistrictCode, selectedStateCode: selectedStateCode, handleCenterChange:handleCenterChange, - selectedCenter: selectedCenter + selectedCenter: selectedCenter, + setSelectedCenter:setSelectedCenter, + selectedCenterCode:selectedCenterCode, + setSelectedCenterCode: setSelectedCenterCode }; + return ( From 892c63d927e39abf2ff4e892204b3f038460bb14 Mon Sep 17 00:00:00 2001 From: Akshata Katwal Date: Thu, 19 Sep 2024 20:02:54 +0530 Subject: [PATCH 15/40] update pr: remove unwanted code --- src/components/UserTable.tsx | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/components/UserTable.tsx b/src/components/UserTable.tsx index c8f879a3..9670227c 100644 --- a/src/components/UserTable.tsx +++ b/src/components/UserTable.tsx @@ -266,11 +266,7 @@ const UserTable: React.FC = ({ setSelectedBlockCode(""); setSelectedDistrictCode(""); setSelectedState(selected); - const updatedQuery = { ...router.query }; - delete updatedQuery.districtCode; - delete updatedQuery.blockCode; - delete updatedQuery.center; - + console.log(selected[0]) if (selected[0] === "" || selected[0] === t("COMMON.ALL_STATES")) { From 0b918012674ed94916aaa123da887421b30b3364 Mon Sep 17 00:00:00 2001 From: Akshata Katwal Date: Fri, 20 Sep 2024 13:11:40 +0530 Subject: [PATCH 16/40] Issue feat: update username created user according to year of joining --- src/components/CommonUserModal.tsx | 14 +++++++++++++- src/components/UserTable.tsx | 6 +++--- src/utils/Helper.ts | 10 +++++++--- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/components/CommonUserModal.tsx b/src/components/CommonUserModal.tsx index 69c57a52..ffaac1b5 100644 --- a/src/components/CommonUserModal.tsx +++ b/src/components/CommonUserModal.tsx @@ -229,7 +229,19 @@ const CommonUserModal: React.FC = ({ const formData = data.formData; console.log("Form data submitted:", formData); const schemaProperties = schema.properties; - const result = generateUsernameAndPassword(selectedStateCode, userType); + + console.log(formData['year of joining scp']) + let result; + if(formData['year of joining scp']) + { + result = generateUsernameAndPassword(selectedStateCode, userType, formData['year of joining scp']); + + } + else + { + result = generateUsernameAndPassword(selectedStateCode, userType); + + } if (result !== null) { const { username, password } = result; diff --git a/src/components/UserTable.tsx b/src/components/UserTable.tsx index 9670227c..864cd533 100644 --- a/src/components/UserTable.tsx +++ b/src/components/UserTable.tsx @@ -538,9 +538,9 @@ router.replace({ return initialFormData; }; const handleEdit = async (rowData: any) => { - if (submitValue) { - setSubmitValue(false); - } + + submitValue ? setSubmitValue(false) : setSubmitValue(true); + console.log("Edit row:", rowData); try { diff --git a/src/utils/Helper.ts b/src/utils/Helper.ts index 391df1ee..a31a0136 100644 --- a/src/utils/Helper.ts +++ b/src/utils/Helper.ts @@ -65,7 +65,10 @@ export const getDeviceId = () => { export const generateUsernameAndPassword = ( stateCode: string, - role: string + role: string, + yearOfJoining?: string, + + ) => { const currentYear = new Date().getFullYear().toString().slice(-2); // Last two digits of the current year const randomNum = Math.floor(10000 + Math.random() * 90000).toString(); //NOSONAR @@ -80,9 +83,10 @@ export const generateUsernameAndPassword = ( console.warn(`Unknown role: ${role}`); // Log a warning for unknown roles return null; // Return null or handle as needed } - + const yearSuffix = + yearOfJoining ? yearOfJoining?.slice(-2) : currentYear; const prefix = rolePrefixes[role]; - const username = `${prefix}${stateCode}${currentYear}${randomNum}`; + const username = `${prefix}${stateCode}${yearSuffix}${randomNum}`; return { username, password: randomNum }; }; From 2d87f187060888a1eff332a79d16d4ed6cb521e4 Mon Sep 17 00:00:00 2001 From: Akshata Katwal Date: Fri, 20 Sep 2024 14:49:18 +0530 Subject: [PATCH 17/40] Issue feat: Return state, district block code from cohort member API response --- src/components/UserTable.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/components/UserTable.tsx b/src/components/UserTable.tsx index 864cd533..978beac4 100644 --- a/src/components/UserTable.tsx +++ b/src/components/UserTable.tsx @@ -604,6 +604,7 @@ router.replace({ setCohortId(rowData?.cohortIds); setBlock(rowData?.blocks) console.log(rowData?.districtValue) + setDistrict(rowData?.districtValue) setDistrictCode(rowData?.districtCode) setBlockCode(rowData?.blockCode) @@ -764,6 +765,12 @@ router.replace({ // updatedAt: user?.updatedAt, createdBy: user?.createdBy, updatedBy: user?.updatedBy, + stateCode:stateField?.code, + + districtCode:districtField?.code, + blockCode:blockField?.code, + districtValue:districtField? districtField?.value: "-" + // // centers: null, // Programs: null, }; From 63893275d04ad4aefeb07e33277172c512125439 Mon Sep 17 00:00:00 2001 From: Akshata Katwal Date: Fri, 20 Sep 2024 15:25:56 +0530 Subject: [PATCH 18/40] Issue feat: change route name for team leader --- src/components/layouts/sidebar/MenuItems.js | 2 +- src/pages/team-leader.tsx | 5 ++ src/pages/teamLeader.tsx | 59 --------------------- 3 files changed, 6 insertions(+), 60 deletions(-) delete mode 100644 src/pages/teamLeader.tsx diff --git a/src/components/layouts/sidebar/MenuItems.js b/src/components/layouts/sidebar/MenuItems.js index c63407c8..a351f0f5 100644 --- a/src/components/layouts/sidebar/MenuItems.js +++ b/src/components/layouts/sidebar/MenuItems.js @@ -27,7 +27,7 @@ const Menuitems = [ subOptions: [ { title: "SIDEBAR.TEAM_LEADERS", - href: "/teamLeader", + href: "/team-leader", }, { title: "SIDEBAR.FACILITATORS", diff --git a/src/pages/team-leader.tsx b/src/pages/team-leader.tsx index b7cf2c6e..6277123e 100644 --- a/src/pages/team-leader.tsx +++ b/src/pages/team-leader.tsx @@ -4,12 +4,15 @@ import UserTable from "@/components/UserTable"; import { useTranslation } from "next-i18next"; import { Role, FormContextType } from "@/utils/app.constant"; import CommonUserModal from "@/components/CommonUserModal"; +import useSubmittedButtonStore from "@/utils/useSharedState"; + const TeamLeader: React.FC = () => { const { t } = useTranslation(); const handleAddTeamLeaderClick = () => { handleOpenAddTeamLeaderModal(); }; const [submitValue, setSubmitValue] = React.useState(false); + const setSubmittedButtonStatus = useSubmittedButtonStore((state:any) => state.setSubmittedButtonStatus); const [openAddTeamLeaderModal, setOpenAddTeamLeaderModal] = React.useState(false); @@ -20,6 +23,8 @@ const TeamLeader: React.FC = () => { setSubmitValue(true); }; const handleCloseAddTeamLeaderModal = () => { + setSubmittedButtonStatus(false) + setOpenAddTeamLeaderModal(false); }; diff --git a/src/pages/teamLeader.tsx b/src/pages/teamLeader.tsx deleted file mode 100644 index 6277123e..00000000 --- a/src/pages/teamLeader.tsx +++ /dev/null @@ -1,59 +0,0 @@ -import React from "react"; -import { serverSideTranslations } from "next-i18next/serverSideTranslations"; -import UserTable from "@/components/UserTable"; -import { useTranslation } from "next-i18next"; -import { Role, FormContextType } from "@/utils/app.constant"; -import CommonUserModal from "@/components/CommonUserModal"; -import useSubmittedButtonStore from "@/utils/useSharedState"; - -const TeamLeader: React.FC = () => { - const { t } = useTranslation(); - const handleAddTeamLeaderClick = () => { - handleOpenAddTeamLeaderModal(); - }; - const [submitValue, setSubmitValue] = React.useState(false); - const setSubmittedButtonStatus = useSubmittedButtonStore((state:any) => state.setSubmittedButtonStatus); - - const [openAddTeamLeaderModal, setOpenAddTeamLeaderModal] = - React.useState(false); - const handleOpenAddTeamLeaderModal = () => { - setOpenAddTeamLeaderModal(true); - }; - const handleModalSubmit = (value: boolean) => { - setSubmitValue(true); - }; - const handleCloseAddTeamLeaderModal = () => { - setSubmittedButtonStatus(false) - - setOpenAddTeamLeaderModal(false); - }; - - return ( - <> - - - - - ); -}; - -export async function getStaticProps({ locale }: any) { - return { - props: { - ...(await serverSideTranslations(locale, ["common"])), - }, - }; -} - -export default TeamLeader; From eed76248e506167825cc363989eb141da1e571da Mon Sep 17 00:00:00 2001 From: vivek kasture Date: Fri, 20 Sep 2024 19:35:39 +0530 Subject: [PATCH 19/40] Issue #PS-000 fix: Resolved UT issues --- src/components/CommonUserModal.tsx | 553 +++++++++++++++-------------- src/utils/Helper.ts | 4 +- 2 files changed, 280 insertions(+), 277 deletions(-) diff --git a/src/components/CommonUserModal.tsx b/src/components/CommonUserModal.tsx index ffaac1b5..ddd2433b 100644 --- a/src/components/CommonUserModal.tsx +++ b/src/components/CommonUserModal.tsx @@ -9,23 +9,29 @@ import { getFormRead, updateUser, } from "@/services/CreateUserService"; -import { generateUsernameAndPassword } from "@/utils/Helper"; +import { sendCredentialService } from "@/services/NotificationService"; +import { firstLetterInUpperCase, generateUsernameAndPassword } from "@/utils/Helper"; import { FormData } from "@/utils/Interfaces"; -import { FormContext, FormContextType, RoleId ,Role, apiCatchingDuration} from "@/utils/app.constant"; +import { + FormContext, + FormContextType, + Role, + RoleId, + apiCatchingDuration, +} from "@/utils/app.constant"; import { useLocationState } from "@/utils/useLocationState"; import useSubmittedButtonStore from "@/utils/useSharedState"; import { Box, Button, useTheme } from "@mui/material"; import { IChangeEvent } from "@rjsf/core"; import { RJSFSchema } from "@rjsf/utils"; +import { useQuery } from "@tanstack/react-query"; import { useTranslation } from "next-i18next"; import React, { useEffect, useState } from "react"; import { tenantId } from "../../app.config"; import { transformArray } from "../utils/Helper"; import AreaSelection from "./AreaSelection"; +import SendCredentialModal from "./SendCredentialModal"; import { showToastMessage } from "./Toastify"; -import SendCredentialModal from './SendCredentialModal'; -import { sendCredentialService } from "@/services/NotificationService"; -import { useQuery } from "@tanstack/react-query"; interface UserModalProps { open: boolean; @@ -54,13 +60,16 @@ const CommonUserModal: React.FC = ({ const messageKeyMap: Record = { [FormContextType.STUDENT]: "LEARNERS.LEARNER_CREATED_SUCCESSFULLY", [FormContextType.TEACHER]: "FACILITATORS.FACILITATOR_CREATED_SUCCESSFULLY", - [FormContextType.TEAM_LEADER]: "TEAM_LEADERS.TEAM_LEADER_CREATED_SUCCESSFULLY", + [FormContextType.TEAM_LEADER]: + "TEAM_LEADERS.TEAM_LEADER_CREATED_SUCCESSFULLY", [FormContextType.ADMIN]: "ADMIN.ADMIN_UPDATED_SUCCESSFULLY", }; const delayCredentialsMessageMap: Record = { [FormContextType.STUDENT]: "LEARNERS.USER_CREDENTIALS_WILL_BE_SEND_SOON", - [FormContextType.TEACHER]: "FACILITATORS.USER_CREDENTIALS_WILL_BE_SEND_SOON", - [FormContextType.TEAM_LEADER]: "TEAM_LEADERS.USER_CREDENTIALS_WILL_BE_SEND_SOON", + [FormContextType.TEACHER]: + "FACILITATORS.USER_CREDENTIALS_WILL_BE_SEND_SOON", + [FormContextType.TEAM_LEADER]: + "TEAM_LEADERS.USER_CREDENTIALS_WILL_BE_SEND_SOON", }; const [submitButtonEnable, setSubmitButtonEnable] = React.useState(false); @@ -77,36 +86,38 @@ const CommonUserModal: React.FC = ({ const setSubmittedButtonStatus = useSubmittedButtonStore( (state: any) => state.setSubmittedButtonStatus ); - const noError = useSubmittedButtonStore( - (state: any) => state.noError); + const noError = useSubmittedButtonStore((state: any) => state.noError); - const userEnteredEmail = useSubmittedButtonStore( + const userEnteredEmail = useSubmittedButtonStore( (state: any) => state.userEnteredEmail ); - const { data:teacherFormData ,isLoading: teacherFormDataLoading, error :teacherFormDataErrror} = useQuery({ + const { + data: teacherFormData, + isLoading: teacherFormDataLoading, + error: teacherFormDataErrror, + } = useQuery({ queryKey: ["teacherFormData"], - queryFn: () => getFormRead( - FormContext.USERS, - FormContextType.TEACHER - ), + queryFn: () => getFormRead(FormContext.USERS, FormContextType.TEACHER), staleTime: apiCatchingDuration.GETREADFORM, - }) - const { data:studentFormData ,isLoading: studentFormDataLoading, error :studentFormDataErrror} = useQuery({ + }); + const { + data: studentFormData, + isLoading: studentFormDataLoading, + error: studentFormDataErrror, + } = useQuery({ queryKey: ["studentFormData"], - queryFn: () => getFormRead( - FormContext.USERS, - FormContextType.STUDENT - ), - staleTime: apiCatchingDuration.GETREADFORM, - }) - const { data:teamLeaderFormData ,isLoading: teamLeaderFormDataLoading, error :teamLeaderFormDataErrror} = useQuery({ + queryFn: () => getFormRead(FormContext.USERS, FormContextType.STUDENT), + staleTime: apiCatchingDuration.GETREADFORM, + }); + const { + data: teamLeaderFormData, + isLoading: teamLeaderFormDataLoading, + error: teamLeaderFormDataErrror, + } = useQuery({ queryKey: ["teamLeaderFormData"], - queryFn: () => getFormRead( - FormContext.USERS, - FormContextType.TEAM_LEADER - ), - staleTime: apiCatchingDuration.GETREADFORM, - }) + queryFn: () => getFormRead(FormContext.USERS, FormContextType.TEAM_LEADER), + staleTime: apiCatchingDuration.GETREADFORM, + }); // const { data:adminFormData ,isLoading: adminFormDataLoading, error :adminFormDataErrror} = useQuery({ // queryKey: ["adminFormData"], // queryFn: () => getFormRead( @@ -152,13 +163,11 @@ const CommonUserModal: React.FC = ({ districtFieldId, stateFieldId, dynamicFormForBlock, - stateDefaultValue + stateDefaultValue, } = useLocationState(open, onClose, roleType); - - useEffect(() => { - const getAddUserFormData = () => { + const getAddUserFormData = () => { try { // const response: FormData = await getFormRead( // FormContext.USERS, @@ -169,10 +178,15 @@ const CommonUserModal: React.FC = ({ // userType // ); // console.log("sortedFields", response); - - const response : FormData = userType===FormContextType.TEACHER? teacherFormData: userType===FormContextType.STUDENT? studentFormData : teamLeaderFormData; - // console.log(studentFormData) - console.log(response) + + const response: FormData = + userType === FormContextType.TEACHER + ? teacherFormData + : userType === FormContextType.STUDENT + ? studentFormData + : teamLeaderFormData; + // console.log(studentFormData) + console.log(response); if (response) { if (userType === FormContextType.TEACHER) { @@ -189,7 +203,7 @@ const CommonUserModal: React.FC = ({ setFormValue(formValues); setSchema(schema); setUiSchema(uiSchema); - console.log("teacher2") + console.log("teacher2"); } else if (userType === FormContextType.TEAM_LEADER) { const { schema, uiSchema, formValues } = GenerateSchemaAndUiSchema( response, @@ -207,7 +221,6 @@ const CommonUserModal: React.FC = ({ setUiSchema(uiSchema); } } - } catch (error) { console.error("Error fetching form data:", error); } @@ -230,17 +243,16 @@ const CommonUserModal: React.FC = ({ console.log("Form data submitted:", formData); const schemaProperties = schema.properties; - console.log(formData['year of joining scp']) + console.log(formData["year of joining scp"]); let result; - if(formData['year of joining scp']) - { - result = generateUsernameAndPassword(selectedStateCode, userType, formData['year of joining scp']); - - } - else - { + if (formData["year of joining scp"]) { + result = generateUsernameAndPassword( + selectedStateCode, + userType, + formData["year of joining scp"] + ); + } else { result = generateUsernameAndPassword(selectedStateCode, userType); - } if (result !== null) { const { username, password } = result; @@ -327,7 +339,7 @@ const CommonUserModal: React.FC = ({ name: apiBody?.name, mobile: apiBody?.mobile, father_name: apiBody?.father_name, - email:apiBody?.email + email: apiBody?.email, }; const customFields = apiBody?.customFields; console.log(customFields); @@ -345,121 +357,101 @@ const CommonUserModal: React.FC = ({ showToastMessage(t(messageKey), "success"); } else { - const response = await createUser(apiBody); console.log(response); if (response) { - const messageKey = messageKeyMap[userType] + const messageKey = messageKeyMap[userType]; - if(userType===FormContextType.STUDENT) - { - - showToastMessage(t(messageKey), "success"); - } - // if(userType===FormContextType.STUDENT) - // setOpenModal(true); + if (userType === FormContextType.STUDENT) { + showToastMessage(t(messageKey), "success"); + } } else { showToastMessage(t("COMMON.SOMETHING_WENT_WRONG"), "error"); } - } onSubmit(true); onClose(); onCloseModal(); + if (!isEditModal) { + const isQueue = false; + const context = "USER"; + let creatorName; + const key = + userType === FormContextType.STUDENT + ? "onLearnerCreated" + : userType === FormContextType.TEACHER + ? "onFacilitatorCreated" + : "onTeamLeaderCreated"; - if(!isEditModal) - { - // setOpenModal(true); - - const isQueue = false; - const context = 'USER'; - let createrName; - const key = userType === FormContextType.STUDENT - ? 'onLearnerCreated' - : userType === FormContextType.TEACHER - ? 'onFacilitatorCreated' - : 'onTeamLeaderCreated'; - - if (typeof window !== 'undefined' && window.localStorage) { - createrName = localStorage.getItem('name'); - } - let replacements: { [key: string]: string }; - replacements={} - console.log(Object.keys(replacements).length === 0) - if (createrName) { - if(userType===FormContextType.STUDENT) - { - replacements = - { - "{FirstName}": createrName, - "{UserName}": username, - "{LearnerName}" : apiBody['name'], - "{Password}": password - } + if (typeof window !== "undefined" && window.localStorage) { + creatorName = localStorage.getItem("name"); } - else{ - replacements = - { - "{FirstName}": apiBody['name'], - "{UserName}": username, - "{Password}": password - } - + let replacements: { [key: string]: string }; + replacements = {}; + console.log(Object.keys(replacements).length === 0); + if (creatorName) { + if (userType === FormContextType.STUDENT) { + replacements = { + "{FirstName}": firstLetterInUpperCase(creatorName), + "{UserName}": username, + "{LearnerName}": firstLetterInUpperCase(apiBody["name"]), + "{Password}": password, + }; + } else { + replacements = { + "{FirstName}": firstLetterInUpperCase(apiBody["name"]), + "{UserName}": username, + "{Password}": password, + }; + } } - - } - const sendTo = { - // receipients: [userEmail], - receipients: userType === FormContextType.STUDENT?[adminInfo?.email]: [formData?.email], - - }; - if (Object.keys(replacements).length !== 0 && sendTo) { - - const response = await sendCredentialService({ - isQueue, - context, - key, - replacements, - email: sendTo, - }); - if(userType!==FormContextType.STUDENT) - { - const messageKey = messageKeyMap[userType] + const sendTo = { + // receipients: [userEmail], + receipients: + userType === FormContextType.STUDENT + ? [adminInfo?.email] + : [formData?.email], + }; + if (Object.keys(replacements).length !== 0 && sendTo) { + const response = await sendCredentialService({ + isQueue, + context, + key, + replacements, + email: sendTo, + }); + if (userType !== FormContextType.STUDENT) { + const messageKey = messageKeyMap[userType]; - if (response?.result[0]?.data[0]?.status === 'success') { + if (response?.result[0]?.data[0]?.status === "success") { showToastMessage(t(messageKey), "success"); + } else { + const messageKey = + delayCredentialsMessageMap[userType] || + "TEAM_LEADERS.USER_CREDENTIALS_WILL_BE_SEND_SOON"; - } - else { - const messageKey = delayCredentialsMessageMap[userType] || "TEAM_LEADERS.USER_CREDENTIALS_WILL_BE_SEND_SOON"; - - showToastMessage(t(messageKey), "success"); - + showToastMessage(t(messageKey), "success"); + } } - } - if(userType===FormContextType.STUDENT ) - { - if( response?.result[0]?.data[0]?.status === 'success' && !isEditModal) - { - setOpenModal(true); - - } - else{ - showToastMessage( - t('LEARNERS.USER_CREDENTIALS_WILL_BE_SEND_SOON'), - 'success' - ); + if (userType === FormContextType.STUDENT) { + if ( + response?.result[0]?.data[0]?.status === "success" && + !isEditModal + ) { + setOpenModal(true); + } else { + showToastMessage( + t("LEARNERS.USER_CREDENTIALS_WILL_BE_SEND_SOON"), + "success" + ); + } + } + } else { + showToastMessage(t("COMMON.SOMETHING_WENT_WRONG"), "error"); } } - - - - } else { - showToastMessage(t('COMMON.SOMETHING_WENT_WRONG'), 'error'); - } - } } catch (error) { onClose(); console.log(error); @@ -509,112 +501,99 @@ const CommonUserModal: React.FC = ({ if (typeof window !== "undefined" && window.localStorage) { const admin = localStorage.getItem("adminInfo"); if (admin) setAdminInfo(JSON.parse(admin)); - console.log(adminInfo?.email) + console.log(adminInfo?.email); } }, []); return ( <> - - - + + + } + > + {!isEditModal && ( + - {!isEditModal ? t("COMMON.CREATE") : t("COMMON.UPDATE")} - - - } - > - {!isEditModal && ( - - - - )} - {formData - ? schema && - uiSchema && ( - - {/* */} - - ) - : userType === FormContextType.TEAM_LEADER - ? dynamicFormForBlock && - schema && + + + )} + {formData + ? schema && uiSchema && ( = ({ // widgets={{}} showErrorList={true} customFields={customFields} - formData={formValue} + formData={formData} > {/* */} ) - : dynamicForm && - schema && - uiSchema && ( - - {/* */} - - )} - - - + : userType === FormContextType.TEAM_LEADER + ? dynamicFormForBlock && + schema && + uiSchema && ( + + {/* */} + + ) + : dynamicForm && + schema && + uiSchema && ( + + {/* */} + + )} + + + ); }; diff --git a/src/utils/Helper.ts b/src/utils/Helper.ts index a31a0136..d7e6c6cf 100644 --- a/src/utils/Helper.ts +++ b/src/utils/Helper.ts @@ -111,9 +111,9 @@ export const transformArray = (arr: State[]): State[] => { })); }; -export const firstLetterInUpperCase = (label: string): string | null => { +export const firstLetterInUpperCase = (label: string): string => { if (!label) { - return null; + return ''; } return label From 1f691959d350537e06be6508f8e43e363d307abb Mon Sep 17 00:00:00 2001 From: Akshata Katwal Date: Mon, 23 Sep 2024 17:28:45 +0530 Subject: [PATCH 20/40] Issue PS-2029 feat: update route path and by default state district block center values --- src/components/AreaSelection.tsx | 4 +- src/components/FormControl.tsx | 6 +- src/components/HeaderComponent.tsx | 162 ++++++++++++- src/components/UserTable.tsx | 361 +++++++++++++++++++++-------- src/utils/Helper.ts | 2 +- src/utils/useSharedState.ts | 11 + 6 files changed, 428 insertions(+), 118 deletions(-) diff --git a/src/components/AreaSelection.tsx b/src/components/AreaSelection.tsx index 2aa4e7e1..f3c0d21d 100644 --- a/src/components/AreaSelection.tsx +++ b/src/components/AreaSelection.tsx @@ -212,11 +212,11 @@ const shouldRenderSelectCheckmarks = tagName={t("CENTERS.CENTERS")} selectedCategories={selectedCenter} onCategoryChange={handleCenterChangeWrapper} - disabled={selectedBlock.length === 0 || selectedCenter[0] === ""} + disabled={selectedBlock.length === 0 || selectedCenter[0] === "" ||selectedBlock[0]===t("COMMON.ALL_BLOCKS")|| (selectedBlock?.length > 0 && allCenters?.length <= 0)} overall={!inModal} defaultValue={ // blockDefaultValue? blockDefaultValue: - selectedBlock?.length > 0 && blocks?.length <= 0 + selectedBlock?.length > 0 && allCenters?.length <= 0 ? t("COMMON.NO_CENTERS") : t("COMMON.ALL_CENTERS") } diff --git a/src/components/FormControl.tsx b/src/components/FormControl.tsx index ac5ee06d..b8e5c949 100644 --- a/src/components/FormControl.tsx +++ b/src/components/FormControl.tsx @@ -85,8 +85,10 @@ const MultipleSelectCheckmarks: React.FC = ({ } onChange={handleChange} input={} - renderValue={(selected) => selected?.join(", ")} - MenuProps={MenuProps} + renderValue={(selected) => { + const selectedArray = Array.isArray(selected) ? selected : [selected]; + return selectedArray.join(", "); + }} MenuProps={MenuProps} > {overall && ( diff --git a/src/components/HeaderComponent.tsx b/src/components/HeaderComponent.tsx index 684f7066..4421affe 100644 --- a/src/components/HeaderComponent.tsx +++ b/src/components/HeaderComponent.tsx @@ -25,6 +25,9 @@ import Tab from "@mui/material/Tab"; import Tabs from "@mui/material/Tabs"; import { useQueryClient } from "@tanstack/react-query"; import { formatedBlocks, formatedDistricts } from "@/services/formatedCohorts"; +import { useRouter } from "next/router"; +import useSubmittedButtonStore from "@/utils/useSharedState"; +import { userAgent } from "next/server"; interface State { value: string; @@ -80,11 +83,13 @@ const HeaderComponent = ({ setSelectedBlock, setSelectedCenter, selectedCenterCode, - setSelectedCenterCode + setSelectedCenterCode, + setSelectedStateCode, }: any) => { const { t } = useTranslation(); const queryClient = useQueryClient(); + const router = useRouter(); const theme = useTheme(); const isMobile = useMediaQuery("(max-width:600px)"); @@ -95,9 +100,27 @@ const HeaderComponent = ({ const [allCenters, setAllCenters] = useState([]); const [initialDistrict, setInitialDistrict] = useState(""); const [initialBlock, setInitialBlock] = useState(""); + const [initialized, setInitialized] = useState(false); const [blocks, setBlocks] = useState([]); - + const selectedBlockStore = useSubmittedButtonStore( + (state: any) => state.selectedBlockStore + ); + const setSelectedBlockStore = useSubmittedButtonStore( + (state: any) => state.setSelectedBlockStore + ); + const selectedDistrictStore = useSubmittedButtonStore( + (state: any) => state.selectedDistrictStore + ); + const setSelectedDistrictStore = useSubmittedButtonStore( + (state: any) => state.setSelectedDistrictStore + ); + const selectedCenterStore = useSubmittedButtonStore( + (state: any) => state.selectedCenterStore + ); + const setSelectedCenterStore = useSubmittedButtonStore( + (state: any) => state.setSelectedCenterStore + ); const handleStateChangeWrapper = async ( selectedNames: string[], selectedCodes: string[] @@ -221,6 +244,20 @@ const HeaderComponent = ({ useEffect(() => { const fetchData = async () => { + const { state, district, center } = router.query; +console.log(router.asPath) +const fullPath = router.asPath; + +// Extract query parameters +const queryString = fullPath.split('?')[1]; // Get the part after '?' +console.log(queryString) +const params = new URLSearchParams(queryString); + +// Check if 'block' is present +const hasBlock = params.has('block'); +const hasDistrict = params.has('district'); +const hasCenter = params.has('center'); +const hasState = params.has('state'); try { const object = { // "limit": 20, @@ -266,13 +303,53 @@ const HeaderComponent = ({ const districtResult= await formatedDistricts(); setDistricts(districtResult); - setSelectedDistrict([districtResult[0]?.label]) - setSelectedDistrictCode(districtResult[0]?.value) + if(!hasDistrict) + { + setSelectedDistrict([districtResult[0]?.label]) + setSelectedDistrictCode(districtResult[0]?.value) + localStorage.setItem('selectedDistrict', districtResult[0]?.label) + setSelectedDistrictStore(districtResult[0]?.label) + + } const blockResult=await formatedBlocks(districtResult[0]?.value) setBlocks(blockResult); + if(!hasBlock && !hasDistrict) + { - setSelectedBlock([blockResult[0]?.label]) - setSelectedBlockCode(blockResult[0]?.value) + if(userType===Role.TEAM_LEADERS) + { + setSelectedBlock([t("COMMON.ALL_BLOCKS")]) + //setSelectedBlockCode("") + router.replace({ + pathname: router.pathname, + query: { + ...router.query, + state: stateField.code, + district: districtResult[0]?.value, + } + }); + } + else{ + + setSelectedBlock([blockResult[0]?.label]) + setSelectedBlockCode(blockResult[0]?.value) + localStorage.setItem('selectedBlock',blockResult[0]?.label ) + setSelectedBlockStore(blockResult[0]?.label) + + router.replace({ + pathname: router.pathname, + query: { + ...router.query, + state: stateField.code, + district: districtResult[0]?.value, + block: blockResult[0]?.value + } + }); + + } + + } + const getCentersObject = { limit: 0, offset: 0, @@ -309,10 +386,29 @@ const HeaderComponent = ({ cohortId: item?.cohortId, name: item?.name, })); + setAllCenters(cohortInfo); + console.log(dataArray); - setAllCenters(cohortInfo); - setSelectedCenter([cohortInfo[0]?.name]) - setSelectedCenterCode(cohortInfo[0]?.cohortId) + console.log(userType) + if(!hasCenter && !hasBlock && !hasDistrict && userType!==Role.TEAM_LEADERS) + { + console.log(hasCenter) + setSelectedCenter([t("COMMON.ALL_CENTERS")]) + // setSelectedCenterCode([cohortInfo[0]?.cohortId]) + // localStorage.setItem('selectedCenter',cohortInfo[0]?.name ) + // setSelectedCenterStore(cohortInfo[0]?.name) + router.replace({ + pathname: router.pathname, + query: { + ...router.query, + state: stateField.code, + district: districtResult[0]?.value, + block: blockResult[0]?.value , + // center: cohortInfo[0]?.cohortId + } + }); + } + console.log(cohortInfo) } @@ -335,7 +431,7 @@ const HeaderComponent = ({ if (shouldFetchDistricts) { fetchData(); } - }, [shouldFetchDistricts]); + }, [shouldFetchDistricts,userType]); const handleChange = (event: React.SyntheticEvent, newValue: any) => { console.log(newValue); setStatusValue(newValue); @@ -357,7 +453,51 @@ const HeaderComponent = ({ // } // }, [blocks, selectedBlock, handleBlockChangeWrapper]); - + useEffect(() => { + + const { state, district, block, center } = router.query; + { + + if (state) { + setSelectedStateCode(state.toString()); + } + + if (district) { + setSelectedDistrictCode(district.toString()); + // setSelectedDistrict([selectedDistrictStore]) + setSelectedDistrict([localStorage.getItem('selectedDistrict')]) + if(!localStorage.getItem('selectedDistrict')) + { + setSelectedDistrict([selectedDistrictStore]) + } + + } + + if (block) { + + setSelectedBlockCode(block.toString()); + console.log(selectedBlockCode) + // setSelectedBlock([selectedBlockStore]) + setSelectedBlock([localStorage.getItem('selectedBlock')]) + if(!localStorage.getItem('selectedBlock')) + setSelectedBlock([selectedBlockStore]) + } + + if (center) { + console.log(center) + + setSelectedCenterCode([center.toString()]); + // setSelectedCenter([selectedCenterStore]) + setSelectedCenter([localStorage.getItem('selectedCenter')]) + if(!localStorage.getItem('selectedCenter')) + setSelectedCenter([selectedCenterStore]) + + } + // setInitialized(true) + } + + }, [router]); + return ( = ({ const [centerMembershipIdList, setCenterMembershipIdList] = React.useState([]); const router = useRouter(); + const selectedBlockStore = useSubmittedButtonStore( + (state: any) => state.selectedBlockStore + ); + const setSelectedBlockStore = useSubmittedButtonStore( + (state: any) => state.setSelectedBlockStore + ); + const selectedDistrictStore = useSubmittedButtonStore( + (state: any) => state.selectedDistrictStore + ); + const setSelectedDistrictStore = useSubmittedButtonStore( + (state: any) => state.setSelectedDistrictStore + ); + const selectedCenterStore = useSubmittedButtonStore( + (state: any) => state.selectedCenterStore + ); + const setSelectedCenterStore = useSubmittedButtonStore( + (state: any) => state.setSelectedCenterStore + ); + + + const [selectedStateCode, setSelectedStateCode] = useState(""); const [selectedDistrict, setSelectedDistrict] = React.useState([]); const [selectedDistrictCode, setSelectedDistrictCode] = useState(""); @@ -125,6 +146,7 @@ const UserTable: React.FC = ({ const [userCohort, setUserCohorts] = useState (""); const [assignedCenters, setAssignedCenters] = useState(); + const [initialized, setInitialized] = useState(false); const [selectedUserId, setSelectedUserId] = useState(""); const [cohortId, setCohortId] = useState([]); @@ -256,6 +278,24 @@ const UserTable: React.FC = ({ /> ); const handleStateChange = async (selected: string[], code: string[]) => { + const newQuery = { ...router.query }; + + if (newQuery.center) { + delete newQuery.center; + } + if (newQuery.district) { + delete newQuery.district; + } + if (newQuery.block) { + delete newQuery.block; + } + router.replace({ + pathname: router.pathname, + query: { + ...newQuery, + state: code?.join(","), + } + }); setSelectedCenterCode([]) setEnableCenterFilter(false) @@ -314,6 +354,22 @@ const UserTable: React.FC = ({ }; const handleDistrictChange = (selected: string[], code: string[]) => { + const newQuery = { ...router.query }; + + if (newQuery.center) { + delete newQuery.center; + } + if (newQuery.block) { + delete newQuery.block; + } + router.replace({ + pathname: router.pathname, + query: { + ...newQuery, + state: selectedStateCode, + district: code?.join(",") + } + }); setSelectedCenterCode([]) setEnableCenterFilter(false) @@ -322,11 +378,9 @@ const UserTable: React.FC = ({ setSelectedBlock([]); setSelectedDistrict(selected); setSelectedBlockCode(""); +localStorage.setItem('selectedDistrict', selected[0]) -router.replace({ - pathname: router.pathname, - query: { ...router.query, stateCode: selectedStateCode ,districtCode: selected[0] } -}); +setSelectedDistrictStore(selected[0]) if (selected[0] === "" || selected[0] === t("COMMON.ALL_DISTRICTS")) { if (filters.status) { setFilters({ @@ -367,8 +421,40 @@ router.replace({ setEnableCenterFilter(false) setSelectedCenter([]); + const newQuery = { ...router.query }; + if (newQuery.center) { + delete newQuery.center; + } + if (newQuery.block) { + delete newQuery.block; + } + console.log(code?.join(",")) + router.replace({ + pathname: router.pathname, + query: { + ...newQuery, + state: selectedStateCode, + district: selectedDistrictCode, + block: code?.join(",") + } + }); + + setSelectedBlock(selected); + localStorage.setItem('selectedBlock', selected[0]) + setSelectedBlockStore(selected[0]) if (selected[0] === "" || selected[0] === t("COMMON.ALL_BLOCKS")) { + if (newQuery.block) { + delete newQuery.block; + } + router.replace({ + pathname: router.pathname, + query: { + ...newQuery, + state: selectedStateCode, + district: selectedDistrictCode, + } + }); if (filters.status) { setFilters({ states: selectedStateCode, @@ -408,14 +494,49 @@ router.replace({ console.log("Selected categories:", selected); }; const handleCenterChange = async(selected: string[], code: string[]) => { + if(code[0]) + { +console.log(code[0]) + router.replace({ + pathname: router.pathname, + query: { + ...router.query, + state: selectedStateCode, + district: selectedDistrictCode, + block: selectedBlockCode, + center: code[0] + } + }); + } + else + { + const newQuery = { ...router.query }; + if (newQuery.center) { + delete newQuery.center; + router.replace({ + ...newQuery, + + }); + } + + } + + + + + + setSelectedCenterCode([code[0]]) setSelectedCenter(selected) + localStorage.setItem('selectedCenter',selected[0] ) + setSelectedCenterStore(selected[0]) console.log(selected[0]) if (selected[0] === "" || selected[0] === t("COMMON.ALL_CENTERS")) { setEnableCenterFilter(false) - + setSelectedCenterCode([]) if (filters.status) { + setFilters({ states: selectedStateCode, districts: selectedDistrictCode, @@ -425,6 +546,7 @@ router.replace({ }); } else { + setFilters({ states: selectedStateCode, districts: selectedDistrictCode, @@ -860,7 +982,7 @@ router.replace({ } }; console.log(data ) - if (selectedBlockCode !== "" || (selectedDistrictCode !== "" && selectedBlockCode === "")) { + if ((selectedBlockCode !== "") || (selectedDistrictCode !== "" && selectedBlockCode === "") || (userType===Role.TEAM_LEADERS && selectedDistrictCode!=="") ){ fetchUserList(); } // fetchUserList(); @@ -875,9 +997,10 @@ router.replace({ deleteUserState, sortByForCohortMemberList, reassignButtonStatus, - enableCenterFilter + enableCenterFilter, + userType ]); - +console.log(selectedBlockStore) useEffect(() => { const fetchData = async () => { try { @@ -964,7 +1087,17 @@ router.replace({ // } // ) - if(selectedBlockCode && selectedDistrictCode) + if(selectedDistrictCode) + { + setFilters({ + states: stateField.code, + districts:selectedDistrictCode, + // blocks:selectedBlockCode, + role: role, + status:[statusValue], + }) + } + if(selectedBlockCode) { setFilters({ states: stateField.code, @@ -993,7 +1126,7 @@ router.replace({ }, [selectedBlockCode, selectedDistrictCode]); useEffect(() => { const fetchData = () => { - console.log(selectedCenter.length) + // console.log(selectedCenter.length) if(userType===Role.TEAM_LEADERS) { setEnableCenterFilter(false); @@ -1003,21 +1136,25 @@ router.replace({ if(selectedCenter.length!==0) { if (selectedCenter[0] === "" || selectedCenter[0] === t("COMMON.ALL_CENTERS")) { + setEnableCenterFilter(false); } else { + console.log(selectedCenterCode) + setEnableCenterFilter(true); } //setEnableCenterFilter(true); if(selectedCenterCode.length!==0) - { setFilters({ + { + setFilters({ // states: selectedStateCode, // districts: selectedDistrictCode, // blocks: blocks, - cohortId:selectedCenterCode, + cohortId:selectedCenterCode[0], role: role, status:[statusValue] });} @@ -1026,6 +1163,7 @@ router.replace({ } else{ setEnableCenterFilter(false) + if(selectedCenterCode.length!==0) setSelectedCenterCode([]) } } @@ -1036,95 +1174,113 @@ router.replace({ fetchData(); }, [selectedCenter, selectedCenterCode]); - - - -useEffect(() => { - - // Handle replacement when only state and district codes are available - if (selectedStateCode!=="" && selectedDistrictCode==="" && selectedBlockCode==="") { - const newQuery = { ...router.query }; - console.log(newQuery) - - if (newQuery.center) { - delete newQuery.center; - } - if (newQuery.district) { - delete newQuery.district; - } - if (newQuery.block) { - delete newQuery.block; - } - router.replace({ - pathname: router.pathname, - query: { - ...newQuery, - state: selectedStateCode, - } - }); - } - if (selectedStateCode!=="" && selectedDistrictCode!=="" && selectedBlockCode==="") { - const newQuery = { ...router.query }; - console.log(newQuery) - - if (newQuery.center) { - delete newQuery.center; - } - if (newQuery.block) { - delete newQuery.block; - } - router.replace({ - pathname: router.pathname, - query: { - ...newQuery, - state: selectedStateCode, - district: selectedDistrictCode - } - }); - } - - // Handle replacement when state, district, and block codes are available - if (selectedStateCode!=="" && selectedDistrictCode!=="" && selectedBlockCode!=="" && selectedCenter.length === 0) { - console.log("heyyy") - const newQuery = { ...router.query }; - - if (newQuery.center) { - delete newQuery.center; - } - if (newQuery.block) { - delete newQuery.block; - } - router.replace({ - pathname: router.pathname, - query: { - ...newQuery, - state: selectedStateCode, - district: selectedDistrictCode, - block: selectedBlockCode - } - }); - } - - // Handle replacement when state, district, block, and center are all selected - if (selectedStateCode !==""&& selectedDistrictCode!=="" && selectedBlockCode!=="" && selectedCenter.length !== 0) { - console.log("heyyy") - - console.log(selectedCenter); - if (userType !== Role.TEAM_LEADERS) { - router.replace({ - pathname: router.pathname, - query: { - ...router.query, - state: selectedStateCode, - district: selectedDistrictCode, - block: selectedBlockCode, - center: selectedCenter - } - }); - } - } -}, [selectedStateCode, selectedDistrictCode, selectedBlockCode, selectedCenter]); - + console.log(enableCenterFilter) + // useEffect(() => { + // const { state, district, block, center } = router.query; + + // { + // if (state) { + // setSelectedStateCode(state.toString()); + // } + // if (district) { + // setSelectedDistrictCode(district.toString()); + // } + // if (block) { + // setSelectedBlockCode(block.toString()); + // } + // if ( center) { + // setSelectedCenter([center.toString()]); + // } + // setInitialized(true); + // } + // }, []); + + // useEffect(() => { + + // // Handle replacement when only state and district codes are available + // if (selectedStateCode!=="" && selectedDistrictCode==="" && selectedBlockCode==="") { + // console.log("true") + // const newQuery = { ...router.query }; + // console.log(newQuery) + + // if (newQuery.center) { + // delete newQuery.center; + // } + // if (newQuery.district) { + // delete newQuery.district; + // } + // if (newQuery.block) { + // delete newQuery.block; + // } + // router.replace({ + // pathname: router.pathname, + // query: { + // ...newQuery, + // state: selectedStateCode, + // } + // }); + // } + // if (selectedStateCode!=="" && selectedDistrictCode!=="" && selectedBlockCode==="") { + // const newQuery = { ...router.query }; + // console.log(newQuery) + + // if (newQuery.center) { + // delete newQuery.center; + // } + // if (newQuery.block) { + // delete newQuery.block; + // } + // router.replace({ + // pathname: router.pathname, + // query: { + // ...newQuery, + // state: selectedStateCode, + // district: selectedDistrictCode + // } + // }); + // } + + // // Handle replacement when state, district, and block codes are available + // if (selectedStateCode!=="" && selectedDistrictCode!=="" && selectedBlockCode!=="" && selectedCenter.length === 0) { + // const newQuery = { ...router.query }; + + // if (newQuery.center) { + // delete newQuery.center; + // } + // if (newQuery.block) { + // delete newQuery.block; + // } + // router.replace({ + // pathname: router.pathname, + // query: { + // ...newQuery, + // state: selectedStateCode, + // district: selectedDistrictCode, + // block: selectedBlockCode + // } + // }); + // } + + // // Handle replacement when state, district, block, and center are all selected + // if (selectedStateCode !==""&& selectedDistrictCode!=="" && selectedBlockCode!=="" && selectedCenter.length !== 0) { + // console.log("heyyy") + + // console.log(selectedCenter); + // if (userType !== Role.TEAM_LEADERS) { + // router.replace({ + // pathname: router.pathname, + // query: { + // ...router.query, + // state: selectedStateCode, + // district: selectedDistrictCode, + // block: selectedBlockCode, + // center: selectedCenter + // } + // }); + // } + // } + // }, [selectedStateCode]); + const handleCloseDeleteModal = () => { @@ -1252,7 +1408,8 @@ useEffect(() => { selectedCenter: selectedCenter, setSelectedCenter:setSelectedCenter, selectedCenterCode:selectedCenterCode, - setSelectedCenterCode: setSelectedCenterCode + setSelectedCenterCode: setSelectedCenterCode, + setSelectedStateCode:setSelectedStateCode }; diff --git a/src/utils/Helper.ts b/src/utils/Helper.ts index a31a0136..9804a6a0 100644 --- a/src/utils/Helper.ts +++ b/src/utils/Helper.ts @@ -129,7 +129,7 @@ export const capitalizeFirstLetterOfEachWordInArray = ( } console.log(arr); return arr?.map((str) => - str.replace(/\b[a-z]/g, (char) => char.toUpperCase()) + str?.replace(/\b[a-z]/g, (char) => char.toUpperCase()) ); }; export const fieldTextValidation = (text: string) => { diff --git a/src/utils/useSharedState.ts b/src/utils/useSharedState.ts index 6ca09a24..dba16d34 100644 --- a/src/utils/useSharedState.ts +++ b/src/utils/useSharedState.ts @@ -16,6 +16,17 @@ const useSubmittedButtonStore = create((set) => ({ setUserEnteredEmail: (status: string) => set({ userEnteredEmail: status }), shouldFetch:true, setShouldFetch:(data: boolean) => set({ shouldFetch: data }), + selectedBlockStore:"", + setSelectedBlockStore: (status: string) => set({ selectedBlockStore: status }), + + selectedDistrictStore:"", + setSelectedDistrictStore: (status: string) => set({ selectedDistrictStore: status }), + + selectedCenterStore:"", + setSelectedCenterStore: (status: string) => set({ selectedCenterStore: status }), + + + })); From 11b1d8657742ab09d7d32d2b4cb08666e23f4ab7 Mon Sep 17 00:00:00 2001 From: vivek kasture Date: Tue, 24 Sep 2024 11:10:24 +0530 Subject: [PATCH 21/40] Issue #PS-000 fix: Resolved UT issues --- src/services/coursePlanner.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/coursePlanner.ts b/src/services/coursePlanner.ts index e32e9247..8b8c5a64 100644 --- a/src/services/coursePlanner.ts +++ b/src/services/coursePlanner.ts @@ -30,7 +30,7 @@ export const getFrameworkDetails = async (frameworkId: string): Promise => }; export const uploadCoursePlanner = async (file: File, metaData: CoursePlannerMetaData): Promise => { - const apiUrl: string = `${process.env.NEXT_PUBLIC_TELEMETRY_URL}/user/v1/course-planner/upload`; + const apiUrl: string = `${process.env.NEXT_PUBLIC_BASE_URL}/user/v1/course-planner/upload`; const formData = new FormData(); formData.append('file', file); formData.append('metaData', JSON.stringify(metaData)); From 93da80e6a286d4393a924badd3df443ba9360060 Mon Sep 17 00:00:00 2001 From: vivek kasture Date: Tue, 24 Sep 2024 11:11:58 +0530 Subject: [PATCH 22/40] Issue #PS-000 fix: Resolved UT issues --- src/services/coursePlanner.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/coursePlanner.ts b/src/services/coursePlanner.ts index 8b8c5a64..8dfc9b6b 100644 --- a/src/services/coursePlanner.ts +++ b/src/services/coursePlanner.ts @@ -30,7 +30,7 @@ export const getFrameworkDetails = async (frameworkId: string): Promise => }; export const uploadCoursePlanner = async (file: File, metaData: CoursePlannerMetaData): Promise => { - const apiUrl: string = `${process.env.NEXT_PUBLIC_BASE_URL}/user/v1/course-planner/upload`; + const apiUrl: string = `${process.env.NEXT_PUBLIC_BASE_URL}/course-planner/upload`; const formData = new FormData(); formData.append('file', file); formData.append('metaData', JSON.stringify(metaData)); From 53702ccd92b4b4e97684b646cbf9cbe2ea176193 Mon Sep 17 00:00:00 2001 From: vivek kasture Date: Tue, 24 Sep 2024 11:49:36 +0530 Subject: [PATCH 23/40] Issue #PS-000 fix: Resolved UT issues --- src/utils/Helper.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/utils/Helper.ts b/src/utils/Helper.ts index efd05165..9aeaea82 100644 --- a/src/utils/Helper.ts +++ b/src/utils/Helper.ts @@ -139,9 +139,21 @@ export const fieldTextValidation = (text: string) => { const regex = /^[A-Za-z\s]+$/; return regex.test(text); }; + export const getCurrentYearPattern = () => { const currentYear = new Date().getFullYear(); - return `^(19[0-9][0-9]|20[0-${Math.floor(currentYear / 10) % 10}][0-${currentYear % 10}])$`; + + // Build the dynamic part for the current century + let regexPart = ''; + if (currentYear >= 2000 && currentYear < 2100) { + const lastDigit = currentYear % 10; + const middleDigit = Math.floor((currentYear % 100) / 10); + + regexPart = `20[0-${middleDigit - 1}][0-9]|20${middleDigit}[0-${lastDigit}]`; + } + + // Full regex covering 1900–1999, 2000 to current year + return `^(19[0-9]{2}|${regexPart})$`; }; export const mapFields = (formFields: any, Details: any) => { From c1d2549c3ac9ec983c724f63e0c559b51d320c62 Mon Sep 17 00:00:00 2001 From: Akshata Katwal Date: Tue, 24 Sep 2024 13:32:31 +0530 Subject: [PATCH 24/40] Issue feat PS-2043: Add confirmation modal while reassigning block having already assigned TL --- public/locales/en/common.json | 5 +- src/components/CustomModal.tsx | 6 +- src/components/DeleteUserModal.tsx | 1 + src/components/ReassignCenterModal.tsx | 267 ++++++++++++++++++++++++- src/services/UserList.ts | 4 +- 5 files changed, 268 insertions(+), 15 deletions(-) diff --git a/public/locales/en/common.json b/public/locales/en/common.json index ec231b01..c13c5c33 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -126,7 +126,10 @@ "NO_BLOCK_AVAILABLE": "No blocks available", "PLEASE_SELECT_BLOCK_LIST": "Please select block from block list", "ALL_CENTERS": "All centers", - "NO_CENTERS": "No centers" + "NO_CENTERS": "No centers", + "MULTIPLE_TEAM_LEADERS_ASSIGNED": "Selected block {{selectedBlockForTL}} already has {{assignedTeamLeader}} Team Leaders assigned.", + "SINGLE_TEAM_LEADERS_ASSIGNED":"Selected block {{selectedBlockForTL}} already has {{assignedTeamLeader}} Team Leader assigned.", + "CONTINUE_ASSIGNED_TEAM_LEADER":"Still do you want to continue to assign team leader to {{selectedBlockForTL}}" }, "LOGIN_PAGE": { "USERNAME": "Username", diff --git a/src/components/CustomModal.tsx b/src/components/CustomModal.tsx index 18f00c94..2dd3d161 100644 --- a/src/components/CustomModal.tsx +++ b/src/components/CustomModal.tsx @@ -15,7 +15,7 @@ import CloseIcon from "@mui/icons-material/Close"; interface CustomModalProps { open: boolean; handleClose: () => void; - title: string; + title?: string; subtitle?: string; primaryBtnText: string; secondaryBtnText?: string; @@ -25,6 +25,7 @@ interface CustomModalProps { backdropClose?: boolean; primaryBtnDisabled?: boolean; children: React.ReactNode; + width?:string } const CustomModal: React.FC = ({ @@ -40,6 +41,7 @@ const CustomModal: React.FC = ({ backdropClose = true, primaryBtnDisabled = true, children, + width }) => { // const isSmallScreen = useMediaQuery((theme: Theme) => // theme.breakpoints.down("sm"), @@ -61,7 +63,7 @@ const CustomModal: React.FC = ({ top: "50%", left: "50%", transform: "translate(-50%, -50%)", - width: isSmallScreen ? "90%" : isLargeScreen ? "65%" : "85%", + width: isSmallScreen ? "90%" : isLargeScreen ? width : "85%", maxWidth: "90%", bgcolor: "background.paper", boxShadow: 24, diff --git a/src/components/DeleteUserModal.tsx b/src/components/DeleteUserModal.tsx index 2103d2f8..c873e360 100644 --- a/src/components/DeleteUserModal.tsx +++ b/src/components/DeleteUserModal.tsx @@ -86,6 +86,7 @@ const DeleteUserModal: React.FC = ({ return ( = ({ open, onClose, @@ -59,6 +68,7 @@ const ReassignCenterModal: React.FC = ({ centers }) => { + console.log(userId) const { t } = useTranslation(); const theme = useTheme(); const roleType = userType; @@ -110,8 +120,29 @@ const { (state: any) => state.reassignButtonStatus ); console.log(names); - + // const [filters, setFilters] = useState({ + // // cohortId:selectedBlockCohortId, + // role: Role.TEAM_LEADER, + // status:[Status.ACTIVE] + + // }); const [searchInput, setSearchInput] = useState(""); + const [reassignAlertModal, setReassignAlertModal] = useState(false); + const [assignedTeamLeader, setAssignedTeamLeader] = useState(""); + const [selectedBlockForTL, setSelectedBlockForTL] = useState(""); + const [assignedTeamLeaderNames, setAssignedTeamLeaderNames] = useState([]); + const [confirmButtonDisable, setConfirmButtonDisable] = useState(true); + const [checkedConfirmation, setCheckedConfirmation] = useState(false); + const [selectedBlockCohortIdForTL, setSelectedBlockCohortIdForTL] = useState(""); + const [selectedTLUserID, setSelectedTLUserID] = useState(userId); + + + // const [reassignOpen, setReassignOpen] = useState(false); + + + + + //const [selectedBlockId, setselectedBlockId] = useState(blockName); @@ -261,6 +292,8 @@ const { "success" ); } else { + + const reassignBlockObject = { limit: 200, offset: 0, @@ -275,15 +308,46 @@ const { const selectedBlockCohortId = cohortDetails?.find( (item: any) => item?.type === "BLOCK" )?.cohortId; - - if (!selectedBlockCohortId) { + setSelectedBlockCohortIdForTL(selectedBlockCohortId) + // setFilters({ + // cohortId:selectedBlockCohortId, + // role: Role.TEAM_LEADER, + // status:[Status.ACTIVE]} + // ) +const filters: FilterDetails= +{ + cohortId:selectedBlockCohortId, + role: Role.TEAM_LEADER, + status:[Status.ACTIVE]} +console.log(filters) + let limit=200; + let offset=0; + let sort= ["name", "asc"] + let resp; + try { + resp = await cohortMemberList({ limit, filters, sort, offset }); + } catch (apiError) { + console.log("API call failed, proceeding to else block"); + resp = null; + } + if (!selectedBlockCohortId) { showToastMessage( t("COMMON.COHORT_ID_NOT_FOUND", { block: checkedCenters[0] }), "info" ); return; } - + if(resp?.userDetails) + { + handleClose(); + setReassignAlertModal(true) + setAssignedTeamLeader(resp?.userDetails?.length) + setSelectedBlockForTL(checkedCenters[0]) + const userNames = resp?.userDetails?.map((user: any )=> user.name); + setSelectedTLUserID(userId) + setAssignedTeamLeaderNames(userNames) + } + else{ const previousBlockObject = { limit: 200, offset: 0, @@ -355,9 +419,10 @@ const { "success" ); reassignButtonStatus ? setReassignButtonStatus(false) : setReassignButtonStatus(true); - + } } } catch (error) { + console.log(error) showToastMessage( t( userType === Role.TEAM_LEADERS @@ -414,12 +479,123 @@ console.log(formattedBlocks) setCheckedCenters([centerName]); } }; - - console.log(filteredCohorts) + const handleChange = (event: React.ChangeEvent) => { + setCheckedConfirmation(event.target.checked); + + }; + + const wrappedHandleReassignAction = async () => { + try{ + console.log(selectedTLUserID) + // await handleDeleteAction(); + const previousBlockObject = { + limit: 200, + offset: 0, + filters: { + status: ["active"], + name: blockName, + }, + }; + const previousResponse = await getCenterList(previousBlockObject); + const previousCohortDetails = previousResponse?.result?.results?.cohortDetails; + const previousBlockId = previousCohortDetails?.find( + (item: any) => item?.type === "BLOCK" + )?.cohortId; + +let unSelectedBlockCohortIds: string[] = []; + +console.log(previousBlockId) +unSelectedBlockCohortIds.push(previousBlockId); +let cohortIds = blocks +.filter((item:any) => item.label !== selectedBlockForTL) +.map((item:any) => item.cohortId); +cohortIds.push(previousBlockId) + const payload = { + userId: [selectedTLUserID], + cohortId: [selectedBlockCohortIdForTL], + removeCohortId:cohortIds, + }; + + await bulkCreateCohortMembers(payload); + handleClose(); + + const userDetails = await getUserDetailsInfo(selectedTLUserID); + const blockField = userDetails?.userData?.customFields.find( + (field: any) => field.label === "BLOCKS" + ); + const selectedCenterCode = filteredCBlocks.find(location => location.label === selectedBlockForTL)?.value; + let customFields = [ + { + fieldId: blockField.fieldId, + value: selectedCenterCode, + }, + ]; + console.log(selectedBlockCode,selectedBlockForTL) + if(selectedDistrict[0]!==districtName) + { + customFields = [ + { + fieldId: blockField.fieldId, + value: selectedCenterCode, + }, + { + fieldId: districtFieldId, + value: selectedDistrictCode, + }, + ]; + } + const updateObject = { + userData: {}, + customFields: customFields, + }; + if (selectedTLUserID) { + + await updateUser(selectedTLUserID, updateObject); + } + + showToastMessage( + t("COMMON.BLOCKS_REASSIGN_SUCCESSFULLY"), + "success" + ); + reassignButtonStatus ? setReassignButtonStatus(false) : setReassignButtonStatus(true); + } + catch(error) + { + console.log(error) + showToastMessage( + t("COMMON.SOMETHING_WENT_WRONG"), + "error" + ); + } + +finally{ handleCloseConfirmation(); +} + }; + const handleCancelAction = async () => { + // await handleDeleteAction(); + handleCloseConfirmation(); + }; + const handleCloseConfirmation= () => { + // await handleDeleteAction(); + // handleCloseConfirmation(); + setReassignAlertModal(false) + setCheckedConfirmation(false); + setConfirmButtonDisable(true) + }; + + + useEffect(() => { + if (checkedConfirmation) { + setConfirmButtonDisable(false); + } else { + setConfirmButtonDisable(true); + } + }, [checkedConfirmation]); return ( <> + { ( + + + +{assignedTeamLeaderNames.length>1 ?( + <> + {t('COMMON.MULTIPLE_TEAM_LEADERS_ASSIGNED', { selectedBlockForTL: selectedBlockForTL,assignedTeamLeader: assignedTeamLeader})} + + + ):(<> + + {t('COMMON.SINGLE_TEAM_LEADERS_ASSIGNED', { selectedBlockForTL: selectedBlockForTL,assignedTeamLeader: assignedTeamLeader})} + + ) +} + + + + {assignedTeamLeaderNames.length>1 ?( + <>{assignedTeamLeaderNames[0]} and more.. + ):(<> + {assignedTeamLeaderNames[0]} + ) + + } + + + } + label={ t('COMMON.CONTINUE_ASSIGNED_TEAM_LEADER', {selectedBlockForTL: selectedBlockForTL})} + sx={{ marginTop: "12px", color: "#555" }} + /> + + + )} ); }; diff --git a/src/services/UserList.ts b/src/services/UserList.ts index 632e7c2d..0682b9e8 100644 --- a/src/services/UserList.ts +++ b/src/services/UserList.ts @@ -4,7 +4,7 @@ export interface userListParam { limit: number; // page: number; filters: { - role: string; + role?: string; status?: string; states?: string; districts?: string; @@ -12,7 +12,7 @@ export interface userListParam { }; fields?: any; sort?: object; - offset: number; + offset?: number; } export const userList = async ({ From b22034449acacbf6ad0ef90b0c830cb6f517bcad Mon Sep 17 00:00:00 2001 From: ttpl-rt-217 Date: Tue, 24 Sep 2024 15:14:18 +0530 Subject: [PATCH 25/40] Task #PS-1656 : UI improvements --- src/components/AreaSelection.tsx | 229 ++++++++++++++--------------- src/components/CommonUserModal.tsx | 9 +- src/components/DynamicForm.tsx | 28 ++-- src/components/FormControl.tsx | 29 ++-- 4 files changed, 143 insertions(+), 152 deletions(-) diff --git a/src/components/AreaSelection.tsx b/src/components/AreaSelection.tsx index f3c0d21d..41490aea 100644 --- a/src/components/AreaSelection.tsx +++ b/src/components/AreaSelection.tsx @@ -3,8 +3,8 @@ import { useTheme } from "@mui/material/styles"; import { useTranslation } from "next-i18next"; import React, { useEffect, useState } from "react"; import MultipleSelectCheckmarks from "./FormControl"; -import { capitalizeFirstLetterOfEachWordInArray} from "@/utils/Helper"; -import { useMediaQuery } from "@mui/material"; +import { capitalizeFirstLetterOfEachWordInArray } from "@/utils/Helper"; +import { useMediaQuery } from "@mui/material"; import { Role } from "@/utils/app.constant"; interface State { @@ -55,11 +55,11 @@ interface DropdownBoxProps { isMobile: boolean; isMediumScreen: boolean; isCenterSelection?: boolean; - stateDefaultValue?:string; + stateDefaultValue?: string; userType?: string; - reAssignModal?:boolean; - blockDefaultValue?:string; - districtDefaultValue?:string + reAssignModal?: boolean; + blockDefaultValue?: string; + districtDefaultValue?: string; } const AreaSelection: React.FC = ({ @@ -82,40 +82,35 @@ const AreaSelection: React.FC = ({ stateDefaultValue, blockDefaultValue, districtDefaultValue, - + userType, - reAssignModal=false + reAssignModal = false, }) => { - -console.log(selectedState.length) + console.log(selectedState.length); const { t } = useTranslation(); const theme = useTheme(); -const [singleState, setSingleState] = useState (true); -const [stateValue, setStateValue] = useState (""); -const [stateCode, setStateCode] = useState (""); -let isSmallScreen = useMediaQuery((theme: any) => -theme.breakpoints.down("sm"), -); -// isSmallScreen=isMobile?true: false; -const blockDisable= districtDefaultValue?false: true -const shouldRenderSelectCheckmarks = -!(reAssignModal && userType === Role.TEAM_LEADERS); + const [singleState, setSingleState] = useState(true); + const [stateValue, setStateValue] = useState(""); + const [stateCode, setStateCode] = useState(""); + let isSmallScreen = useMediaQuery((theme: any) => + theme.breakpoints.down("sm") + ); + // isSmallScreen=isMobile?true: false; + const blockDisable = districtDefaultValue ? false : true; + const shouldRenderSelectCheckmarks = !( + reAssignModal && userType === Role.TEAM_LEADERS + ); return ( - - {userType && !reAssignModal && ( @@ -126,102 +121,102 @@ const shouldRenderSelectCheckmarks = {!isSmallScreen && ( )} - - - state.label?.toLowerCase().charAt(0).toUpperCase() + - state.label?.toLowerCase().slice(1) - )} - codes={states?.map((state) => state.value)} - tagName={t("FACILITATORS.STATE")} - selectedCategories={selectedState} - onCategoryChange={handleStateChangeWrapper} - disabled={ - stateDefaultValue === t("COMMON.ALL_STATES") ? false : true - } - overall={!inModal} - defaultValue={stateDefaultValue} - /> - districts.label)} - codes={districts?.map((districts) => districts.value)} - tagName={t("FACILITATORS.DISTRICT")} - selectedCategories={selectedDistrict} - onCategoryChange={handleDistrictChangeWrapper} - disabled={ - districts?.length <= 0 || - (selectedState.length === 0 && - stateDefaultValue === t("COMMON.ALL_STATES")) - } - overall={!inModal} - defaultValue={ - //districtDefaultValue? districtDefaultValue: - - reAssignModal - ? districtDefaultValue - : selectedState.length > 0 && districts?.length === 0 - ? t("COMMON.NO_DISTRICTS") - : t("COMMON.ALL_DISTRICTS") - } - /> - { shouldRenderSelectCheckmarks &&( blocks.label) - )} - codes={blocks?.map((blocks) => blocks.value)} - tagName={t("FACILITATORS.BLOCK")} - selectedCategories={capitalizeFirstLetterOfEachWordInArray(selectedBlock)} - onCategoryChange={handleBlockChangeWrapper} - disabled={ - // blockDefaultValue? false: - - blocks?.length <= 0 || - selectedDistrict?.length === 0 || - (selectedDistrict && selectedDistrict[0] === "") || - selectedDistrict[0] === t("COMMON.ALL_DISTRICTS") - } - overall={!inModal} - defaultValue={ - // blockDefaultValue? blockDefaultValue: - selectedDistrict?.length > 0 && blocks?.length <= 0 - ? t("COMMON.NO_BLOCKS") - : t("COMMON.ALL_BLOCKS") - } - />) -} - - - { isCenterSelection && ( centers.name))} - codes={allCenters?.map((centers) => centers.cohortId)} - tagName={t("CENTERS.CENTERS")} - selectedCategories={selectedCenter} - onCategoryChange={handleCenterChangeWrapper} - disabled={selectedBlock.length === 0 || selectedCenter[0] === "" ||selectedBlock[0]===t("COMMON.ALL_BLOCKS")|| (selectedBlock?.length > 0 && allCenters?.length <= 0)} - overall={!inModal} - defaultValue={ - // blockDefaultValue? blockDefaultValue: - selectedBlock?.length > 0 && allCenters?.length <= 0 - ? t("COMMON.NO_CENTERS") - : t("COMMON.ALL_CENTERS") + + + + + state.label?.toLowerCase().charAt(0).toUpperCase() + + state.label?.toLowerCase().slice(1) + )} + codes={states?.map((state) => state.value)} + tagName={t("FACILITATORS.STATE")} + selectedCategories={selectedState} + onCategoryChange={handleStateChangeWrapper} + disabled={stateDefaultValue !== t("COMMON.ALL_STATES")} + overall={!inModal} + defaultValue={stateDefaultValue} + /> + + + district.label)} + codes={districts?.map((district) => district.value)} + tagName={t("FACILITATORS.DISTRICT")} + selectedCategories={selectedDistrict} + onCategoryChange={handleDistrictChangeWrapper} + disabled={ + districts?.length <= 0 || + (selectedState.length === 0 && + stateDefaultValue === t("COMMON.ALL_STATES")) + } + overall={!inModal} + defaultValue={ + reAssignModal + ? districtDefaultValue + : selectedState.length > 0 && districts?.length === 0 + ? t("COMMON.NO_DISTRICTS") + : t("COMMON.ALL_DISTRICTS") } - /> - )} + /> + + + {shouldRenderSelectCheckmarks && ( + block.label) + )} + codes={blocks?.map((block) => block.value)} + tagName={t("FACILITATORS.BLOCK")} + selectedCategories={capitalizeFirstLetterOfEachWordInArray( + selectedBlock + )} + onCategoryChange={handleBlockChangeWrapper} + disabled={ + blocks?.length <= 0 || + selectedDistrict?.length === 0 || + selectedDistrict[0] === t("COMMON.ALL_DISTRICTS") + } + overall={!inModal} + defaultValue={ + selectedDistrict?.length > 0 && blocks?.length === 0 + ? t("COMMON.NO_BLOCKS") + : t("COMMON.ALL_BLOCKS") + } + /> + )} + + + {isCenterSelection && ( + center.name) + )} + codes={allCenters?.map((center) => center.cohortId)} + tagName={t("CENTERS.CENTERS")} + selectedCategories={selectedCenter} + onCategoryChange={handleCenterChangeWrapper} + disabled={ + selectedBlock.length === 0 || + selectedBlock[0] === t("COMMON.ALL_BLOCKS") || + (selectedBlock?.length > 0 && allCenters?.length === 0) + } + overall={!inModal} + defaultValue={ + selectedBlock?.length > 0 && allCenters?.length === 0 + ? t("COMMON.NO_CENTERS") + : t("COMMON.ALL_CENTERS") + } + /> + )} + + diff --git a/src/components/CommonUserModal.tsx b/src/components/CommonUserModal.tsx index ddd2433b..c306c664 100644 --- a/src/components/CommonUserModal.tsx +++ b/src/components/CommonUserModal.tsx @@ -10,7 +10,10 @@ import { updateUser, } from "@/services/CreateUserService"; import { sendCredentialService } from "@/services/NotificationService"; -import { firstLetterInUpperCase, generateUsernameAndPassword } from "@/utils/Helper"; +import { + firstLetterInUpperCase, + generateUsernameAndPassword, +} from "@/utils/Helper"; import { FormData } from "@/utils/Interfaces"; import { FormContext, @@ -374,7 +377,6 @@ const CommonUserModal: React.FC = ({ onCloseModal(); if (!isEditModal) { - const isQueue = false; const context = "USER"; let creatorName; @@ -565,9 +567,6 @@ const CommonUserModal: React.FC = ({ {!isEditModal && ( diff --git a/src/components/DynamicForm.tsx b/src/components/DynamicForm.tsx index dec1dd95..8ff64385 100644 --- a/src/components/DynamicForm.tsx +++ b/src/components/DynamicForm.tsx @@ -9,7 +9,7 @@ import CustomRadioWidget from "./form/CustomRadioWidget"; import MultiSelectCheckboxes from "./form/MultiSelectCheckboxes"; import MultiSelectDropdown from "./form/MultiSelectDropdown"; const FormWithMaterialUI = withTheme(MaterialUITheme); -import { getCurrentYearPattern } from '@/utils/Helper'; +import { getCurrentYearPattern } from "@/utils/Helper"; interface DynamicFormProps { schema: any; @@ -55,9 +55,7 @@ const DynamicForm: React.FC = ({ const setUserEnteredEmail = useSubmittedButtonStore( (state: any) => state.setUserEnteredEmail ); - const setNoError= useSubmittedButtonStore( - (state: any) => state.setNoError - ); + const setNoError = useSubmittedButtonStore((state: any) => state.setNoError); const widgets: any = { MultiSelectDropdown: MultiSelectDropdown, @@ -67,9 +65,9 @@ const DynamicForm: React.FC = ({ const handleError = (errors: any) => { if (errors.length === 0) { - console.log("No errors"); - // You can perform any additional action here when there are no errors - } + console.log("No errors"); + // You can perform any additional action here when there are no errors + } console.log("handle error1"); if (errors.length > 0) { const property = errors[0].property?.replace(/^root\./, ""); @@ -117,7 +115,7 @@ const DynamicForm: React.FC = ({ console.log("Form data changed:", cleanedFormData); setLocalFormData(cleanedFormData); - setUserEnteredEmail(cleanedFormData?.email) + setUserEnteredEmail(cleanedFormData?.email); onChange({ ...event, formData: cleanedFormData }); }; @@ -125,14 +123,14 @@ const DynamicForm: React.FC = ({ const currentYearPattern = new RegExp(getCurrentYearPattern()); console.log("errors", errors); - errors.length===0? setNoError(true): setNoError(false) - + errors.length === 0 ? setNoError(true) : setNoError(false); + console.log("schema", schema); return errors?.map((error: any) => { switch (error.name) { case "required": { - console.log(submittedButtonStatus) + console.log(submittedButtonStatus); error.message = submittedButtonStatus ? t("FORM_ERROR_MESSAGES.THIS_IS_REQUIRED_FIELD") : ""; @@ -211,7 +209,7 @@ const DynamicForm: React.FC = ({ default: { const validRange = currentYearPattern.test(pattern); if (!validRange) { - error.message = t('FORM_ERROR_MESSAGES.ENTER_VALID_YEAR'); + error.message = t("FORM_ERROR_MESSAGES.ENTER_VALID_YEAR"); } break; } @@ -250,10 +248,10 @@ const DynamicForm: React.FC = ({ }); }; useEffect(() => { - // setSubmittedButtonStatus(false); + // setSubmittedButtonStatus(false); }, []); return ( -
+
= ({ fields={customFields} id={id} > - + {children}
diff --git a/src/components/FormControl.tsx b/src/components/FormControl.tsx index b8e5c949..85d81116 100644 --- a/src/components/FormControl.tsx +++ b/src/components/FormControl.tsx @@ -6,7 +6,7 @@ import FormControl from "@mui/material/FormControl"; import ListItemText from "@mui/material/ListItemText"; import Select, { SelectChangeEvent } from "@mui/material/Select"; import { useTranslation } from "next-i18next"; -import { useMediaQuery } from "@mui/material"; +import { useMediaQuery } from "@mui/material"; const ITEM_HEIGHT = 48; const ITEM_PADDING_TOP = 8; @@ -42,27 +42,25 @@ const MultipleSelectCheckmarks: React.FC = ({ }) => { const { t } = useTranslation(); const isSmallScreen = useMediaQuery((theme: any) => - theme.breakpoints.down("sm"), + theme.breakpoints.down("sm") ); const isMediumScreen = useMediaQuery("(max-width:900px)"); - const handleChange = ( - event: SelectChangeEvent, + event: SelectChangeEvent ) => { const { target: { value }, } = event; - let selectedNames = - typeof value === "string" ? value.split(",") : value; + let selectedNames = typeof value === "string" ? value.split(",") : value; if (selectedNames.includes("all")) { selectedNames = defaultValue ? [defaultValue] : []; } const selectedCodes = selectedNames?.map( - (name) => codes[names.indexOf(name)], + (name) => codes[names.indexOf(name)] ); onCategoryChange(selectedNames, selectedCodes); @@ -70,9 +68,8 @@ const MultipleSelectCheckmarks: React.FC = ({ return (
- - {tagName} + + {tagName} From 8cf554e3e6ccb00b2938115e40fe5dad71bd66d8 Mon Sep 17 00:00:00 2001 From: Akshata Katwal Date: Tue, 24 Sep 2024 15:57:38 +0530 Subject: [PATCH 26/40] update pr --- src/components/CommonUserModal.tsx | 35 +++++++++++++++++++++++--- src/components/ReassignCenterModal.tsx | 13 +++++++--- 2 files changed, 40 insertions(+), 8 deletions(-) diff --git a/src/components/CommonUserModal.tsx b/src/components/CommonUserModal.tsx index ffaac1b5..be3fcc87 100644 --- a/src/components/CommonUserModal.tsx +++ b/src/components/CommonUserModal.tsx @@ -11,7 +11,7 @@ import { } from "@/services/CreateUserService"; import { generateUsernameAndPassword } from "@/utils/Helper"; import { FormData } from "@/utils/Interfaces"; -import { FormContext, FormContextType, RoleId ,Role, apiCatchingDuration} from "@/utils/app.constant"; +import { FormContext, FormContextType, RoleId ,Role, apiCatchingDuration, Status} from "@/utils/app.constant"; import { useLocationState } from "@/utils/useLocationState"; import useSubmittedButtonStore from "@/utils/useSharedState"; import { Box, Button, useTheme } from "@mui/material"; @@ -26,6 +26,7 @@ import { showToastMessage } from "./Toastify"; import SendCredentialModal from './SendCredentialModal'; import { sendCredentialService } from "@/services/NotificationService"; import { useQuery } from "@tanstack/react-query"; +import { cohortMemberList } from "@/services/UserList"; interface UserModalProps { open: boolean; @@ -36,7 +37,15 @@ interface UserModalProps { onSubmit: (submitValue: boolean) => void; userType: string; } - +type FilterDetails = { + role: any; + status?: any; + districts?: any; + states?: any; + blocks?: any; + name?: any; + cohortId?: any +}; const CommonUserModal: React.FC = ({ open, onClose, @@ -156,7 +165,7 @@ const CommonUserModal: React.FC = ({ } = useLocationState(open, onClose, roleType); - +console.log(selectedBlockCohortId) useEffect(() => { const getAddUserFormData = () => { try { @@ -345,7 +354,25 @@ const CommonUserModal: React.FC = ({ showToastMessage(t(messageKey), "success"); } else { - + if(userType===Role.TEAM_LEADER) + { + + const filters: FilterDetails= +{ + cohortId:selectedBlockCohortId, + role: Role.TEAM_LEADER, + status:[Status.ACTIVE]} + let limit=200; + let offset=0; + let sort= ["name", "asc"] + let resp; + try { + resp = await cohortMemberList({ limit, filters, sort, offset }); + } catch (apiError) { + console.log("API call failed, proceeding to else block"); + resp = null; + } + } const response = await createUser(apiBody); console.log(response); if (response) { diff --git a/src/components/ReassignCenterModal.tsx b/src/components/ReassignCenterModal.tsx index 8028209e..504297f3 100644 --- a/src/components/ReassignCenterModal.tsx +++ b/src/components/ReassignCenterModal.tsx @@ -320,12 +320,12 @@ const filters: FilterDetails= role: Role.TEAM_LEADER, status:[Status.ACTIVE]} console.log(filters) - let limit=200; - let offset=0; + // let limit=200; + // let offset=0; let sort= ["name", "asc"] let resp; try { - resp = await cohortMemberList({ limit, filters, sort, offset }); + resp = await cohortMemberList({ filters, sort }); } catch (apiError) { console.log("API call failed, proceeding to else block"); resp = null; @@ -770,7 +770,12 @@ finally{ handleCloseConfirmation(); }} > {assignedTeamLeaderNames.length>1 ?( - <>{assignedTeamLeaderNames[0]} and more.. + <> + {t('COMMON.ASSIGNED_TEAM_LEADERS', { assignedTeamLeaderNames:assignedTeamLeaderNames[0]})} + + + + ):(<> {assignedTeamLeaderNames[0]} ) From ff99b8a2bc5734a90f2dca239598d87b48da054c Mon Sep 17 00:00:00 2001 From: Akshata Katwal Date: Tue, 24 Sep 2024 16:07:59 +0530 Subject: [PATCH 27/40] update pr --- src/services/UserList.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/UserList.ts b/src/services/UserList.ts index 0682b9e8..0ce35335 100644 --- a/src/services/UserList.ts +++ b/src/services/UserList.ts @@ -1,7 +1,7 @@ import { post, get } from "./RestClient"; export interface userListParam { - limit: number; + limit?: number; // page: number; filters: { role?: string; From ea112d0ad3d3d7eab62b8f3fbb7e9db8d114cd2c Mon Sep 17 00:00:00 2001 From: Akshata Katwal Date: Tue, 24 Sep 2024 16:13:30 +0530 Subject: [PATCH 28/40] add translation --- public/locales/en/common.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/public/locales/en/common.json b/public/locales/en/common.json index c13c5c33..69a05594 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -129,7 +129,8 @@ "NO_CENTERS": "No centers", "MULTIPLE_TEAM_LEADERS_ASSIGNED": "Selected block {{selectedBlockForTL}} already has {{assignedTeamLeader}} Team Leaders assigned.", "SINGLE_TEAM_LEADERS_ASSIGNED":"Selected block {{selectedBlockForTL}} already has {{assignedTeamLeader}} Team Leader assigned.", - "CONTINUE_ASSIGNED_TEAM_LEADER":"Still do you want to continue to assign team leader to {{selectedBlockForTL}}" + "CONTINUE_ASSIGNED_TEAM_LEADER":"Still do you want to continue to assign team leader to {{selectedBlockForTL}}", + "ASSIGNED_TEAM_LEADERS":"{{assignedTeamLeaderNames}} and more.." }, "LOGIN_PAGE": { "USERNAME": "Username", From 369315e117aa34c3b5694f787a24d3cb7017ac38 Mon Sep 17 00:00:00 2001 From: Akshata Katwal Date: Tue, 24 Sep 2024 16:39:50 +0530 Subject: [PATCH 29/40] update pr: add blockcode while updating user after reassigning block --- src/components/ReassignCenterModal.tsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/components/ReassignCenterModal.tsx b/src/components/ReassignCenterModal.tsx index 504297f3..0dde6a0f 100644 --- a/src/components/ReassignCenterModal.tsx +++ b/src/components/ReassignCenterModal.tsx @@ -367,8 +367,11 @@ console.log(filters) unSelectedBlockCohortIds.push(previousBlockId); + let cohortCode = formattedBlocks +.filter((item:any) => item.label === checkedCenters[0]) +.map((item:any) => item.value); let cohortIds = blocks - .filter((item:any) => item.label !== checkedCenters[0]) + .filter((item:any) => item.value !== cohortCode[0]) .map((item:any) => item.cohortId); cohortIds.push(previousBlockId) payload = { @@ -388,7 +391,7 @@ console.log(filters) let customFields = [ { fieldId: blockField.fieldId, - value: selectedCenterCode, + value: cohortCode, }, ]; console.log(selectedBlockCode,checkedCenters[0]) @@ -507,8 +510,11 @@ let unSelectedBlockCohortIds: string[] = []; console.log(previousBlockId) unSelectedBlockCohortIds.push(previousBlockId); +let cohortCode = formattedBlocks +.filter((item:any) => item.label === selectedBlockForTL) +.map((item:any) => item.value); let cohortIds = blocks -.filter((item:any) => item.label !== selectedBlockForTL) +.filter((item:any) => item.value !== cohortCode) .map((item:any) => item.cohortId); cohortIds.push(previousBlockId) const payload = { @@ -537,7 +543,7 @@ cohortIds.push(previousBlockId) customFields = [ { fieldId: blockField.fieldId, - value: selectedCenterCode, + value: cohortCode, }, { fieldId: districtFieldId, From 945225b080dcd6fbab9d8c40fc1cd5b704fa2a18 Mon Sep 17 00:00:00 2001 From: Akshata Katwal Date: Tue, 24 Sep 2024 20:05:13 +0530 Subject: [PATCH 30/40] Issue feat: PS-2045Add confirmation modal while creating block having already assigned TL --- public/locales/en/common.json | 3 +- src/components/CommonUserModal.tsx | 188 ++++++++++++++++++++++++++++- src/components/CustomModal.tsx | 2 +- src/utils/useLocationState.tsx | 72 +++++++++-- 4 files changed, 252 insertions(+), 13 deletions(-) diff --git a/public/locales/en/common.json b/public/locales/en/common.json index 69a05594..0e97950d 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -130,7 +130,8 @@ "MULTIPLE_TEAM_LEADERS_ASSIGNED": "Selected block {{selectedBlockForTL}} already has {{assignedTeamLeader}} Team Leaders assigned.", "SINGLE_TEAM_LEADERS_ASSIGNED":"Selected block {{selectedBlockForTL}} already has {{assignedTeamLeader}} Team Leader assigned.", "CONTINUE_ASSIGNED_TEAM_LEADER":"Still do you want to continue to assign team leader to {{selectedBlockForTL}}", - "ASSIGNED_TEAM_LEADERS":"{{assignedTeamLeaderNames}} and more.." + "ASSIGNED_TEAM_LEADERS":"{{assignedTeamLeaderNames}} and more..", + "CONTINUE":"Continue" }, "LOGIN_PAGE": { "USERNAME": "Username", diff --git a/src/components/CommonUserModal.tsx b/src/components/CommonUserModal.tsx index 6215c729..ff8375fb 100644 --- a/src/components/CommonUserModal.tsx +++ b/src/components/CommonUserModal.tsx @@ -20,11 +20,12 @@ import { FormContextType, Role, RoleId, + Status, apiCatchingDuration, } from "@/utils/app.constant"; import { useLocationState } from "@/utils/useLocationState"; import useSubmittedButtonStore from "@/utils/useSharedState"; -import { Box, Button, useTheme } from "@mui/material"; +import { Box, Button, Checkbox, FormControlLabel, Typography, useTheme } from "@mui/material"; import { IChangeEvent } from "@rjsf/core"; import { RJSFSchema } from "@rjsf/utils"; import { useQuery } from "@tanstack/react-query"; @@ -35,6 +36,9 @@ import { transformArray } from "../utils/Helper"; import AreaSelection from "./AreaSelection"; import SendCredentialModal from "./SendCredentialModal"; import { showToastMessage } from "./Toastify"; +import { cohortMemberList } from "@/services/UserList"; +import CustomModal from "./CustomModal"; +import { setConfig } from "next/config"; interface UserModalProps { open: boolean; @@ -46,6 +50,16 @@ interface UserModalProps { userType: string; } + +type FilterDetails = { + role: any; + status?: any; + districts?: any; + states?: any; + blocks?: any; + name?: any; + cohortId?: any +}; const CommonUserModal: React.FC = ({ open, onClose, @@ -60,6 +74,13 @@ const CommonUserModal: React.FC = ({ const [uiSchema, setUiSchema] = React.useState(); const [openModal, setOpenModal] = React.useState(false); const [adminInfo, setAdminInfo] = React.useState(); + const [createTLAlertModal, setcreateTLAlertModal] = useState(false); + const [selectedBlockForTL, setSelectedBlockForTL] = useState(""); + const [confirmButtonDisable, setConfirmButtonDisable] = useState(true); + const [checkedConfirmation, setCheckedConfirmation] = useState(false); + const [selectedBlockCohortIdForTL, setSelectedBlockCohortIdForTL] = useState(""); + const [selectedTLUserID, setSelectedTLUserID] = useState(userId); + const messageKeyMap: Record = { [FormContextType.STUDENT]: "LEARNERS.LEARNER_CREATED_SUCCESSFULLY", [FormContextType.TEACHER]: "FACILITATORS.FACILITATOR_CREATED_SUCCESSFULLY", @@ -167,7 +188,10 @@ const CommonUserModal: React.FC = ({ stateFieldId, dynamicFormForBlock, stateDefaultValue, + assignedTeamLeader, + assignedTeamLeaderNames } = useLocationState(open, onClose, roleType); + console.log(assignedTeamLeaderNames) useEffect(() => { const getAddUserFormData = () => { @@ -464,7 +488,6 @@ const CommonUserModal: React.FC = ({ const handleChange = (event: IChangeEvent) => { console.log("Form data changed:", event.formData); }; - const handleError = (errors: any) => { console.log("Form errors:", errors); }; @@ -472,7 +495,33 @@ const CommonUserModal: React.FC = ({ setCreateFacilitator(false); setOpenModal(false); }; + const handleBlockAction = async() => { + // const filters: FilterDetails= + // { + // cohortId:selectedBlockCohortId, + // role: Role.TEAM_LEADER, + // status:[Status.ACTIVE]} + + // let sort= ["name", "asc"] + // let resp; + // try { + // resp = await cohortMemberList({ filters, sort }); + // } catch (apiError) { + // console.log("API call failed, proceeding to else block"); + // resp = null; + // } + // if(resp?.userDetails) + // { + // // onClose(); + // setcreateTLAlertModal(true) + // // setAssignedTeamLeader(resp?.userDetails?.length) + // setSelectedBlockForTL(selectedBlock[0]) + // const userNames = resp?.userDetails?.map((user: any )=> user.name); + // //setSelectedTLUserID(userId) + // // setAssignedTeamLeaderNames(userNames) + // } + }; const handleAction = () => { setTimeout(() => { setCreateFacilitator(true); @@ -499,6 +548,45 @@ const CommonUserModal: React.FC = ({ setSubmitButtonEnable(true); } }, [dynamicForm, dynamicFormForBlock, open]); + + + const handleChangeCheckBox = (event: React.ChangeEvent) => { + setCheckedConfirmation(event.target.checked); + + }; + + const wrappedHandleContinueAction = () => { + handleCloseConfirmation(); + setOpenModal(true); + //onClose(); + + + +} + + const handleCancelAction = async () => { + // await handleDeleteAction(); + handleCloseConfirmation(); +//setAssignedTeamLeaderNames([]); + }; + const handleCloseConfirmation= () => { + // await handleDeleteAction(); + // handleCloseConfirmation(); + setcreateTLAlertModal(false); + setCheckedConfirmation(false); + setConfirmButtonDisable(true); + // setAssignedTeamLeaderNames([]); + + }; + + + useEffect(() => { + if (checkedConfirmation) { + setConfirmButtonDisable(false); + } else { + setConfirmButtonDisable(true); + } + }, [checkedConfirmation]); useEffect(() => { if (typeof window !== "undefined" && window.localStorage) { const admin = localStorage.getItem("adminInfo"); @@ -554,7 +642,18 @@ const CommonUserModal: React.FC = ({ !isEditModal && noError ) { - setOpenModal(true); + // setOpenModal(true); + console.log(assignedTeamLeaderNames.length) + if(assignedTeamLeaderNames.length!==0 && userType===FormContextType.TEAM_LEADER) + { + setcreateTLAlertModal(true); + // setOpenModal(true) + + } + else{ + //onClose(); + setOpenModal(true) + } } console.log("Submit button was clicked"); }} @@ -664,6 +763,89 @@ const CommonUserModal: React.FC = ({ : Role.TEACHER } /> + + + + + + + + + + + + +{assignedTeamLeaderNames.length>1 ?( + <> + {t('COMMON.MULTIPLE_TEAM_LEADERS_ASSIGNED', { selectedBlockForTL: selectedBlock[0],assignedTeamLeader: assignedTeamLeader})} + + + ):(<> + + {t('COMMON.SINGLE_TEAM_LEADERS_ASSIGNED', { selectedBlockForTL: selectedBlock[0],assignedTeamLeader: assignedTeamLeader})} + + ) +} + + + + {assignedTeamLeaderNames.length>1 ?( + <> + {t('COMMON.ASSIGNED_TEAM_LEADERS', { assignedTeamLeaderNames:assignedTeamLeaderNames[0]})} + + + + + ):(<> + {assignedTeamLeaderNames[0]} + ) + + } + + + } + label={ t('COMMON.CONTINUE_ASSIGNED_TEAM_LEADER', {selectedBlockForTL: selectedBlock[0]})} + sx={{ marginTop: "12px", color: "#555" }} + /> + + ); }; diff --git a/src/components/CustomModal.tsx b/src/components/CustomModal.tsx index 2dd3d161..3a32cdd9 100644 --- a/src/components/CustomModal.tsx +++ b/src/components/CustomModal.tsx @@ -63,7 +63,7 @@ const CustomModal: React.FC = ({ top: "50%", left: "50%", transform: "translate(-50%, -50%)", - width: isSmallScreen ? "90%" : isLargeScreen ? width : "85%", + width: isSmallScreen ? "90%" : isLargeScreen ? width : width, maxWidth: "90%", bgcolor: "background.paper", boxShadow: 24, diff --git a/src/utils/useLocationState.tsx b/src/utils/useLocationState.tsx index 07a51343..76ec2c07 100644 --- a/src/utils/useLocationState.tsx +++ b/src/utils/useLocationState.tsx @@ -5,11 +5,20 @@ import { getCenterList, } from "../services/MasterDataService"; // Update the import path as needed import { getCohortList } from "@/services/CohortService/cohortService"; -import { FormContextType, QueryKeys } from "./app.constant"; +import { FormContextType, QueryKeys, Status, Role } from "./app.constant"; import { useTranslation } from "react-i18next"; import { useQueryClient } from "@tanstack/react-query"; import { formatedBlocks, formatedDistricts } from "@/services/formatedCohorts"; - +import { cohortMemberList } from "@/services/UserList"; +type FilterDetails = { + role: any; + status?: any; + districts?: any; + states?: any; + blocks?: any; + name?: any; + cohortId?: any +}; interface FieldProp { value: string; label: string; @@ -50,6 +59,8 @@ export const useLocationState = ( const [stateDefaultValue, setStateDefaultValue] = useState(""); const { t } = useTranslation(); const queryClient = useQueryClient(); + const [assignedTeamLeader, setAssignedTeamLeader] = useState(""); + const [assignedTeamLeaderNames, setAssignedTeamLeaderNames] = useState([]); const handleStateChangeWrapper = useCallback( async (selectedNames: string[], selectedCodes: string[]) => { @@ -154,17 +165,53 @@ export const useLocationState = ( }; const response = await getCenterList(object); const getCohortDetails = response?.result?.results?.cohortDetails; + console.log(getCohortDetails) const blockId = getCohortDetails?.map((item: any) => { if (item?.type === "BLOCK") { return item?.cohortId; } - }); + }) + const blockCohortId = getCohortDetails?.find( + (item: any) => item?.type === "BLOCK" + )?.cohortId; if (blockId) { console.log("blockId", blockId[0]); setSelectedBlockCohortId(blockId[0]); } else { console.log("No Block Id found"); } + + + const filters: FilterDetails= + { + cohortId:blockCohortId, + role: Role.TEAM_LEADER, + status:[Status.ACTIVE]} + + let sort= ["name", "asc"] + let resp; + try { + resp = await cohortMemberList({ filters, sort }); + } catch (apiError) { + console.log("API call failed, proceeding to else block"); + resp = null; + } + if(resp?.userDetails) + { + + // onClose(); + // setcreateTLAlertModal(true) + setAssignedTeamLeader(resp?.userDetails?.length) + // setSelectedBlockForTL(selectedBlock[0]) + const userNames = resp?.userDetails?.map((user: any )=> user.name); + //setSelectedTLUserID(userId) + setAssignedTeamLeaderNames(userNames) + } + else{ + setAssignedTeamLeader(""); + setAssignedTeamLeaderNames([]) + } + } else { const getCentersObject = { limit: 0, @@ -180,9 +227,14 @@ export const useLocationState = ( }; const response = await getCenterList(getCentersObject); console.log(response?.result?.results?.cohortDetails[0].cohortId); - setSelectedBlockCohortId( - response?.result?.results?.cohortDetails[0].cohortId - ); + // setSelectedBlockCohortId( + // response?.result?.results?.cohortDetails[0].cohortId + // ); + const blockCohortId = response?.result?.results?.cohortDetails?.find( + (item: any) => item?.type === "BLOCK" + )?.cohortId; + console.log(blockCohortId) + setSelectedBlockCohortId(blockCohortId) // const result = response?.result?.cohortDetails; const dataArray = response?.result?.results?.cohortDetails; @@ -195,7 +247,9 @@ export const useLocationState = ( console.log(dataArray); setAllCenters(cohortInfo); } - console.log(selected); + + + console.log(selected); } catch (error) { setAllCenters([]); @@ -462,7 +516,9 @@ export const useLocationState = ( setSelectedBlock, setSelectedDistrict, setSelectedDistrictCode, - setSelectedBlockCode + setSelectedBlockCode, + assignedTeamLeaderNames, + assignedTeamLeader }; }; From 9f433413bae4042d3f6d6d24d5a7101cfc2c09b7 Mon Sep 17 00:00:00 2001 From: Akshata Katwal Date: Tue, 24 Sep 2024 20:11:37 +0530 Subject: [PATCH 31/40] update pr --- src/components/CommonUserModal.tsx | 28 +--------------------------- 1 file changed, 1 insertion(+), 27 deletions(-) diff --git a/src/components/CommonUserModal.tsx b/src/components/CommonUserModal.tsx index ff8375fb..8e4d7e6b 100644 --- a/src/components/CommonUserModal.tsx +++ b/src/components/CommonUserModal.tsx @@ -495,33 +495,7 @@ const CommonUserModal: React.FC = ({ setCreateFacilitator(false); setOpenModal(false); }; - const handleBlockAction = async() => { - // const filters: FilterDetails= - // { - // cohortId:selectedBlockCohortId, - // role: Role.TEAM_LEADER, - // status:[Status.ACTIVE]} - - // let sort= ["name", "asc"] - // let resp; - // try { - // resp = await cohortMemberList({ filters, sort }); - // } catch (apiError) { - // console.log("API call failed, proceeding to else block"); - // resp = null; - // } - // if(resp?.userDetails) - // { - - // // onClose(); - // setcreateTLAlertModal(true) - // // setAssignedTeamLeader(resp?.userDetails?.length) - // setSelectedBlockForTL(selectedBlock[0]) - // const userNames = resp?.userDetails?.map((user: any )=> user.name); - // //setSelectedTLUserID(userId) - // // setAssignedTeamLeaderNames(userNames) - // } - }; + const handleAction = () => { setTimeout(() => { setCreateFacilitator(true); From 8f7c329d2f35a0474c6939eec02392c803fecd0d Mon Sep 17 00:00:00 2001 From: Akshata Katwal Date: Wed, 25 Sep 2024 08:39:21 +0530 Subject: [PATCH 32/40] update pr: remove unwanted code --- src/components/CommonUserModal.tsx | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/src/components/CommonUserModal.tsx b/src/components/CommonUserModal.tsx index 8e4d7e6b..cfdc7f91 100644 --- a/src/components/CommonUserModal.tsx +++ b/src/components/CommonUserModal.tsx @@ -51,15 +51,7 @@ interface UserModalProps { } -type FilterDetails = { - role: any; - status?: any; - districts?: any; - states?: any; - blocks?: any; - name?: any; - cohortId?: any -}; + const CommonUserModal: React.FC = ({ open, onClose, @@ -75,12 +67,9 @@ const CommonUserModal: React.FC = ({ const [openModal, setOpenModal] = React.useState(false); const [adminInfo, setAdminInfo] = React.useState(); const [createTLAlertModal, setcreateTLAlertModal] = useState(false); - const [selectedBlockForTL, setSelectedBlockForTL] = useState(""); const [confirmButtonDisable, setConfirmButtonDisable] = useState(true); const [checkedConfirmation, setCheckedConfirmation] = useState(false); - const [selectedBlockCohortIdForTL, setSelectedBlockCohortIdForTL] = useState(""); - const [selectedTLUserID, setSelectedTLUserID] = useState(userId); - + const messageKeyMap: Record = { [FormContextType.STUDENT]: "LEARNERS.LEARNER_CREATED_SUCCESSFULLY", [FormContextType.TEACHER]: "FACILITATORS.FACILITATOR_CREATED_SUCCESSFULLY", From ba614eef893f6dc7384b14fbcb574c9b6b96cc74 Mon Sep 17 00:00:00 2001 From: ttpl-rt-217 Date: Wed, 25 Sep 2024 15:01:51 +0530 Subject: [PATCH 33/40] Task #PS-1656 : UI improvements --- src/components/AreaSelection.tsx | 68 ++++++-- src/components/HeaderComponent.tsx | 271 ++++++++++++++--------------- src/components/SimpleModal.tsx | 8 +- 3 files changed, 184 insertions(+), 163 deletions(-) diff --git a/src/components/AreaSelection.tsx b/src/components/AreaSelection.tsx index 41490aea..8a3dcf09 100644 --- a/src/components/AreaSelection.tsx +++ b/src/components/AreaSelection.tsx @@ -111,24 +111,36 @@ const AreaSelection: React.FC = ({ sx={{ display: "flex", width: "100%", + justifyContent: "space-between", + "@media (max-width: 900px)": { + flexDirection: "column", + }, }} > {userType && !reAssignModal && ( - - {userType} - + + + {userType} + + )} - {!isSmallScreen && ( - - )} - + + - + @@ -144,7 +156,13 @@ const AreaSelection: React.FC = ({ defaultValue={stateDefaultValue} /> - + district.label)} codes={districts?.map((district) => district.value)} @@ -166,7 +184,13 @@ const AreaSelection: React.FC = ({ } /> - + {shouldRenderSelectCheckmarks && ( = ({ /> )} - - {isCenterSelection && ( + {isCenterSelection && ( + center.name) @@ -214,8 +244,8 @@ const AreaSelection: React.FC = ({ : t("COMMON.ALL_CENTERS") } /> - )} - + + )} diff --git a/src/components/HeaderComponent.tsx b/src/components/HeaderComponent.tsx index 4421affe..93ba3bd5 100644 --- a/src/components/HeaderComponent.tsx +++ b/src/components/HeaderComponent.tsx @@ -86,7 +86,6 @@ const HeaderComponent = ({ setSelectedCenterCode, setSelectedStateCode, }: any) => { - const { t } = useTranslation(); const queryClient = useQueryClient(); const router = useRouter(); @@ -183,7 +182,7 @@ const HeaderComponent = ({ // }; // const response = await getStateBlockDistrictList(object); const result = response?.result?.values; - const blockResult=await formatedBlocks(selectedCodes[0]) + const blockResult = await formatedBlocks(selectedCodes[0]); setBlocks(blockResult); } catch (error) { @@ -244,20 +243,20 @@ const HeaderComponent = ({ useEffect(() => { const fetchData = async () => { - const { state, district, center } = router.query; -console.log(router.asPath) -const fullPath = router.asPath; - -// Extract query parameters -const queryString = fullPath.split('?')[1]; // Get the part after '?' -console.log(queryString) -const params = new URLSearchParams(queryString); - -// Check if 'block' is present -const hasBlock = params.has('block'); -const hasDistrict = params.has('district'); -const hasCenter = params.has('center'); -const hasState = params.has('state'); + const { state, district, center } = router.query; + console.log(router.asPath); + const fullPath = router.asPath; + + // Extract query parameters + const queryString = fullPath.split("?")[1]; // Get the part after '?' + console.log(queryString); + const params = new URLSearchParams(queryString); + + // Check if 'block' is present + const hasBlock = params.has("block"); + const hasDistrict = params.has("district"); + const hasCenter = params.has("center"); + const hasState = params.has("state"); try { const object = { // "limit": 20, @@ -300,116 +299,116 @@ const hasState = params.has('state'); // console.log(object); // const response = await getStateBlockDistrictList(object); const result = response?.result?.values; - const districtResult= await formatedDistricts(); + const districtResult = await formatedDistricts(); setDistricts(districtResult); - if(!hasDistrict) - { - setSelectedDistrict([districtResult[0]?.label]) - setSelectedDistrictCode(districtResult[0]?.value) - localStorage.setItem('selectedDistrict', districtResult[0]?.label) - setSelectedDistrictStore(districtResult[0]?.label) - + if (!hasDistrict) { + setSelectedDistrict([districtResult[0]?.label]); + setSelectedDistrictCode(districtResult[0]?.value); + localStorage.setItem( + "selectedDistrict", + districtResult[0]?.label + ); + setSelectedDistrictStore(districtResult[0]?.label); } - const blockResult=await formatedBlocks(districtResult[0]?.value) + const blockResult = await formatedBlocks( + districtResult[0]?.value + ); setBlocks(blockResult); - if(!hasBlock && !hasDistrict) - { - - if(userType===Role.TEAM_LEADERS) - { - setSelectedBlock([t("COMMON.ALL_BLOCKS")]) + if (!hasBlock && !hasDistrict) { + if (userType === Role.TEAM_LEADERS) { + setSelectedBlock([t("COMMON.ALL_BLOCKS")]); //setSelectedBlockCode("") router.replace({ pathname: router.pathname, - query: { - ...router.query, - state: stateField.code, - district: districtResult[0]?.value, - } + query: { + ...router.query, + state: stateField.code, + district: districtResult[0]?.value, + }, }); - } - else{ + } else { + setSelectedBlock([blockResult[0]?.label]); + setSelectedBlockCode(blockResult[0]?.value); + localStorage.setItem("selectedBlock", blockResult[0]?.label); + setSelectedBlockStore(blockResult[0]?.label); - setSelectedBlock([blockResult[0]?.label]) - setSelectedBlockCode(blockResult[0]?.value) - localStorage.setItem('selectedBlock',blockResult[0]?.label ) - setSelectedBlockStore(blockResult[0]?.label) + router.replace({ + pathname: router.pathname, + query: { + ...router.query, + state: stateField.code, + district: districtResult[0]?.value, + block: blockResult[0]?.value, + }, + }); + } + } + + const getCentersObject = { + limit: 0, + offset: 0, + filters: { + // "type":"COHORT", + status: ["active"], + states: stateField.code, + districts: districtResult[0]?.value, + blocks: blockResult[0]?.value, + // "name": selected[0] + }, + }; + const centerResponse = await queryClient.fetchQuery({ + queryKey: [ + QueryKeys.FIELD_OPTION_READ, + getCentersObject.limit, + getCentersObject.offset, + getCentersObject.filters, + ], + queryFn: () => getCenterList(getCentersObject), + }); + // const response = await getCenterList(getCentersObject); + console.log(centerResponse); + // setSelectedBlockCohortId( + // response?.result?.results?.cohortDetails[0].cohortId + // ); + // const result = response?.result?.cohortDetails; + const dataArray = centerResponse?.result?.results?.cohortDetails; + console.log(dataArray); + + const cohortInfo = dataArray + ?.filter((cohort: any) => cohort.type !== "BLOCK") + .map((item: any) => ({ + cohortId: item?.cohortId, + name: item?.name, + })); + setAllCenters(cohortInfo); + console.log(dataArray); + console.log(userType); + if ( + !hasCenter && + !hasBlock && + !hasDistrict && + userType !== Role.TEAM_LEADERS + ) { + console.log(hasCenter); + setSelectedCenter([t("COMMON.ALL_CENTERS")]); + // setSelectedCenterCode([cohortInfo[0]?.cohortId]) + // localStorage.setItem('selectedCenter',cohortInfo[0]?.name ) + // setSelectedCenterStore(cohortInfo[0]?.name) router.replace({ pathname: router.pathname, - query: { - ...router.query, - state: stateField.code, - district: districtResult[0]?.value, - block: blockResult[0]?.value - } + query: { + ...router.query, + state: stateField.code, + district: districtResult[0]?.value, + block: blockResult[0]?.value, + // center: cohortInfo[0]?.cohortId + }, }); + } - } - - } - - const getCentersObject = { - limit: 0, - offset: 0, - filters: { - // "type":"COHORT", - status: ["active"], - states: stateField.code, - districts: districtResult[0]?.value, - blocks: blockResult[0]?.value, - // "name": selected[0] - }, - }; - const centerResponse = await queryClient.fetchQuery({ - queryKey: [ - QueryKeys.FIELD_OPTION_READ, - getCentersObject.limit, - getCentersObject.offset, - getCentersObject.filters, - ], - queryFn: () => getCenterList(getCentersObject), - }); - // const response = await getCenterList(getCentersObject); - console.log(centerResponse); - // setSelectedBlockCohortId( - // response?.result?.results?.cohortDetails[0].cohortId - // ); - // const result = response?.result?.cohortDetails; - const dataArray = centerResponse?.result?.results?.cohortDetails; - console.log(dataArray); - - const cohortInfo = dataArray - ?.filter((cohort: any) => cohort.type !== "BLOCK") - .map((item: any) => ({ - cohortId: item?.cohortId, - name: item?.name, - })); - setAllCenters(cohortInfo); - - console.log(dataArray); - console.log(userType) - if(!hasCenter && !hasBlock && !hasDistrict && userType!==Role.TEAM_LEADERS) - { - console.log(hasCenter) - setSelectedCenter([t("COMMON.ALL_CENTERS")]) - // setSelectedCenterCode([cohortInfo[0]?.cohortId]) - // localStorage.setItem('selectedCenter',cohortInfo[0]?.name ) - // setSelectedCenterStore(cohortInfo[0]?.name) - router.replace({ - pathname: router.pathname, - query: { - ...router.query, - state: stateField.code, - district: districtResult[0]?.value, - block: blockResult[0]?.value , - // center: cohortInfo[0]?.cohortId - } - }); - } - - console.log(cohortInfo) + console.log(cohortInfo); } const object = [ @@ -431,7 +430,7 @@ const hasState = params.has('state'); if (shouldFetchDistricts) { fetchData(); } - }, [shouldFetchDistricts,userType]); + }, [shouldFetchDistricts, userType]); const handleChange = (event: React.SyntheticEvent, newValue: any) => { console.log(newValue); setStatusValue(newValue); @@ -454,50 +453,42 @@ const hasState = params.has('state'); // }, [blocks, selectedBlock, handleBlockChangeWrapper]); useEffect(() => { - const { state, district, block, center } = router.query; { - if (state) { - setSelectedStateCode(state.toString()); + setSelectedStateCode(state.toString()); } - + if (district) { setSelectedDistrictCode(district.toString()); - // setSelectedDistrict([selectedDistrictStore]) - setSelectedDistrict([localStorage.getItem('selectedDistrict')]) - if(!localStorage.getItem('selectedDistrict')) - { - setSelectedDistrict([selectedDistrictStore]) + // setSelectedDistrict([selectedDistrictStore]) + setSelectedDistrict([localStorage.getItem("selectedDistrict")]); + if (!localStorage.getItem("selectedDistrict")) { + setSelectedDistrict([selectedDistrictStore]); } - } - + if (block) { - setSelectedBlockCode(block.toString()); - console.log(selectedBlockCode) - // setSelectedBlock([selectedBlockStore]) - setSelectedBlock([localStorage.getItem('selectedBlock')]) - if(!localStorage.getItem('selectedBlock')) - setSelectedBlock([selectedBlockStore]) + console.log(selectedBlockCode); + // setSelectedBlock([selectedBlockStore]) + setSelectedBlock([localStorage.getItem("selectedBlock")]); + if (!localStorage.getItem("selectedBlock")) + setSelectedBlock([selectedBlockStore]); } - + if (center) { - console.log(center) + console.log(center); setSelectedCenterCode([center.toString()]); - // setSelectedCenter([selectedCenterStore]) - setSelectedCenter([localStorage.getItem('selectedCenter')]) - if(!localStorage.getItem('selectedCenter')) - setSelectedCenter([selectedCenterStore]) - + // setSelectedCenter([selectedCenterStore]) + setSelectedCenter([localStorage.getItem("selectedCenter")]); + if (!localStorage.getItem("selectedCenter")) + setSelectedCenter([selectedCenterStore]); } - // setInitialized(true) + // setInitialized(true) } - }, [router]); - return ( = ({ top: "50%", left: "50%", transform: "translate(-50%, -50%)", - width: isSmallScreen ? "90%" : isLargeScreen ? "65%" : "85%", + width: isSmallScreen ? "90%" : "40%", maxHeight: "80vh", backgroundColor: "#fff", - borderRadius: '8px', + borderRadius: "8px", boxShadow: theme.shadows[5], }; @@ -60,8 +60,8 @@ const SimpleModal: React.FC = ({ padding: theme.spacing(2), zIndex: 9999, borderBottom: `1px solid ${theme.palette.divider}`, - borderTopLeftRadius: '8px', - borderTopRightRadius: '8px', + borderTopLeftRadius: "8px", + borderTopRightRadius: "8px", }; const contentStyle = { From 26e8a7a66a22b16d69e514d7e7ef63c447eaf1f9 Mon Sep 17 00:00:00 2001 From: Akshata Katwal Date: Thu, 26 Sep 2024 12:45:41 +0530 Subject: [PATCH 34/40] Issue bug: Filter center list by type cohort --- src/pages/centers.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/pages/centers.tsx b/src/pages/centers.tsx index 829369e6..15fff100 100644 --- a/src/pages/centers.tsx +++ b/src/pages/centers.tsx @@ -214,8 +214,10 @@ const Center: React.FC = () => { return await getCohortMemberlistData(cohortId); }) ); - - result?.forEach((item: any, index: number) => { +console.log(result) +const finalResult= result +?.filter((cohort: any) => cohort.type === "COHORT") +finalResult?.forEach((item: any, index: number) => { const cohortType = item?.customFields?.find( (field: any) => field.label === "TYPE_OF_COHORT" @@ -243,6 +245,7 @@ const Center: React.FC = () => { }; resultData?.push(requiredData); }); + console.log(resultData) setCohortData(resultData); const totalCount = resp?.count; setTotalCound(totalCount); From 483ce2731759c4521944b04dd3824e5fb146090c Mon Sep 17 00:00:00 2001 From: Akshata Katwal Date: Thu, 26 Sep 2024 14:04:14 +0530 Subject: [PATCH 35/40] update pr: add correct block cohort id --- src/utils/useLocationState.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/utils/useLocationState.tsx b/src/utils/useLocationState.tsx index 76ec2c07..0fa78df2 100644 --- a/src/utils/useLocationState.tsx +++ b/src/utils/useLocationState.tsx @@ -174,9 +174,10 @@ export const useLocationState = ( const blockCohortId = getCohortDetails?.find( (item: any) => item?.type === "BLOCK" )?.cohortId; - if (blockId) { - console.log("blockId", blockId[0]); - setSelectedBlockCohortId(blockId[0]); + console.log(blockCohortId) + if (blockCohortId) { + console.log("blockId", blockId); + setSelectedBlockCohortId(blockCohortId); } else { console.log("No Block Id found"); } From 3b73b8aa2383fdadf1d89b656830c46e4cec6889 Mon Sep 17 00:00:00 2001 From: Akshata Katwal Date: Thu, 26 Sep 2024 14:53:29 +0530 Subject: [PATCH 36/40] update confermation popup modal width --- src/components/CommonUserModal.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/CommonUserModal.tsx b/src/components/CommonUserModal.tsx index cfdc7f91..89e263b5 100644 --- a/src/components/CommonUserModal.tsx +++ b/src/components/CommonUserModal.tsx @@ -736,7 +736,7 @@ const CommonUserModal: React.FC = ({ Date: Thu, 26 Sep 2024 15:09:28 +0530 Subject: [PATCH 37/40] update pr --- src/components/UserTable.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/UserTable.tsx b/src/components/UserTable.tsx index 5532267b..2544586a 100644 --- a/src/components/UserTable.tsx +++ b/src/components/UserTable.tsx @@ -22,7 +22,7 @@ import PersonSearchIcon from "@mui/icons-material/PersonSearch"; import { Role, apiCatchingDuration } from "@/utils/app.constant"; import { getFormRead } from "@/services/CreateUserService"; import { showToastMessage } from "./Toastify"; -import { capitalizeFirstLetterOfEachWordInArray } from "../utils/Helper"; +import { capitalizeFirstLetterOfEachWordInArray , firstLetterInUpperCase} from "../utils/Helper"; import { getUserTableColumns, getTLTableColumns } from "@/data/tableColumns"; import { TablePagination, useMediaQuery } from "@mui/material"; import { Theme } from "@mui/system"; @@ -876,9 +876,9 @@ console.log(code[0]) // gender: user.gender, mobile: user.mobile === "NaN" ? "-" : user.mobile, age: ageField ? ageField?.value : "-", - district: districtField ? districtField?.value+" , "+blockField?.value : "-", + district: districtField ? districtField?.value+" , "+firstLetterInUpperCase(blockField?.value) : "-", state: stateField ? stateField?.value : "-", - blocks: blockField ? blockField?.value : "-", + blocks: blockField ? firstLetterInUpperCase(blockField?.value) : "-", gender: genderField ? genderField?.value?.charAt(0)?.toUpperCase() + genderField?.value?.slice(1).toLowerCase() @@ -930,9 +930,9 @@ console.log(code[0]) // gender: user.gender, mobile: user.mobile === "NaN" ? "-" : user?.mobile, age: ageField ? ageField?.value : "-", - district: districtField ? districtField?.value+" , "+blockField?.value : "-", + district: districtField ? districtField?.value+" , "+firstLetterInUpperCase(blockField?.value) : "-", state: stateField ? stateField?.value : "-", - blocks: blockField ? blockField?.value : "-", + blocks: blockField ? firstLetterInUpperCase(blockField?.value) : "-", gender: genderField ? genderField.value?.charAt(0)?.toUpperCase() + genderField.value.slice(1).toLowerCase() From 01e4b92bf6c8962fefcd6a1dd4a1b09ac1bf05e2 Mon Sep 17 00:00:00 2001 From: Akshata Katwal Date: Thu, 26 Sep 2024 18:16:56 +0530 Subject: [PATCH 38/40] Issue bug: Resolve route query param issue --- src/components/HeaderComponent.tsx | 11 +-- src/components/UserTable.tsx | 105 +++++++++++++++++++++++------ 2 files changed, 92 insertions(+), 24 deletions(-) diff --git a/src/components/HeaderComponent.tsx b/src/components/HeaderComponent.tsx index 93ba3bd5..b6155132 100644 --- a/src/components/HeaderComponent.tsx +++ b/src/components/HeaderComponent.tsx @@ -458,8 +458,8 @@ const HeaderComponent = ({ if (state) { setSelectedStateCode(state.toString()); } - - if (district) { + console.log(selectedDistrict) + if (district && selectedDistrict.length!==0 && selectedDistrict[0]!==t("COMMON.ALL_DISTRICTS")) { setSelectedDistrictCode(district.toString()); // setSelectedDistrict([selectedDistrictStore]) setSelectedDistrict([localStorage.getItem("selectedDistrict")]); @@ -467,8 +467,9 @@ const HeaderComponent = ({ setSelectedDistrict([selectedDistrictStore]); } } + - if (block) { + if (block && selectedBlock.length!==0 &&selectedBlock[0]!==t("COMMON.ALL_BLOCKS")) { setSelectedBlockCode(block.toString()); console.log(selectedBlockCode); // setSelectedBlock([selectedBlockStore]) @@ -476,8 +477,9 @@ const HeaderComponent = ({ if (!localStorage.getItem("selectedBlock")) setSelectedBlock([selectedBlockStore]); } + - if (center) { + if (center && selectedCenter.length!==0 &&selectedCenter[0]!==t("COMMON.ALL_CENTERS")) { console.log(center); setSelectedCenterCode([center.toString()]); @@ -486,6 +488,7 @@ const HeaderComponent = ({ if (!localStorage.getItem("selectedCenter")) setSelectedCenter([selectedCenterStore]); } + // setInitialized(true) } }, [router]); diff --git a/src/components/UserTable.tsx b/src/components/UserTable.tsx index 2544586a..d1d2af86 100644 --- a/src/components/UserTable.tsx +++ b/src/components/UserTable.tsx @@ -355,21 +355,14 @@ const UserTable: React.FC = ({ const handleDistrictChange = (selected: string[], code: string[]) => { const newQuery = { ...router.query }; - +console.log(selected) if (newQuery.center) { delete newQuery.center; } if (newQuery.block) { delete newQuery.block; } - router.replace({ - pathname: router.pathname, - query: { - ...newQuery, - state: selectedStateCode, - district: code?.join(",") - } - }); + setSelectedCenterCode([]) setEnableCenterFilter(false) @@ -382,6 +375,7 @@ localStorage.setItem('selectedDistrict', selected[0]) setSelectedDistrictStore(selected[0]) if (selected[0] === "" || selected[0] === t("COMMON.ALL_DISTRICTS")) { + if (filters.status) { setFilters({ states: selectedStateCode, @@ -395,7 +389,25 @@ setSelectedDistrictStore(selected[0]) role: role, }); } + if (newQuery.district) { + delete newQuery.district; + } + router.replace({ + pathname: router.pathname, + query: { + ...newQuery, + state: selectedStateCode, + } + }); } else { + router.replace({ + pathname: router.pathname, + query: { + ...newQuery, + state: selectedStateCode, + district: code?.join(",") + } + }); const districts = code?.join(","); setSelectedDistrictCode(districts); if (filters.status) { @@ -429,15 +441,7 @@ setSelectedDistrictStore(selected[0]) delete newQuery.block; } console.log(code?.join(",")) - router.replace({ - pathname: router.pathname, - query: { - ...newQuery, - state: selectedStateCode, - district: selectedDistrictCode, - block: code?.join(",") - } - }); + setSelectedBlock(selected); @@ -471,6 +475,15 @@ setSelectedDistrictStore(selected[0]) }); } } else { + router.replace({ + pathname: router.pathname, + query: { + ...newQuery, + state: selectedStateCode, + district: selectedDistrictCode, + block: code?.join(",") + } + }); const blocks = code?.join(","); setSelectedBlockCode(blocks); if (filters.status) { @@ -1087,8 +1100,60 @@ console.log(selectedBlockStore) // } // ) - if(selectedDistrictCode) + // console.log(selectedDistrict) + // console.log(selectedBlock) + // if( selectedDistrict.length===0 ||selectedDistrict[0]==="All Districts") + // { + // const newQuery = { ...router.query }; + + // if (newQuery.district) { + // delete newQuery.district; + // } + // if (newQuery.block) { + // delete newQuery.block; + // } + // if(newQuery.center) + // { + // delete newQuery.center; + // } + // console.log(newQuery) + // router.replace({ + // pathname: router.pathname, + // query: { + // ...newQuery, + // } + // }); + + // } + // console.log(selectedBlock) + // if( selectedBlock.length===0 ||selectedBlock[0]==="All Blocks") + // { + // const newQuery = { ...router.query }; + + // // if (newQuery.district) { + // // delete newQuery.district; + // // } + + // if (newQuery.block) { + // delete newQuery.block; + // } + // if(newQuery.center) + // { + // delete newQuery.center; + // } + // router.replace({ + // pathname: router.pathname, + // query: { + // ...newQuery, + // } + // }); + + // } + + + if(selectedDistrictCode && selectedDistrict.length!==0 &&selectedDistrict[0]!==t("COMMON.ALL_DISTRICTS")) { + console.log("true---") setFilters({ states: stateField.code, districts:selectedDistrictCode, @@ -1097,7 +1162,7 @@ console.log(selectedBlockStore) status:[statusValue], }) } - if(selectedBlockCode) + if(selectedBlockCode && selectedBlock.length!==0 && selectedBlock[0]!==t("COMMON.ALL_BLOCKS")) { setFilters({ states: stateField.code, From bdb7d738ffc74ee592150c758cb91a96bf78e992 Mon Sep 17 00:00:00 2001 From: Akshata Katwal Date: Fri, 27 Sep 2024 18:49:53 +0530 Subject: [PATCH 39/40] Issue feat: remove unwanted condition to set query param --- src/components/HeaderComponent.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/HeaderComponent.tsx b/src/components/HeaderComponent.tsx index b6155132..58141a47 100644 --- a/src/components/HeaderComponent.tsx +++ b/src/components/HeaderComponent.tsx @@ -459,7 +459,7 @@ const HeaderComponent = ({ setSelectedStateCode(state.toString()); } console.log(selectedDistrict) - if (district && selectedDistrict.length!==0 && selectedDistrict[0]!==t("COMMON.ALL_DISTRICTS")) { + if (district) { setSelectedDistrictCode(district.toString()); // setSelectedDistrict([selectedDistrictStore]) setSelectedDistrict([localStorage.getItem("selectedDistrict")]); @@ -469,7 +469,7 @@ const HeaderComponent = ({ } - if (block && selectedBlock.length!==0 &&selectedBlock[0]!==t("COMMON.ALL_BLOCKS")) { + if (block ) { setSelectedBlockCode(block.toString()); console.log(selectedBlockCode); // setSelectedBlock([selectedBlockStore]) @@ -479,7 +479,7 @@ const HeaderComponent = ({ } - if (center && selectedCenter.length!==0 &&selectedCenter[0]!==t("COMMON.ALL_CENTERS")) { + if (center) { console.log(center); setSelectedCenterCode([center.toString()]); From ff7dfc7dfb79792527a521445ec243593c16ba60 Mon Sep 17 00:00:00 2001 From: Akshata Katwal Date: Sat, 28 Sep 2024 10:54:28 +0530 Subject: [PATCH 40/40] Issue feat: Change warning message of delete popup according ti cohort type -block and centers --- public/locales/en/common.json | 10 +++++++--- src/components/DeleteUserModal.tsx | 8 ++++++-- src/components/UserTable.tsx | 2 +- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/public/locales/en/common.json b/public/locales/en/common.json index 0e97950d..af9b987a 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -120,9 +120,13 @@ "BLOCKS_REASSIGN_SUCCESSFULLY": "Block reassign successfully", "CENTERS_REASSIGN_FAILED": "Center Reassignment fails", "BLOCKS_REASSIGN_FAILED": "Block Reassignment fails", - "USER_COHORTS": "{{name}} belongs to below cohorts", - "DELETE_COHORT_WARNING": "Do you want to delete user from cohort?", - "NO_CENTER_AVAILABLE": "No centers available", + "USER_BLOCK": "{{name}} belongs to below block", + "USER_CENTERS": "{{name}} belongs to below centers", + "USER_CENTER": "{{name}} belongs to below center", + "DELETE_FROM_BLOCK_WARNING": "Do you want to delete user from block?", + "DELETE_FROM_CENTER_WARNING": "Do you want to delete user from center?", + "DELETE_FROM_CENTERS_WARNING": "Do you want to delete user from centers?", + "NO_CENTER_AVAILABLE": "No centers available", "NO_BLOCK_AVAILABLE": "No blocks available", "PLEASE_SELECT_BLOCK_LIST": "Please select block from block list", "ALL_CENTERS": "All centers", diff --git a/src/components/DeleteUserModal.tsx b/src/components/DeleteUserModal.tsx index c873e360..11bd32db 100644 --- a/src/components/DeleteUserModal.tsx +++ b/src/components/DeleteUserModal.tsx @@ -10,6 +10,7 @@ import React, { useEffect, useState } from "react"; import { useTheme } from "@mui/material/styles"; import { useTranslation } from "next-i18next"; import CustomModal from "./CustomModal"; +import { Role } from "@/utils/app.constant"; interface DeleteUserModalProps { open: boolean; @@ -40,7 +41,9 @@ const DeleteUserModal: React.FC = ({ centers, userId, userName, + userType }) => { + console.log(centers) const { t } = useTranslation(); const theme = useTheme(); const reasons = [ @@ -109,7 +112,7 @@ const DeleteUserModal: React.FC = ({ variant="body1" sx={{ marginBottom: "12px", fontWeight: "bold", color: "#333" }} > - {t("COMMON.USER_COHORTS", { name: userName })} + {userType===Role.TEAM_LEADERS?t("COMMON.USER_BLOCK", { name: userName }): centers.split(', ').length===1 ? t("COMMON.USER_CENTER", { name: userName }) : t("COMMON.USER_CENTERS", { name: userName })} = ({ color="primary" /> } - label={t("COMMON.DELETE_COHORT_WARNING")} + label={userType===Role.TEAM_LEADERS?t("COMMON.DELETE_FROM_BLOCK_WARNING"): centers.split(', ').length===1 ? t("COMMON.DELETE_FROM_CENTER_WARNING") : t("COMMON.DELETE_FROM_CENTERS_WARNING")} + sx={{ marginTop: "12px", color: "#555" }} /> diff --git a/src/components/UserTable.tsx b/src/components/UserTable.tsx index d1d2af86..f7d98dba 100644 --- a/src/components/UserTable.tsx +++ b/src/components/UserTable.tsx @@ -1559,7 +1559,7 @@ console.log(selectedBlockStore) centers={userCohort} userId={selectedUserId} userName={userName} - + userType={userType} />