"use client"; import { useRouter } from "next/navigation"; import { useForm } from "react-hook-form"; import { zodResolver } from "@hookform/resolvers/zod"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@/components/ui/card"; import { useSendCampaign } from "@/modules/campaigns/hooks"; import { sendCampaignSchema, type SendCampaignInput } from "@/modules/campaigns/schemas"; import { useToast } from "@/hooks/use-toast"; import { ArrowLeft, Send } from "lucide-react"; export default function SendCampaignPage() { const router = useRouter(); const { toast } = useToast(); const sendMutation = useSendCampaign(); const { register, handleSubmit, reset, formState: { errors }, } = useForm({ resolver: zodResolver(sendCampaignSchema), defaultValues: { data: {}, }, }); const onSubmit = async (data: SendCampaignInput) => { try { await sendMutation.mutateAsync(data); toast({ title: "Campaign sent", description: "Campaign has been sent successfully to the user", }); reset(); router.push("/campaigns"); } catch (error) { toast({ title: "Send failed", description: "Failed to send campaign", variant: "destructive", }); } }; return (

Send Single Campaign

Send an immediate campaign to a specific user

Send Campaign Send a notification campaign immediately to a specific user
{errors.userID && (

{errors.userID.message}

)}
{errors.title && (

{errors.title.message}

)}
{errors.body && (

{errors.body.message}

)}
); }