| @@ -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<Props> = 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; | |||
| @@ -38,9 +38,9 @@ const GenerateLastModifiedReport: React.FC<Props> = ({ 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 | |||
| } | |||
| @@ -95,10 +95,10 @@ const MailSetting: React.FC<Props> = ({ | |||
| 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) | |||
| @@ -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<Props> = ({ 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<Props> = ({ abilities, username }) => { | |||
| icon: <Analytics />, | |||
| 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: <Analytics />, | |||
| label: "Project Manhour Summary Daily Report", | |||
| path: "/analytics/ProjectMonthlyReport", | |||
| isHidden: ![G_PROJ_MANHOUR_SUMMARY_DAILY_REPORT].some((ability) => | |||
| abilities!.includes(ability), | |||
| ), | |||
| }, | |||
| { | |||
| icon: <Analytics />, | |||
| @@ -342,6 +354,9 @@ const NavigationContent: React.FC<Props> = ({ abilities, username }) => { | |||
| icon: <Analytics />, | |||
| label: "Last Modified Report", | |||
| path: "/analytics/LastModifiedReport", | |||
| isHidden: ![GENERATE_LAST_MODIFIED_REPORT].some((ability) => | |||
| abilities!.includes(ability), | |||
| ), | |||
| }, | |||
| ], | |||
| }, | |||
| @@ -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' | |||
| ] | |||