FPSMS-frontend
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

46 lines
1.3 KiB

  1. 'use server'
  2. import { serverFetchJson } from "@/app/utils/fetchUtil";
  3. import { Machine, Operator } from ".";
  4. import { BASE_API_URL } from "@/config/api";
  5. import { revalidateTag } from "next/cache";
  6. export interface IsOperatorExistResponse<T> {
  7. id: number | null;
  8. name: string;
  9. code: string;
  10. type?: string
  11. message: string | null;
  12. errorPosition: string | keyof T;
  13. entity: T
  14. }
  15. export interface isCorrectMachineUsedResponse<T> {
  16. id: number | null;
  17. name: string;
  18. code: string;
  19. type?: string
  20. message: string | null;
  21. errorPosition: string | keyof T;
  22. entity: T
  23. }
  24. export const isOperatorExist = async (username: string) => {
  25. const isExist = await serverFetchJson<IsOperatorExistResponse<Operator>>(`${BASE_API_URL}/jop/isOperatorExist`, {
  26. method: "POST",
  27. body: JSON.stringify({ username }),
  28. headers: { "Content-Type": "application/json" },
  29. });
  30. revalidateTag("po");
  31. return isExist
  32. }
  33. export const isCorrectMachineUsed = async (machineCode: string) => {
  34. const isExist = await serverFetchJson<isCorrectMachineUsedResponse<Machine>>(`${BASE_API_URL}/jop/isCorrectMachineUsed`, {
  35. method: "POST",
  36. body: JSON.stringify({ machineCode }),
  37. headers: { "Content-Type": "application/json" },
  38. });
  39. revalidateTag("po");
  40. return isExist
  41. }