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:
@@ -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} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user