diff --git a/public/locales/en/common.json b/public/locales/en/common.json index f4e9c2bc..648aa95e 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -119,7 +119,6 @@ "USER_COHORTS": "{{name}} belongs to below cohorts", "DELETE_COHORT_WARNING":"Do you want to delete user from cohort?" - }, "LOGIN_PAGE": { "USERNAME": "Username", diff --git a/src/components/DeleteUserModal.tsx b/src/components/DeleteUserModal.tsx index 4000c724..2103d2f8 100644 --- a/src/components/DeleteUserModal.tsx +++ b/src/components/DeleteUserModal.tsx @@ -1,21 +1,15 @@ import { Box, - Button, + Checkbox, Divider, - FormControl, - Modal, + FormControlLabel, Radio, - TextField, Typography, } from "@mui/material"; -import React, { useState } from "react"; +import React, { useEffect, useState } from "react"; import { useTheme } from "@mui/material/styles"; import { useTranslation } from "next-i18next"; -import CloseIcon from "@mui/icons-material/Close"; -import { showToastMessage } from "./Toastify"; import CustomModal from "./CustomModal"; -import { Checkbox, FormControlLabel } from '@mui/material'; - interface DeleteUserModalProps { open: boolean; @@ -27,11 +21,10 @@ interface DeleteUserModalProps { handleDeleteAction: any; confirmButtonDisable: boolean; setConfirmButtonDisable: any; - centers:any; - userId?:string; - userType?:string; - userName?:string - + centers: any; + userId?: string; + userType?: string; + userName?: string; } const DeleteUserModal: React.FC = ({ @@ -46,137 +39,142 @@ const DeleteUserModal: React.FC = ({ setConfirmButtonDisable, centers, userId, - userName + userName, }) => { - console.log(userName) const { t } = useTranslation(); const theme = useTheme(); const reasons = [ { value: "Incorrect Data Entry", label: t("COMMON.INCORRECT_DATA_ENTRY") }, { value: "Duplicated User", label: t("COMMON.DUPLICATED_USER") }, ]; - const [checkedCohortDeletion, setCheckedCohortDeletion] = useState(centers!=="-"? true: false); + const [checkedCohortDeletion, setCheckedCohortDeletion] = useState(centers === "-" ? true : false); + + useEffect(() => { + if (centers === "-") { + setCheckedCohortDeletion(true); + } else { + setCheckedCohortDeletion(false); + } + }, [centers]); const handleRadioChange = (value: string) => { - console.log(value); setSelectedValue(value); setConfirmButtonDisable(false); }; + const handleChange = (event: React.ChangeEvent) => { setCheckedCohortDeletion(event.target.checked); }; + const handleOtherReasonChange = (event: any) => { setOtherReason(event.target.value); }; - + const handleClose = () => { - if(centers!=="") - { setCheckedCohortDeletion(true);} - else - { + if (centers === "-") { + setCheckedCohortDeletion(true); + } else { setCheckedCohortDeletion(false); } onClose(); }; + const wrappedHandleDeleteAction = async () => { - // setCheckedCohortDeletion(false); - await handleDeleteAction(); - handleClose(); + await handleDeleteAction(); + handleClose(); }; + return ( - <> - - <> - { centers!=="-" && ( - - {t("COMMON.USER_COHORTS", {name: userName})} - - - - {centers} - + + {centers !== "-" && ( + + + {t("COMMON.USER_COHORTS", { name: userName })} + - - } - label= {t("COMMON.DELETE_COHORT_WARNING")} - sx={{ marginTop: '12px', color: '#555' }} - /> -) -} + + {centers} + + + + } + label={t("COMMON.DELETE_COHORT_WARNING")} + sx={{ marginTop: "12px", color: "#555" }} + /> + + )} + {checkedCohortDeletion && ( + + + {t("COMMON.REASON_FOR_DELETION")} + - {checkedCohortDeletion && ( - - { t("COMMON.REASON_FOR_DELETION")} - - {reasons?.map((option) => ( - <> - ( + + + - - {option.label} - + {option.label} + - handleRadioChange(option.value)} - value={option.value} - checked={selectedValue === option.value} - /> - - - - ))} - - ) -} - - - + handleRadioChange(option.value)} + value={option.value} + checked={selectedValue === option.value} + /> + + + + ))} + + )} + ); }; diff --git a/src/components/KaTableComponent.tsx b/src/components/KaTableComponent.tsx index 50d7583e..9c795514 100644 --- a/src/components/KaTableComponent.tsx +++ b/src/components/KaTableComponent.tsx @@ -38,7 +38,7 @@ interface KaTableComponentProps { showIcons?: boolean; noDataMessage?: any; pagination?: boolean; - + reassignType?:string; } const KaTableComponent: React.FC = ({ @@ -54,6 +54,7 @@ const KaTableComponent: React.FC = ({ pageSizes, noDataMessage, pagination = true, + reassignType }) => { const [selectedRowIds, setSelectedRowIds] = useState([]); const { t } = useTranslation(); @@ -118,6 +119,7 @@ console.log(columns) onDelete={onDelete} userAction={props.rowData?.userId} disable={props.rowData?.status === Status.ARCHIVED} + reassignType={reassignType} /> ); } diff --git a/src/components/UserTable.tsx b/src/components/UserTable.tsx index 76635bab..fd44660d 100644 --- a/src/components/UserTable.tsx +++ b/src/components/UserTable.tsx @@ -1040,6 +1040,7 @@ const UserTable: React.FC = ({ pagination={pagination} // reassignCohort={reassignCohort} noDataMessage={data?.length === 0 ? t("COMMON.NO_USER_FOUND") : ""} + reassignType={userType===Role.TEAM_LEADERS? t("COMMON.REASSIGN_BLOCKS"): t("COMMON.REASSIGN_CENTERS")} /> ) : ( loading === false &&