|
|
@@ -1,18 +1,30 @@ |
|
|
|
import React from "react"; |
|
|
|
import { fetchAllCustomers } from "@/app/api/customer"; |
|
|
|
import { fetchTeam } from "@/app/api/team"; |
|
|
|
import { fetchIndivTeam, fetchTeam } from "@/app/api/team"; |
|
|
|
import CostAndExpenseReport from "./CostAndExpenseReport"; |
|
|
|
import CostAndExpenseReportLoading from "./CostAndExpenseReportLoading"; |
|
|
|
|
|
|
|
import { headers, cookies } from 'next/headers'; |
|
|
|
import { getServerSession } from "next-auth"; |
|
|
|
import { authOptions } from "@/config/authConfig"; |
|
|
|
import { TEAM_LEAD } from "@/middleware"; |
|
|
|
interface SubComponents { |
|
|
|
Loading: typeof CostAndExpenseReportLoading; |
|
|
|
} |
|
|
|
|
|
|
|
const CostAndExpenseReportWrapper: React.FC & SubComponents = async () => { |
|
|
|
const customers = await fetchAllCustomers() |
|
|
|
const teams = await fetchTeam () |
|
|
|
const session: any = await getServerSession(authOptions) |
|
|
|
const teamId = session.staff?.team.id |
|
|
|
const role = session!.role |
|
|
|
let customers = await fetchAllCustomers() |
|
|
|
let teams = await fetchTeam() |
|
|
|
let needAll = true |
|
|
|
|
|
|
|
if (role === TEAM_LEAD) { |
|
|
|
needAll = false |
|
|
|
teams = teams.filter((team) => team.id === teamId); |
|
|
|
} |
|
|
|
|
|
|
|
return <CostAndExpenseReport team={teams} customer={customers}/> |
|
|
|
return <CostAndExpenseReport team={teams} customer={customers} needAll={needAll} /> |
|
|
|
}; |
|
|
|
|
|
|
|
CostAndExpenseReportWrapper.Loading = CostAndExpenseReportLoading; |
|
|
|