import { serverFetchJson } from "@/app/utils/fetchUtil"; import { BASE_API_URL } from "@/config/api"; import { cache } from "react"; import "server-only"; export interface Claim { id: number; created: string; name: string; cost: number; type: "Expense" | "Petty Cash"; status: "Not Submitted" | "Waiting for Approval" | "Approved" | "Rejected"; remarks: string; } export interface ClaimSearchForm { id: number; created: string; createdTo: string; name: string; cost: number; type: "Expense" | "Petty Cash"; status: "Not Submitted" | "Waiting for Approval" | "Approved" | "Rejected"; remarks: string; } export interface ProjectCombo { id: number; name: string; code: string; } export interface SupportingDocument { id: number; skey: string; filename: string; } export const preloadClaims = () => { fetchClaims(); }; export const fetchClaims = cache(async () => { return mockClaims; // return serverFetchJson(`${BASE_API_URL}/claim`); }); export const fetchProjectCombo = cache(async () => { return serverFetchJson(`${BASE_API_URL}/projects`, { next: { tags: ["projects"] }, }); }); // export const fetchAllCustomers = cache(async () => { // return serverFetchJson(`${BASE_API_URL}/customer`); // }); const mockClaims: Claim[] = [ { id: 1, created: "2023/11/22", name: "Consultancy Project A", cost: 121.0, type: "Expense", status: "Not Submitted", remarks: "", }, { id: 2, created: "2023/11/30", name: "Consultancy Project A", cost: 4300.0, type: "Expense", status: "Waiting for Approval", remarks: "", }, { id: 3, created: "2023/12/12", name: "Construction Project C", cost: 3675.0, type: "Petty Cash", status: "Rejected", remarks: "Duplicate Claim Form", }, ];