Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 

35 linhas
820 B

  1. "use server"
  2. import { serverFetchJson } from "@/app/utils/fetchUtil";
  3. import { BASE_API_URL } from "@/config/api";
  4. import { cache } from "react";
  5. export interface comboProp {
  6. id: any;
  7. label: string;
  8. }
  9. export interface combo {
  10. records: comboProp[];
  11. }
  12. export interface CreateDepartmentInputs {
  13. departmentCode: string;
  14. departmentName: string;
  15. description: string;
  16. }
  17. export const saveDepartment = async (data: CreateDepartmentInputs) => {
  18. return serverFetchJson(`${BASE_API_URL}/departments/new`, {
  19. method: "POST",
  20. body: JSON.stringify(data),
  21. headers: { "Content-Type": "application/json" },
  22. });
  23. };
  24. export const fetchDepartmentCombo = cache(async () => {
  25. return serverFetchJson<combo>(`${BASE_API_URL}/departments/combo`, {
  26. next: { tags: ["department"] },
  27. });
  28. });