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.
 
 

48 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. brand?: string;
  13. description?: string;
  14. ip?: string;
  15. port?: number;
  16. }
  17. export interface PrinterResult {
  18. action: any;
  19. id: number;
  20. name?: string;
  21. code?: string;
  22. type?: string;
  23. brand?: string;
  24. description?: string;
  25. ip?: string;
  26. port?: number;
  27. dpi?: number;
  28. }
  29. export const fetchPrinterCombo = cache(async () => {
  30. return serverFetchJson<PrinterCombo[]>(`${BASE_API_URL}/printers/combo`, {
  31. next: { tags: ["printers"] },
  32. })
  33. })
  34. export const fetchPrinters = cache(async () => {
  35. return serverFetchJson<PrinterResult[]>(`${BASE_API_URL}/printers`, {
  36. next: { tags: ["printers"] },
  37. });
  38. });
  39. export const fetchPrinterDescriptions = cache(async () => {
  40. return serverFetchJson<string[]>(`${BASE_API_URL}/printers/descriptions`, {
  41. next: { tags: ["printers"] },
  42. });
  43. });