Skip to content

Commit

Permalink
Issue feat: Add main branch bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
AkshataKatwal16 committed Oct 16, 2024
1 parent f431905 commit 7023e72
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 19 deletions.
5 changes: 4 additions & 1 deletion public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,10 @@
"LANGUAGE": "Language",
"SCIENCE": "Science",
"SOCIAL_SCIENCE": "Social Science",
"LIFE_SKILLS": "Life Skills"
"LIFE_SKILLS": "Life Skills",
"BOARD":"Board",
"MEDIUM":"Medium",
"GRADE":"Grade"
},
"FORM_ERROR_MESSAGES": {
"INVALID_INPUT": "Invalid Input.",
Expand Down
8 changes: 7 additions & 1 deletion src/components/AddNewCenters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,12 @@ const AddNewCenters: React.FC<AddLearnerModalProps> = ({
);
const [stateDefaultValueForCenter, setStateDefaultValueForCenter] =
useState<string>("");

const createCenterStatus = useSubmittedButtonStore(
(state: any) => state.createCenterStatus
);
const setCreateCenterStatus = useSubmittedButtonStore(
(state: any) => state.setCreateCenterStatus
);
function removeHiddenFields(formResponse: any) {
return {
...formResponse,
Expand Down Expand Up @@ -212,6 +217,7 @@ const AddNewCenters: React.FC<AddLearnerModalProps> = ({
const cohortData = await createCohort(cohortDetails);
if (cohortData) {
showToastMessage(t("CENTERS.CENTER_CREATED_SUCCESSFULLY"), "success");
createCenterStatus? setCreateCenterStatus(false):setCreateCenterStatus(true)
setOpenAddNewCohort(false);
onClose();
localStorage.removeItem("BMGSData");
Expand Down
2 changes: 1 addition & 1 deletion src/components/FrameworkCategories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const FrameworkCategories: React.FC<FrameworkCategoriesProps> = ({

useEffect(() => {
const handleBMGS = async () => {
const userStateName = localStorage.getItem('userStateName');
const userStateName = localStorage.getItem('stateName');
try {
const url = `${process.env.NEXT_PUBLIC_SUNBIRDSAAS_API_URL}/api/framework/v1/read/${frameworkId}`;
const boardData = await fetch(url).then((res) => res.json());
Expand Down
9 changes: 9 additions & 0 deletions src/pages/block.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,15 @@ const Block: React.FC = () => {
}
}, [isFirstVisit, searchKeyword, pageLimit, pageOffset, stateCode]);


useEffect(() => {
if(districtData[0]?.value && isFirstVisit)
{
setSelectedDistrict(districtData[0]?.value);
setIsFirstVisit(false);
}

}, [districtData]);
const fetchBlocks = async () => {
try {
// const response = await queryClient.fetchQuery({
Expand Down
33 changes: 19 additions & 14 deletions src/pages/centers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
CohortTypes,
Numbers,
QueryKeys,
Role,
SORT,
Status,
Storage,
Expand All @@ -34,15 +35,14 @@ import { showToastMessage } from "@/components/Toastify";
import AddNewCenters from "@/components/AddNewCenters";
import { getCenterTableData } from "@/data/tableColumns";
import { Theme } from "@mui/system";
import { firstLetterInUpperCase, mapFields } from "@/utils/Helper";
import { firstLetterInUpperCase, mapFields , transformLabel} from "@/utils/Helper";
import SimpleModal from "@/components/SimpleModal";
import { IChangeEvent } from "@rjsf/core";
import { RJSFSchema } from "@rjsf/utils";
import DynamicForm from "@/components/DynamicForm";
import useSubmittedButtonStore from "@/utils/useSharedState";
import { useQueryClient } from "@tanstack/react-query";
import { useRouter } from "next/router";

type cohortFilterDetails = {
type?: string;
status?: any;
Expand Down Expand Up @@ -142,7 +142,12 @@ const Center: React.FC = () => {
const setAdminInformation = useSubmittedButtonStore(
(state: any) => state.setAdminInformation
);

const createCenterStatus = useSubmittedButtonStore(
(state: any) => state.createCenterStatus
);
const setCreateCenterStatus = useSubmittedButtonStore(
(state: any) => state.setCreateCenterStatus
);
const [filters, setFilters] = useState<cohortFilterDetails>({
type: CohortTypes.COHORT,
states: selectedStateCode,
Expand Down Expand Up @@ -259,8 +264,8 @@ finalResult?.forEach((item: any, index: number) => {
createdAt: item?.createdAt,
updatedAt: item?.updatedAt,
cohortId: item?.cohortId,
customFieldValues: cohortType[0] ? cohortType : "-",
totalActiveMembers: counts?.totalActiveMembers,
customFieldValues: cohortType[0] ? transformLabel(cohortType) : "-",
totalActiveMembers: counts?.totalActiveMembers,
totalArchivedMembers: counts?.totalArchivedMembers,
};
resultData?.push(requiredData);
Expand Down Expand Up @@ -333,13 +338,11 @@ const response= await fetchCohortMemberList(data);
if (response?.result) {
const userDetails = response.result.userDetails;
const getActiveMembers = userDetails?.filter(
(member: any) => member?.status === Status.ACTIVE
);
(member: any) => member?.status === Status.ACTIVE && member?.role === Role.STUDENT );
const totalActiveMembers = getActiveMembers?.length || 0;

const getArchivedMembers = userDetails?.filter(
(member: any) => member?.status === Status.ARCHIVED
);
(member: any) => member?.status === Status.ARCHIVED && member?.role === Role.STUDENT );
const totalArchivedMembers = getArchivedMembers?.length || 0;

return {
Expand Down Expand Up @@ -372,9 +375,11 @@ const response= await fetchCohortMemberList(data);
};

useEffect(() => {
fetchUserList();
if ((selectedBlockCode !== "") || (selectedDistrictCode !== "" && selectedBlockCode === "") ){
fetchUserList();
}
getFormData();
}, [pageOffset, pageLimit, sortBy, filters, filters.states, filters.status]);
}, [pageOffset, pageLimit, sortBy, filters, filters.states, filters.status, createCenterStatus]);

// handle functions
const handleChange = (event: SelectChangeEvent<typeof pageSize>) => {
Expand Down Expand Up @@ -990,9 +995,9 @@ const response= await fetchCohortMemberList(data);


if (urlData) {
router.push(
`learners?state=${urlData.stateCode}&district=${urlData.districtCode}&block=${urlData.blockCode}&status=${urlData.type}`
);
// router.push(
// `learners?state=${urlData.stateCode}&district=${urlData.districtCode}&block=${urlData.blockCode}&status=${urlData.type}`
// );
}

console.log("urlData", urlData);
Expand Down
4 changes: 2 additions & 2 deletions src/pages/stateDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ const StateDetails = () => {
<IconButton onClick={handleBackClick}>
<ArrowBackIcon />
</IconButton>
<Typography variant="h2">{card.state}</Typography>
<Box sx={{ display: "flex", gap: 3, alignItems: "center" }}>
<Typography variant="h2">{tStore.state}</Typography>
<Box sx={{ display: "flex", gap: 3, alignItems: "center" }}>
</Box>
</Box>
<Grid spacing={2} container sx={{ marginTop: "16px", ml: 2 }}>
Expand Down
5 changes: 5 additions & 0 deletions src/utils/Helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,11 @@ export const mapFields = (formFields: any, Details: any) => {
return field?.value?.toLowerCase();
}
} else if (item?.type === InputTypes.RADIO) {
if(field?.value===FormValues?.REGULAR|| field?.value===FormValues?.REMOTE)
{

return field?.code;
}
return field?.value || null;
} else if (item?.type === InputTypes.NUMERIC) {
return parseInt(String(field?.value));
Expand Down
2 changes: 2 additions & 0 deletions src/utils/app.constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ export enum CohortTypes {
export enum FormValues {
FEMALE = "FEMALE",
MALE = "MALE",
REGULAR="REGULAR",
REMOTE="REMOTE"
}

export enum InputTypes {
Expand Down
3 changes: 3 additions & 0 deletions src/utils/useSharedState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ const useSubmittedButtonStore = create((set) => ({
submittedButtonStatus: false,
setSubmittedButtonStatus: (status: boolean) =>
set({ submittedButtonStatus: status }),
createCenterStatus: false,
setCreateCenterStatus: (status: boolean) =>
set({ createCenterStatus: status }),
reassignButtonStatus: false,
setReassignButtonStatus: (status: boolean) =>
set({ reassignButtonStatus: status }),
Expand Down

0 comments on commit 7023e72

Please sign in to comment.