diff --git a/.env b/.env index 446fc325..3e8ea4bd 100644 --- a/.env +++ b/.env @@ -4,4 +4,4 @@ NEXT_PUBLIC_TELEMETRY_URL=https://qa.prathamteacherapp.tekdinext.com NEXT_PUBLIC_NOTIFICATION_BASE_URL=https://notification.prathamdigital.org # NEXT_PUBLIC_NOTIFICATION_BASE_URL=https://qa.prathamteacherapp.tekdinext.com/notification-service NEXT_PUBLIC_COURSE_PLANNER_API_URL=https://courseplan.tekdinext.com/project/v1 -NEXT_PUBLIC_SUNBIRDSAAS_API_URL=https://sunbirdsaas.com +NEXT_PUBLIC_SUNBIRDSAAS_API_URL=https://sunbirdsaas.com \ No newline at end of file diff --git a/src/components/CommonUserModal.tsx b/src/components/CommonUserModal.tsx index f8fc23e1..c9f31875 100644 --- a/src/components/CommonUserModal.tsx +++ b/src/components/CommonUserModal.tsx @@ -51,6 +51,7 @@ interface UserModalProps { userId?: string; onSubmit: (submitValue: boolean) => void; userType: string; + userName?:string; } @@ -63,8 +64,9 @@ const CommonUserModal: React.FC = ({ userId, onSubmit, userType, + userName }) => { - console.log(userType); + console.log(userName); const [schema, setSchema] = React.useState(); const [uiSchema, setUiSchema] = React.useState(); const [openModal, setOpenModal] = React.useState(false); @@ -383,8 +385,11 @@ const CommonUserModal: React.FC = ({ getNotification(userId, "FACILITATOR_PROFILE_UPDATE"); } if( userType === FormContextType.STUDENT){ - getNotification(userId, "LEARNER_PROFILE_UPDATE_ALERT"); - getNotification(userId, "LEARNER_PROFILE_UPDATE_BY_ADMIN_TL_FC"); + const replacements = { + "{learnerName}":userName + } + getNotification(userId, "LEARNER_PROFILE_UPDATE_ALERT", replacements); + getNotification(userId, "LEARNER_PROFILE_UPDATE_BY_ADMIN_TL_FC", replacements); } diff --git a/src/components/ReassignCenterModal.tsx b/src/components/ReassignCenterModal.tsx index 561b71ed..767ff3a3 100644 --- a/src/components/ReassignCenterModal.tsx +++ b/src/components/ReassignCenterModal.tsx @@ -38,6 +38,8 @@ interface ReassignCohortModalProps { districtCode?: any; cohortId?: any; centers: any; + userName?:any + } interface Cohort { @@ -67,8 +69,8 @@ const ReassignCenterModal: React.FC = ({ districtName, districtCode, centers, + userName }) => { - console.log(userId); const { t } = useTranslation(); const theme = useTheme(); const roleType = userType; @@ -140,6 +142,7 @@ const ReassignCenterModal: React.FC = ({ useState(""); const [selectedTLUserID, setSelectedTLUserID] = useState(userId); + // const [reassignOpen, setReassignOpen] = useState(false); //const [selectedBlockId, setselectedBlockId] = useState(blockName); @@ -186,6 +189,8 @@ const ReassignCenterModal: React.FC = ({ const { getNotification } = useNotification(); const handleReassign = async () => { + console.log("TL_DISTRICT_UPDATE",selectedDistrict[0] , districtName) + try { let selectedData; let unSelectedData: string[]; @@ -232,6 +237,8 @@ const ReassignCenterModal: React.FC = ({ if (selectedBlock[0] !== blockName) { + console.log("TL_DISTRICT_UPDATE",selectedDistrict[0] , districtName) + const userDetails = await getUserDetailsInfo(userId); if(userType === Role.FACILITATORS){ @@ -252,12 +259,15 @@ const ReassignCenterModal: React.FC = ({ ]; - + if (selectedDistrict[0] !== districtName) { + console.log("TL_DISTRICT_UPDATE",selectedDistrict[0] , districtName) const userDetails = await getUserDetailsInfo(userId); if(userType === Role.TEAM_LEADERS){ getNotification(selectedTLUserID, "TL_DISTRICT_UPDATE"); + getNotification(selectedTLUserID, "TL_BLOCK_REASSIGNMENT"); + } const blockField = userDetails?.userData?.customFields.find( @@ -275,6 +285,7 @@ const ReassignCenterModal: React.FC = ({ ]; } else { + console.log("TL_BLOCK_REASSIGNMENT") getNotification(selectedTLUserID, "TL_BLOCK_REASSIGNMENT"); } } @@ -297,10 +308,24 @@ const ReassignCenterModal: React.FC = ({ "success" ); if( userType === Role.FACILITATORS) { + if (selectedDistrict[0] !== districtName) + { + if (selectedBlock[0] !== blockName) { + getNotification(userId, "FACILITATOR_BLOCK_UPDATE"); + + } + console.log("TL_DISTRICT_UPDATE",selectedDistrict[0] , districtName) + getNotification(userId, "FACILITATOR_DISTRICT_UPDATE"); + + } getNotification(userId, "FACILITATOR_CENTER_REASSIGNMENT"); } + if(userType === Role.LEARNERS) { - getNotification(selectedTLUserID, "LEARNER_REASSIGNMENT_NOTIFICATION"); + const replacements = { + "{learnerName}":userName + } + getNotification(selectedTLUserID, "LEARNER_REASSIGNMENT_NOTIFICATION", replacements); } } else { const reassignBlockObject = { @@ -421,7 +446,24 @@ const ReassignCenterModal: React.FC = ({ reassignButtonStatus ? setReassignButtonStatus(false) : setReassignButtonStatus(true); + + if (selectedDistrict[0] !== districtName) { + console.log("TL_DISTRICT_UPDATE",selectedDistrict[0] , districtName) + if(userType === Role.TEAM_LEADERS){ + + getNotification(selectedTLUserID, "TL_DISTRICT_UPDATE"); getNotification(selectedTLUserID, "TL_BLOCK_REASSIGNMENT"); + + } + + } + else{ + getNotification(selectedTLUserID, "TL_BLOCK_REASSIGNMENT"); + + } + + + } } } catch (error) { @@ -541,10 +583,13 @@ console.log(formattedBlocks) value: selectedCenterCode, }, ]; - if ( selectedDistrict[0] !== districtName) { + if ( selectedDistrict[0] && selectedDistrict[0] !== districtName) { if(userType === Role.TEAM_LEADERS){ getNotification(selectedTLUserID, "TL_DISTRICT_UPDATE"); + getNotification(selectedTLUserID, "TL_BLOCK_REASSIGNMENT"); + + } customFields = [ { @@ -635,6 +680,7 @@ console.log(formattedBlocks) stateDefaultValue={stateDefaultValue} reAssignModal={true} userType={userType} + // setSelectedDistrict={ setSelectedDistrict} // selectedState={selectedState} districtDefaultValue={districtName} diff --git a/src/components/UserTable.tsx b/src/components/UserTable.tsx index 399872b4..88723abb 100644 --- a/src/components/UserTable.tsx +++ b/src/components/UserTable.tsx @@ -183,6 +183,7 @@ const UserTable: React.FC = ({ const [loading, setLoading] = useState(undefined); const [openAddLearnerModal, setOpenAddLearnerModal] = React.useState(false); const [userId, setUserId] = useState(); + const [submitValue, setSubmitValue] = useState(false); console.log(selectedBlockCode) const reassignButtonStatus = useSubmittedButtonStore( @@ -738,6 +739,7 @@ console.log(code[0]) const handleEdit = async (rowData: any) => { submitValue ? setSubmitValue(false) : setSubmitValue(true); + setUserName(rowData?.name) console.log("Edit row:", rowData); @@ -799,6 +801,8 @@ console.log(code[0]) // setIsDeleteModalOpen(true); console.log(rowData) setSelectedUserId(rowData?.userId ); + setUserName(rowData?.name) + setCohortId(rowData?.cohortIds); setBlock(rowData?.blocks) console.log(rowData?.districtValue) @@ -1650,6 +1654,8 @@ console.log(selectedBlockStore) districtCode={districtCode} cohortId={cohortId} centers={assignedCenters} + userName={userName} + /> @@ -1660,6 +1666,7 @@ console.log(selectedBlockStore) isEditModal={true} userId={userId} onSubmit={handleModalSubmit} + userName={userName} userType={ userType === Role.LEARNERS ? FormContextType.STUDENT diff --git a/src/hooks/useNotification.tsx b/src/hooks/useNotification.tsx index 04e05cb1..c6928373 100644 --- a/src/hooks/useNotification.tsx +++ b/src/hooks/useNotification.tsx @@ -3,7 +3,7 @@ import { getUserDetailsInfo } from "@/services/UserList"; import { useCallback } from "react"; const useNotification = () => { - const getNotification = useCallback(async (userId: any, key: any) => { + const getNotification = useCallback(async (userId: any, key: any, replacements?:any) => { try { // const userId = localStorage.getItem("userId"); @@ -26,6 +26,7 @@ const useNotification = () => { isQueue: false, context: "USER", key: key, + replacements: replacements, push: { receipients: [deviceId], }, diff --git a/src/utils/useLocationState.tsx b/src/utils/useLocationState.tsx index c938c1ec..d7a93d79 100644 --- a/src/utils/useLocationState.tsx +++ b/src/utils/useLocationState.tsx @@ -321,6 +321,7 @@ export const useLocationState = ( useEffect(() => { if (!open) { setSelectedBlock([]); + if(!reAssignModal) setSelectedDistrict([]); setSelectedState([]); setSelectedCenter([]);