fix: Ayarlar sayfasındaki switch'ler kapatılıp kaydedilince kalıcı olmuyordu
Radix Switch'in kendi gizli-input form entegrasyonu bu ortamda Server Action'ın FormData'sına güvenilir şekilde ulaşmıyordu — switch'i "off" yapıp Kaydet'e basınca eski değer kalıcı oluyordu (STT hep otomatik çalışmaya devam ediyordu). Artık her switch kendi değerini doğrudan kontrol eden bir hidden input'la (SettingSwitch) submit ediliyor, Radix'in iç mekanizmasına bağımlı değil. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -137,7 +137,7 @@ export async function updateSystemSettings(formData: FormData) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function updateSttEnabled(formData: FormData) {
|
export async function updateSttEnabled(formData: FormData) {
|
||||||
const enabled = formData.get("sttEnabled") === "on";
|
const enabled = formData.get("sttEnabled") === "true";
|
||||||
await prisma.appSetting.upsert({
|
await prisma.appSetting.upsert({
|
||||||
where: { key: "stt_enabled" },
|
where: { key: "stt_enabled" },
|
||||||
create: { key: "stt_enabled", value: String(enabled) },
|
create: { key: "stt_enabled", value: String(enabled) },
|
||||||
@@ -147,8 +147,8 @@ export async function updateSttEnabled(formData: FormData) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function updateNotificationPrefs(formData: FormData) {
|
export async function updateNotificationPrefs(formData: FormData) {
|
||||||
const streamStart = formData.get("notifyStreamStart") === "on";
|
const streamStart = formData.get("notifyStreamStart") === "true";
|
||||||
const renderDone = formData.get("notifyRenderDone") === "on";
|
const renderDone = formData.get("notifyRenderDone") === "true";
|
||||||
|
|
||||||
await prisma.appSetting.upsert({
|
await prisma.appSetting.upsert({
|
||||||
where: { key: "notify_stream_start" },
|
where: { key: "notify_stream_start" },
|
||||||
|
|||||||
@@ -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 (
|
||||||
|
<>
|
||||||
|
<input type="hidden" name={name} value={checked ? "true" : "false"} />
|
||||||
|
<Switch checked={checked} onCheckedChange={setChecked} />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -4,7 +4,7 @@ import { Button } from "@/components/ui/button";
|
|||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
import { Label } from "@/components/ui/label";
|
import { Label } from "@/components/ui/label";
|
||||||
import { Textarea } from "@/components/ui/textarea";
|
import { Textarea } from "@/components/ui/textarea";
|
||||||
import { Switch } from "@/components/ui/switch";
|
import { SettingSwitch } from "../components/SettingSwitch";
|
||||||
import { Badge } from "@/components/ui/badge";
|
import { Badge } from "@/components/ui/badge";
|
||||||
import { Card, CardContent, CardHeader, CardTitle, CardDescription, CardFooter } from "@/components/ui/card";
|
import { Card, CardContent, CardHeader, CardTitle, CardDescription, CardFooter } from "@/components/ui/card";
|
||||||
|
|
||||||
@@ -110,7 +110,7 @@ export default async function SettingsPage() {
|
|||||||
<CardContent>
|
<CardContent>
|
||||||
<Label className="flex items-center justify-between gap-4 text-sm font-normal">
|
<Label className="flex items-center justify-between gap-4 text-sm font-normal">
|
||||||
Otomatik transkripsiyon aktif
|
Otomatik transkripsiyon aktif
|
||||||
<Switch name="sttEnabled" defaultChecked={sttEnabled} />
|
<SettingSwitch name="sttEnabled" defaultChecked={sttEnabled} />
|
||||||
</Label>
|
</Label>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
<CardFooter>
|
<CardFooter>
|
||||||
@@ -127,11 +127,11 @@ export default async function SettingsPage() {
|
|||||||
<CardContent className="flex flex-col gap-4">
|
<CardContent className="flex flex-col gap-4">
|
||||||
<Label className="flex items-center justify-between gap-4 text-sm font-normal">
|
<Label className="flex items-center justify-between gap-4 text-sm font-normal">
|
||||||
Yayın başladığında Telegram bildirimi
|
Yayın başladığında Telegram bildirimi
|
||||||
<Switch name="notifyStreamStart" defaultChecked={notifyStreamStart} />
|
<SettingSwitch name="notifyStreamStart" defaultChecked={notifyStreamStart} />
|
||||||
</Label>
|
</Label>
|
||||||
<Label className="flex items-center justify-between gap-4 text-sm font-normal">
|
<Label className="flex items-center justify-between gap-4 text-sm font-normal">
|
||||||
9:16 render tamamlandığında Telegram bildirimi
|
9:16 render tamamlandığında Telegram bildirimi
|
||||||
<Switch name="notifyRenderDone" defaultChecked={notifyRenderDone} />
|
<SettingSwitch name="notifyRenderDone" defaultChecked={notifyRenderDone} />
|
||||||
</Label>
|
</Label>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
<CardFooter>
|
<CardFooter>
|
||||||
|
|||||||
Reference in New Issue
Block a user