FPSMS-frontend
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.
 
 

71 lines
1.8 KiB

  1. "use server";
  2. import { BASE_API_URL } from "@/config/api";
  3. // import { ServerFetchError, serverFetchJson, serverFetchWithNoContent } from "@/app/utils/fetchUtil";
  4. import { revalidateTag } from "next/cache";
  5. import { cache } from "react";
  6. import { serverFetchJson } from "@/app/utils/fetchUtil";
  7. import { QcItemResult } from "../settings/qcItem";
  8. import { RecordsRes } from "../utils";
  9. import { DoResult } from ".";
  10. import { GridRowId, GridRowSelectionModel } from "@mui/x-data-grid";
  11. export interface CreateConsoDoInput {
  12. ids: GridRowSelectionModel;
  13. }
  14. export interface DoDetail {
  15. id: number;
  16. code: string;
  17. supplierCode: string;
  18. shopCode: string;
  19. currencyCode: string;
  20. orderDate: string;
  21. estimatedArrivalDate: string;
  22. completeDate: string;
  23. status: string;
  24. deliveryOrderLines: DoDetailLine[];
  25. }
  26. export interface DoDetailLine {
  27. id: number;
  28. itemNo: string;
  29. qty: number;
  30. price: number;
  31. status: string;
  32. itemName?: string;
  33. uomCode?: string;
  34. }
  35. export interface ReleaseDoRequest {
  36. id: number;
  37. }
  38. export interface ReleaseDoResponse {
  39. id: number;
  40. entity: { status: string }
  41. }
  42. export const releaseDo = cache(async (data: ReleaseDoRequest) => {
  43. return await serverFetchJson<ReleaseDoResponse>(`${BASE_API_URL}/do/release`,
  44. {
  45. method: "POST",
  46. body: JSON.stringify(data),
  47. headers: { "Content-Type": "application/json" },
  48. })
  49. })
  50. export const preloadDo = () => {
  51. fetchDoList();
  52. };
  53. export const fetchDoList = cache(async () => {
  54. return serverFetchJson<DoResult[]>(`${BASE_API_URL}/do/list`, {
  55. next: { tags: ["doList"] },
  56. });
  57. });
  58. export const fetchDoDetail = cache(async (id: number) => {
  59. return serverFetchJson<DoDetail>(`${BASE_API_URL}/do/detail/${id}`, {
  60. method: "GET",
  61. headers: { "Content-Type": "application/json" },
  62. next: {
  63. tags: ["doDetail"]
  64. }
  65. });
  66. });