"use client";
import { useEffect } from "react";
import useVerifyEmail from "../../../hooks/features/auth/verify-email/useVerifyEmail";
import { errorToast, successToast } from "../../../utils/toast";
import { AxiosError } from "axios";
import { ErrorApiResponse } from "../../../types/api-response";

export default function VerifyEmailContent() {
  const { data, loading, error } = useVerifyEmail();

  useEffect(() => {
    if (data) {
      successToast(data.message);
    }
    if (error) {
      const axiosError = error as AxiosError<
        ErrorApiResponse<Record<string, string[]>>
      >;
      errorToast(
        axiosError?.response?.data?.message ?? "Something went wrong.",
      );
    }
  }, [data, error]);

  return null;
}
