'use client'; import { getSubscribeList } from '@/services/admin/subscribe'; import { getRegisterConfig, updateRegisterConfig } from '@/services/admin/system'; import { useQuery } from '@tanstack/react-query'; import { Card, CardContent, CardHeader, CardTitle } from '@workspace/ui/components/card'; import { Label } from '@workspace/ui/components/label'; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from '@workspace/ui/components/select'; import { Switch } from '@workspace/ui/components/switch'; import { Table, TableBody, TableCell, TableRow } from '@workspace/ui/components/table'; import { Combobox } from '@workspace/ui/custom-components/combobox'; import { EnhancedInput } from '@workspace/ui/custom-components/enhanced-input'; import { useTranslations } from 'next-intl'; import { toast } from 'sonner'; export function Register() { const t = useTranslations('auth-control.register'); const { data, refetch } = useQuery({ queryKey: ['getRegisterConfig'], queryFn: async () => { const { data } = await getRegisterConfig(); return data.data; }, }); async function updateConfig(key: string, value: unknown) { if (data?.[key] === value) return; await updateRegisterConfig({ ...data, [key]: value, } as API.RegisterConfig); toast.success(t('saveSuccess')); refetch(); } const { data: subscribe } = useQuery({ queryKey: ['getSubscribeList', 'all'], queryFn: async () => { const { data } = await getSubscribeList({ page: 1, size: 9999, }); return data.data?.list as API.Subscribe[]; }, }); return ( {t('registerSettings')}

{t('stopNewUserRegistrationDescription')}

{ updateConfig('stop_register', checked); }} />

{t('ipRegistrationLimitDescription')}

{ updateConfig('enable_ip_register_limit', checked); }} />

{t('registrationLimitCountDescription')}

updateConfig('ip_register_limit', value)} />

{t('penaltyTimeDescription')}

updateConfig('ip_register_limit_duration', value)} />

{t('trialRegistrationDescription')}

{ updateConfig('enable_trial', checked); }} />

{t('trialSubscribePlanDescription')}

updateConfig('trial_time', value)} prefix={ } suffix={ { if (value) { updateConfig('trial_time_unit', value); } }} options={[ { label: t('noLimit'), value: 'NoLimit' }, { label: t('year'), value: 'Year' }, { label: t('month'), value: 'Month' }, { label: t('day'), value: 'Day' }, { label: t('hour'), value: 'Hour' }, { label: t('minute'), value: 'Minute' }, ]} /> } />
); }