|
@@ -2,20 +2,6 @@ import { serverFetchJson } from "@/app/utils/fetchUtil"; |
|
|
import { BASE_API_URL } from "@/config/api"; |
|
|
import { BASE_API_URL } from "@/config/api"; |
|
|
import { cache } from "react"; |
|
|
import { cache } from "react"; |
|
|
import "server-only"; |
|
|
import "server-only"; |
|
|
import { Staff } from "../staff"; |
|
|
|
|
|
|
|
|
|
|
|
interface Project { |
|
|
|
|
|
id: number; |
|
|
|
|
|
code: string; |
|
|
|
|
|
name: string; |
|
|
|
|
|
projectCategory: { |
|
|
|
|
|
name: string; |
|
|
|
|
|
}; |
|
|
|
|
|
teamLead: Staff; |
|
|
|
|
|
customer: { |
|
|
|
|
|
name: string; |
|
|
|
|
|
}; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export interface ProjectResult { |
|
|
export interface ProjectResult { |
|
|
id: number; |
|
|
id: number; |
|
@@ -37,24 +23,9 @@ export const preloadProjects = () => { |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
export const fetchProjects = cache(async () => { |
|
|
export const fetchProjects = cache(async () => { |
|
|
const projects = await serverFetchJson<Project[]>( |
|
|
|
|
|
`${BASE_API_URL}/projects`, |
|
|
|
|
|
{ |
|
|
|
|
|
next: { tags: ["projects"] }, |
|
|
|
|
|
}, |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
// TODO: Replace this with a project |
|
|
|
|
|
return projects.map<ProjectResult>( |
|
|
|
|
|
({ id, code, name, projectCategory, teamLead, customer }) => ({ |
|
|
|
|
|
id, |
|
|
|
|
|
code, |
|
|
|
|
|
name, |
|
|
|
|
|
category: projectCategory.name, |
|
|
|
|
|
team: teamLead.team.code, |
|
|
|
|
|
client: customer.name, |
|
|
|
|
|
}), |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
return serverFetchJson<ProjectResult[]>(`${BASE_API_URL}/projects`, { |
|
|
|
|
|
next: { tags: ["projects"] }, |
|
|
|
|
|
}); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
export const fetchProjectCategories = cache(async () => { |
|
|
export const fetchProjectCategories = cache(async () => { |
|
|