import {EmailForm} from "@/components/wrappers/dashboard/admin/AdminEmailTab/EmailForm/EmailForm"; import {Settings} from "@prisma/client"; import {Send} from "lucide-react"; import {ButtonWithLoading} from "@/components/wrappers/common/button/ButtonWithLoading/ButtonWithLoading"; import {useMutation} from "@tanstack/react-query"; import {sendEmail} from "@/utils/email-helper"; import TestEmailSettings from "../../../../../../emails/TestEmailSettings"; import {render} from "@react-email/render"; import {toast} from "sonner"; export type SettingsEmailTabProps = { settings: Settings } export const SettingsEmailTab = (props: SettingsEmailTabProps) => { const mutation = useMutation({ mutationFn: async () => { const email = await sendEmail({ to: props.settings.smtpUser, subject: "Portabase", html: await render(TestEmailSettings(),{}) }); if(email.response){ toast.success("Test Email Successfully sent !"); } } }) const handleSendMailTest = async () => { await mutation.mutateAsync() } return (

Settings for Portabase email setup

{props.settings.smtpFrom && ( { await handleSendMailTest() }} icon={} text="Send email test" size="default" /> )}
) }