diff --git a/src/components/CommonUserModal.tsx b/src/components/CommonUserModal.tsx index 8a83b4d1..071348aa 100644 --- a/src/components/CommonUserModal.tsx +++ b/src/components/CommonUserModal.tsx @@ -359,6 +359,7 @@ const CommonUserModal: React.FC = ({ mobile: apiBody?.mobile, father_name: apiBody?.father_name, email: apiBody?.email, + updatedBy:localStorage.getItem("userId") }; const customFields = apiBody?.customFields; console.log(customFields); diff --git a/src/components/HeaderComponent.tsx b/src/components/HeaderComponent.tsx index 77031ddd..5e8bc287 100644 --- a/src/components/HeaderComponent.tsx +++ b/src/components/HeaderComponent.tsx @@ -730,7 +730,7 @@ const HeaderComponent = ({ )} - {showAddNew && ( + {/* {showAddNew && ( */} )} - )} + {/* )} */} {children} diff --git a/src/components/UserTable.tsx b/src/components/UserTable.tsx index bfe0f872..b9c3f7fa 100644 --- a/src/components/UserTable.tsx +++ b/src/components/UserTable.tsx @@ -34,6 +34,7 @@ import { updateCohortMemberStatus } from "@/services/CohortService/cohortService import useSubmittedButtonStore from "@/utils/useSharedState"; import { useRouter } from "next/router"; import { telemetryFactory } from "@/utils/telemetry"; +import useStore from "@/store/store"; type UserDetails = { userId: any; username: any; @@ -99,6 +100,8 @@ const UserTable: React.FC = ({ const [blockMembershipIdList, setBlockMembershipIdList] = React.useState([]); const [centerMembershipIdList, setCenterMembershipIdList] = React.useState([]); const router = useRouter(); + const store = useStore(); + const isActiveYear = store.isActiveYearSelected; const selectedBlockStore = useSubmittedButtonStore( (state: any) => state.selectedBlockStore @@ -1534,7 +1537,8 @@ console.log(selectedBlockStore) setSelectedCenter:setSelectedCenter, selectedCenterCode:selectedCenterCode, setSelectedCenterCode: setSelectedCenterCode, - setSelectedStateCode:setSelectedStateCode + setSelectedStateCode:setSelectedStateCode, + showAddNew: !!isActiveYear }; diff --git a/src/components/layouts/header/Header.tsx b/src/components/layouts/header/Header.tsx index 4167c00b..f715db87 100644 --- a/src/components/layouts/header/Header.tsx +++ b/src/components/layouts/header/Header.tsx @@ -15,6 +15,7 @@ import { useTranslation } from "next-i18next"; import { createTheme, useTheme } from "@mui/material/styles"; import Profile from "./Profile"; import { AcademicYear } from "@/utils/Interfaces"; +import useStore from "@/store/store"; const Header = ({ sx, customClass, toggleMobileSidebar, position }: any) => { const { t } = useTranslation(); @@ -23,6 +24,9 @@ const Header = ({ sx, customClass, toggleMobileSidebar, position }: any) => { const router = useRouter(); const [anchorEl, setAnchorEl] = React.useState(null); const open = Boolean(anchorEl); + const setIsActiveYearSelected = useStore( + (state: { setIsActiveYearSelected: any }) => state.setIsActiveYearSelected + ); const [selectedLanguage, setSelectedLanguage] = useState(lang); const [academicYearList, setAcademicYearList] = useState([]); @@ -50,6 +54,13 @@ 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( + (year) => year.id === event.target.value + ); + const isActive = selectedYear ? selectedYear.isActive : false; + // localStorage.setItem('isActiveYearSelected', JSON.stringify(isActive)); + setIsActiveYearSelected(isActive); window.location.reload(); }; diff --git a/src/components/layouts/sidebar/MenuItems.js b/src/components/layouts/sidebar/MenuItems.js index 775ef6d5..26b639db 100644 --- a/src/components/layouts/sidebar/MenuItems.js +++ b/src/components/layouts/sidebar/MenuItems.js @@ -2,10 +2,11 @@ import masterIcon from "../../../../public/images/database.svg"; import centerIcon from "../../../../public/images/centers.svg"; import dashboardIcon from "../../../../public/images/dashboard.svg"; import userIcon from "../../../../public/images/group.svg"; -import coursePannerIcon from "../../../../public/images/event_available.svg"; -const ENV = process.env.NEXT_PUBLIC_SHOW_WORKSPACE; +import coursePlannerIcon from "../../../../public/images/event_available.svg"; +import { store } from "@/store/store"; -// +const ENV = process.env.NEXT_PUBLIC_SHOW_WORKSPACE; +const isActiveYear = store.getState().isActiveYearSelected; const Menuitems = [ // { @@ -37,7 +38,6 @@ const Menuitems = [ }, ], }, - { title: "Master ", icon: masterIcon, @@ -57,12 +57,16 @@ const Menuitems = [ }, ], }, - { - title: "SIDEBAR.COURSE_PLANNER", - icon: coursePannerIcon, - href: "/course-planner", - }, - ...(ENV === "true" + ...(isActiveYear + ? [ + { + title: "SIDEBAR.COURSE_PLANNER", + icon: coursePlannerIcon, + href: "/course-planner", + }, + ] + : []), + ...(isActiveYear && ENV === "true" ? [ { title: "SIDEBAR.WORKSPACE", diff --git a/src/data/tableColumns.ts b/src/data/tableColumns.ts index a2c2bcac..f6a23a3b 100644 --- a/src/data/tableColumns.ts +++ b/src/data/tableColumns.ts @@ -1,3 +1,4 @@ +import { store } from "@/store/store"; import { DataType, SortDirection } from "ka-table"; interface ColumnConfig { @@ -7,6 +8,7 @@ interface ColumnConfig { sortDirection?: SortDirection; isSortable?: boolean; } +const isActiveYear = store.getState().isActiveYearSelected; const generateColumns = ( t: any, @@ -36,13 +38,16 @@ export const getUserTableColumns = (t: any, isMobile: boolean) => { // { key: "createdBy", titleKey: "TABLE_TITLE.CREATED_BY", width: 130, sortDirection: SortDirection.Ascend }, // { key: "createdAt", titleKey: "TABLE_TITLE.CREATED_DATE", width: 160, sortDirection: SortDirection.Ascend }, { key: "updatedAt", titleKey: "TABLE_TITLE.UPDATED_DATE", width: 160 }, - { + ]; + // Conditionally add the "actions" column if isActiveYear is true + if (isActiveYear) { + configs.push({ key: "actions", titleKey: "TABLE_TITLE.ACTIONS", width: 170, isSortable: false, - }, - ]; + }); + } return generateColumns(t, configs, isMobile); }; @@ -58,13 +63,16 @@ export const getTLTableColumns = (t: any, isMobile: boolean) => { { key: "createdBy", titleKey: "TABLE_TITLE.CREATED_BY", width: 130 }, { key: "createdAt", titleKey: "TABLE_TITLE.CREATED_DATE", width: 160 }, { key: "updatedAt", titleKey: "TABLE_TITLE.UPDATED_DATE", width: 160 }, - { + ]; + // Conditionally add the "actions" column if isActiveYear is true + if (isActiveYear) { + configs.push({ key: "actions", titleKey: "TABLE_TITLE.ACTIONS", width: 170, isSortable: false, - }, - ]; + }); + } return generateColumns(t, configs, isMobile); }; @@ -88,9 +96,15 @@ export const getCenterTableData = (t: any, isMobile: boolean) => { titleKey: "TABLE_TITLE.ARCHIVED_LEARNERS", width: 130, }, - { key: "actions", titleKey: "TABLE_TITLE.ACTIONS", width: 125 }, ]; - + // Conditionally add the "actions" column if isActiveYear is true + if (isActiveYear) { + configs.push({ + key: "actions", + titleKey: "TABLE_TITLE.ACTIONS", + width: 125, + }); + } return generateColumns(t, configs, isMobile); }; @@ -156,12 +170,15 @@ export const getDistrictTableData = (t: any, isMobile: boolean) => { titleKey: t("TABLE_TITLE.UPDATED_DATE").toUpperCase(), width: 130, }, - { + ]; + // Conditionally add the "actions" column if isActiveYear is true + if (isActiveYear) { + configs.push({ key: "actions", titleKey: t("TABLE_TITLE.ACTIONS").toUpperCase(), width: 160, - }, - ]; + }); + } return generateColumns(t, configs, isMobile); }; @@ -190,12 +207,14 @@ export const getBlockTableData = (t: any, isMobile: boolean) => { titleKey: t("TABLE_TITLE.UPDATED_DATE").toUpperCase(), width: 130, }, - { + ]; + if (isActiveYear) { + configs.push({ key: "actions", titleKey: t("TABLE_TITLE.ACTIONS").toUpperCase(), width: 160, - }, - ]; + }); + } return generateColumns(t, configs, isMobile); }; diff --git a/src/pages/block.tsx b/src/pages/block.tsx index 32887cc0..e8ea43e4 100644 --- a/src/pages/block.tsx +++ b/src/pages/block.tsx @@ -40,6 +40,7 @@ import { import { getBlockTableData } from "@/data/tableColumns"; import { Theme } from "@mui/system"; import { telemetryFactory } from "@/utils/telemetry"; +import useStore from "@/store/store"; type StateDetail = { name: string | undefined; @@ -77,6 +78,8 @@ interface BlockOption { const Block: React.FC = () => { const { t } = useTranslation(); + const store = useStore(); + const isActiveYear = store.isActiveYearSelected; const [selectedSort, setSelectedSort] = useState("Sort"); const [selectedState, setSelectedState] = useState(""); const [selectedDistrict, setSelectedDistrict] = useState(""); @@ -858,66 +861,76 @@ const Block: React.FC = () => { DistrictId?: string, extraArgument?: any ) => { - const newDistrict = { - options: [ - { - controllingfieldfk: controllingField, - name, - value, - }, - ], - }; - try { - const response = await createOrUpdateOption(blocksFieldId, newDistrict); + const updatedBy=localStorage.getItem("userId") +if(updatedBy) +{ + const newDistrict = { + + options: [ + { + controllingfieldfk: controllingField, + name, + value, + updatedBy - if (response) { - filteredCohortOptionData(); - } - } catch (error) { - console.error("Error adding district:", error); + }, + ], + }; + try { + const response = await createOrUpdateOption(blocksFieldId, newDistrict); + + if (response) { + filteredCohortOptionData(); } + } catch (error) { + console.error("Error adding district:", error); + } - const queryParameters = { - name: name, - }; + const queryParameters = { + name: name, + updatedBy:localStorage.getItem('userId'), - try { - const cohortCreateResponse = await updateCohort( - cohortIdForEdit, - queryParameters - ); - if (cohortCreateResponse) { - await fetchBlocks(); - await getCohortSearchBlock(selectedDistrict); - showToastMessage(t("COMMON.BLOCK_UPDATED_SUCCESS"), "success"); - const windowUrl = window.location.pathname; - const cleanedUrl = windowUrl.replace(/^\//, ''); - const env = cleanedUrl.split("/")[0]; + }; + try { + const cohortCreateResponse = await updateCohort( + cohortIdForEdit, + queryParameters + ); + if (cohortCreateResponse) { + await fetchBlocks(); + await getCohortSearchBlock(selectedDistrict); + showToastMessage(t("COMMON.BLOCK_UPDATED_SUCCESS"), "success"); + const windowUrl = window.location.pathname; + const cleanedUrl = windowUrl.replace(/^\//, ''); + const env = cleanedUrl.split("/")[0]; - const telemetryInteract = { - context: { - env: env, - cdata: [], - }, - edata: { - id: 'block-update-success', - type: TelemetryEventType.CLICK, - subtype: '', - pageid: cleanedUrl, - }, - }; - telemetryFactory.interact(telemetryInteract); - } else if (cohortCreateResponse.responseCode === 409) { - showToastMessage(t("COMMON.BLOCK_DUPLICATION_FAILURE"), "error"); - } - } catch (error) { - console.error("Error creating cohort:", error); + const telemetryInteract = { + context: { + env: env, + cdata: [], + }, + edata: { + id: 'block-update-success', + type: TelemetryEventType.CLICK, + subtype: '', + pageid: cleanedUrl, + }, + }; + telemetryFactory.interact(telemetryInteract); + + } else if (cohortCreateResponse.responseCode === 409) { showToastMessage(t("COMMON.BLOCK_DUPLICATION_FAILURE"), "error"); } - setModalOpen(false); - setSelectedStateForEdit(null); + } catch (error) { + console.error("Error creating cohort:", error); + showToastMessage(t("COMMON.BLOCK_DUPLICATION_FAILURE"), "error"); + } + setModalOpen(false); + setSelectedStateForEdit(null); +} + }; const userProps = { @@ -928,6 +941,7 @@ const Block: React.FC = () => { searchPlaceHolder: t("MASTER.SEARCHBAR_PLACEHOLDER_BLOCK"), showFilter: true, showSort: true, + showAddNew: !!isActiveYear, statusValue: statusValue, setStatusValue: setStatusValue, handleFilterChange: handleFilterChange, diff --git a/src/pages/centers.tsx b/src/pages/centers.tsx index c19cd022..24a0fbc5 100644 --- a/src/pages/centers.tsx +++ b/src/pages/centers.tsx @@ -48,6 +48,7 @@ import useSubmittedButtonStore from "@/utils/useSharedState"; import { useQuery, useQueryClient } from "@tanstack/react-query"; import { useRouter } from "next/router"; import { telemetryFactory } from "@/utils/telemetry"; +import useStore from "@/store/store"; type cohortFilterDetails = { type?: string; status?: any; @@ -73,6 +74,8 @@ const Center: React.FC = () => { // use hooks const queryClient = useQueryClient(); const router = useRouter(); + const store = useStore(); + const isActiveYear = store.isActiveYearSelected; const { t } = useTranslation(); const adminInformation = useSubmittedButtonStore( @@ -214,7 +217,7 @@ const Center: React.FC = () => { getAddCenterFormData(); // getCohortMemberlistData(); getAdminInformation(); - }, []); + }, [cohortFormData]); const fetchUserList = async () => { setLoading(true); @@ -943,6 +946,7 @@ const response= await fetchCohortMemberList(data); } let cohortDetails = { name: formData?.name, + updatedBy:localStorage.getItem('userId'), customFields: customFields, }; const resp = await updateCohortUpdate(selectedCohortId, cohortDetails); @@ -1152,7 +1156,7 @@ const response= await fetchCohortMemberList(data); handleSortChange: handleSortChange, handleFilterChange: handleFilterChange, handleSearch: handleSearch, - showAddNew: true, + showAddNew: !!isActiveYear, handleAddUserClick: handleAddUserClick, statusValue: statusValue, setStatusValue: setStatusValue, diff --git a/src/pages/course-planner/index.tsx b/src/pages/course-planner/index.tsx index 497bd4b6..51a2719f 100644 --- a/src/pages/course-planner/index.tsx +++ b/src/pages/course-planner/index.tsx @@ -23,6 +23,8 @@ import { getChannelDetails } from "@/services/coursePlanner"; import { getOptionsByCategory } from "@/utils/Helper"; import coursePlannerStore from "@/store/coursePlannerStore"; import taxonomyStore from "@/store/tanonomyStore"; +import { telemetryFactory } from "@/utils/telemetry"; +import { TelemetryEventType } from "@/utils/app.constant"; const Foundation = () => { const router = useRouter(); @@ -145,7 +147,27 @@ const Foundation = () => { navigator.clipboard.writeText(link).then( () => { alert("Link copied to clipboard"); - }, + + const windowUrl = window.location.pathname; + const cleanedUrl = windowUrl.replace(/^\//, ''); + const env = cleanedUrl.split("/")[0]; + + const telemetryInteract = { + context: { + env: env, + cdata: [], + }, + edata: { + id: 'copy_link', + + type: TelemetryEventType.CLICK, + subtype: '', + pageid: cleanedUrl, + }, + }; + telemetryFactory.interact(telemetryInteract); + } + , (err) => { console.error("Failed to copy link: ", err); } diff --git a/src/pages/district.tsx b/src/pages/district.tsx index ceec010f..3079720a 100644 --- a/src/pages/district.tsx +++ b/src/pages/district.tsx @@ -40,6 +40,7 @@ import { serverSideTranslations } from "next-i18next/serverSideTranslations"; import React, { useEffect, useState } from "react"; import KaTableComponent from "../components/KaTableComponent"; import { telemetryFactory } from "@/utils/telemetry"; +import useStore from "@/store/store"; type StateDetail = { stateCode: string | undefined; @@ -62,6 +63,8 @@ type DistrictDetail = { const District: React.FC = () => { const { t } = useTranslation(); + const store = useStore(); + const isActiveYear = store.isActiveYearSelected; const [districtData, setDistrictData] = useState([]); const [modalOpen, setModalOpen] = useState(false); const [selectedStateForEdit, setSelectedStateForEdit] = @@ -502,79 +505,87 @@ const response= await getCohortList(reqParams) DistrictId?: string, extraArgument?: any ) => { - const newDistrict = { - options: [ - { - controllingfieldfk: controllingField, - name, - value, - }, - ], - }; + const updatedBy=localStorage.getItem("userId") +if(updatedBy) +{ + const newDistrict = { + options: [ + { + controllingfieldfk: controllingField, + name, + value, + updatedBy + }, + ], + }; - try { - const response = await createOrUpdateOption(districtFieldId, newDistrict); + try { + const response = await createOrUpdateOption(districtFieldId, newDistrict); - if (response) { - setDistrictsOptionRead((prevDistricts: any[]) => - prevDistricts.map((district: { value: string | undefined; }) => - district.value === DistrictId - ? { ...district, name, value } - : district - ) - ); - queryClient.invalidateQueries({ - queryKey: [QueryKeys.FIELD_OPTION_READ, stateCode, "districts"], - }); - } - } catch (error) { - console.error("Error adding district:", error); + if (response) { + setDistrictsOptionRead((prevDistricts: any[]) => + prevDistricts.map((district: { value: string | undefined; }) => + district.value === DistrictId + ? { ...district, name, value } + : district + ) + ); + queryClient.invalidateQueries({ + queryKey: [QueryKeys.FIELD_OPTION_READ, stateCode, "districts"], + }); } + } catch (error) { + console.error("Error adding district:", error); + } - const queryParameters = { - name: name, - }; + const queryParameters = { + name: name, + updatedBy:localStorage.getItem('userId'), - try { - const cohortCreateResponse = await updateCohort( - cohortIdForEdit, - queryParameters - ); + }; - if (cohortCreateResponse) { - queryClient.invalidateQueries({ - queryKey: [QueryKeys.FIELD_OPTION_READ, stateCode, "districts"], - }); + try { + const cohortCreateResponse = await updateCohort( + cohortIdForEdit, + queryParameters + ); - showToastMessage(t("COMMON.DISTRICT_UPDATED_SUCCESS"), "success"); - const windowUrl = window.location.pathname; - const cleanedUrl = windowUrl.replace(/^\//, ''); - const env = cleanedUrl.split("/")[0]; - - const telemetryInteract = { - context: { - env: env, - cdata: [], - }, - edata: { - id: 'district-updated-success', - type: TelemetryEventType.CLICK, - subtype: '', - pageid: cleanedUrl, - }, - }; - telemetryFactory.interact(telemetryInteract); + if (cohortCreateResponse) { + queryClient.invalidateQueries({ + queryKey: [QueryKeys.FIELD_OPTION_READ, stateCode, "districts"], + }); - } else if (cohortCreateResponse.responseCode === 409) { - showToastMessage(t("COMMON.DISTRICT_DUPLICATION_FAILURE"), "error"); - } - } catch (error) { - console.error("Error creating cohort:", error); + showToastMessage(t("COMMON.DISTRICT_UPDATED_SUCCESS"), "success"); + const windowUrl = window.location.pathname; + const cleanedUrl = windowUrl.replace(/^\//, ''); + const env = cleanedUrl.split("/")[0]; + + const telemetryInteract = { + context: { + env: env, + cdata: [], + }, + edata: { + id: 'district-updated-success', + type: TelemetryEventType.CLICK, + subtype: '', + pageid: cleanedUrl, + }, + }; + telemetryFactory.interact(telemetryInteract); + + } else if (cohortCreateResponse.responseCode === 409) { showToastMessage(t("COMMON.DISTRICT_DUPLICATION_FAILURE"), "error"); } + } catch (error) { + console.error("Error creating cohort:", error); + showToastMessage(t("COMMON.DISTRICT_DUPLICATION_FAILURE"), "error"); + } - setModalOpen(false); - setSelectedStateForEdit(null); + setModalOpen(false); + setSelectedStateForEdit(null); +} + }; const handleChangePageSize = (event: SelectChangeEvent) => { @@ -737,7 +748,8 @@ const response= await getCohortList(reqParams) selectedSort={selectedSort} shouldFetchDistricts={false} handleSearch={handleSearch} - showFilter={false} + showFilter={false} + showAddNew= {!!isActiveYear} handleAddUserClick={() => { setModalOpen(true); setSelectedStateForEdit(null); diff --git a/src/pages/login.tsx b/src/pages/login.tsx index 1d7daf45..e396821d 100644 --- a/src/pages/login.tsx +++ b/src/pages/login.tsx @@ -36,6 +36,7 @@ import useSubmittedButtonStore from "@/utils/useSharedState"; import { Role } from "@/utils/app.constant"; import { AcademicYear } from "@/utils/Interfaces"; import { getAcademicYear } from "@/services/AcademicYearService"; +import useStore from '@/store/store'; const LoginPage = () => { const { t } = useTranslation(); @@ -49,6 +50,9 @@ const LoginPage = () => { const [lang, setLang] = useState(""); const [selectedLanguage, setSelectedLanguage] = useState(lang); const [language, setLanguage] = useState(selectedLanguage); + const setIsActiveYearSelected = useStore( + (state: { setIsActiveYearSelected: any }) => state.setIsActiveYearSelected + ); const theme = useTheme(); const router = useRouter(); @@ -164,8 +168,9 @@ const LoginPage = () => { (item) => item.isActive ); const activeSessionId = activeSession ? activeSession.id : ""; - localStorage.setItem("academicYearId", activeSessionId); + localStorage.setItem("academicYearId", activeSessionId); if (activeSessionId){ + setIsActiveYearSelected(true); router.push("/centers"); } } diff --git a/src/pages/stateDetails.tsx b/src/pages/stateDetails.tsx index c440e8b2..bc4b2eee 100644 --- a/src/pages/stateDetails.tsx +++ b/src/pages/stateDetails.tsx @@ -23,6 +23,8 @@ import Loader from "@/components/Loader"; import { CircularProgressbar, buildStyles } from "react-circular-progressbar"; import coursePlannerStore from "@/store/coursePlannerStore"; import taxonomyStore from "@/store/tanonomyStore"; +import { TelemetryEventType } from "@/utils/app.constant"; +import { telemetryFactory } from "@/utils/telemetry"; const StateDetails = () => { const router = useRouter(); @@ -91,6 +93,24 @@ const StateDetails = () => { navigator.clipboard.writeText(link).then( () => { alert("Link copied to clipboard"); + const windowUrl = window.location.pathname; + const cleanedUrl = windowUrl.replace(/^\//, ''); + const env = cleanedUrl.split("/")[0]; + + const telemetryInteract = { + context: { + env: env, + cdata: [], + }, + edata: { + id: 'copy_link', + + type: TelemetryEventType.CLICK, + subtype: '', + pageid: cleanedUrl, + }, + }; + telemetryFactory.interact(telemetryInteract); }, (err) => { console.error("Failed to copy link: ", err); diff --git a/src/pages/subjectDetails.tsx b/src/pages/subjectDetails.tsx index 234ca35a..cdd034cc 100644 --- a/src/pages/subjectDetails.tsx +++ b/src/pages/subjectDetails.tsx @@ -29,6 +29,8 @@ import { getAssociationsByCodeNew, getOptionsByCategory, } from "@/utils/Helper"; +import { TelemetryEventType } from "@/utils/app.constant"; +import { telemetryFactory } from "@/utils/telemetry"; // Define Card interface interface Card { @@ -227,6 +229,24 @@ const SubjectDetails = () => { setGrade(overAllCommonGrade); setGradeOptions(overAllCommonGrade); } + const windowUrl = window.location.pathname; + const cleanedUrl = windowUrl.replace(/^\//, ''); + const env = cleanedUrl.split("/")[0]; + + const telemetryInteract = { + context: { + env: env, + cdata: [], + }, + edata: { + id: 'change-medium', + + type: TelemetryEventType.CLICK, + subtype: '', + pageid: cleanedUrl, + }, + }; + telemetryFactory.interact(telemetryInteract); }; const handleGradeChange = (event: any) => { @@ -281,6 +301,24 @@ const SubjectDetails = () => { setTypeOptions(commonType3Data); setType(commonType3Data); } + const windowUrl = window.location.pathname; + const cleanedUrl = windowUrl.replace(/^\//, ''); + const env = cleanedUrl.split("/")[0]; + + const telemetryInteract = { + context: { + env: env, + cdata: [], + }, + edata: { + id: 'grade_change', + + type: TelemetryEventType.CLICK, + subtype: '', + pageid: cleanedUrl, + }, + }; + telemetryFactory.interact(telemetryInteract); }; const handleTypeChange = (event: any) => { @@ -369,6 +407,24 @@ const SubjectDetails = () => { JSON.stringify(overallCommonSubjects) ); } + const windowUrl = window.location.pathname; + const cleanedUrl = windowUrl.replace(/^\//, ''); + const env = cleanedUrl.split("/")[0]; + + const telemetryInteract = { + context: { + env: env, + cdata: [], + }, + edata: { + id: 'change_type', + + type: TelemetryEventType.CLICK, + subtype: '', + pageid: cleanedUrl, + }, + }; + telemetryFactory.interact(telemetryInteract); }; return ( diff --git a/src/services/MasterDataService.ts b/src/services/MasterDataService.ts index 69688dd3..039ec7e0 100644 --- a/src/services/MasterDataService.ts +++ b/src/services/MasterDataService.ts @@ -192,7 +192,7 @@ export const deleteOption = async ( export const createOrUpdateOption = async ( fieldId: string, fieldParams: { - options: { name: string; value: string; controllingfieldfk?: string }[]; + options: { name: string; value: string; controllingfieldfk?: string ,updatedBy?:string}[]; } // stateId?: string ): Promise => { diff --git a/src/store/store.js b/src/store/store.js index 5ac7e49e..f05efc7c 100644 --- a/src/store/store.js +++ b/src/store/store.js @@ -8,16 +8,23 @@ const useStore = create( // state: "", // district: "", // block: "", + isActiveYearSelected: '', // setPid: (newPid) => set((state) => ({ pid: newPid })), // setPid: (newPid) => set((state) => ({ pid: newPid })), // setPid: (newPid) => set((state) => ({ pid: newPid })), // setPid: (newPid) => set((state) => ({ pid: newPid })), + setIsActiveYearSelected: (newYear) => set(() => ({ isActiveYearSelected: newYear })), }), - // { - // name: "adminApp", - // getStorage: () => localStorage, - // } + { + name: "adminAppStore", + getStorage: () => localStorage, + } ) ); +export const store = { + getState: useStore.getState, + setState: useStore.setState, +}; + export default useStore;