'use client'; import { useQuery } from '@tanstack/react-query'; import { useTranslations } from 'next-intl'; import { toast } from 'sonner'; import { getSubscribeConfig, updateSubscribeConfig } from '@/services/admin/system'; import { Label } from '@workspace/ui/components/label'; import { Switch } from '@workspace/ui/components/switch'; import { Table, TableBody, TableCell, TableRow } from '@workspace/ui/components/table'; import { Textarea } from '@workspace/ui/components/textarea'; import { EnhancedInput } from '@workspace/ui/custom-components/enhanced-input'; export default function SubscribeConfig() { const t = useTranslations('subscribe.config'); const { data, refetch } = useQuery({ queryKey: ['getSubscribeConfig'], queryFn: async () => { const { data } = await getSubscribeConfig(); return data.data; }, }); async function updateConfig(key: string, value: unknown) { if (data?.[key] === value) return; try { await updateSubscribeConfig({ ...data, [key]: value, } as API.SubscribeConfig); toast.success(t('saveSuccess')); refetch(); } catch (error) { /* empty */ } } return (