Skip to content

Commit

Permalink
Merge pull request #310 from AkshataKatwal16/relese-changes
Browse files Browse the repository at this point in the history
Issue feat: Integrate notifications for teacher and learner
  • Loading branch information
itsvick authored Nov 11, 2024
2 parents cefd594 + cd6ca6c commit 9ff1f2f
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 8 additions & 3 deletions src/components/CommonUserModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ interface UserModalProps {
userId?: string;
onSubmit: (submitValue: boolean) => void;
userType: string;
userName?:string;
}


Expand All @@ -63,8 +64,9 @@ const CommonUserModal: React.FC<UserModalProps> = ({
userId,
onSubmit,
userType,
userName
}) => {
console.log(userType);
console.log(userName);
const [schema, setSchema] = React.useState<any>();
const [uiSchema, setUiSchema] = React.useState<any>();
const [openModal, setOpenModal] = React.useState(false);
Expand Down Expand Up @@ -383,8 +385,11 @@ const CommonUserModal: React.FC<UserModalProps> = ({
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);
}


Expand Down
54 changes: 50 additions & 4 deletions src/components/ReassignCenterModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ interface ReassignCohortModalProps {
districtCode?: any;
cohortId?: any;
centers: any;
userName?:any

}

interface Cohort {
Expand Down Expand Up @@ -67,8 +69,8 @@ const ReassignCenterModal: React.FC<ReassignCohortModalProps> = ({
districtName,
districtCode,
centers,
userName
}) => {
console.log(userId);
const { t } = useTranslation();
const theme = useTheme<any>();
const roleType = userType;
Expand Down Expand Up @@ -140,6 +142,7 @@ const ReassignCenterModal: React.FC<ReassignCohortModalProps> = ({
useState("");
const [selectedTLUserID, setSelectedTLUserID] = useState(userId);


// const [reassignOpen, setReassignOpen] = useState(false);

//const [selectedBlockId, setselectedBlockId] = useState(blockName);
Expand Down Expand Up @@ -186,6 +189,8 @@ const ReassignCenterModal: React.FC<ReassignCohortModalProps> = ({

const { getNotification } = useNotification();
const handleReassign = async () => {
console.log("TL_DISTRICT_UPDATE",selectedDistrict[0] , districtName)

try {
let selectedData;
let unSelectedData: string[];
Expand Down Expand Up @@ -232,6 +237,8 @@ const ReassignCenterModal: React.FC<ReassignCohortModalProps> = ({


if (selectedBlock[0] !== blockName) {
console.log("TL_DISTRICT_UPDATE",selectedDistrict[0] , districtName)

const userDetails = await getUserDetailsInfo(userId);
if(userType === Role.FACILITATORS){

Expand All @@ -252,12 +259,15 @@ const ReassignCenterModal: React.FC<ReassignCohortModalProps> = ({
];



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(
Expand All @@ -275,6 +285,7 @@ const ReassignCenterModal: React.FC<ReassignCohortModalProps> = ({
];
}
else {
console.log("TL_BLOCK_REASSIGNMENT")
getNotification(selectedTLUserID, "TL_BLOCK_REASSIGNMENT");
}
}
Expand All @@ -297,10 +308,24 @@ const ReassignCenterModal: React.FC<ReassignCohortModalProps> = ({
"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 = {
Expand Down Expand Up @@ -421,7 +446,24 @@ const ReassignCenterModal: React.FC<ReassignCohortModalProps> = ({
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) {
Expand Down Expand Up @@ -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 = [
{
Expand Down Expand Up @@ -635,6 +680,7 @@ console.log(formattedBlocks)
stateDefaultValue={stateDefaultValue}
reAssignModal={true}
userType={userType}
// setSelectedDistrict={ setSelectedDistrict}
// selectedState={selectedState}

districtDefaultValue={districtName}
Expand Down
7 changes: 7 additions & 0 deletions src/components/UserTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ const UserTable: React.FC<UserTableProps> = ({
const [loading, setLoading] = useState<boolean | undefined>(undefined);
const [openAddLearnerModal, setOpenAddLearnerModal] = React.useState(false);
const [userId, setUserId] = useState();

const [submitValue, setSubmitValue] = useState<boolean>(false);
console.log(selectedBlockCode)
const reassignButtonStatus = useSubmittedButtonStore(
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -1650,6 +1654,8 @@ console.log(selectedBlockStore)
districtCode={districtCode}
cohortId={cohortId}
centers={assignedCenters}
userName={userName}


/>

Expand All @@ -1660,6 +1666,7 @@ console.log(selectedBlockStore)
isEditModal={true}
userId={userId}
onSubmit={handleModalSubmit}
userName={userName}
userType={
userType === Role.LEARNERS
? FormContextType.STUDENT
Expand Down
3 changes: 2 additions & 1 deletion src/hooks/useNotification.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand All @@ -26,6 +26,7 @@ const useNotification = () => {
isQueue: false,
context: "USER",
key: key,
replacements: replacements,
push: {
receipients: [deviceId],
},
Expand Down
1 change: 1 addition & 0 deletions src/utils/useLocationState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ export const useLocationState = (
useEffect(() => {
if (!open) {
setSelectedBlock([]);
if(!reAssignModal)
setSelectedDistrict([]);
setSelectedState([]);
setSelectedCenter([]);
Expand Down

0 comments on commit 9ff1f2f

Please sign in to comment.