FPSMS-frontend
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 

82 行
2.1 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 { QcCategoryResult } from "../qcCategory";
  8. import { Uom } from "../uom";
  9. // import { TypeInputs, UomInputs, WeightUnitInputs } from "./actions";
  10. export type ItemQc = {
  11. id: number; // id = qc_check #
  12. name: string;
  13. code: string;
  14. description: string | undefined;
  15. instruction: string | undefined;
  16. lowerLimit: number | undefined;
  17. upperLimit: number | undefined;
  18. isActive: boolean | undefined;
  19. };
  20. export type ItemsResultResponse = {
  21. records: ItemsResult[];
  22. total: number;
  23. };
  24. export type Item = {
  25. id: number;
  26. code: string;
  27. name: string;
  28. description?: string;
  29. remarks?: string;
  30. type?: string;
  31. shelfLife?: number;
  32. countryOfOrigin?: string;
  33. qcCategory?: QcCategoryResult;
  34. uom: Uom;
  35. }
  36. export type ItemsResult = {
  37. id: string | number;
  38. code: string;
  39. name: string;
  40. description: string | undefined;
  41. remarks: string | undefined;
  42. shelfLife: number | undefined;
  43. countryOfOrigin: string | undefined;
  44. maxQty: number | undefined;
  45. type: string;
  46. qcChecks: ItemQc[];
  47. action?: any;
  48. fgName?: string;
  49. excludeDate?: string;
  50. qcCategory?: QcCategoryResult;
  51. store_id?: string | undefined;
  52. warehouse?: string | undefined;
  53. area?: string | undefined;
  54. slot?: string | undefined;
  55. LocationCode?: string | undefined;
  56. locationCode?: string | undefined; // Backend may return lowercase version
  57. isEgg?: boolean | undefined;
  58. isFee?: boolean | undefined;
  59. isBag?: boolean | undefined;
  60. };
  61. export type Result = {
  62. item: ItemsResult;
  63. qcChecks: ItemQc[];
  64. };
  65. export const fetchAllItems = cache(async () => {
  66. return serverFetchJson<ItemsResult[]>(`${BASE_API_URL}/items`, {
  67. next: { tags: ["items"] },
  68. });
  69. });
  70. export const fetchItem = cache(async (id: number) => {
  71. return serverFetchJson<Result>(`${BASE_API_URL}/items/details/${id}`, {
  72. next: { tags: ["items"] },
  73. });
  74. });