"use client";

import { createContext, useContext } from "react";

import type { SuperAdminSessionResponse } from "@/types/api";

type SuperAdminSessionContextValue = {
  session: SuperAdminSessionResponse | null;
  permissions: string[];
};

const SuperAdminSessionContext = createContext<SuperAdminSessionContextValue>({
  session: null,
  permissions: [],
});

export function SuperAdminSessionProvider({
  children,
  value,
}: {
  children: React.ReactNode;
  value: SuperAdminSessionContextValue;
}) {
  return (
    <SuperAdminSessionContext.Provider value={value}>
      {children}
    </SuperAdminSessionContext.Provider>
  );
}

export function useSuperAdminSession() {
  return useContext(SuperAdminSessionContext);
}
