"use client";

import { RedirectType, redirect } from "next/navigation";
import { useEffect } from "react";
import { toast } from "sonner";

type CallToast = {
  notify: {
    type: string;
    message: string;
    options?: object;
  };
  target: string;
};
export default function CallToast({ notify, target }: CallToast) {
  useEffect(() => {
    toast[notify.type](notify.message, notify.options);

    if (target) redirect(target, RedirectType.push);
  }, [notify, target]);

  return <></>;
}
