FPSMS-frontend
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 

20 rindas
615 B

  1. "use server";
  2. import { ServerFetchError, serverFetchJson, serverFetchWithNoContent } from "@/app/utils/fetchUtil";
  3. import { revalidateTag } from "next/cache";
  4. import { BASE_API_URL } from "@/config/api";
  5. export type CreateMaterialInputs = {
  6. name: string;
  7. }
  8. export const saveMaterial = async (data: CreateMaterialInputs) => {
  9. // try {
  10. const materials = await serverFetchJson(`${BASE_API_URL}/materials/save`, {
  11. method: "POST",
  12. body: JSON.stringify(data),
  13. headers: { "Content-Type": "application/json" },
  14. });
  15. revalidateTag("materials");
  16. return materials
  17. };