diff --git a/apps/admin/app/dashboard/auth-control/general/invite.tsx b/apps/admin/app/dashboard/auth-control/general/invite.tsx new file mode 100644 index 0000000..0b71f42 --- /dev/null +++ b/apps/admin/app/dashboard/auth-control/general/invite.tsx @@ -0,0 +1,103 @@ +'use client'; + +import { getInviteConfig, updateInviteConfig } 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 { Switch } from '@workspace/ui/components/switch'; +import { Table, TableBody, TableCell, TableRow } from '@workspace/ui/components/table'; +import { EnhancedInput } from '@workspace/ui/custom-components/enhanced-input'; +import { useTranslations } from 'next-intl'; +import { toast } from 'sonner'; + +export function Invite() { + const t = useTranslations('auth-control.invite'); + + const { data, refetch } = useQuery({ + queryKey: ['getInviteConfig'], + queryFn: async () => { + const { data } = await getInviteConfig(); + + return data.data; + }, + }); + + async function updateConfig(key: string, value: unknown) { + if (data?.[key] === value) return; + try { + await updateInviteConfig({ + ...data, + [key]: value, + } as API.InviteConfig); + toast.success(t('saveSuccess')); + refetch(); + } catch (error) { + /* empty */ + } + } + + return ( + + + {t('inviteSettings')} + + + + + + + +

+ {t('enableForcedInviteDescription')} +

+
+ + { + updateConfig('forced_invite', checked); + }} + /> + +
+ + + +

+ {t('inviteCommissionPercentageDescription')} +

+
+ + updateConfig('referral_percentage', value)} + /> + +
+ + + +

+ {t('commissionFirstTimeOnlyDescription')} +

+
+ + { + updateConfig('only_first_purchase', checked); + }} + /> + +
+
+
+
+
+ ); +} diff --git a/apps/admin/app/dashboard/auth-control/general/page.tsx b/apps/admin/app/dashboard/auth-control/general/page.tsx index 2740914..f29cfc5 100644 --- a/apps/admin/app/dashboard/auth-control/general/page.tsx +++ b/apps/admin/app/dashboard/auth-control/general/page.tsx @@ -1,118 +1,15 @@ 'use client'; -import { getRegisterConfig, updateRegisterConfig } from '@/services/admin/system'; -import { useQuery } from '@tanstack/react-query'; -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 { EnhancedInput } from '@workspace/ui/custom-components/enhanced-input'; -import { useTranslations } from 'next-intl'; -import { toast } from 'sonner'; +import { Invite } from './invite'; +import { Register } from './register'; +import { Verify } from './verify'; export default function Page() { - const t = useTranslations('auth-control'); - - 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; - try { - await updateRegisterConfig({ - ...data, - [key]: value, - } as API.RegisterConfig); - toast.success(t('saveSuccess')); - refetch(); - } catch (error) { - /* empty */ - } - } - return ( - - - - - -

- {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); - }} - /> - -
-
-
+
+ + + +
); } diff --git a/apps/admin/app/dashboard/auth-control/general/register.tsx b/apps/admin/app/dashboard/auth-control/general/register.tsx new file mode 100644 index 0000000..76cf937 --- /dev/null +++ b/apps/admin/app/dashboard/auth-control/general/register.tsx @@ -0,0 +1,124 @@ +'use client'; + +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 { Switch } from '@workspace/ui/components/switch'; +import { Table, TableBody, TableCell, TableRow } from '@workspace/ui/components/table'; +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(); + } + + 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); + }} + /> + +
+
+
+
+
+ ); +} diff --git a/apps/admin/app/dashboard/auth-control/general/verify.tsx b/apps/admin/app/dashboard/auth-control/general/verify.tsx new file mode 100644 index 0000000..d0cb5c3 --- /dev/null +++ b/apps/admin/app/dashboard/auth-control/general/verify.tsx @@ -0,0 +1,125 @@ +'use client'; + +import { getVerifyConfig, updateVerifyConfig } 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 { Switch } from '@workspace/ui/components/switch'; +import { Table, TableBody, TableCell, TableRow } from '@workspace/ui/components/table'; +import { EnhancedInput } from '@workspace/ui/custom-components/enhanced-input'; +import { useTranslations } from 'next-intl'; +import { toast } from 'sonner'; + +export function Verify() { + const t = useTranslations('auth-control.verify'); + + const { data, refetch } = useQuery({ + queryKey: ['getVerifyConfig'], + queryFn: async () => { + const { data } = await getVerifyConfig(); + return data.data; + }, + }); + + async function updateConfig(key: string, value: unknown) { + if (data?.[key] === value) return; + try { + await updateVerifyConfig({ + ...data, + [key]: value, + } as API.VerifyConfig); + toast.success(t('saveSuccess')); + refetch(); + } catch (error) { + /* empty */ + } + } + + return ( + + + {t('verifySettings')} + + + + + + + +

{t('turnstileSiteKeyDescription')}

+
+ + updateConfig('turnstile_site_key', value)} + /> + +
+ + + +

{t('turnstileSecretDescription')}

+
+ + updateConfig('turnstile_secret', value)} + /> + +
+ + + +

+ {t('registrationVerificationCodeDescription')} +

+
+ + { + updateConfig('enable_register_verify', checked); + }} + /> + +
+ + + +

+ {t('loginVerificationCodeDescription')} +

+
+ + { + updateConfig('enable_login_verify', checked); + }} + /> + +
+ + + +

+ {t('resetPasswordVerificationCodeDescription')} +

+
+ + { + updateConfig('enable_reset_password_verify', checked); + }} + /> + +
+
+
+
+
+ ); +} diff --git a/apps/admin/app/dashboard/auth-control/phone/page.tsx b/apps/admin/app/dashboard/auth-control/phone/page.tsx index 0ed0a72..16b65c9 100644 --- a/apps/admin/app/dashboard/auth-control/phone/page.tsx +++ b/apps/admin/app/dashboard/auth-control/phone/page.tsx @@ -358,30 +358,34 @@ export default function Page() { )} - - - -

- {t('templateTip', { code: platformConfig?.code_variable })} -

-
- -