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

type SocialMediaSettingsResponse = {
  facebook: string;
  instagram: string;
  twitter: string;
  linkedIn: string;
  youtube: string;
  customLink: string;
};

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

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