diff --git a/src/components/EditTeam/Allocation.tsx b/src/components/EditTeam/Allocation.tsx index fa2c09d..5f202b9 100644 --- a/src/components/EditTeam/Allocation.tsx +++ b/src/components/EditTeam/Allocation.tsx @@ -96,7 +96,7 @@ const Allocation: React.FC = ({ allStaffs: staff, teamLead }) => { [addStaff, selectedStaff] ); - const clearSubsidiary = useCallback(() => { + const clearValues = useCallback(() => { if (defaultValues !== undefined) { resetField("addStaffIds"); setSelectedStaff( @@ -169,9 +169,9 @@ const Allocation: React.FC = ({ allStaffs: staff, teamLead }) => { initialStaffs.filter((i) => { const q = query.toLowerCase(); return ( - i.staffId.toLowerCase().includes(q) || - i.name.toLowerCase().includes(q) || - i.currentPosition.toLowerCase().includes(q) + i.staffId.toLowerCase().includes(q) + || i.name.toLowerCase().includes(q) + || i.currentPosition?.toLowerCase().includes(q) ); }) ); @@ -183,8 +183,8 @@ const Allocation: React.FC = ({ allStaffs: staff, teamLead }) => { const resetStaff = React.useCallback(() => { clearQueryInput(); - clearSubsidiary(); - }, [clearQueryInput, clearSubsidiary]); + clearValues(); + }, [clearQueryInput, clearValues]); const formProps = useForm({}); diff --git a/src/components/GenerateMonthlyWorkHoursReport/GenerateMonthlyWorkHoursReportWrapper.tsx b/src/components/GenerateMonthlyWorkHoursReport/GenerateMonthlyWorkHoursReportWrapper.tsx index 71da6c3..8461512 100644 --- a/src/components/GenerateMonthlyWorkHoursReport/GenerateMonthlyWorkHoursReportWrapper.tsx +++ b/src/components/GenerateMonthlyWorkHoursReport/GenerateMonthlyWorkHoursReportWrapper.tsx @@ -1,6 +1,5 @@ import React from "react"; import GenerateMonthlyWorkHoursReportLoading from "./GenerateMonthlyWorkHoursReportLoading"; -import { fetchProjects } from "@/app/api/projects"; import GenerateMonthlyWorkHoursReport from "./GenerateMonthlyWorkHoursReport"; import { fetchStaff } from "@/app/api/staff"; import { getServerSession } from "next-auth"; @@ -10,19 +9,20 @@ interface SubComponents { Loading: typeof GenerateMonthlyWorkHoursReportLoading; } -const GenerateMonthlyWorkHoursReportWrapper: React.FC & SubComponents = async () => { - const session: any = await getServerSession(authOptions) - const teamId = session.staff?.team.id - const role = session.role +const GenerateMonthlyWorkHoursReportWrapper: React.FC & + SubComponents = async () => { + const session: any = await getServerSession(authOptions); + const teamId = session.staff?.team.id; + const role = session.role; let staffs = await fetchStaff(); if (role === TEAM_LEAD) { staffs = staffs.filter((staff) => staff.teamId === teamId); - } + } - return ; + return ; }; GenerateMonthlyWorkHoursReportWrapper.Loading = GenerateMonthlyWorkHoursReportLoading; -export default GenerateMonthlyWorkHoursReportWrapper; \ No newline at end of file +export default GenerateMonthlyWorkHoursReportWrapper; diff --git a/src/components/ResourceOverconsumptionReport/ResourceOverconsumptionReportWrapper.tsx b/src/components/ResourceOverconsumptionReport/ResourceOverconsumptionReportWrapper.tsx index ac688fa..092301c 100644 --- a/src/components/ResourceOverconsumptionReport/ResourceOverconsumptionReportWrapper.tsx +++ b/src/components/ResourceOverconsumptionReport/ResourceOverconsumptionReportWrapper.tsx @@ -12,29 +12,34 @@ interface SubComponents { Loading: typeof ResourceOvercomsumptionReportLoading; } -const ResourceOvercomsumptionReportWrapper: React.FC & SubComponents = async () => { - const session: any = await getServerSession(authOptions) - const teamId = session.staff?.team.id - const role = session.role - let needAll = true - let teams = await fetchTeam() - const [ - customers, - subsidiaries] - = await Promise.all( - [ - fetchAllCustomers(), - fetchAllSubsidiaries() - ]) +const ResourceOvercomsumptionReportWrapper: React.FC & + SubComponents = async () => { + const session: any = await getServerSession(authOptions); + const teamId = session.staff?.team.id; + const role = session.role; + let needAll = true; + let teams = await fetchTeam(); + const [customers, subsidiaries] = await Promise.all([ + fetchAllCustomers(), + fetchAllSubsidiaries(), + ]); if (role === TEAM_LEAD) { - needAll = false + needAll = false; teams = teams.filter((team) => team.id === teamId); - } + } - return ; + return ( + + ); }; -ResourceOvercomsumptionReportWrapper.Loading = ResourceOvercomsumptionReportLoading; +ResourceOvercomsumptionReportWrapper.Loading = + ResourceOvercomsumptionReportLoading; -export default ResourceOvercomsumptionReportWrapper; \ No newline at end of file +export default ResourceOvercomsumptionReportWrapper;