Skip to content

Commit

Permalink
Merge branch 'release-1.0.0' of github.com:tekdi/shiksha-admin into r…
Browse files Browse the repository at this point in the history
…elease-1.0.0
  • Loading branch information
itsvick committed Nov 11, 2024
2 parents 411df28 + f947f61 commit 56ccd4d
Show file tree
Hide file tree
Showing 11 changed files with 112 additions and 20 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
4 changes: 4 additions & 0 deletions next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ const nextConfig = {
source: "/action/asset/:path*", // Match other /action/asset routes
destination: `${process.env.WORKSPACE_BASE_URL}/api/proxy?path=/action/asset/:path*`, // Forward other /action/asset requests to proxy.js
},
{
source: "/action/v1/telemetry",
destination: `${process.env.NEXT_PUBLIC_TELEMETRY_URL}/v1/telemetry`,
},
{
source: "/action/content/:path*", // Match other /action/asset routes
destination: `${process.env.WORKSPACE_BASE_URL}/api/proxy?path=/action/content/:path*`, // Forward other /action/asset requests to proxy.js
Expand Down
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
26 changes: 22 additions & 4 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 @@ -897,8 +901,11 @@ console.log(code[0])
resp = await userList({ limit, filters, sort, offset, fields });

}
console.log(resp?.getUserDetails);
const result = enableCenterFilter?resp?.userDetails:resp?.getUserDetails;
if (!resp?.getUserDetails) {
setData([]);
//showToastMessage("No data found", "info");
}
const result = enableCenterFilter?resp?.userDetails:resp?.getUserDetails;
console.log(result)
console.log(resp?.totalCount)
if (resp?.totalCount >= 15) {
Expand Down Expand Up @@ -1029,7 +1036,7 @@ console.log(code[0])
}
console.log(finalResult)

if (filters?.name) {
if (filters?.name && resp?.getUserDetails) {
const prioritizedResult = finalResult.sort((a: any, b: any) => {
const aStartsWith = a.name.toLowerCase().startsWith(filters?.name);
const bStartsWith = b.name.toLowerCase().startsWith(filters?.name);
Expand All @@ -1040,9 +1047,14 @@ console.log(code[0])
});

setData(prioritizedResult);
} else {
} else if (resp?.getUserDetails){
setData(finalResult);
}
else
{
setData([]);

}

setLoading(false);
setCohortsFetched(false);
Expand Down Expand Up @@ -1508,6 +1520,9 @@ console.log(selectedBlockStore)
</Typography>
</Box>
);


console.log("data-----------------------------", data)
const userProps = {
userType: userType,
searchPlaceHolder: searchPlaceholder,
Expand Down Expand Up @@ -1639,6 +1654,8 @@ console.log(selectedBlockStore)
districtCode={districtCode}
cohortId={cohortId}
centers={assignedCenters}
userName={userName}


/>

Expand All @@ -1649,6 +1666,7 @@ console.log(selectedBlockStore)
isEditModal={true}
userId={userId}
onSubmit={handleModalSubmit}
userName={userName}
userType={
userType === Role.LEARNERS
? FormContextType.STUDENT
Expand Down
16 changes: 12 additions & 4 deletions src/components/layouts/header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,14 @@ const Header = ({ sx, customClass, toggleMobileSidebar, position }: any) => {
setLanguage(lang);
const storedList = localStorage.getItem("academicYearList");
try {
setAcademicYearList(storedList ? JSON.parse(storedList) : []);
const parsedList = storedList ? JSON.parse(storedList) : [];
const modifiedList = parsedList.map((item: { isActive: any; session: any; }) => {
if (item.isActive) {
return { ...item, session: `${item.session} (${t('COMMON.ACTIVE')})` };
}
return item;
});
setAcademicYearList(modifiedList);
const selectedAcademicYearId = localStorage.getItem("academicYearId");
setSelectedSessionId(selectedAcademicYearId ?? "");
} catch (error) {
Expand All @@ -54,14 +61,15 @@ const Header = ({ sx, customClass, toggleMobileSidebar, position }: any) => {
setSelectedSessionId(event.target.value);
console.log("selected academic year id", event.target.value);
localStorage.setItem("academicYearId", event.target.value);
// Check if the selected academic year is active
const selectedYear = academicYearList?.find(
// Check if the selected academic year is active
const selectedYear = academicYearList?.find(
(year) => year.id === event.target.value
);
const isActive = selectedYear ? selectedYear.isActive : false;
// localStorage.setItem('isActiveYearSelected', JSON.stringify(isActive));
setIsActiveYearSelected(isActive);
window.location.reload();
// window.location.reload();
window.location.href = "/centers";
};

const handleChange = (event: SelectChangeEvent) => {
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
6 changes: 5 additions & 1 deletion src/pages/course-planner/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@ import coursePlannerStore from "@/store/coursePlannerStore";
import taxonomyStore from "@/store/tanonomyStore";
import { telemetryFactory } from "@/utils/telemetry";
import { TelemetryEventType } from "@/utils/app.constant";
import useStore from "@/store/store";

const Foundation = () => {
const router = useRouter();
const { t } = useTranslation();
const theme = useTheme();
const userStore = useStore();
const isActiveYear = userStore.isActiveYearSelected;
const isSmallScreen = useMediaQuery(theme.breakpoints.down("sm"));
const isMediumScreen = useMediaQuery(theme.breakpoints.between("sm", "md"));
const store = coursePlannerStore();
Expand Down Expand Up @@ -116,7 +119,8 @@ const Foundation = () => {
if (userStateName) {
getFrameworkDetails();
}
}, [userStateName]);
!isActiveYear && router.push("/centers");
}, [userStateName, isActiveYear]);

const handleCardClick = (id: any) => {
router.push(`/stateDetails?cardId=${id}`);
Expand Down
3 changes: 2 additions & 1 deletion src/pages/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ const LoginPage = () => {
localStorage.setItem("academicYearId", activeSessionId);
if (activeSessionId){
setIsActiveYearSelected(true);
router.push("/centers");
// router.push("/centers");
window.location.href = "/centers";
}
}
};
Expand Down
6 changes: 5 additions & 1 deletion src/pages/play/content/[identifier].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
import { V1PlayerConfig, V2PlayerConfig } from "../../../data/player-config";
import Loader from "@/components/Loader";
import { useTranslation } from "react-i18next";
import useStore from "@/store/store";

// @ts-ignore
const SunbirdPlayers = dynamic(() => import("editor/SunbirdPlayers"), {
Expand All @@ -34,6 +35,8 @@ const Players: React.FC<SunbirdPlayerProps> = () => {
const { t } = useTranslation();
const { identifier } = router.query;
const [loading, setLoading] = useState(true);
const store = useStore();
const isActiveYear = store.isActiveYearSelected;

useEffect(() => {
const loadContent = async () => {
Expand Down Expand Up @@ -66,7 +69,8 @@ const Players: React.FC<SunbirdPlayerProps> = () => {
}
};
loadContent();
}, [identifier]);
!isActiveYear && router.push("/centers");
}, [identifier, isActiveYear]);

return (
<Box>
Expand Down
Loading

0 comments on commit 56ccd4d

Please sign in to comment.