diff --git a/public/locales/en/common.json b/public/locales/en/common.json index 8b13d4d5..0df7a57f 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -191,6 +191,10 @@ "VIEW_PLANS": "View Plans", "FOUNDATION_COURSE": "Foundation Course", "MAIN_COURSE": "Main Course", + "CONTENT_CREATOR_REVIEWER": "Content Creator/Reviewer", + "SCTA":"State Content Team Associate", + + "WORKSPACE": "Workspace" }, "FACILITATORS": { @@ -438,5 +442,13 @@ "WORKSPACE": { "EDITOR_WORKSPACE": "Editor Workspace", "COURSE": "Course" + + }, + + "CONTENT_CREATOR_REVIEWER": { + "CONTENT_CREATOR": "Content Creator", + "CONTENT_REVIEWER": "Content Reviewer", + "CONTENT_CREATOR_REVIEWER": "Content Creator/Reviewer", + "SEARCH_CONTENT_CREATOR":"Search content creator..." } } \ No newline at end of file diff --git a/src/components/ActionIcon.tsx b/src/components/ActionIcon.tsx index 6936a990..4a36dfe2 100644 --- a/src/components/ActionIcon.tsx +++ b/src/components/ActionIcon.tsx @@ -127,7 +127,7 @@ const ActionIcon: React.FC = ({ - { userAction && ( + { userAction && reassignType && ( { if(reassignCohort) diff --git a/src/components/AreaSelection.tsx b/src/components/AreaSelection.tsx index dc432b93..0234d73f 100644 --- a/src/components/AreaSelection.tsx +++ b/src/components/AreaSelection.tsx @@ -5,7 +5,7 @@ import React, { useEffect, useState } from "react"; import MultipleSelectCheckmarks from "./FormControl"; import { capitalizeFirstLetterOfEachWordInArray } from "@/utils/Helper"; import { useMediaQuery } from "@mui/material"; -import { Role } from "@/utils/app.constant"; +import { FormContextType, Role } from "@/utils/app.constant"; interface State { value: string; @@ -117,15 +117,15 @@ const AreaSelection: React.FC = ({ }, }} > - {userType && !reAssignModal && ( + {userType && !reAssignModal && inModal===false && ( - {userType} + {userType=== Role.CONTENT_CREATOR?t("SIDEBAR.SCTA"):userType} )} - = ({ defaultValue={stateDefaultValue} /> - + + + {userType!== FormContextType.CONTENT_CREATOR && inModal && + ( + <> + 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 &&( district.label)} - codes={districts?.map((district) => district.value)} - tagName={t("FACILITATORS.DISTRICT")} - selectedCategories={selectedDistrict} - onCategoryChange={handleDistrictChangeWrapper} + names={capitalizeFirstLetterOfEachWordInArray( + blocks?.length > 0 ? blocks.map((block) => block.label) : [] + // blocks.map((block) => block.label) + + )} + codes={ + + blocks?.length > 0 ? blocks?.map((block) => block.value) : [] + // blocks?.map((block) => block.value) + } + tagName={t("FACILITATORS.BLOCK")} + selectedCategories={capitalizeFirstLetterOfEachWordInArray( + selectedBlock + )} + onCategoryChange={handleBlockChangeWrapper} disabled={ - districts?.length <= 0 || - (selectedState.length === 0 && - stateDefaultValue === t("COMMON.ALL_STATES")) + blocks?.length <= 0 || + selectedDistrict?.length === 0 || + selectedDistrict[0] === t("COMMON.ALL_DISTRICTS") } overall={!inModal} defaultValue={ - reAssignModal - ? districtDefaultValue - : selectedState.length > 0 && districts?.length === 0 - ? t("COMMON.NO_DISTRICTS") - : t("COMMON.ALL_DISTRICTS") + selectedDistrict?.length > 0 && (blocks?.length === 0) + ? t("COMMON.NO_BLOCKS") + : t("COMMON.ALL_BLOCKS") } /> - - - {shouldRenderSelectCheckmarks &&( - 0 ? blocks.map((block) => block.label) : [] - // blocks.map((block) => block.label) + )} + + ) + } + - )} - codes={ - - blocks?.length > 0 ? blocks?.map((block) => block.value) : [] - // 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 && ( = ({ /> )} + - + )} ); diff --git a/src/components/CommonUserModal.tsx b/src/components/CommonUserModal.tsx index 5118d720..1f852cb0 100644 --- a/src/components/CommonUserModal.tsx +++ b/src/components/CommonUserModal.tsx @@ -121,7 +121,7 @@ const CommonUserModal: React.FC = ({ const { data: studentFormData, isLoading: studentFormDataLoading, - error: studentFormDataErrror, + error: studentFormDataError, } = useQuery({ queryKey: ["studentFormData"], queryFn: () => getFormRead(FormContext.USERS, FormContextType.STUDENT), @@ -130,12 +130,22 @@ const CommonUserModal: React.FC = ({ const { data: teamLeaderFormData, isLoading: teamLeaderFormDataLoading, - error: teamLeaderFormDataErrror, + error: teamLeaderFormDataError, } = useQuery({ queryKey: ["teamLeaderFormData"], queryFn: () => getFormRead(FormContext.USERS, FormContextType.TEAM_LEADER), staleTime: apiCatchingDuration.GETREADFORM, }); + + const { + data: contentCreatorFormData, + isLoading: contentCreatorFormDataLoading, + error: contentCreatorFormDataError, + } = useQuery({ + queryKey: ["contentCreatorFormData"], + queryFn: () => getFormRead(FormContext.USERS, FormContextType.CONTENT_CREATOR), + staleTime: apiCatchingDuration.GETREADFORM, + }); // const { data:adminFormData ,isLoading: adminFormDataLoading, error :adminFormDataErrror} = useQuery({ // queryKey: ["adminFormData"], // queryFn: () => getFormRead( @@ -149,12 +159,12 @@ const CommonUserModal: React.FC = ({ ? t("LEARNERS.NEW_LEARNER") : userType === FormContextType.TEACHER ? t("FACILITATORS.NEW_FACILITATOR") - : t("TEAM_LEADERS.NEW_TEAM_LEADER") + :userType === FormContextType.CONTENT_CREATOR?t("CONTENT_CREATOR_REVIEWER.CREATE_CONTENT_CREATOR") :t("TEAM_LEADERS.NEW_TEAM_LEADER") : userType === FormContextType.STUDENT ? t("LEARNERS.EDIT_LEARNER") : userType === FormContextType.TEACHER ? t("FACILITATORS.EDIT_FACILITATOR") - : t("TEAM_LEADERS.EDIT_TEAM_LEADER"); + :userType === FormContextType.CONTENT_CREATOR?t("CONTENT_CREATOR_REVIEWER.EDIT_CONTENT_REVIEWER"): t("TEAM_LEADERS.EDIT_TEAM_LEADER"); const theme = useTheme(); const { states, @@ -183,7 +193,8 @@ const CommonUserModal: React.FC = ({ dynamicFormForBlock, stateDefaultValue, assignedTeamLeader, - assignedTeamLeaderNames + assignedTeamLeaderNames, + selectedStateCohortId } = useLocationState(open, onClose, roleType); console.log(assignedTeamLeaderNames) @@ -199,15 +210,15 @@ const CommonUserModal: React.FC = ({ // userType // ); // console.log("sortedFields", response); - +console.log("userType",userType, FormContextType.CONTENT_CREATOR) const response: FormData = userType === FormContextType.TEACHER ? teacherFormData : userType === FormContextType.STUDENT ? studentFormData - : teamLeaderFormData; + :userType === FormContextType.CONTENT_CREATOR?contentCreatorFormData: teamLeaderFormData; // console.log(studentFormData) - console.log(response); + console.log("object",response); if (response) { if (userType === FormContextType.TEACHER) { @@ -247,7 +258,7 @@ const CommonUserModal: React.FC = ({ } }; getAddUserFormData(); - }, [userType, teacherFormData, studentFormData, teamLeaderFormData]); + }, [userType, teacherFormData, studentFormData, teamLeaderFormData, contentCreatorFormData]); const { getNotification } = useNotification(); const handleSubmit = async ( data: IChangeEvent, @@ -289,17 +300,18 @@ const CommonUserModal: React.FC = ({ ? RoleId.STUDENT : userType === FormContextType.TEACHER ? RoleId.TEACHER - : RoleId.TEAM_LEADER, + :userType === FormContextType.CONTENT_CREATOR?RoleId.SCTA: RoleId.TEAM_LEADER, cohortIds: userType === FormContextType.TEAM_LEADER ? [selectedBlockCohortId] - : [selectedCenterCode], + :userType === FormContextType.CONTENT_CREATOR? selectedStateCohortId: [selectedCenterCode], }, ], customFields: [], }; Object.entries(formData).forEach(([fieldKey, fieldValue]) => { + console.log(fieldKey, fieldValue); const fieldSchema = schemaProperties[fieldKey]; const fieldId = fieldSchema?.fieldId; console.log( @@ -338,7 +350,13 @@ const CommonUserModal: React.FC = ({ } } }); - if (!isEditModal) { + if(userType === FormContextType.CONTENT_CREATOR && !isEditModal){ + apiBody.customFields.push({ + fieldId: stateFieldId, + value: [selectedStateCode], + }); + } + else if (!isEditModal) { apiBody.customFields.push({ fieldId: blockFieldId, value: [selectedBlockCode], @@ -441,92 +459,95 @@ const CommonUserModal: React.FC = ({ telemetryFactory.interact(telemetryInteract); } - } 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 (typeof window !== "undefined" && window.localStorage) { - creatorName = localStorage.getItem("name"); - } - 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]; - - 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"; - - showToastMessage(t(messageKey), "success"); + + if (!isEditModal) { + const isQueue = false; + const context = "USER"; + let creatorName; + const key = + userType === FormContextType.STUDENT + ? "onLearnerCreated" + : userType === FormContextType.TEACHER + ? "onFacilitatorCreated" + : "onTeamLeaderCreated"; + + if (typeof window !== "undefined" && window.localStorage) { + creatorName = localStorage.getItem("name"); } - } - if (userType === FormContextType.STUDENT) { - if ( - response?.result[0]?.data[0]?.status === "success" && - !isEditModal - ) { - setOpenModal(true); + 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]; + + 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"; + + 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" + ); + } + } } else { - showToastMessage( - t("LEARNERS.USER_CREDENTIALS_WILL_BE_SEND_SOON"), - "success" - ); + showToastMessage(t("COMMON.SOMETHING_WENT_WRONG"), "error"); } } + } else { showToastMessage(t("COMMON.SOMETHING_WENT_WRONG"), "error"); } } + onSubmit(true); + onClose(); + onCloseModal(); + + } catch (error) { onClose(); console.log(error); @@ -704,11 +725,12 @@ const CommonUserModal: React.FC = ({ handleBlockChangeWrapper={handleBlockChangeWrapper} isMobile={isMobile} isMediumScreen={isMediumScreen} - isCenterSelection={userType !== "TEAM LEADER"} + isCenterSelection={userType !== "TEAM LEADER" && userType !== FormContextType.CONTENT_CREATOR} allCenters={allCenters} selectedCenter={selectedCenter} handleCenterChangeWrapper={handleCenterChangeWrapper} inModal={true} + userType= {userType} stateDefaultValue={stateDefaultValue} /> diff --git a/src/components/HeaderComponent.tsx b/src/components/HeaderComponent.tsx index 695e4157..27e53f0b 100644 --- a/src/components/HeaderComponent.tsx +++ b/src/components/HeaderComponent.tsx @@ -385,7 +385,7 @@ const HeaderComponent = ({ } } - if (!hasBlock && !hasDistrict) { + if (!hasBlock && !hasDistrict && userType!==Role.CONTENT_CREATOR) { if (userType === Role.TEAM_LEADERS || userType==="Centers") { // setSelectedBlock([t("COMMON.ALL_BLOCKS")]); //setSelectedBlockCode("") @@ -422,6 +422,17 @@ const HeaderComponent = ({ }); } } + else if(userType===Role.CONTENT_CREATOR) + { + router.replace({ + pathname: router.pathname, + query: { + ...router.query, + state: stateField.code, + + }, + }); + } const getCentersObject = { limit: 0, @@ -467,7 +478,7 @@ const HeaderComponent = ({ !hasCenter && !hasBlock && !hasDistrict && - userType !== Role.TEAM_LEADERS + userType !== Role.TEAM_LEADERS && userType !== Role.CONTENT_CREATOR ) { console.log(hasCenter); setSelectedCenter([t("COMMON.ALL_CENTERS")]); @@ -608,7 +619,7 @@ const HeaderComponent = ({ )} - {showStateDropdown && ( + {showStateDropdown && ( = ({ staleTime: apiCatchingDuration.GETREADFORM, enabled: false, }); + const { data:contentCreatorFormData ,isLoading: contentCreatorFormDataFormDataLoading, error :contentCreatorFormDataErrror } = useQuery({ + queryKey: ["contentCreatorFormData"], + queryFn: () => Promise.resolve([]), + staleTime: apiCatchingDuration.GETREADFORM, + enabled: false, + }); const handleOpenAddLearnerModal = () => { setOpenAddLearnerModal(true); }; @@ -776,6 +782,11 @@ console.log(code[0]) setFormData(mapFields(teamLeaderFormData, response)); // handleOpenAddTeamLeaderModal(); } + else if(Role.CONTENT_CREATOR === role) + { + formFields = await getFormRead("USERS", Role.CONTENT_CREATOR); + setFormData(mapFields(contentCreatorFormData, response)); + } handleOpenAddLearnerModal(); console.log("response", response); @@ -1155,7 +1166,7 @@ console.log(selectedBlockStore) fetchData(); }, [data, cohortsFetched]); - +console.log(userType) useEffect(() => { const fetchData = () => { try { @@ -1235,11 +1246,19 @@ console.log(selectedBlockStore) // }); // } + if(userType===Role.CONTENT_CREATOR) + { + setFilters({ + states: stateField.code, + role: role, + status:[statusValue], + }) + } + else{ - if(selectedDistrictCode && selectedDistrict.length!==0 &&selectedDistrict[0]!==t("COMMON.ALL_DISTRICTS")) + if(selectedDistrictCode && selectedDistrict.length!==0 &&selectedDistrict[0]!==t("COMMON.ALL_DISTRICTS") &&userType!==Role.CONTENT_CREATOR) { - console.log("true---") setFilters({ states: stateField.code, districts:selectedDistrictCode, @@ -1248,7 +1267,7 @@ console.log(selectedBlockStore) status:[statusValue], }) } - if(selectedBlockCode && selectedBlock.length!==0 && selectedBlock[0]!==t("COMMON.ALL_BLOCKS")) + if(selectedBlockCode && selectedBlock.length!==0 && selectedBlock[0]!==t("COMMON.ALL_BLOCKS") && userType!==Role.CONTENT_CREATOR) { setFilters({ states: stateField.code, @@ -1261,6 +1280,7 @@ console.log(selectedBlockStore) } + } // setStates(object); @@ -1274,11 +1294,11 @@ console.log(selectedBlockStore) }; fetchData(); - }, [selectedBlockCode, selectedDistrictCode]); + }, [selectedBlockCode, selectedDistrictCode, userType]); useEffect(() => { const fetchData = () => { // console.log(selectedCenter.length) - if(userType===Role.TEAM_LEADERS) + if(userType===Role.TEAM_LEADERS || userType===Role.CONTENT_CREATOR) { setEnableCenterFilter(false); @@ -1582,9 +1602,9 @@ console.log(selectedBlockStore) ) : data?.length !== 0 && loading === false ? ( ) : ( loading === false && @@ -1682,7 +1702,7 @@ console.log(selectedBlockStore) ? FormContextType.STUDENT : userType === Role.FACILITATORS ? FormContextType.TEACHER - : FormContextType.TEAM_LEADER + : userType === Role.CONTENT_CREATOR?FormContextType.CONTENT_CREATOR: FormContextType.TEAM_LEADER } /> diff --git a/src/components/layouts/header/Profile.tsx b/src/components/layouts/header/Profile.tsx index b18fcd6a..efd2bdb8 100644 --- a/src/components/layouts/header/Profile.tsx +++ b/src/components/layouts/header/Profile.tsx @@ -207,7 +207,7 @@ const Profile = () => { useEffect(() => { if (typeof window !== "undefined" && window.localStorage) { const admin = localStorage.getItem("adminInfo"); - if (admin) setAdminInfo(JSON.parse(admin)); + if (admin) setAdminInfo(JSON?.parse(admin)||{}); } }, []); diff --git a/src/components/layouts/sidebar/MenuItems.js b/src/components/layouts/sidebar/MenuItems.js index 26b639db..cd5b35c2 100644 --- a/src/components/layouts/sidebar/MenuItems.js +++ b/src/components/layouts/sidebar/MenuItems.js @@ -36,6 +36,10 @@ const Menuitems = [ title: "SIDEBAR.LEARNERS", href: "/learners", }, + { + title: "SIDEBAR.SCTA", + href: "/content-users", + }, ], }, { diff --git a/src/data/tableColumns.ts b/src/data/tableColumns.ts index 62450202..7a0a9e72 100644 --- a/src/data/tableColumns.ts +++ b/src/data/tableColumns.ts @@ -81,6 +81,31 @@ export const getTLTableColumns = (t: any, isMobile: boolean, isArchived:any) => return generateColumns(t, configs, isMobile); }; +export const getContentCreatorTableColumns = (t: any, isMobile: boolean, isArchived:any) => { + + const configs: ColumnConfig[] = [ + { key: "name", titleKey: "TABLE_TITLE.NAME", width: 130 }, + { key: "age", titleKey: "TABLE_TITLE.AGE", width: 70 }, + { key: "gender", titleKey: "TABLE_TITLE.GENDER", width: 90 }, + // { key: "blocks", titleKey: "TABLE_TITLE.BLOCK", width: 130 }, + { key: "updatedBy", titleKey: "TABLE_TITLE.UPDATED_BY", width: 130 }, + { 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 && !isArchived) { + configs.push({ + key: "actions", + titleKey: "TABLE_TITLE.ACTIONS", + width: 170, + isSortable: false, + }); + } + + return generateColumns(t, configs, isMobile); +}; + export const getCenterTableData = (t: any, isMobile: boolean, isArchived:any) => { const configs: ColumnConfig[] = [ diff --git a/src/pages/content-users.tsx b/src/pages/content-users.tsx new file mode 100644 index 00000000..d0f55e83 --- /dev/null +++ b/src/pages/content-users.tsx @@ -0,0 +1,79 @@ +import React from "react"; +import { serverSideTranslations } from "next-i18next/serverSideTranslations"; +import UserTable from "@/components/UserTable"; +import { useTranslation } from "next-i18next"; +import { Role, FormContextType, TelemetryEventType } from "@/utils/app.constant"; +import CommonUserModal from "@/components/CommonUserModal"; +import useSubmittedButtonStore from "@/utils/useSharedState"; +import { telemetryFactory } from "@/utils/telemetry"; + +const ContentUsers: React.FC = () => { + const { t } = useTranslation(); + const handleAddContentCreatorClick = () => { + const windowUrl = window.location.pathname; + const cleanedUrl = windowUrl.replace(/^\//, ''); + const env = cleanedUrl.split("/")[0]; + + + const telemetryInteract = { + context: { + env: env, + cdata: [], + }, + edata: { + id: 'click-on-add-new', + type: TelemetryEventType.CLICK, + subtype: '', + pageid: cleanedUrl, + }, + }; + telemetryFactory.interact(telemetryInteract); + + handleOpenAddContentCreatorModal(); + }; + const [submitValue, setSubmitValue] = React.useState(false); + const setSubmittedButtonStatus = useSubmittedButtonStore((state:any) => state.setSubmittedButtonStatus); + + const [ openAddContentCreatorModal, setOpenAddContentCreatorModal] = + React.useState(false); + const handleOpenAddContentCreatorModal = () => { + setOpenAddContentCreatorModal(true); + }; + const handleModalSubmit = (value: boolean) => { + setSubmitValue(true); + }; + const handleCloseAddContentCreatorModal = () => { + setSubmittedButtonStatus(false) + + setOpenAddContentCreatorModal(false); + }; + + return ( + <> + + + + + ); +}; + +export async function getStaticProps({ locale }: any) { + return { + props: { + ...(await serverSideTranslations(locale, ["common"])), + }, + }; +} + +export default ContentUsers; diff --git a/src/pages/login.tsx b/src/pages/login.tsx index 26ba2b8f..ba898ac6 100644 --- a/src/pages/login.tsx +++ b/src/pages/login.tsx @@ -439,4 +439,4 @@ export async function getStaticProps({ locale }: any) { }; } -export default LoginPage; +export default LoginPage; \ No newline at end of file diff --git a/src/utils/Helper.ts b/src/utils/Helper.ts index 8d16f64f..5b4358d3 100644 --- a/src/utils/Helper.ts +++ b/src/utils/Helper.ts @@ -77,6 +77,7 @@ export const generateUsernameAndPassword = ( [FormContextType.TEACHER]: "FSC", [FormContextType.STUDENT]: "SC", [FormContextType.TEAM_LEADER]: "TLSC", + [FormContextType.CONTENT_CREATOR]: "SCTA",//prefix is not fix till now assume this SCTA(State Content Team Associate) }; if (!(role in rolePrefixes)) { diff --git a/src/utils/app.constant.ts b/src/utils/app.constant.ts index 117b4a46..d26f029e 100644 --- a/src/utils/app.constant.ts +++ b/src/utils/app.constant.ts @@ -7,6 +7,9 @@ export enum Role { ADMIN = "Admin", LEARNERS = "Learners", FACILITATORS = "Facilitators", + CONTENT_CREATOR= "Content Creator", + CONTENT_REVIEWER = "Content Reviewer", + } export enum Status { @@ -44,7 +47,8 @@ export enum FormContextType { TEAM_LEADER = "TEAM LEADER", ADMIN = "ADMIN", ADMIN_CENTER = "ADMIN_CENTER", - COHORT="cohort" + COHORT="cohort", + CONTENT_CREATOR="CONTENT CREATOR" } export enum RoleId { @@ -52,6 +56,7 @@ export enum RoleId { TEACHER = "3bde0028-6900-4900-9d05-eeb608843718", TEAM_LEADER = "9dd9328f-1bc7-444f-96e3-c5e1daa3514a", ADMIN = "ee482faf-8a41-45fe-9656-5533dd6a787c", + SCTA="f972a14e-afdb-4502-8ede-cf1fcf171e46" } export enum DataKey { diff --git a/src/utils/useLocationState.tsx b/src/utils/useLocationState.tsx index d7a93d79..c8afac5f 100644 --- a/src/utils/useLocationState.tsx +++ b/src/utils/useLocationState.tsx @@ -53,6 +53,8 @@ export const useLocationState = ( const [selectedBlockCode, setSelectedBlockCode] = useState(""); const [selectedCenterCode, setSelectedCenterCode] = useState(""); const [selectedBlockCohortId, setSelectedBlockCohortId] = useState(""); + const [selectedStateCohortId, setSelectedStateCohortId] = useState(""); + const [blockFieldId, setBlockFieldId] = useState(""); const [stateFieldId, setStateFieldId] = useState(""); const [districtFieldId, setDistrictFieldId] = useState(""); @@ -392,7 +394,27 @@ export const useLocationState = ( localStorage.setItem('userStateName',stateField?.value ) setSelectedState([stateField.value]); + const StateObject = { + limit: 0, + offset: 0, + filters: { + status: ["active"], + + name: stateField.value, + }, + }; setSelectedStateCode(stateField.code) + + const stateResponse = await getCenterList(StateObject); + const getCohortDetails = stateResponse?.result?.results?.cohortDetails; + console.log(getCohortDetails) + const stateId = getCohortDetails?.map((item: any) => { + if (item?.type === "STATE") { + return item?.cohortId; + } + }) + setSelectedStateCohortId(stateId) + const object = { controllingfieldfk: stateField.code, @@ -630,7 +652,8 @@ export const useLocationState = ( setSelectedDistrictCode, setSelectedBlockCode, assignedTeamLeaderNames, - assignedTeamLeader + assignedTeamLeader, + selectedStateCohortId }; };