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.
 
 

46 lines
1.1 KiB

  1. import { serverFetchJson } from '@/app/utils/fetchUtil';
  2. import { BASE_API_URL } from '@/config/api';
  3. import { cache } from "react";
  4. import "server-only";
  5. export interface PrinterCombo {
  6. id: number;
  7. value: number;
  8. label?: string;
  9. code?: string;
  10. name?: string;
  11. type?: string;
  12. description?: string;
  13. ip?: string;
  14. port?: number;
  15. }
  16. export interface PrinterResult {
  17. action: any;
  18. id: number;
  19. name?: string;
  20. code?: string;
  21. type?: string;
  22. description?: string;
  23. ip?: string;
  24. port?: number;
  25. dpi?: number;
  26. }
  27. export const fetchPrinterCombo = cache(async () => {
  28. return serverFetchJson<PrinterCombo[]>(`${BASE_API_URL}/printers/combo`, {
  29. next: { tags: ["printers"] },
  30. })
  31. })
  32. export const fetchPrinters = cache(async () => {
  33. return serverFetchJson<PrinterResult[]>(`${BASE_API_URL}/printers`, {
  34. next: { tags: ["printers"] },
  35. });
  36. });
  37. export const fetchPrinterDescriptions = cache(async () => {
  38. return serverFetchJson<string[]>(`${BASE_API_URL}/printers/descriptions`, {
  39. next: { tags: ["printers"] },
  40. });
  41. });