Skip to content

Commit

Permalink
Merge pull request #230 from AkshataKatwal16/admin
Browse files Browse the repository at this point in the history
Issue feat: change warning message of delete popup according to cohort type -block and centers
  • Loading branch information
itsvick authored Sep 28, 2024
2 parents ce52859 + ff7dfc7 commit 8de712a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
10 changes: 7 additions & 3 deletions public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,13 @@
"BLOCKS_REASSIGN_SUCCESSFULLY": "Block reassign successfully",
"CENTERS_REASSIGN_FAILED": "Center Reassignment fails",
"BLOCKS_REASSIGN_FAILED": "Block Reassignment fails",
"USER_COHORTS": "{{name}} belongs to below cohorts",
"DELETE_COHORT_WARNING": "Do you want to delete user from cohort?",
"NO_CENTER_AVAILABLE": "No centers available",
"USER_BLOCK": "{{name}} belongs to below block",
"USER_CENTERS": "{{name}} belongs to below centers",
"USER_CENTER": "{{name}} belongs to below center",
"DELETE_FROM_BLOCK_WARNING": "Do you want to delete user from block?",
"DELETE_FROM_CENTER_WARNING": "Do you want to delete user from center?",
"DELETE_FROM_CENTERS_WARNING": "Do you want to delete user from centers?",
"NO_CENTER_AVAILABLE": "No centers available",
"NO_BLOCK_AVAILABLE": "No blocks available",
"PLEASE_SELECT_BLOCK_LIST": "Please select block from block list",
"ALL_CENTERS": "All centers",
Expand Down
8 changes: 6 additions & 2 deletions src/components/DeleteUserModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import React, { useEffect, useState } from "react";
import { useTheme } from "@mui/material/styles";
import { useTranslation } from "next-i18next";
import CustomModal from "./CustomModal";
import { Role } from "@/utils/app.constant";

interface DeleteUserModalProps {
open: boolean;
Expand Down Expand Up @@ -40,7 +41,9 @@ const DeleteUserModal: React.FC<DeleteUserModalProps> = ({
centers,
userId,
userName,
userType
}) => {
console.log(centers)
const { t } = useTranslation();
const theme = useTheme<any>();
const reasons = [
Expand Down Expand Up @@ -109,7 +112,7 @@ const DeleteUserModal: React.FC<DeleteUserModalProps> = ({
variant="body1"
sx={{ marginBottom: "12px", fontWeight: "bold", color: "#333" }}
>
{t("COMMON.USER_COHORTS", { name: userName })}
{userType===Role.TEAM_LEADERS?t("COMMON.USER_BLOCK", { name: userName }): centers.split(', ').length===1 ? t("COMMON.USER_CENTER", { name: userName }) : t("COMMON.USER_CENTERS", { name: userName })}
</Typography>

<Box
Expand All @@ -134,7 +137,8 @@ const DeleteUserModal: React.FC<DeleteUserModalProps> = ({
color="primary"
/>
}
label={t("COMMON.DELETE_COHORT_WARNING")}
label={userType===Role.TEAM_LEADERS?t("COMMON.DELETE_FROM_BLOCK_WARNING"): centers.split(', ').length===1 ? t("COMMON.DELETE_FROM_CENTER_WARNING") : t("COMMON.DELETE_FROM_CENTERS_WARNING")}

sx={{ marginTop: "12px", color: "#555" }}
/>
</Box>
Expand Down
2 changes: 1 addition & 1 deletion src/components/UserTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1559,7 +1559,7 @@ console.log(selectedBlockStore)
centers={userCohort}
userId={selectedUserId}
userName={userName}

userType={userType}

/>
<ReassignCenterModal
Expand Down

0 comments on commit 8de712a

Please sign in to comment.