Skip to content

Commit

Permalink
Merge pull request #12 from chaitanyakole/build_issue
Browse files Browse the repository at this point in the history
[FIX]-Build issue
  • Loading branch information
gouravmore authored Dec 24, 2024
2 parents c8cdc5e + 2c3601a commit f5e429a
Show file tree
Hide file tree
Showing 11 changed files with 106 additions and 76 deletions.
32 changes: 16 additions & 16 deletions src/components/AreaSelection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,24 @@ import { capitalizeFirstLetterOfEachWordInArray } from "@/utils/Helper";
import { useMediaQuery } from "@mui/material";
import { Role } from "@/utils/app.constant";

interface State {
value: string;
label: string;
}
// interface State {
// value: string;
// label: string;
// }

interface District {
value: string;
label: string;
}
// interface District {
// value: string;
// label: string;
// }

interface Block {
value: string;
label: string;
}
interface Centers {
cohortId: string;
name: string;
}
// interface Block {
// value: string;
// label: string;
// }
// interface Centers {
// cohortId: string;
// name: string;
// }
interface Tenant {
value: string;
label: string;
Expand Down
32 changes: 17 additions & 15 deletions src/components/CommonUserModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ interface UserModalProps {
userId?: string;
onSubmit: (submitValue: boolean) => void;
userType: string;
tenants: any[];
cohorts: any[];
handleTenantChange: (tenant: any) => void;
handleCohortChange: (cohort: any) => void;
}

const CommonUserModal: React.FC<UserModalProps> = ({
Expand All @@ -65,6 +69,10 @@ const CommonUserModal: React.FC<UserModalProps> = ({
userId,
onSubmit,
userType,
tenants,
handleCohortChange,
handleTenantChange,
cohorts,
}) => {
const [schema, setSchema] = React.useState<any>();
const [uiSchema, setUiSchema] = React.useState<any>();
Expand Down Expand Up @@ -157,9 +165,6 @@ const CommonUserModal: React.FC<UserModalProps> = ({
: t("TEAM_LEADERS.EDIT_TEAM_LEADER");
const theme = useTheme<any>();
const {
states,
districts,
blocks,
allCenters,
isMobile,
isMediumScreen,
Expand Down Expand Up @@ -613,21 +618,18 @@ const CommonUserModal: React.FC<UserModalProps> = ({
}}
>
<AreaSelection
states={transformArray(states)}
districts={transformArray(districts)}
blocks={transformArray(blocks)}
selectedState={selectedState}
selectedDistrict={selectedDistrict}
selectedBlock={selectedBlock}
handleStateChangeWrapper={handleStateChangeWrapper}
handleDistrictChangeWrapper={handleDistrictChangeWrapper}
handleBlockChangeWrapper={handleBlockChangeWrapper}
tenants={transformArray(tenants)}
cohorts={transformArray(cohorts)}
selectedTenant={selectedState}
selectedCohort={selectedDistrict}
isMobile={isMobile}
isMediumScreen={isMediumScreen}
isCenterSelection={userType !== "TEAM LEADER"}
allCenters={allCenters}
selectedCenter={selectedCenter}
handleCenterChangeWrapper={handleCenterChangeWrapper}
handleTenantChange={handleTenantChange}
handleCohortChange={handleCohortChange}
// allCenters={allCenters}
// selectedCenter={selectedCenter}
// handleCenterChangeWrapper={handleCenterChangeWrapper}
inModal={true}
stateDefaultValue={stateDefaultValue}
/>
Expand Down
52 changes: 30 additions & 22 deletions src/components/ReassignCenterModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ interface ReassignCohortModalProps {
districtCode?: any;
cohortId?: any;
centers: any;
tenants?: any;
cohorts?: any;
handleTenantChange: (tenant: any) => void;
handleCohortChange: (cohort: any) => void;
}

interface Cohort {
Expand Down Expand Up @@ -66,6 +70,10 @@ const ReassignCenterModal: React.FC<ReassignCohortModalProps> = ({
districtName,
districtCode,
centers,
tenants,
cohorts,
handleTenantChange,
handleCohortChange,
}) => {
const { t } = useTranslation();
const theme = useTheme<any>();
Expand Down Expand Up @@ -103,7 +111,7 @@ const ReassignCenterModal: React.FC<ReassignCohortModalProps> = ({
setSelectedDistrictCode,
setSelectedBlockCode,
} = useLocationState(open, onClose, roleType, true);
let cohorts: Cohort[] = allCenters?.map(
let cohort: Cohort[] = allCenters?.map(
(cohort: { cohortId: any; name: string }) => ({
name: cohort.name,
id: cohort.cohortId,
Expand Down Expand Up @@ -184,15 +192,17 @@ const ReassignCenterModal: React.FC<ReassignCohortModalProps> = ({
if (userType !== Role.TEAM_LEADERS) {
selectedData = cohorts
.filter(
(center) => center?.name && checkedCenters.includes(center.name)
(center: any) =>
center?.name && checkedCenters.includes(center.name)
)
.map((center) => center!.id);
.map((center: any) => center!.id);

unSelectedData = cohorts
.filter(
(center) => center?.name && !checkedCenters.includes(center.name)
(center: any) =>
center?.name && !checkedCenters.includes(center.name)
)
.map((center) => center!.id);
.map((center: any) => center!.id);
} else {
selectedData = blocks
.filter(
Expand Down Expand Up @@ -405,17 +415,18 @@ const ReassignCenterModal: React.FC<ReassignCohortModalProps> = ({
}
};

let filteredCohorts = cohorts?.filter((cohort) =>
let filteredCohorts = cohorts?.filter((cohort: any) =>
cohort?.name?.toLowerCase().includes(searchInput)
);

const formattedCohorts = filteredCohorts?.map((location) => ({
const formattedCohorts = filteredCohorts?.map((location: any) => ({
...location,
name: location.name
? location.name
.split(" ")
.map(
(word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()
(word: any) =>
word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()
)
.join(" ")
: "",
Expand Down Expand Up @@ -574,21 +585,18 @@ const ReassignCenterModal: React.FC<ReassignCohortModalProps> = ({
primaryBtnDisabled={checkedCenters.length === 0}
>
<AreaSelection
states={transformArray(states)}
districts={transformArray(districts)}
blocks={transformArray(blocks)}
selectedState={selectedState}
selectedDistrict={selectedDistrict}
selectedBlock={selectedBlock}
handleStateChangeWrapper={handleStateChangeWrapper}
handleDistrictChangeWrapper={handleDistrictChangeWrapper}
handleBlockChangeWrapper={handleBlockChangeWrapper}
tenants={transformArray(tenants)}
cohorts={transformArray(cohorts)}
selectedTenant={selectedState}
selectedCohort={selectedDistrict}
handleTenantChange={handleTenantChange}
handleCohortChange={handleCohortChange}
isMobile={true}
isMediumScreen={isMediumScreen}
isCenterSelection={false}
allCenters={allCenters}
selectedCenter={selectedCenter}
handleCenterChangeWrapper={handleCenterChangeWrapper}
// isCenterSelection={false}
// allCenters={allCenters}
// selectedCenter={selectedCenter}
// handleCenterChangeWrapper={handleCenterChangeWrapper}
inModal={true}
stateDefaultValue={stateDefaultValue}
reAssignModal={true}
Expand Down Expand Up @@ -637,7 +645,7 @@ const ReassignCenterModal: React.FC<ReassignCohortModalProps> = ({
<Box sx={{ p: 3, maxHeight: "300px", overflowY: "auto" }}>
{userType !== Role.TEAM_LEADERS ? (
formattedCohorts && formattedCohorts.length > 0 ? (
formattedCohorts.map((center) => (
formattedCohorts.map((center: any) => (
<Box key={center.id}>
<Box
sx={{
Expand Down
14 changes: 9 additions & 5 deletions src/components/UserTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,11 @@ const UserTable: React.FC<UserTableProps> = ({
role: "learner",
});
// else setFilters({ role: role });
else setFilters({});
else
setFilters({
role: "learner",
status: [statusValue],
});
} else {
const stateCodes = code?.join(",");
setSelectedStateCode(stateCodes);
Expand Down Expand Up @@ -1564,7 +1568,7 @@ const UserTable: React.FC<UserTableProps> = ({
handleCloseModal={() => setConfirmationModalOpen(false)}
modalOpen={confirmationModalOpen}
/>

{/*
<ReassignCenterModal
open={isReassignCohortModalOpen}
onClose={handleCloseReassignModal}
Expand All @@ -1578,9 +1582,9 @@ const UserTable: React.FC<UserTableProps> = ({
districtCode={districtCode}
cohortId={cohortId}
centers={assignedCenters}
/>
/> */}

<CommonUserModal
{/* <CommonUserModal
open={openAddLearnerModal}
onClose={handleCloseAddLearnerModal}
formData={formData}
Expand All @@ -1594,7 +1598,7 @@ const UserTable: React.FC<UserTableProps> = ({
? FormContextType.TEACHER
: FormContextType.TEAM_LEADER
}
/>
/> */}
</HeaderComponent>
);
};
Expand Down
4 changes: 2 additions & 2 deletions src/components/layouts/header/Profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ const Profile = () => {
</Box>
</Box>
</Menu>
{openEditModal && (
{/* {openEditModal && (
<CommonUserModal
open={openEditModal}
onClose={handleCloseAddLearnerModal}
Expand All @@ -371,7 +371,7 @@ const Profile = () => {
onSubmit={handleModalSubmit}
userType={userType}
/>
)}
)} */}
</>
);
};
Expand Down
10 changes: 6 additions & 4 deletions src/pages/faciliator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ const Faciliator: React.FC = () => {
const [openAddFacilitatorModal, setOpenAddFacilitatorModal] =
React.useState(false);
const [submitValue, setSubmitValue] = React.useState<boolean>(false);
const setSubmittedButtonStatus = useSubmittedButtonStore((state:any) => state.setSubmittedButtonStatus);
const setSubmittedButtonStatus = useSubmittedButtonStore(
(state: any) => state.setSubmittedButtonStatus
);

const handleOpenAddFacilitatorModal = () => {
setOpenAddFacilitatorModal(true);
Expand All @@ -20,7 +22,7 @@ const Faciliator: React.FC = () => {
setSubmitValue(true);
};
const handleCloseAddFacilitatorModal = () => {
setSubmittedButtonStatus(false)
setSubmittedButtonStatus(false);
setOpenAddFacilitatorModal(false);
};

Expand All @@ -36,12 +38,12 @@ const Faciliator: React.FC = () => {
handleAddUserClick={handleAddFaciliatorClick}
parentState={submitValue}
/>
<CommonUserModal
{/* <CommonUserModal
open={openAddFacilitatorModal}
onClose={handleCloseAddFacilitatorModal}
userType={FormContextType.TEACHER}
onSubmit={handleModalSubmit}
/>
/> */}
</>
);
};
Expand Down
10 changes: 6 additions & 4 deletions src/pages/facilitator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ const Facilitator: React.FC = () => {
const [openAddFacilitatorModal, setOpenAddFacilitatorModal] =
React.useState(false);
const [submitValue, setSubmitValue] = React.useState<boolean>(false);
const setSubmittedButtonStatus = useSubmittedButtonStore((state:any) => state.setSubmittedButtonStatus);
const setSubmittedButtonStatus = useSubmittedButtonStore(
(state: any) => state.setSubmittedButtonStatus
);

const handleOpenAddFacilitatorModal = () => {
setOpenAddFacilitatorModal(true);
Expand All @@ -20,7 +22,7 @@ const Facilitator: React.FC = () => {
setSubmitValue(true);
};
const handleCloseAddFacilitatorModal = () => {
setSubmittedButtonStatus(false)
setSubmittedButtonStatus(false);
setOpenAddFacilitatorModal(false);
};

Expand All @@ -36,12 +38,12 @@ const Facilitator: React.FC = () => {
handleAddUserClick={handleAddFaciliatorClick}
parentState={submitValue}
/>
<CommonUserModal
{/* <CommonUserModal
open={openAddFacilitatorModal}
onClose={handleCloseAddFacilitatorModal}
userType={FormContextType.TEACHER}
onSubmit={handleModalSubmit}
/>
/> */}
</>
);
};
Expand Down
4 changes: 2 additions & 2 deletions src/pages/learners.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ const Learners: React.FC = () => {
onSubmit={handleModalSubmit}
/> */}
<CommonUserModal
{/* <CommonUserModal
open={openAddLearnerModal}
onClose={handleCloseAddLearnerModal}
onSubmit={handleModalSubmit}
userType={FormContextType.STUDENT}
/>
/> */}
</>
);
};
Expand Down
Loading

0 comments on commit f5e429a

Please sign in to comment.