You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

48 line
1.1 KiB

  1. "use server";
  2. import { BASE_API_URL } from "@/config/api";
  3. import { Claim, ProjectCombo, SupportingDocument } from ".";
  4. import { serverFetchJson } from "@/app/utils/fetchUtil";
  5. import { revalidateTag } from "next/cache";
  6. export interface ClaimInputFormByStaff {
  7. id: number | null;
  8. code: string | null;
  9. expenseType: string;
  10. status: string;
  11. addClaimDetails: ClaimDetailTable[]
  12. }
  13. export interface ClaimDetailTable {
  14. id: number;
  15. invoiceDate: Date;
  16. description: string;
  17. project: ProjectCombo;
  18. amount: number;
  19. supportingDocumentName: string;
  20. oldSupportingDocument: SupportingDocument;
  21. newSupportingDocument: File;
  22. isNew: boolean;
  23. }
  24. export interface SaveClaimResponse {
  25. claim: Claim;
  26. message: string;
  27. }
  28. export const saveClaim = async (data: FormData) => {
  29. console.log(data)
  30. const saveCustomer = await serverFetchJson<SaveClaimResponse>(
  31. `${BASE_API_URL}/claim/save`,
  32. {
  33. method: "POST",
  34. body: data,
  35. // headers: { "Content-Type": "multipart/form-data" },
  36. },
  37. );
  38. revalidateTag("claims");
  39. return saveCustomer;
  40. };