Posts a message to the league Discord webhook each time a pick is made, announcing the picked participant and pinging the next team on the clock if their owner has opted into Discord notifications. Enabled via a separate toggle in league settings (independent from standings update notifications). https://claude.ai/code/session_01Tvwsv3LfL9JUqxoLct8dTn
67 lines
2.5 KiB
TypeScript
67 lines
2.5 KiB
TypeScript
import { Bell } from "lucide-react";
|
|
import { Input } from "~/components/ui/input";
|
|
import { Label } from "~/components/ui/label";
|
|
import { Switch } from "~/components/ui/switch";
|
|
import { SettingsSection, SettingsStatusPill } from "./SettingsSection";
|
|
|
|
export function NotificationsSection({
|
|
active,
|
|
savedDiscordWebhookUrl,
|
|
discordWebhookUrl,
|
|
onDiscordWebhookUrlChange,
|
|
discordPicksAnnouncementEnabled,
|
|
onDiscordPicksAnnouncementEnabledChange,
|
|
}: {
|
|
active: boolean;
|
|
savedDiscordWebhookUrl: string | null;
|
|
discordWebhookUrl: string;
|
|
onDiscordWebhookUrlChange: (v: string) => void;
|
|
discordPicksAnnouncementEnabled: boolean;
|
|
onDiscordPicksAnnouncementEnabledChange: (v: boolean) => void;
|
|
}) {
|
|
return (
|
|
<SettingsSection
|
|
id="notifications"
|
|
icon={Bell}
|
|
title="Notifications"
|
|
description="Send Discord alerts when standings change after scoring events."
|
|
status={<SettingsStatusPill tone={savedDiscordWebhookUrl ? "success" : "warning"}>{savedDiscordWebhookUrl ? "Configured" : "Optional"}</SettingsStatusPill>}
|
|
className={active ? undefined : "hidden"}
|
|
>
|
|
<div className="space-y-4">
|
|
<div className="space-y-2">
|
|
<Label htmlFor="discordWebhookUrl">Discord Webhook URL</Label>
|
|
<Input
|
|
id="discordWebhookUrl"
|
|
name="discordWebhookUrl"
|
|
type="url"
|
|
value={discordWebhookUrl}
|
|
onChange={(e) => onDiscordWebhookUrlChange(e.target.value)}
|
|
placeholder="https://discord.com/api/webhooks/..."
|
|
/>
|
|
<p className="text-sm text-muted-foreground">
|
|
Create a webhook in Discord under Server Settings, Integrations, Webhooks.
|
|
</p>
|
|
</div>
|
|
{savedDiscordWebhookUrl && (
|
|
<div className="flex items-center gap-3">
|
|
<Switch
|
|
id="discordPicksAnnouncementEnabled"
|
|
name="discordPicksAnnouncementEnabled"
|
|
checked={discordPicksAnnouncementEnabled}
|
|
onCheckedChange={onDiscordPicksAnnouncementEnabledChange}
|
|
/>
|
|
<div>
|
|
<Label htmlFor="discordPicksAnnouncementEnabled" className="cursor-pointer">
|
|
Announce draft picks
|
|
</Label>
|
|
<p className="text-sm text-muted-foreground">
|
|
Post a message for each pick and ping the next team's owner if they've enabled Discord notifications.
|
|
</p>
|
|
</div>
|
|
</div>
|
|
)}
|
|
</div>
|
|
</SettingsSection>
|
|
);
|
|
}
|