// "use server";
// import { redirect } from "next/navigation";
import { URL } from "../config";

export const AdminLogin = async (email: string, password: string) => {
  try {
    const res = await fetch(`${URL}/v1/api/admin/admin-login`, {
      method: "POST",
      headers: { "Content-Type": "application/json" },
      body: JSON.stringify({ email, password }),
    });

    const jsonResponse = await res.json();

    return jsonResponse;
  } catch (error) {
    console.error("Error fetching data:", error);
  }
};
export const ListAllNotifications = async (token: string) => {
  try {
    const res = await fetch(`${URL}/v1/api/admin/list-all-notifications`, {
      method: "GET",
      headers: {
        "Content-Type": "application/json",
        Authorization: `Bearer ${token}`,
      },
      // body: JSON.stringify({ email, password }),
    });

    const jsonResponse = await res.json();

    return jsonResponse;
  } catch (error) {
    console.error("Error fetching data:", error);
  }
};
export const updateNotificationRead = async (token: string, id: string) => {
  try {
    await fetch(`${URL}/v1/api/admin/seen-notification/${id}`, {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
        Authorization: `Bearer ${token}`,
      },
      // body: JSON.stringify({ email, password }),
    });
  } catch (error) {
    console.error("Error fetching data:", error);
  }
};
