| @@ -25,7 +25,6 @@ import { | |||||
| import { CreateProjectInputs, saveProject } from "@/app/api/projects/actions"; | import { CreateProjectInputs, saveProject } from "@/app/api/projects/actions"; | ||||
| import { Error } from "@mui/icons-material"; | import { Error } from "@mui/icons-material"; | ||||
| import { ProjectCategory } from "@/app/api/projects"; | import { ProjectCategory } from "@/app/api/projects"; | ||||
| import { Staff } from "@/app/api/staff"; | |||||
| import { Grid, Typography } from "@mui/material"; | import { Grid, Typography } from "@mui/material"; | ||||
| import CreateStaffForm from "@/components/CreateStaff/CreateStaffForm"; | import CreateStaffForm from "@/components/CreateStaff/CreateStaffForm"; | ||||
| @@ -3,15 +3,6 @@ import { BASE_API_URL } from "@/config/api"; | |||||
| import { cache } from "react"; | import { cache } from "react"; | ||||
| import "server-only"; | import "server-only"; | ||||
| export interface Staff { | |||||
| id: number; | |||||
| name: string; | |||||
| staffId: string; | |||||
| team: { | |||||
| name: string; | |||||
| code: string; | |||||
| }; | |||||
| } | |||||
| export interface StaffResult { | export interface StaffResult { | ||||
| id: number; | id: number; | ||||
| name: string; | name: string; | ||||
| @@ -31,11 +22,10 @@ export interface searchInput { | |||||
| export const preloadTeamLeads = () => { | export const preloadTeamLeads = () => { | ||||
| fetchTeamLeads(); | fetchTeamLeads(); | ||||
| // fetchStaff(); | |||||
| }; | }; | ||||
| export const fetchTeamLeads = cache(async () => { | export const fetchTeamLeads = cache(async () => { | ||||
| return serverFetchJson<Staff[]>(`${BASE_API_URL}/staffs/teamLeads`, { | |||||
| return serverFetchJson<StaffResult[]>(`${BASE_API_URL}/staffs/teamLeads`, { | |||||
| next: { tags: ["teamLeads"] }, | next: { tags: ["teamLeads"] }, | ||||
| }); | }); | ||||
| }); | }); | ||||
| @@ -20,7 +20,6 @@ import { | |||||
| import { CreateProjectInputs, saveProject } from "@/app/api/projects/actions"; | import { CreateProjectInputs, saveProject } from "@/app/api/projects/actions"; | ||||
| import { Error } from "@mui/icons-material"; | import { Error } from "@mui/icons-material"; | ||||
| import { ProjectCategory } from "@/app/api/projects"; | import { ProjectCategory } from "@/app/api/projects"; | ||||
| import { Staff } from "@/app/api/staff"; | |||||
| import { Typography } from "@mui/material"; | import { Typography } from "@mui/material"; | ||||
| import { CustomerFormInputs, saveCustomer } from "@/app/api/customer/actions"; | import { CustomerFormInputs, saveCustomer } from "@/app/api/customer/actions"; | ||||
| import CustomerDetails from "./CustomerDetails"; | import CustomerDetails from "./CustomerDetails"; | ||||
| @@ -20,7 +20,6 @@ import { | |||||
| import { CreateDepartmentInputs, saveDepartment } from "@/app/api/departments/actions"; | import { CreateDepartmentInputs, saveDepartment } from "@/app/api/departments/actions"; | ||||
| import { Error } from "@mui/icons-material"; | import { Error } from "@mui/icons-material"; | ||||
| import { ProjectCategory } from "@/app/api/projects"; | import { ProjectCategory } from "@/app/api/projects"; | ||||
| import { Staff } from "@/app/api/staff"; | |||||
| import { Typography } from "@mui/material"; | import { Typography } from "@mui/material"; | ||||
| import DepartmentDetails from "./DepartmentDetails"; | import DepartmentDetails from "./DepartmentDetails"; | ||||
| @@ -17,7 +17,6 @@ import RestartAlt from "@mui/icons-material/RestartAlt"; | |||||
| import Button from "@mui/material/Button"; | import Button from "@mui/material/Button"; | ||||
| import { Controller, useFormContext } from "react-hook-form"; | import { Controller, useFormContext } from "react-hook-form"; | ||||
| import { CreateDepartmentInputs } from "@/app/api/departments/actions"; | import { CreateDepartmentInputs } from "@/app/api/departments/actions"; | ||||
| import { Staff } from "@/app/api/staff"; | |||||
| const DepartmentDetails: React.FC = ({ | const DepartmentDetails: React.FC = ({ | ||||
| }) => { | }) => { | ||||
| @@ -20,7 +20,6 @@ import { | |||||
| import { CreatePositionInputs, savePosition } from "@/app/api/positions/actions"; | import { CreatePositionInputs, savePosition } from "@/app/api/positions/actions"; | ||||
| import { Error } from "@mui/icons-material"; | import { Error } from "@mui/icons-material"; | ||||
| import { ProjectCategory } from "@/app/api/projects"; | import { ProjectCategory } from "@/app/api/projects"; | ||||
| import { Staff } from "@/app/api/staff"; | |||||
| import { Typography } from "@mui/material"; | import { Typography } from "@mui/material"; | ||||
| import PositionDetails from "./PositionDetails"; | import PositionDetails from "./PositionDetails"; | ||||
| @@ -17,7 +17,6 @@ import RestartAlt from "@mui/icons-material/RestartAlt"; | |||||
| import Button from "@mui/material/Button"; | import Button from "@mui/material/Button"; | ||||
| import { Controller, useFormContext } from "react-hook-form"; | import { Controller, useFormContext } from "react-hook-form"; | ||||
| import { CreatePositionInputs } from "@/app/api/positions/actions"; | import { CreatePositionInputs } from "@/app/api/positions/actions"; | ||||
| import { Staff } from "@/app/api/staff"; | |||||
| const PositionDetails: React.FC = ({ | const PositionDetails: React.FC = ({ | ||||
| }) => { | }) => { | ||||
| @@ -24,14 +24,14 @@ import { | |||||
| import { CreateProjectInputs, saveProject } from "@/app/api/projects/actions"; | import { CreateProjectInputs, saveProject } from "@/app/api/projects/actions"; | ||||
| import { Error } from "@mui/icons-material"; | import { Error } from "@mui/icons-material"; | ||||
| import { ProjectCategory } from "@/app/api/projects"; | import { ProjectCategory } from "@/app/api/projects"; | ||||
| import { Staff } from "@/app/api/staff"; | |||||
| import { StaffResult } from "@/app/api/staff"; | |||||
| import { Typography } from "@mui/material"; | import { Typography } from "@mui/material"; | ||||
| export interface Props { | export interface Props { | ||||
| allTasks: Task[]; | allTasks: Task[]; | ||||
| projectCategories: ProjectCategory[]; | projectCategories: ProjectCategory[]; | ||||
| taskTemplates: TaskTemplate[]; | taskTemplates: TaskTemplate[]; | ||||
| teamLeads: Staff[]; | |||||
| teamLeads: StaffResult[]; | |||||
| } | } | ||||
| const hasErrorsInTab = ( | const hasErrorsInTab = ( | ||||
| @@ -18,12 +18,12 @@ import Button from "@mui/material/Button"; | |||||
| import { Controller, useFormContext } from "react-hook-form"; | import { Controller, useFormContext } from "react-hook-form"; | ||||
| import { CreateProjectInputs } from "@/app/api/projects/actions"; | import { CreateProjectInputs } from "@/app/api/projects/actions"; | ||||
| import { ProjectCategory } from "@/app/api/projects"; | import { ProjectCategory } from "@/app/api/projects"; | ||||
| import { Staff } from "@/app/api/staff"; | |||||
| import { StaffResult } from "@/app/api/staff"; | |||||
| interface Props { | interface Props { | ||||
| isActive: boolean; | isActive: boolean; | ||||
| projectCategories: ProjectCategory[]; | projectCategories: ProjectCategory[]; | ||||
| teamLeads: Staff[]; | |||||
| teamLeads: StaffResult[]; | |||||
| } | } | ||||
| const ProjectClientDetails: React.FC<Props> = ({ | const ProjectClientDetails: React.FC<Props> = ({ | ||||
| @@ -99,7 +99,7 @@ const ProjectClientDetails: React.FC<Props> = ({ | |||||
| <Select label={t("Team Lead")} {...field}> | <Select label={t("Team Lead")} {...field}> | ||||
| {teamLeads.map((staff, index) => ( | {teamLeads.map((staff, index) => ( | ||||
| <MenuItem key={`${staff.id}-${index}`} value={staff.id}> | <MenuItem key={`${staff.id}-${index}`} value={staff.id}> | ||||
| {`${staff.staffId} - ${staff.name} (${staff.team.code})`} | |||||
| {`${staff.staffId} - ${staff.name} (${staff.team})`} | |||||
| </MenuItem> | </MenuItem> | ||||
| ))} | ))} | ||||
| </Select> | </Select> | ||||