FPSMS-frontend
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 

92 строки
2.3 KiB

  1. import { cache } from "react";
  2. import "server-only";
  3. // import { serverFetchJson } from "@/app/utils/fetchUtil";
  4. // import { BASE_API_URL } from "@/config/api";
  5. import { serverFetchJson } from "../../utils/fetchUtil";
  6. import { BASE_API_URL } from "../../../config/api";
  7. import { Uom } from "../settings/uom";
  8. import { RecordsRes } from "../utils";
  9. // import { IQCItems } from "@/components/DashboardPage/QC/SupervisorQcApproval";
  10. export interface PoResult {
  11. id: number;
  12. code: string;
  13. orderDate: string;
  14. supplier: string;
  15. estimatedArrivalDate: string;
  16. completedDate: string;
  17. escalated: boolean;
  18. status: string;
  19. pol?: PurchaseOrderLine[];
  20. }
  21. export interface PurchaseOrderLine {
  22. id: number;
  23. purchaseOrderId: number;
  24. itemId: number;
  25. itemNo: string;
  26. itemName: string;
  27. qty: number;
  28. processed: number;
  29. uom: Uom;
  30. price: number;
  31. status: string;
  32. stockInLine: StockInLine[];
  33. }
  34. export interface StockInLine {
  35. id: number;
  36. stockInId: number;
  37. purchaseOrderId?: number;
  38. purchaseOrderLineId: number;
  39. itemId: number;
  40. itemNo: string;
  41. itemName: string;
  42. itemType: string;
  43. demandQty: number;
  44. acceptedQty: number;
  45. price: number;
  46. priceUnit: string;
  47. shelfLife?: number;
  48. receiptDate?: string;
  49. productionDate?: string;
  50. expiryDate?: string;
  51. status: string;
  52. supplier: string;
  53. lotNo: string;
  54. poCode: string;
  55. uom: Uom;
  56. defaultWarehouseId: number; // id for now
  57. }
  58. export const fetchPoList = cache(async (queryParams?: Record<string, any>) => {
  59. if (queryParams) {
  60. const queryString = new URLSearchParams(queryParams).toString();
  61. return serverFetchJson<RecordsRes<PoResult[]>>(
  62. `${BASE_API_URL}/po/list?${queryString}`,
  63. {
  64. method: "GET",
  65. next: { tags: ["po"] },
  66. },
  67. );
  68. } else {
  69. return serverFetchJson<RecordsRes<PoResult[]>>(`${BASE_API_URL}/po/list`, {
  70. method: "GET",
  71. next: { tags: ["po"] },
  72. });
  73. }
  74. });
  75. export const fetchPoWithStockInLines = cache(async (id: number) => {
  76. return serverFetchJson<PoResult>(`${BASE_API_URL}/po/detail/${id}`, {
  77. next: { tags: ["po"] },
  78. });
  79. });
  80. export const fetchIqcLogByUser = cache(async () => {
  81. // return serverFetchJson<IQCItems[]>(`${BASE_API_URL}/supervisionApprovalLog/stock-in`, {
  82. // next: { tags: ["qcLog"] },
  83. // });
  84. return undefined;
  85. });