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.
 
 

51 lines
1.2 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. // is grid editing
  13. isGridEditing: boolean | null;
  14. }
  15. export interface ClaimDetailTable {
  16. id: number;
  17. invoiceDate: Date;
  18. description: string;
  19. project: number;
  20. amount: number;
  21. supportingDocumentName: string;
  22. oldSupportingDocument: SupportingDocument;
  23. newSupportingDocument: File;
  24. isNew: boolean;
  25. }
  26. export interface SaveClaimResponse {
  27. claim: Claim;
  28. message: string;
  29. }
  30. export const saveClaim = async (data: FormData) => {
  31. console.log(data)
  32. const saveCustomer = await serverFetchJson<SaveClaimResponse>(
  33. `${BASE_API_URL}/claim/save`,
  34. {
  35. method: "POST",
  36. body: data,
  37. // headers: { "Content-Type": "multipart/form-data" },
  38. },
  39. );
  40. revalidateTag("claims");
  41. return saveCustomer;
  42. };