'use client'; import type { FunConfigDashboard } from '@nexumi/shared'; import { FieldAnchor } from '@/components/layout/field-anchor'; import { useTranslations } from '@/components/locale-provider'; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'; import { Label } from '@/components/ui/label'; import { Switch } from '@/components/ui/switch'; import type { SettingsSaveResult } from '@/components/settings/settings-form'; import { SettingsForm } from '@/components/settings/settings-form'; async function saveFun(guildId: string, value: FunConfigDashboard): Promise { try { const response = await fetch(`/api/guilds/${guildId}/fun`, { method: 'PATCH', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(value) }); if (!response.ok) { const body = (await response.json().catch(() => null)) as { error?: string } | null; return { ok: false, error: body?.error ?? `Request failed with status ${response.status}` }; } return { ok: true }; } catch { return { ok: false, error: 'Network error' }; } } interface FunFormProps { guildId: string; initialValue: FunConfigDashboard; } export function FunForm({ guildId, initialValue }: FunFormProps) { const t = useTranslations(); return ( initialValue={initialValue} onSave={(value) => saveFun(guildId, value)}> {({ value, setValue }) => ( {t('modulePages.fun.title')} {t('modulePages.fun.description')}

{t('modulePages.fun.enabledHint')}

setValue((prev) => ({ ...prev, enabled: checked }))} />

{t('modulePages.fun.mediaEnabledHint')}

setValue((prev) => ({ ...prev, mediaEnabled: checked }))} />
)} ); }