import { useQuery } from "@tanstack/react-query";
import { apiGet } from "../../../../../lib/api/methods";
import { SETTINGS_ENDPOINTS } from "../endpoints";

type SecuritySettingsResponse = {
  privacyPolicy: string;
  termsAndConditions: string;
};

export default function useFetchSecuritySettings() {
  const { data, isPending, isError, error } = useQuery({
    queryKey: ["security-settings"],
    queryFn: async () => {
      const response = await apiGet<SecuritySettingsResponse>(
        SETTINGS_ENDPOINTS.SECURITY,
      );
      return response.data;
    },
    staleTime: 10 * 60 * 1000,
  });

  return {
    securitySettings: data,
    loading: isPending,
    isError,
    error,
  };
}
