From 38836465668e54f80417b6d53e9713422e988d37 Mon Sep 17 00:00:00 2001 From: "web@ppanel" Date: Sun, 9 Feb 2025 20:14:27 +0700 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(auth-control):=20Update=20gene?= =?UTF-8?q?ral?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dashboard/auth-control/general/invite.tsx | 103 +++++++++++++++ .../dashboard/auth-control/general/page.tsx | 119 ++--------------- .../auth-control/general/register.tsx | 124 +++++++++++++++++ .../dashboard/auth-control/general/verify.tsx | 125 ++++++++++++++++++ .../app/dashboard/auth-control/phone/page.tsx | 52 ++++---- apps/admin/app/dashboard/system/invite.tsx | 93 ------------- apps/admin/app/dashboard/system/page.tsx | 16 --- apps/admin/app/dashboard/system/telegram.tsx | 99 -------------- apps/admin/app/dashboard/system/verify.tsx | 115 ---------------- apps/admin/locales/cs-CZ/auth-control.json | 51 +++++-- apps/admin/locales/cs-CZ/system.json | 43 +----- apps/admin/locales/de-DE/auth-control.json | 51 +++++-- apps/admin/locales/de-DE/system.json | 43 +----- apps/admin/locales/en-US/auth-control.json | 51 +++++-- apps/admin/locales/en-US/system.json | 43 +----- apps/admin/locales/es-ES/auth-control.json | 51 +++++-- apps/admin/locales/es-ES/system.json | 43 +----- apps/admin/locales/es-MX/auth-control.json | 51 +++++-- apps/admin/locales/es-MX/system.json | 43 +----- apps/admin/locales/fa-IR/auth-control.json | 51 +++++-- apps/admin/locales/fa-IR/system.json | 43 +----- apps/admin/locales/fi-FI/auth-control.json | 51 +++++-- apps/admin/locales/fi-FI/system.json | 43 +----- apps/admin/locales/fr-FR/auth-control.json | 51 +++++-- apps/admin/locales/fr-FR/system.json | 43 +----- apps/admin/locales/hi-IN/auth-control.json | 51 +++++-- apps/admin/locales/hi-IN/system.json | 43 +----- apps/admin/locales/hu-HU/auth-control.json | 51 +++++-- apps/admin/locales/hu-HU/system.json | 43 +----- apps/admin/locales/ja-JP/auth-control.json | 51 +++++-- apps/admin/locales/ja-JP/system.json | 43 +----- apps/admin/locales/ko-KR/auth-control.json | 51 +++++-- apps/admin/locales/ko-KR/system.json | 43 +----- apps/admin/locales/no-NO/auth-control.json | 51 +++++-- apps/admin/locales/no-NO/system.json | 43 +----- apps/admin/locales/pl-PL/auth-control.json | 51 +++++-- apps/admin/locales/pl-PL/system.json | 43 +----- apps/admin/locales/pt-BR/auth-control.json | 51 +++++-- apps/admin/locales/pt-BR/system.json | 43 +----- apps/admin/locales/ro-RO/auth-control.json | 51 +++++-- apps/admin/locales/ro-RO/system.json | 43 +----- apps/admin/locales/ru-RU/auth-control.json | 51 +++++-- apps/admin/locales/ru-RU/system.json | 43 +----- apps/admin/locales/th-TH/auth-control.json | 51 +++++-- apps/admin/locales/th-TH/system.json | 43 +----- apps/admin/locales/tr-TR/auth-control.json | 51 +++++-- apps/admin/locales/tr-TR/system.json | 43 +----- apps/admin/locales/uk-UA/auth-control.json | 51 +++++-- apps/admin/locales/uk-UA/system.json | 43 +----- apps/admin/locales/vi-VN/auth-control.json | 51 +++++-- apps/admin/locales/vi-VN/system.json | 43 +----- apps/admin/locales/zh-CN/auth-control.json | 51 +++++-- apps/admin/locales/zh-CN/system.json | 43 +----- apps/admin/locales/zh-HK/auth-control.json | 51 +++++-- apps/admin/locales/zh-HK/system.json | 43 +----- 55 files changed, 1331 insertions(+), 1677 deletions(-) create mode 100644 apps/admin/app/dashboard/auth-control/general/invite.tsx create mode 100644 apps/admin/app/dashboard/auth-control/general/register.tsx create mode 100644 apps/admin/app/dashboard/auth-control/general/verify.tsx delete mode 100644 apps/admin/app/dashboard/system/invite.tsx delete mode 100644 apps/admin/app/dashboard/system/telegram.tsx delete mode 100644 apps/admin/app/dashboard/system/verify.tsx 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 })} -

-
- -