diff --git a/src/components/CreateProject/CreateProjectWrapper.tsx b/src/components/CreateProject/CreateProjectWrapper.tsx index 6dcb46a..51362e7 100644 --- a/src/components/CreateProject/CreateProjectWrapper.tsx +++ b/src/components/CreateProject/CreateProjectWrapper.tsx @@ -19,6 +19,7 @@ import { } from "@/app/api/customer"; import { fetchGrades } from "@/app/api/grades"; import { fetchUserAbilities, fetchUserStaff } from "@/app/utils/fetchUtil"; +import { MAINTAIN_ALL_PROJECTS } from "@/middleware"; type CreateProjectProps = { isEditMode?: false; @@ -80,14 +81,25 @@ const CreateProjectWrapper: React.FC = async (props) => { ]); const userStaff = await fetchUserStaff(); const teamId = userStaff?.teamId; + + const isMaintainAllProjectsRight = [MAINTAIN_ALL_PROJECTS].some((ability) => + abilities.includes(ability), + ); + var filteredTeamLeads = teamId ? teamLeads.filter( (teamLead) => teamLead.teamId === teamId, ) : teamLeads + if (userStaff?.id != null && userStaff?.id == 1) { filteredTeamLeads = teamLeads.filter( (teamLead) => teamLead.teamId === teamId || teamLead.team == "ST", ) } + + if(isMaintainAllProjectsRight){ + filteredTeamLeads = teamLeads + } + const projectInfo = props.isEditMode || props.isCopyMode ? await fetchProjectDetails(props.projectId!) : undefined; diff --git a/src/components/GenerateLastModifiedReport/GenerateLastModifiedReport.tsx b/src/components/GenerateLastModifiedReport/GenerateLastModifiedReport.tsx index 1c899ed..6984021 100644 --- a/src/components/GenerateLastModifiedReport/GenerateLastModifiedReport.tsx +++ b/src/components/GenerateLastModifiedReport/GenerateLastModifiedReport.tsx @@ -38,9 +38,9 @@ const GenerateLastModifiedReport: React.FC = ({ projects, companyHolidays paramName: "dayRange", type: "autocomplete", options: [ - {label: t("30 Days"), value: 30}, - {label: t("60 Days"), value: 60}, - {label: t("90 Days"), value: 90}, + {label: t("Past 30 Days"), value: 30}, + {label: t("Past 60 Days"), value: 60}, + {label: t("Past 90 Days"), value: 90}, ], needAll: false } diff --git a/src/components/MailSetting/MailSetting.tsx b/src/components/MailSetting/MailSetting.tsx index e11495b..6e19c59 100644 --- a/src/components/MailSetting/MailSetting.tsx +++ b/src/components/MailSetting/MailSetting.tsx @@ -95,10 +95,10 @@ const MailSetting: React.FC = ({ try { // msg = "testEveryone" // await testEveryone() - // msg = "test7th" - // await test7th() - msg = "test15th" - await test15th() + msg = "test7th" + await test7th() + // msg = "test15th" + // await test15th() } catch (error) { console.log(error) console.log(msg) diff --git a/src/components/NavigationContent/NavigationContent.tsx b/src/components/NavigationContent/NavigationContent.tsx index d42e3b3..86ce93d 100644 --- a/src/components/NavigationContent/NavigationContent.tsx +++ b/src/components/NavigationContent/NavigationContent.tsx @@ -81,7 +81,10 @@ import { GENERATE_STAFF_MONTHLY_WORK_HOURS_ANALYSIS_REPORT, GENERATE_CROSS_TEAM_CHARGE_REPORT, VIEW_MAIL, - MAINTAIN_MAIL + MAINTAIN_MAIL, + G_PROJ_MANHOUR_SUMMARY_MONTHLY_REPORT, + G_PROJ_MANHOUR_SUMMARY_DAILY_REPORT, + GENERATE_LAST_MODIFIED_REPORT } from "@/middleware"; import { SessionWithAbilities } from "../AppBar/NavigationToggle"; import { authOptions } from "@/config/authConfig"; @@ -232,7 +235,10 @@ const NavigationContent: React.FC = ({ abilities, username }) => { GENERATE_FINANCIAL_STATUS_REPORT, GENERATE_PROJECT_CASH_FLOW_REPORT, GENERATE_STAFF_MONTHLY_WORK_HOURS_ANALYSIS_REPORT, - GENERATE_CROSS_TEAM_CHARGE_REPORT + GENERATE_CROSS_TEAM_CHARGE_REPORT, + G_PROJ_MANHOUR_SUMMARY_MONTHLY_REPORT, + G_PROJ_MANHOUR_SUMMARY_DAILY_REPORT, + GENERATE_LAST_MODIFIED_REPORT ].some((ability) => abilities!.includes(ability), ), @@ -315,12 +321,18 @@ const NavigationContent: React.FC = ({ abilities, username }) => { icon: , label: "Project Manhour Summary Monthly Report", path: "/analytics/ProjectManhourSummaryReport", - isHidden: false + isHidden: ![G_PROJ_MANHOUR_SUMMARY_MONTHLY_REPORT].some((ability) => + abilities!.includes(ability), + ), + // isHidden: false }, { icon: , label: "Project Manhour Summary Daily Report", path: "/analytics/ProjectMonthlyReport", + isHidden: ![G_PROJ_MANHOUR_SUMMARY_DAILY_REPORT].some((ability) => + abilities!.includes(ability), + ), }, { icon: , @@ -342,6 +354,9 @@ const NavigationContent: React.FC = ({ abilities, username }) => { icon: , label: "Last Modified Report", path: "/analytics/LastModifiedReport", + isHidden: ![GENERATE_LAST_MODIFIED_REPORT].some((ability) => + abilities!.includes(ability), + ), }, ], }, diff --git a/src/middleware.ts b/src/middleware.ts index c2519f5..7b5e7b0 100644 --- a/src/middleware.ts +++ b/src/middleware.ts @@ -71,7 +71,11 @@ export const [ GENERATE_PROJECT_CASH_FLOW_REPORT, GENERATE_STAFF_MONTHLY_WORK_HOURS_ANALYSIS_REPORT, GENERATE_CROSS_TEAM_CHARGE_REPORT, + G_PROJ_MANHOUR_SUMMARY_MONTHLY_REPORT, + G_PROJ_MANHOUR_SUMMARY_DAILY_REPORT, + GENERATE_LAST_MODIFIED_REPORT, VIEW_ALL_PROJECTS, + MAINTAIN_ALL_PROJECTS, SATURDAY_WORKERS ] = [ 'MAINTAIN_USER', @@ -125,7 +129,11 @@ export const [ 'G_PROJECT_CASH_FLOW_REPORT', 'G_STAFF_MONTHLY_WORK_HOURS_ANALYSIS_REPORT', 'G_CROSS_TEAM_CHARGE_REPORT', + 'G_PROJ_MANHOUR_SUMMARY_MONTHLY_R', + 'G_PROJ_MANHOUR_SUMMARY_DAILY_R', + 'G_LAST_MODIFIED_REPORT', 'VIEW_ALL_PROJECTS', + 'MAINTAIN_ALL_PROJECTS', 'SATURDAY_WORKERS' ]