25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 

51 satır
1.6 KiB

  1. import { fetchProjectCategories, fetchProjects } from "@/app/api/projects";
  2. import React from "react";
  3. import ProjectSearch from "./ProjectSearch";
  4. import ProjectSearchLoading from "./ProjectSearchLoading";
  5. import { fetchUserAbilities, fetchUserStaff } from "@/app/utils/fetchUtil";
  6. import { authOptions } from "@/config/authConfig";
  7. import { getServerSession } from "next-auth";
  8. import { VIEW_ALL_PROJECTS } from "@/middleware";
  9. import { fetchTeam } from "@/app/api/team";
  10. import { fetchAllCustomers } from "@/app/api/customer";
  11. interface SubComponents {
  12. Loading: typeof ProjectSearchLoading;
  13. }
  14. const ProjectSearchWrapper: React.FC & SubComponents = async () => {
  15. const projectCategories = await fetchProjectCategories();
  16. const userStaff = await fetchUserStaff();
  17. const teamId = userStaff?.teamId;
  18. const projects = await fetchProjects();
  19. const teams = await fetchTeam();
  20. const customers = await fetchAllCustomers();
  21. const abilities = await fetchUserAbilities();
  22. const isViewAllProjectRight = [VIEW_ALL_PROJECTS].some((ability) =>
  23. abilities.includes(ability),
  24. );
  25. let filteredProjects = projects;
  26. if (!isViewAllProjectRight) {
  27. filteredProjects = projects.filter((project) => project.teamId === teamId );
  28. if (teamId == 1){
  29. filteredProjects = projects.filter((project) => project.teamId === teamId || project.team === "ST");
  30. }
  31. }
  32. return (
  33. <ProjectSearch
  34. projects={filteredProjects}
  35. projectCategories={projectCategories}
  36. abilities={abilities}
  37. teams={teams}
  38. customers={customers}
  39. />
  40. );
  41. };
  42. ProjectSearchWrapper.Loading = ProjectSearchLoading;
  43. export default ProjectSearchWrapper;