"use client"; import { useState, useTransition } from "react"; import { useRouter } from "next/navigation"; import { CalendarClockIcon } from "lucide-react"; import { toast } from "sonner"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover"; import { scheduleContactPingsAction } from "@/server/actions"; import { DateField } from "@/components/ui/date-field"; /** * One ping date across a selection — "chase everyone I met at the conference * in two weeks". * * Only on the contacts list. A company has nothing to chase, and putting a * disabled control on both screens for symmetry would be worse than an * asymmetric bar that only offers what each list can do. */ export function PingSelected({ ids, onDone }: { ids: string[]; onDone: () => void }) { const router = useRouter(); const [open, setOpen] = useState(false); const [date, setDate] = useState(""); const [pending, startTransition] = useTransition(); const save = (value: string) => startTransition(async () => { try { const result = await scheduleContactPingsAction(ids, value); toast.success( result.cleared ? `${result.changed} taken off the chase list` : `${result.changed} on the chase list`, ); setOpen(false); onDone(); router.refresh(); } catch (error) { toast.error(error instanceof Error ? error.message : "Could not schedule that."); } }); return (

Chase all {ids.length} of them on

); }