Selaa lähdekoodia

update

tags/Baseline_30082024_FRONTEND_UAT
MSI\derek 1 vuosi sitten
vanhempi
commit
94d590aec9
3 muutettua tiedostoa jossa 38 lisäystä ja 33 poistoa
  1. +6
    -6
      src/components/EditTeam/Allocation.tsx
  2. +8
    -8
      src/components/GenerateMonthlyWorkHoursReport/GenerateMonthlyWorkHoursReportWrapper.tsx
  3. +24
    -19
      src/components/ResourceOverconsumptionReport/ResourceOverconsumptionReportWrapper.tsx

+ 6
- 6
src/components/EditTeam/Allocation.tsx Näytä tiedosto

@@ -96,7 +96,7 @@ const Allocation: React.FC<Props> = ({ allStaffs: staff, teamLead }) => {
[addStaff, selectedStaff] [addStaff, selectedStaff]
); );


const clearSubsidiary = useCallback(() => {
const clearValues = useCallback(() => {
if (defaultValues !== undefined) { if (defaultValues !== undefined) {
resetField("addStaffIds"); resetField("addStaffIds");
setSelectedStaff( setSelectedStaff(
@@ -169,9 +169,9 @@ const Allocation: React.FC<Props> = ({ allStaffs: staff, teamLead }) => {
initialStaffs.filter((i) => { initialStaffs.filter((i) => {
const q = query.toLowerCase(); const q = query.toLowerCase();
return ( 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<Props> = ({ allStaffs: staff, teamLead }) => {


const resetStaff = React.useCallback(() => { const resetStaff = React.useCallback(() => {
clearQueryInput(); clearQueryInput();
clearSubsidiary();
}, [clearQueryInput, clearSubsidiary]);
clearValues();
}, [clearQueryInput, clearValues]);


const formProps = useForm({}); const formProps = useForm({});




+ 8
- 8
src/components/GenerateMonthlyWorkHoursReport/GenerateMonthlyWorkHoursReportWrapper.tsx Näytä tiedosto

@@ -1,6 +1,5 @@
import React from "react"; import React from "react";
import GenerateMonthlyWorkHoursReportLoading from "./GenerateMonthlyWorkHoursReportLoading"; import GenerateMonthlyWorkHoursReportLoading from "./GenerateMonthlyWorkHoursReportLoading";
import { fetchProjects } from "@/app/api/projects";
import GenerateMonthlyWorkHoursReport from "./GenerateMonthlyWorkHoursReport"; import GenerateMonthlyWorkHoursReport from "./GenerateMonthlyWorkHoursReport";
import { fetchStaff } from "@/app/api/staff"; import { fetchStaff } from "@/app/api/staff";
import { getServerSession } from "next-auth"; import { getServerSession } from "next-auth";
@@ -10,19 +9,20 @@ interface SubComponents {
Loading: typeof GenerateMonthlyWorkHoursReportLoading; 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(); let staffs = await fetchStaff();


if (role === TEAM_LEAD) { if (role === TEAM_LEAD) {
staffs = staffs.filter((staff) => staff.teamId === teamId); staffs = staffs.filter((staff) => staff.teamId === teamId);
}
}


return <GenerateMonthlyWorkHoursReport staffs={staffs}/>;
return <GenerateMonthlyWorkHoursReport staffs={staffs} />;
}; };


GenerateMonthlyWorkHoursReportWrapper.Loading = GenerateMonthlyWorkHoursReportLoading; GenerateMonthlyWorkHoursReportWrapper.Loading = GenerateMonthlyWorkHoursReportLoading;


export default GenerateMonthlyWorkHoursReportWrapper;
export default GenerateMonthlyWorkHoursReportWrapper;

+ 24
- 19
src/components/ResourceOverconsumptionReport/ResourceOverconsumptionReportWrapper.tsx Näytä tiedosto

@@ -12,29 +12,34 @@ interface SubComponents {
Loading: typeof ResourceOvercomsumptionReportLoading; 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) { if (role === TEAM_LEAD) {
needAll = false
needAll = false;
teams = teams.filter((team) => team.id === teamId); teams = teams.filter((team) => team.id === teamId);
}
}


return <ResourceOverconsumptionReport team={teams} customer={customers} subsidiaries={subsidiaries} needAll={needAll}/>;
return (
<ResourceOverconsumptionReport
team={teams}
customer={customers}
subsidiaries={subsidiaries}
needAll={needAll}
/>
);
}; };


ResourceOvercomsumptionReportWrapper.Loading = ResourceOvercomsumptionReportLoading;
ResourceOvercomsumptionReportWrapper.Loading =
ResourceOvercomsumptionReportLoading;


export default ResourceOvercomsumptionReportWrapper;
export default ResourceOvercomsumptionReportWrapper;

Ladataan…
Peruuta
Tallenna