From 9d61a46092f0f851e598811864291055b212ce9b Mon Sep 17 00:00:00 2001 From: Wayne Date: Tue, 2 Apr 2024 23:25:16 +0900 Subject: [PATCH] Remove Staff type and use StaffResult --- src/app/(main)/staff/create/page.tsx | 1 - src/app/api/staff/index.ts | 12 +----------- src/components/CreateCustomer/CreateCustomer.tsx | 1 - src/components/CreateDepartment/CreateDepartment.tsx | 1 - .../CreateDepartment/DepartmentDetails.tsx | 1 - src/components/CreatePosition/CreatePosition.tsx | 1 - src/components/CreatePosition/PositionDetails.tsx | 1 - src/components/CreateProject/CreateProject.tsx | 4 ++-- .../CreateProject/ProjectClientDetails.tsx | 6 +++--- 9 files changed, 6 insertions(+), 22 deletions(-) diff --git a/src/app/(main)/staff/create/page.tsx b/src/app/(main)/staff/create/page.tsx index 8262b64..f097298 100644 --- a/src/app/(main)/staff/create/page.tsx +++ b/src/app/(main)/staff/create/page.tsx @@ -25,7 +25,6 @@ import { import { CreateProjectInputs, saveProject } from "@/app/api/projects/actions"; import { Error } from "@mui/icons-material"; import { ProjectCategory } from "@/app/api/projects"; -import { Staff } from "@/app/api/staff"; import { Grid, Typography } from "@mui/material"; import CreateStaffForm from "@/components/CreateStaff/CreateStaffForm"; diff --git a/src/app/api/staff/index.ts b/src/app/api/staff/index.ts index 4444245..013f7e4 100644 --- a/src/app/api/staff/index.ts +++ b/src/app/api/staff/index.ts @@ -3,15 +3,6 @@ import { BASE_API_URL } from "@/config/api"; import { cache } from "react"; import "server-only"; -export interface Staff { - id: number; - name: string; - staffId: string; - team: { - name: string; - code: string; - }; -} export interface StaffResult { id: number; name: string; @@ -31,11 +22,10 @@ export interface searchInput { export const preloadTeamLeads = () => { fetchTeamLeads(); - // fetchStaff(); }; export const fetchTeamLeads = cache(async () => { - return serverFetchJson(`${BASE_API_URL}/staffs/teamLeads`, { + return serverFetchJson(`${BASE_API_URL}/staffs/teamLeads`, { next: { tags: ["teamLeads"] }, }); }); diff --git a/src/components/CreateCustomer/CreateCustomer.tsx b/src/components/CreateCustomer/CreateCustomer.tsx index 2735bac..e3777d8 100644 --- a/src/components/CreateCustomer/CreateCustomer.tsx +++ b/src/components/CreateCustomer/CreateCustomer.tsx @@ -20,7 +20,6 @@ import { import { CreateProjectInputs, saveProject } from "@/app/api/projects/actions"; import { Error } from "@mui/icons-material"; import { ProjectCategory } from "@/app/api/projects"; -import { Staff } from "@/app/api/staff"; import { Typography } from "@mui/material"; import { CustomerFormInputs, saveCustomer } from "@/app/api/customer/actions"; import CustomerDetails from "./CustomerDetails"; diff --git a/src/components/CreateDepartment/CreateDepartment.tsx b/src/components/CreateDepartment/CreateDepartment.tsx index d3b1d5a..42088fe 100644 --- a/src/components/CreateDepartment/CreateDepartment.tsx +++ b/src/components/CreateDepartment/CreateDepartment.tsx @@ -20,7 +20,6 @@ import { import { CreateDepartmentInputs, saveDepartment } from "@/app/api/departments/actions"; import { Error } from "@mui/icons-material"; import { ProjectCategory } from "@/app/api/projects"; -import { Staff } from "@/app/api/staff"; import { Typography } from "@mui/material"; import DepartmentDetails from "./DepartmentDetails"; diff --git a/src/components/CreateDepartment/DepartmentDetails.tsx b/src/components/CreateDepartment/DepartmentDetails.tsx index ea3fd3e..4039587 100644 --- a/src/components/CreateDepartment/DepartmentDetails.tsx +++ b/src/components/CreateDepartment/DepartmentDetails.tsx @@ -17,7 +17,6 @@ import RestartAlt from "@mui/icons-material/RestartAlt"; import Button from "@mui/material/Button"; import { Controller, useFormContext } from "react-hook-form"; import { CreateDepartmentInputs } from "@/app/api/departments/actions"; -import { Staff } from "@/app/api/staff"; const DepartmentDetails: React.FC = ({ }) => { diff --git a/src/components/CreatePosition/CreatePosition.tsx b/src/components/CreatePosition/CreatePosition.tsx index eb3a06a..0edfe0a 100644 --- a/src/components/CreatePosition/CreatePosition.tsx +++ b/src/components/CreatePosition/CreatePosition.tsx @@ -20,7 +20,6 @@ import { import { CreatePositionInputs, savePosition } from "@/app/api/positions/actions"; import { Error } from "@mui/icons-material"; import { ProjectCategory } from "@/app/api/projects"; -import { Staff } from "@/app/api/staff"; import { Typography } from "@mui/material"; import PositionDetails from "./PositionDetails"; diff --git a/src/components/CreatePosition/PositionDetails.tsx b/src/components/CreatePosition/PositionDetails.tsx index 042a8e2..5e03acd 100644 --- a/src/components/CreatePosition/PositionDetails.tsx +++ b/src/components/CreatePosition/PositionDetails.tsx @@ -17,7 +17,6 @@ import RestartAlt from "@mui/icons-material/RestartAlt"; import Button from "@mui/material/Button"; import { Controller, useFormContext } from "react-hook-form"; import { CreatePositionInputs } from "@/app/api/positions/actions"; -import { Staff } from "@/app/api/staff"; const PositionDetails: React.FC = ({ }) => { diff --git a/src/components/CreateProject/CreateProject.tsx b/src/components/CreateProject/CreateProject.tsx index 3fb6c4a..d9fb246 100644 --- a/src/components/CreateProject/CreateProject.tsx +++ b/src/components/CreateProject/CreateProject.tsx @@ -24,14 +24,14 @@ import { import { CreateProjectInputs, saveProject } from "@/app/api/projects/actions"; import { Error } from "@mui/icons-material"; import { ProjectCategory } from "@/app/api/projects"; -import { Staff } from "@/app/api/staff"; +import { StaffResult } from "@/app/api/staff"; import { Typography } from "@mui/material"; export interface Props { allTasks: Task[]; projectCategories: ProjectCategory[]; taskTemplates: TaskTemplate[]; - teamLeads: Staff[]; + teamLeads: StaffResult[]; } const hasErrorsInTab = ( diff --git a/src/components/CreateProject/ProjectClientDetails.tsx b/src/components/CreateProject/ProjectClientDetails.tsx index 3d9ca2b..abb2ba7 100644 --- a/src/components/CreateProject/ProjectClientDetails.tsx +++ b/src/components/CreateProject/ProjectClientDetails.tsx @@ -18,12 +18,12 @@ import Button from "@mui/material/Button"; import { Controller, useFormContext } from "react-hook-form"; import { CreateProjectInputs } from "@/app/api/projects/actions"; import { ProjectCategory } from "@/app/api/projects"; -import { Staff } from "@/app/api/staff"; +import { StaffResult } from "@/app/api/staff"; interface Props { isActive: boolean; projectCategories: ProjectCategory[]; - teamLeads: Staff[]; + teamLeads: StaffResult[]; } const ProjectClientDetails: React.FC = ({ @@ -99,7 +99,7 @@ const ProjectClientDetails: React.FC = ({