Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

67 строки
1.3 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 Customer {
  6. id: number;
  7. code: string;
  8. name: string;
  9. }
  10. export interface NewCustomerResponse {
  11. customer: Customer;
  12. message: string;
  13. }
  14. export interface CustomerType {
  15. id: number;
  16. name: string;
  17. }
  18. export interface Subsidiary {
  19. id: number;
  20. code: string;
  21. name: string;
  22. description: string | null;
  23. brNo: string | null;
  24. contactName: string | null;
  25. phone: string | null;
  26. address: string | null;
  27. district: string | null;
  28. email: string | null;
  29. }
  30. export interface Contact {
  31. id: number;
  32. name: string;
  33. phone: string;
  34. email: string;
  35. isNew: boolean;
  36. }
  37. export const preloadAllCustomers = () => {
  38. fetchAllCustomers();
  39. };
  40. export const fetchAllCustomers = cache(async () => {
  41. return serverFetchJson<Customer[]>(`${BASE_API_URL}/customer`);
  42. });
  43. export const fetchSubsidiaries = cache(async () => {
  44. return serverFetchJson<Subsidiary[]>(
  45. `${BASE_API_URL}/subsidiary`,
  46. {
  47. next: { tags: ["subsidiary"] },
  48. },
  49. );
  50. });
  51. export const fetchCustomerTypes = cache(async () => {
  52. return serverFetchJson<CustomerType[]>(
  53. `${BASE_API_URL}/customer/types`,
  54. {
  55. next: { tags: ["CustomerTypes"] },
  56. },
  57. );
  58. });