25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

32 lines
1.1 KiB

  1. import React from "react";
  2. import { fetchAllCustomers } from "@/app/api/customer";
  3. import { fetchIndivTeam, fetchTeam } from "@/app/api/team";
  4. import CostAndExpenseReport from "./CostAndExpenseReport";
  5. import CostAndExpenseReportLoading from "./CostAndExpenseReportLoading";
  6. import { headers, cookies } from 'next/headers';
  7. import { getServerSession } from "next-auth";
  8. import { authOptions } from "@/config/authConfig";
  9. import { TEAM_LEAD } from "@/middleware";
  10. interface SubComponents {
  11. Loading: typeof CostAndExpenseReportLoading;
  12. }
  13. const CostAndExpenseReportWrapper: React.FC & SubComponents = async () => {
  14. const session: any = await getServerSession(authOptions)
  15. const teamId = session.staff?.team.id
  16. const role = session.role
  17. let customers = await fetchAllCustomers()
  18. let teams = await fetchTeam()
  19. let needAll = true
  20. if (role === TEAM_LEAD) {
  21. needAll = false
  22. teams = teams.filter((team) => team.id === teamId);
  23. }
  24. return <CostAndExpenseReport team={teams} customer={customers} needAll={needAll} />
  25. };
  26. CostAndExpenseReportWrapper.Loading = CostAndExpenseReportLoading;
  27. export default CostAndExpenseReportWrapper;