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.
 
 
 

20 lines
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. };