import { useFetcher } from "react-router"; import { Switch } from "~/components/ui/switch"; import { Label } from "~/components/ui/label"; type Props = { discordPingEnabled: boolean; hasDiscordLinked: boolean; success?: boolean; error?: string; onNavigateToAccount: () => void; }; export function NotificationsSection({ discordPingEnabled, hasDiscordLinked, success, error, onNavigateToAccount }: Props) { const fetcher = useFetcher(); const optimisticEnabled = fetcher.state !== "idle" ? fetcher.formData?.get("discordPingEnabled") === "true" : discordPingEnabled; const handleToggle = (checked: boolean) => { fetcher.submit( { intent: "update-discord-ping", discordPingEnabled: String(checked) }, { method: "post" } ); }; return (

Notifications

Manage how you receive league notifications.

Discord Pings

{!hasDiscordLinked ? (

Link your Discord account in{" "} {" "} to enable Discord pings for league notifications.

) : ( <>

When enabled, you'll be @mentioned in league Discord notifications and your Discord display name will appear in place of your brackt username.

{success && (

Notification preference saved.

)} {error && (

{error}

)} )}
); }