|
- "use server"
-
- import { serverFetchJson } from "@/app/utils/fetchUtil";
- import { BASE_API_URL } from "@/config/api";
- import { cache } from "react";
-
- export interface InvoiceResult {
- id: number;
- projectCode: string;
- projectName: string;
- stage: string;
- comingPaymentMileStone: string;
- paymentMilestoneDate: string;
- resourceUsage: number;
- unbilledHours: number;
- reminder: string;
- }
-
- export interface CreateInvoiceInputs {
- id: number;
-
- // Project Details
- projectCode: string;
- projectName: string;
- stage: string;
- comingPaymentMileStone: string;
- paymentMilestoneDate: string;
- resourceUsage: number;
- unbilledHours: number;
-
- // Invoice Info
- client: string;
- address: string;
- attention: string;
- invoiceDate: string;
- dueDate: string;
- projectRefNo: string;
-
- // Invoice related Info
- reminder: string;
- amount: number;
- billHours: number;
- }
-
- export interface InvoiceInformation{
- id: number;
- client: string;
- address: string;
- attention: string;
- invoiceDate: string;
- dueDate: string;
- projectRefNo: string;
-
- amount: number;
- }
-
- export const fetchProjectInvoiceById = cache(async (id: number) => {
- return serverFetchJson<InvoiceResult[]>(`${BASE_API_URL}/invoices/getProjectDetail/${id}`, {
- next: { tags: ["projectDetailById"] },
- });
- })
-
- export const fetchInvoiceInfoById = cache(async (id: number) => {
- return serverFetchJson<InvoiceInformation[]>(`${BASE_API_URL}/invoices/getInvoiceInfo/${id}`, {
- next: { tags: ["invoiceInfoById"] },
- });
- })
|