|
- "use server";
-
- import { convertObjToURLSearchParams } from "@/app/utils/commonUtil";
- import { serverFetchJson } from "@/app/utils/fetchUtil";
- import { BASE_API_URL } from "@/config/api";
- import { cache } from "react";
- import { ScheduleType } from ".";
-
- export interface SearchProdSchedule {
- scheduleAt?: string;
- schedulePeriod?: string;
- schedulePeriodTo?: string;
- totalEstProdCount?: number;
- types?: ScheduleType[];
- pageSize?: number;
- pageNum?: number;
- }
-
- export interface ProdScheduleResult {
- id: number;
- scheduleAt: number[];
- schedulePeriod: number[];
- schedulePeriodTo: number[];
- totalEstProdCount: number;
- totalFGType: number;
- type: string;
- }
-
- export interface ProdScheduleResultByPage {
- total: number;
- records: ProdScheduleResult[];
- }
-
- export const fetchProdSchedules = cache(
- async (data: SearchProdSchedule | null) => {
- const params = convertObjToURLSearchParams<SearchProdSchedule>(data);
- // console.log(params)
- return serverFetchJson<ProdScheduleResultByPage>(
- `${BASE_API_URL}/productionSchedule/getRecordByPage?${params}`,
- {
- method: "GET",
- headers: { "Content-Type": "application/json" },
- next: {
- tags: ["prodSchedules"],
- },
- },
- );
- },
- );
-
- export const testRoughSchedule = cache(async () => {
- return serverFetchJson(
- `${BASE_API_URL}/productionSchedule/testRoughSchedule`,
- {
- method: "GET",
- headers: { "Content-Type": "application/json" },
- next: {
- tags: ["prodSchedules"],
- },
- },
- );
- });
-
- export const testDetailSchedule = cache(async () => {
- return serverFetchJson(
- `${BASE_API_URL}/productionSchedule/testDetailSchedule`,
- {
- method: "GET",
- headers: { "Content-Type": "application/json" },
- next: {
- tags: ["prodSchedules"],
- },
- },
- );
- });
|