"use client"; import { useActionState } from "react"; import { Button } from "@/components/ui/button"; import { saveNotificationPreferences, type PreferencesState } from "@/server/actions/notifications/preferences"; export type PreferenceItem = { type: string; label: string; email: boolean; mandatory: boolean }; /** E-mail opt-out per notification type (in-app notifications are always on). */ export function NotificationPreferencesForm({ items, labels, }: { items: PreferenceItem[]; labels: { email: string; mandatory: string; save: string; saved: string; error: string }; }) { const [state, action, pending] = useActionState(saveNotificationPreferences, { status: "idle" } as PreferencesState); return (

{state.status === "saved" && ✓ {labels.saved}} {state.status === "error" && ⚠ {labels.error}}

); }