diff --git a/public/locales/en/common.json b/public/locales/en/common.json index 2239fa6..7ec10dc 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -144,7 +144,8 @@ "ASSIGN_ROLE": "Assign Role", "ENABLE_ROLE": "Enable Role", "SEND_INVITATION_TO_NEW_ADMIN": "Send Invitation to new cohort admin", - "SEND_INVITATION": "Send Invitation" + "SEND_INVITATION": "Send Invitation", + "METABASE_REPORTS": "Metabase Report" }, "LOGIN_PAGE": { "USERNAME": "Username", @@ -478,25 +479,25 @@ "NO_CHANGES_TO_UPDATE": "No Changes to Update" }, "COHORTINVITATION": { - "TAKE_ACTION": "Take Action", - "INVITED_AS_ADMIN": "You have been invited to be the Admin of the cohort", - "SENT":"Sent", - "RECEIVED":"Received", - "ACCEPT_INVITATION": "Accept Invitation", - "REJECT_INVITATION": "Reject Invitation", - "NO_PENDING_REQUESTS_SENT": "No pending requests sent", - "NO_PENDING_INVITATIONS": "No pending invitations", - "INVITED_TO_JOIN_COHORT": "Invited to join cohort", - "INVITED_BY": "Invited by", - "REVOKE_INVITATION": "Revoke Invitation", - "DELETE_CONFIRMATION": "Revoke request of ", - "CANCEL": "Cancel", - "REVOKE": "Revoke", - "ACCEPTED_SUCCESS": "Accepted request successfully", - "REJECTED_SUCCESS": "Rejected request", - "ERROR_UPDATING_REQUEST": "Error in updating request", - "INVITATION_DELETED_SUCCESS": "Invitation deleted successfully", - "INVITATION_DELETED_ERROR": "Failed to delete invitation", - "FETCH_INVITATIONS_ERROR": "Failed to fetch invitations" - } + "TAKE_ACTION": "Take Action", + "INVITED_AS_ADMIN": "You have been invited to be the Admin of the cohort", + "SENT": "Sent", + "RECEIVED": "Received", + "ACCEPT_INVITATION": "Accept Invitation", + "REJECT_INVITATION": "Reject Invitation", + "NO_PENDING_REQUESTS_SENT": "No pending requests sent", + "NO_PENDING_INVITATIONS": "No pending invitations", + "INVITED_TO_JOIN_COHORT": "Invited to join cohort", + "INVITED_BY": "Invited by", + "REVOKE_INVITATION": "Revoke Invitation", + "DELETE_CONFIRMATION": "Revoke request of ", + "CANCEL": "Cancel", + "REVOKE": "Revoke", + "ACCEPTED_SUCCESS": "Accepted request successfully", + "REJECTED_SUCCESS": "Rejected request", + "ERROR_UPDATING_REQUEST": "Error in updating request", + "INVITATION_DELETED_SUCCESS": "Invitation deleted successfully", + "INVITATION_DELETED_ERROR": "Failed to delete invitation", + "FETCH_INVITATIONS_ERROR": "Failed to fetch invitations" + } } diff --git a/src/components/ActionIcon.tsx b/src/components/ActionIcon.tsx index 8852c92..be83244 100644 --- a/src/components/ActionIcon.tsx +++ b/src/components/ActionIcon.tsx @@ -7,10 +7,12 @@ import deleteIcon from "../../public/images/deleteIcon.svg"; import editIcon from "../../public/images/editIcon.svg"; import cohortIcon from "../../public/images/apartment.svg"; import addIcon from "../../public/images/addIcon.svg"; - +import Dashboard from "@/pages/dashboard"; import Image from "next/image"; import { useRouter } from "next/router"; - +import AssessmentIcon from "@mui/icons-material/Assessment"; // MUI report icon +import ApartmentIcon from "@mui/icons-material/Apartment"; // MUI cohort icon +import AddIcon from "@mui/icons-material/Add"; interface ActionCellProps { onEdit: (rowData: any) => void; onDelete: (rowData: any) => void; @@ -44,7 +46,13 @@ const ActionIcon: React.FC = ({ const isCohortAdmin = rowData?.userRoleTenantMapping?.code === "cohort_admin"; const isLearnersPage = router.pathname === "/learners"; + const isCohortPage = router.pathname === "/cohorts"; + + const showEditDeleteButtons = true; const isActionAllowed = isCohortAdmin && !isLearnersPage; + const isAddEnabled = isCohortAdmin && isCohortPage; + const isEditDeleteEnabled = isLearnersPage || !isCohortAdmin; + return ( = ({ flexDirection: "row", gap: "20px", alignItems: "center", - pointerEvents: isActionAllowed ? "none" : "auto", - opacity: isActionAllowed ? 0.5 : 1, }} > {roleButton && ( @@ -83,40 +89,39 @@ const ActionIcon: React.FC = ({ { - if (!isActionAllowed) onAdd(rowData); + if (isAddEnabled) onAdd(rowData); }} sx={{ display: "flex", flexDirection: "column", alignItems: "center", - cursor: "pointer", - color: disable ? theme?.palette?.secondary.contrastText : "", - backgroundColor: "#EAF2FF", + cursor: isAddEnabled ? "pointer" : "not-allowed", + color: isAddEnabled ? "" : theme?.palette?.secondary.contrastText, + backgroundColor: isAddEnabled ? "#EAF2FF" : "#d3d3d3", p: "10px", + opacity: isAddEnabled ? 1 : 0.5, }} > - {/* - - {t("COMMON.DELETE")} - */} )} - {allowEditIcon && ( + + {(showEditDeleteButtons || allowEditIcon) && ( <> { - if (!isActionAllowed) onEdit(rowData); + if (isEditDeleteEnabled) onEdit(rowData); }} sx={{ display: "flex", flexDirection: "column", alignItems: "center", - cursor: isActionAllowed ? "not-allowed" : "pointer", - backgroundColor: isActionAllowed ? "#d3d3d3" : "#E3EAF0", + cursor: isEditDeleteEnabled ? "pointer" : "not-allowed", + backgroundColor: isEditDeleteEnabled ? "#E3EAF0" : "#d3d3d3", p: "10px", + opacity: isEditDeleteEnabled ? 1 : 0.5, }} > @@ -126,20 +131,42 @@ const ActionIcon: React.FC = ({ { - if (!isActionAllowed) onDelete(rowData); + if (isEditDeleteEnabled) onDelete(rowData); }} sx={{ display: "flex", flexDirection: "column", alignItems: "center", - cursor: isActionAllowed ? "not-allowed" : "pointer", - backgroundColor: isActionAllowed ? "#d3d3d3" : "#EAF2FF", + cursor: isEditDeleteEnabled ? "pointer" : "not-allowed", + backgroundColor: isEditDeleteEnabled ? "#EAF2FF" : "#d3d3d3", p: "10px", + opacity: isEditDeleteEnabled ? 1 : 0.5, }} > + + { + router.push({ + pathname: "/dashboard", + query: rowData, + }); + }} + sx={{ + display: "flex", + flexDirection: "column", + alignItems: "center", + cursor: "pointer", + backgroundColor: "#EAF2FF", + p: "10px", + opacity: 1, + }} + > + + + )} @@ -147,15 +174,17 @@ const ActionIcon: React.FC = ({ { - if (!isActionAllowed && reassignCohort) reassignCohort(rowData); + if (isEditDeleteEnabled && reassignCohort) + reassignCohort(rowData); }} sx={{ display: "flex", flexDirection: "column", alignItems: "center", - cursor: isActionAllowed ? "not-allowed" : "pointer", - backgroundColor: isActionAllowed ? "#d3d3d3" : "#E5E5E5", + cursor: isEditDeleteEnabled ? "pointer" : "not-allowed", + backgroundColor: isEditDeleteEnabled ? "#E5E5E5" : "#d3d3d3", p: "10px", + opacity: isEditDeleteEnabled ? 1 : 0.5, }} > diff --git a/src/components/layouts/header/Profile.tsx b/src/components/layouts/header/Profile.tsx index d9b32a2..144079a 100644 --- a/src/components/layouts/header/Profile.tsx +++ b/src/components/layouts/header/Profile.tsx @@ -362,7 +362,7 @@ const Profile = () => { {adminInfo?.email} - { Dashboard - + */} diff --git a/src/data/tableColumns.ts b/src/data/tableColumns.ts index 24cea83..95e98b6 100644 --- a/src/data/tableColumns.ts +++ b/src/data/tableColumns.ts @@ -141,8 +141,9 @@ export const getCohortTableData = ( // }, // { key: "roleDefine", titleKey: "TABLE_TITLE.ROLE", width: 130 }, - ...(role == true && - !(filter?.status?.[0] === "inactive" || filter?.status?.[0] === "archived") + ...(!( + filter?.status?.[0] === "inactive" || filter?.status?.[0] === "archived" + ) ? [ { key: "cohortAdmin", diff --git a/src/pages/dashboard.tsx b/src/pages/dashboard.tsx index 68a9e25..33f4526 100644 --- a/src/pages/dashboard.tsx +++ b/src/pages/dashboard.tsx @@ -2,19 +2,23 @@ import { serverSideTranslations } from "next-i18next/serverSideTranslations"; import { useRouter } from "next/router"; import { useEffect, useState } from "react"; +interface RowData { + tenantId?: string; +} const Dashboard = () => { const router = useRouter(); - const { userId } = router.query; + const [rowData, setRowData] = useState(); const [isError, setIsError] = useState(false); // Validate userId useEffect(() => { - if (!userId) { - setIsError(true); + if (router.query) { + setRowData(router.query); } - }, [userId]); + }, [router.query]); + console.log({ rowData }); - const metabaseUrl = `${process.env.NEXT_PUBLIC_METABASE_URL}${userId}`; + const metabaseUrl = `${process.env.NEXT_PUBLIC_METABASE_URL}${rowData?.tenantId}`; return (