diff --git a/apps/frontend/app/actions.ts b/apps/frontend/app/actions.ts index 57af7f3..b31e410 100644 --- a/apps/frontend/app/actions.ts +++ b/apps/frontend/app/actions.ts @@ -137,7 +137,7 @@ export async function updateSystemSettings(formData: FormData) { } export async function updateSttEnabled(formData: FormData) { - const enabled = formData.get("sttEnabled") === "on"; + const enabled = formData.get("sttEnabled") === "true"; await prisma.appSetting.upsert({ where: { key: "stt_enabled" }, create: { key: "stt_enabled", value: String(enabled) }, @@ -147,8 +147,8 @@ export async function updateSttEnabled(formData: FormData) { } export async function updateNotificationPrefs(formData: FormData) { - const streamStart = formData.get("notifyStreamStart") === "on"; - const renderDone = formData.get("notifyRenderDone") === "on"; + const streamStart = formData.get("notifyStreamStart") === "true"; + const renderDone = formData.get("notifyRenderDone") === "true"; await prisma.appSetting.upsert({ where: { key: "notify_stream_start" }, diff --git a/apps/frontend/app/components/SettingSwitch.tsx b/apps/frontend/app/components/SettingSwitch.tsx new file mode 100644 index 0000000..7cbb571 --- /dev/null +++ b/apps/frontend/app/components/SettingSwitch.tsx @@ -0,0 +1,22 @@ +"use client"; + +import { useState } from "react"; + +import { Switch } from "@/components/ui/switch"; + +/** + * Radix Switch's own hidden-input form integration wasn't reliably reaching + * the Server Action's FormData in this app (toggling off + saving silently + * kept the old value) — this owns the submitted value directly instead of + * depending on that mechanism. + */ +export function SettingSwitch({ name, defaultChecked }: { name: string; defaultChecked: boolean }) { + const [checked, setChecked] = useState(defaultChecked); + + return ( + <> + + + + ); +} diff --git a/apps/frontend/app/settings/page.tsx b/apps/frontend/app/settings/page.tsx index bf93d09..1004675 100644 --- a/apps/frontend/app/settings/page.tsx +++ b/apps/frontend/app/settings/page.tsx @@ -4,7 +4,7 @@ import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Textarea } from "@/components/ui/textarea"; -import { Switch } from "@/components/ui/switch"; +import { SettingSwitch } from "../components/SettingSwitch"; import { Badge } from "@/components/ui/badge"; import { Card, CardContent, CardHeader, CardTitle, CardDescription, CardFooter } from "@/components/ui/card"; @@ -110,7 +110,7 @@ export default async function SettingsPage() { @@ -127,11 +127,11 @@ export default async function SettingsPage() {