import { serverFetchJson } from "@/app/utils/fetchUtil"; import { BASE_API_URL } from "@/config/api"; import { cache } from "react"; import "server-only"; export interface Customer { id: number; code: string; name: string; } export interface NewCustomerResponse { customer: Customer; message: string; } export interface CustomerType { id: number; name: string; } export interface Subsidiary { id: number; code: string; name: string; description: string | null; brNo: string | null; contactName: string | null; phone: string | null; address: string | null; district: string | null; email: string | null; } export interface Contact { id: number; name: string; phone: string; email: string; isNew: boolean; } export const preloadAllCustomers = () => { fetchAllCustomers(); }; export const fetchAllCustomers = cache(async () => { return serverFetchJson(`${BASE_API_URL}/customer`); }); export const fetchSubsidiaries = cache(async () => { return serverFetchJson( `${BASE_API_URL}/subsidiary`, { next: { tags: ["subsidiary"] }, }, ); }); export const fetchCustomerTypes = cache(async () => { return serverFetchJson( `${BASE_API_URL}/customer/types`, { next: { tags: ["CustomerTypes"] }, }, ); });