"use client"; import { useState } from "react"; import { Loader2, Minus, Plus } from "lucide-react"; import { useCreateNotificationDestination, useUnlinkNotificationDestinationCompany, } from "@/hooks/use-notification-destinations"; import type { NotificationDestinationResponse, NotificationType } from "@/lib/types"; /** * A simplified single-destination view over the full notification * destinations list, scoped to one company - shows the first destination * of `type` linked to this company (if any) with an add/remove control. * Shares the same React Query cache as the Settings page's full * multi-destination UI, so changes here show up there instantly. */ export function NotificationChannelBox({ type, label, placeholder, companyId, destination, disabled, disabledReason, }: { type: NotificationType; label: string; placeholder: string; companyId: string; destination: NotificationDestinationResponse | undefined; disabled?: boolean; disabledReason?: string; }) { const [value, setValue] = useState(""); const create = useCreateNotificationDestination(); const unlink = useUnlinkNotificationDestinationCompany(); return (
setValue(e.target.value)} readOnly={Boolean(destination)} disabled={disabled} placeholder={placeholder} className="focus-ring block w-full rounded-md border border-slate-300 px-3 py-2 text-sm shadow-sm transition-colors duration-150 disabled:cursor-not-allowed disabled:bg-slate-100 disabled:text-slate-400" /> {destination ? ( ) : ( )}
{disabled && disabledReason &&

{disabledReason}

}
); }