🐛 fix(user): Update notification and verify code settings

This commit is contained in:
web@ppanel
2025-02-14 15:39:25 +07:00
parent e3f9ef6ebe
commit 574b043be6
112 changed files with 500 additions and 502 deletions
@@ -13,9 +13,6 @@ import { toast } from 'sonner';
import { z } from 'zod';
const FormSchema = z.object({
telegram: z.number().nullish(),
enable_email_notify: z.boolean(),
enable_telegram_notify: z.boolean(),
enable_balance_notify: z.boolean(),
enable_login_notify: z.boolean(),
enable_subscribe_notify: z.boolean(),
@@ -28,9 +25,6 @@ export default function NotifySettings() {
const form = useForm<z.infer<typeof FormSchema>>({
resolver: zodResolver(FormSchema),
defaultValues: {
telegram: user?.telegram,
enable_email_notify: user?.enable_email_notify,
enable_telegram_notify: user?.enable_telegram_notify,
enable_balance_notify: user?.enable_balance_notify,
enable_login_notify: user?.enable_login_notify,
enable_subscribe_notify: user?.enable_subscribe_notify,
@@ -59,8 +53,6 @@ export default function NotifySettings() {
<form id='notify-form' onSubmit={form.handleSubmit(onSubmit)} className='space-y-4'>
<div className='space-y-4'>
{[
{ name: 'enable_email_notify', label: 'emailNotification' },
{ name: 'enable_telegram_notify', label: 'telegramNotification' },
{ name: 'enable_balance_notify', label: 'balanceChange' },
{ name: 'enable_login_notify', label: 'login' },
{ name: 'enable_subscribe_notify', label: 'subscribe' },
+25 -3
View File
@@ -1,10 +1,11 @@
'use client';
import useGlobalStore from '@/config/use-global';
import { sendEmailCode, sendSmsCode } from '@/services/common/common';
import { Button } from '@workspace/ui/components/button';
import { useCountDown } from 'ahooks';
import { useTranslations } from 'next-intl';
import { useState } from 'react';
import { useEffect, useState } from 'react';
interface SendCodeProps {
type: 'email' | 'phone';
@@ -17,22 +18,43 @@ interface SendCodeProps {
}
export default function SendCode({ type, params }: SendCodeProps) {
const t = useTranslations('auth');
const { common } = useGlobalStore();
const { verify_code_interval } = common.verify_code;
const [targetDate, setTargetDate] = useState<number>();
useEffect(() => {
const storedEndTime = localStorage.getItem(`verify_code_${type}`);
if (storedEndTime) {
const endTime = parseInt(storedEndTime);
if (endTime > Date.now()) {
setTargetDate(endTime);
} else {
localStorage.removeItem(`verify_code_${type}`);
}
}
}, [type]);
const [, { seconds }] = useCountDown({
targetDate,
onEnd: () => {
setTargetDate(undefined);
localStorage.removeItem(`verify_code_${type}`);
},
});
const setCodeTimer = () => {
const endTime = Date.now() + verify_code_interval * 1000;
setTargetDate(endTime);
localStorage.setItem(`verify_code_${type}`, endTime.toString());
};
const getEmailCode = async () => {
if (params.email && params.type) {
await sendEmailCode({
email: params.email,
type: params.type,
});
setTargetDate(Date.now() + 60000);
setCodeTimer();
}
};
@@ -43,7 +65,7 @@ export default function SendCode({ type, params }: SendCodeProps) {
telephone_area_code: params.telephone_area_code,
type: params.type,
});
setTargetDate(Date.now() + 60000);
setCodeTimer();
}
};
+1 -1
View File
@@ -84,7 +84,7 @@ export default function Purchase({ subscribe, setSubscribe }: Readonly<PurchaseP
console.log(error);
}
});
}, [params, router]);
}, [params, router, getUserInfo]);
return (
<Dialog
+1 -1
View File
@@ -92,7 +92,7 @@ export default function Renewal({ id, subscribe }: Readonly<RenewalProps>) {
console.log(error);
}
});
}, [params, router]);
}, [params, router, getUserInfo]);
return (
<Dialog open={open} onOpenChange={setOpen}>
+8
View File
@@ -43,6 +43,9 @@ export const useGlobalStore = create<GlobalStore>((set, get) => ({
register: {
stop_register: false,
enable_trial: false,
trial_subscribe: 0,
trial_time: 0,
trial_time_unit: '',
enable_ip_register_limit: false,
ip_register_limit: 0,
ip_register_limit_duration: 0,
@@ -63,6 +66,11 @@ export const useGlobalStore = create<GlobalStore>((set, get) => ({
subscribe_domain: '',
pan_domain: false,
},
verify_code: {
verify_code_expire_time: 5,
verify_code_limit: 15,
verify_code_interval: 60,
},
oauth_methods: [],
},
user: undefined,
-5
View File
@@ -9,18 +9,13 @@
},
"notify": {
"balanceChange": "Změna zůstatku",
"bind": "Přejít na vazbu",
"channels": "Notifikační kanály",
"emailNotification": "E-mailové oznámení",
"finance": "Finance",
"login": "Přihlášení",
"notificationSettings": "Nastavení oznámení",
"notificationTypes": "Typy notifikací",
"save": "Uložit změny",
"subscribe": "Přihlásit se",
"telegramIdPlaceholder": "Zadejte Telegram ID",
"telegramNotification": "Telegram oznámení",
"unbind": "Zrušit vazbu",
"updateSuccess": "Aktualizace byla úspěšná"
},
"thirdParty": {
-5
View File
@@ -9,18 +9,13 @@
},
"notify": {
"balanceChange": "Kontostandsänderung",
"bind": "Zur Bindung gehen",
"channels": "Benachrichtigungskanäle",
"emailNotification": "E-Mail-Benachrichtigung",
"finance": "Finanzen",
"login": "Anmelden",
"notificationSettings": "Benachrichtigungseinstellungen",
"notificationTypes": "Benachrichtigungstypen",
"save": "Änderungen speichern",
"subscribe": "Abonnieren",
"telegramIdPlaceholder": "Telegram-ID eingeben",
"telegramNotification": "Telegram-Benachrichtigung",
"unbind": "Lösen",
"updateSuccess": "Erfolgreich aktualisiert"
},
"thirdParty": {
-5
View File
@@ -9,18 +9,13 @@
},
"notify": {
"balanceChange": "Balance Change",
"bind": "Go to Binding",
"channels": "Notification Channels",
"emailNotification": "Email Notification",
"finance": "Finance",
"login": "Login",
"notificationSettings": "Notification Settings",
"notificationTypes": "Notification Types",
"save": "Save Changes",
"subscribe": "Subscribe",
"telegramIdPlaceholder": "Enter Telegram ID",
"telegramNotification": "Telegram Notification",
"unbind": "Unbind",
"updateSuccess": "Update Successful"
},
"thirdParty": {
-5
View File
@@ -9,18 +9,13 @@
},
"notify": {
"balanceChange": "Cambio de Saldo",
"bind": "Ir a Vinculación",
"channels": "Canales de Notificación",
"emailNotification": "Notificación por correo electrónico",
"finance": "Finanzas",
"login": "Iniciar Sesión",
"notificationSettings": "Configuración de notificaciones",
"notificationTypes": "Tipos de Notificación",
"save": "Guardar Cambios",
"subscribe": "Suscribirse",
"telegramIdPlaceholder": "Ingrese ID de Telegram",
"telegramNotification": "Notificación de Telegram",
"unbind": "Desvincular",
"updateSuccess": "Actualización exitosa"
},
"thirdParty": {
-5
View File
@@ -9,18 +9,13 @@
},
"notify": {
"balanceChange": "Cambio de Saldo",
"bind": "Ir a Vinculación",
"channels": "Canales de Notificación",
"emailNotification": "Notificación por correo electrónico",
"finance": "Finanzas",
"login": "Iniciar Sesión",
"notificationSettings": "Configuración de notificaciones",
"notificationTypes": "Tipos de Notificación",
"save": "Guardar Cambios",
"subscribe": "Suscribirse",
"telegramIdPlaceholder": "Ingrese ID de Telegram",
"telegramNotification": "Notificación de Telegram",
"unbind": "Desvincular",
"updateSuccess": "Actualización exitosa"
},
"thirdParty": {
-5
View File
@@ -9,18 +9,13 @@
},
"notify": {
"balanceChange": "تغییر موجودی",
"bind": "رفتن به اتصال",
"channels": "کانال‌های اعلان",
"emailNotification": "اعلان ایمیل",
"finance": "مالی",
"login": "ورود",
"notificationSettings": "تنظیمات اعلان",
"notificationTypes": "نوع‌های اعلان",
"save": "ذخیره تغییرات",
"subscribe": "اشتراک‌گذاری",
"telegramIdPlaceholder": "شناسه تلگرام را وارد کنید",
"telegramNotification": "اعلان تلگرام",
"unbind": "لغو اتصال",
"updateSuccess": "به‌روزرسانی موفقیت‌آمیز"
},
"thirdParty": {
-5
View File
@@ -9,18 +9,13 @@
},
"notify": {
"balanceChange": "Saldo Muutos",
"bind": "Siirry sitomiseen",
"channels": "Ilmoituskanavat",
"emailNotification": "Sähköposti-ilmoitus",
"finance": "Rahoitus",
"login": "Kirjaudu",
"notificationSettings": "Ilmoitusasetukset",
"notificationTypes": "Ilmoitustyypit",
"save": "Tallenna muutokset",
"subscribe": "Tilaa",
"telegramIdPlaceholder": "Syötä Telegram ID",
"telegramNotification": "Telegram-ilmoitus",
"unbind": "Poista sitominen",
"updateSuccess": "Päivitys onnistui"
},
"thirdParty": {
-5
View File
@@ -9,18 +9,13 @@
},
"notify": {
"balanceChange": "Changement de Solde",
"bind": "Aller à la liaison",
"channels": "Canaux de Notification",
"emailNotification": "Notification par e-mail",
"finance": "Finance",
"login": "Connexion",
"notificationSettings": "Paramètres de notification",
"notificationTypes": "Types de Notification",
"save": "Enregistrer les Modifications",
"subscribe": "S'abonner",
"telegramIdPlaceholder": "Entrez l'ID Telegram",
"telegramNotification": "Notification Telegram",
"unbind": "Délier",
"updateSuccess": "Mise à jour réussie"
},
"thirdParty": {
-5
View File
@@ -9,18 +9,13 @@
},
"notify": {
"balanceChange": "बैलेंस परिवर्तन",
"bind": "बाइंडिंग पर जाएं",
"channels": "सूचना चैनल",
"emailNotification": "ईमेल सूचना",
"finance": "वित्त",
"login": "लॉगिन",
"notificationSettings": "सूचना सेटिंग्स",
"notificationTypes": "सूचना प्रकार",
"save": "परिवर्तन सहेजें",
"subscribe": "सदस्यता लें",
"telegramIdPlaceholder": "टेलीग्राम आईडी दर्ज करें",
"telegramNotification": "टेलीग्राम सूचना",
"unbind": "अनबाइंड करें",
"updateSuccess": "सफलतापूर्वक अपडेट किया गया"
},
"thirdParty": {
-5
View File
@@ -9,18 +9,13 @@
},
"notify": {
"balanceChange": "Egyenleg Változás",
"bind": "Menj a kötéshez",
"channels": "Értesítési Csatornák",
"emailNotification": "E-mail értesítés",
"finance": "Pénzügy",
"login": "Bejelentkezés",
"notificationSettings": "Értesítési beállítások",
"notificationTypes": "Értesítési Típusok",
"save": "Változtatások Mentése",
"subscribe": "Feliratkozás",
"telegramIdPlaceholder": "Adja meg a Telegram azonosítót",
"telegramNotification": "Telegram értesítés",
"unbind": "Kötés feloldása",
"updateSuccess": "Sikeres frissítés"
},
"thirdParty": {
-5
View File
@@ -9,18 +9,13 @@
},
"notify": {
"balanceChange": "残高の変更",
"bind": "バインディングに移動",
"channels": "通知チャネル",
"emailNotification": "メール通知",
"finance": "ファイナンス",
"login": "ログイン",
"notificationSettings": "通知設定",
"notificationTypes": "通知タイプ",
"save": "変更を保存",
"subscribe": "購読する",
"telegramIdPlaceholder": "Telegram IDを入力",
"telegramNotification": "Telegram通知",
"unbind": "バインド解除",
"updateSuccess": "更新成功"
},
"thirdParty": {
-5
View File
@@ -9,18 +9,13 @@
},
"notify": {
"balanceChange": "잔액 변경",
"bind": "바인딩으로 이동",
"channels": "알림 채널",
"emailNotification": "이메일 알림",
"finance": "재무",
"login": "로그인",
"notificationSettings": "알림 설정",
"notificationTypes": "알림 유형",
"save": "변경 사항 저장",
"subscribe": "구독",
"telegramIdPlaceholder": "텔레그램 ID 입력",
"telegramNotification": "텔레그램 알림",
"unbind": "바인딩 해제",
"updateSuccess": "업데이트 성공"
},
"thirdParty": {
-5
View File
@@ -9,18 +9,13 @@
},
"notify": {
"balanceChange": "Endring i saldo",
"bind": "Gå til binding",
"channels": "Varslingskanaler",
"emailNotification": "E-postvarsling",
"finance": "Økonomi",
"login": "Logg inn",
"notificationSettings": "Varslingsinnstillinger",
"notificationTypes": "Varslingstyper",
"save": "Lagre endringer",
"subscribe": "Abonner",
"telegramIdPlaceholder": "Skriv inn Telegram-ID",
"telegramNotification": "Telegram-varsling",
"unbind": "Løsne",
"updateSuccess": "Oppdatering vellykket"
},
"thirdParty": {
-5
View File
@@ -9,18 +9,13 @@
},
"notify": {
"balanceChange": "Zmiana salda",
"bind": "Przejdź do wiązania",
"channels": "Kanały powiadomień",
"emailNotification": "Powiadomienie e-mail",
"finance": "Finanse",
"login": "Zaloguj się",
"notificationSettings": "Ustawienia powiadomień",
"notificationTypes": "Typy powiadomień",
"save": "Zapisz zmiany",
"subscribe": "Subskrybuj",
"telegramIdPlaceholder": "Wprowadź Telegram ID",
"telegramNotification": "Powiadomienie Telegram",
"unbind": "Odwiąż",
"updateSuccess": "Aktualizacja zakończona sukcesem"
},
"thirdParty": {
-5
View File
@@ -9,18 +9,13 @@
},
"notify": {
"balanceChange": "Mudança de Saldo",
"bind": "Ir para Vinculação",
"channels": "Canais de Notificação",
"emailNotification": "Notificação por e-mail",
"finance": "Finanças",
"login": "Login",
"notificationSettings": "Configurações de notificação",
"notificationTypes": "Tipos de Notificação",
"save": "Salvar Alterações",
"subscribe": "Inscrever-se",
"telegramIdPlaceholder": "Insira o ID do Telegram",
"telegramNotification": "Notificação do Telegram",
"unbind": "Desvincular",
"updateSuccess": "Atualização bem-sucedida"
},
"thirdParty": {
-5
View File
@@ -9,18 +9,13 @@
},
"notify": {
"balanceChange": "Schimbare Sold",
"bind": "Mergi la Legare",
"channels": "Canale de Notificare",
"emailNotification": "Notificare prin email",
"finance": "Finanțe",
"login": "Autentificare",
"notificationSettings": "Setări notificări",
"notificationTypes": "Tipuri de Notificare",
"save": "Salvează Modificările",
"subscribe": "Abonează-te",
"telegramIdPlaceholder": "Introduceți ID-ul Telegram",
"telegramNotification": "Notificare Telegram",
"unbind": "Dezleagă",
"updateSuccess": "Actualizare reușită"
},
"thirdParty": {
-5
View File
@@ -9,18 +9,13 @@
},
"notify": {
"balanceChange": "Изменение баланса",
"bind": "Перейти к привязке",
"channels": "Каналы уведомлений",
"emailNotification": "Уведомление по электронной почте",
"finance": "Финансы",
"login": "Вход",
"notificationSettings": "Настройки уведомлений",
"notificationTypes": "Типы уведомлений",
"save": "Сохранить изменения",
"subscribe": "Подписаться",
"telegramIdPlaceholder": "Введите Telegram ID",
"telegramNotification": "Уведомление в Telegram",
"unbind": "Отвязать",
"updateSuccess": "Успешно обновлено"
},
"thirdParty": {
-5
View File
@@ -9,18 +9,13 @@
},
"notify": {
"balanceChange": "การเปลี่ยนแปลงยอดเงิน",
"bind": "ไปที่การผูก",
"channels": "ช่องทางการแจ้งเตือน",
"emailNotification": "การแจ้งเตือนทางอีเมล",
"finance": "การเงิน",
"login": "เข้าสู่ระบบ",
"notificationSettings": "การตั้งค่าการแจ้งเตือน",
"notificationTypes": "ประเภทการแจ้งเตือน",
"save": "บันทึกการเปลี่ยนแปลง",
"subscribe": "สมัครสมาชิก",
"telegramIdPlaceholder": "กรอก Telegram ID",
"telegramNotification": "การแจ้งเตือนทาง Telegram",
"unbind": "ยกเลิกการผูก",
"updateSuccess": "อัปเดตสำเร็จ"
},
"thirdParty": {
-5
View File
@@ -9,18 +9,13 @@
},
"notify": {
"balanceChange": "Bakiye Değişikliği",
"bind": "Bağlamaya Git",
"channels": "Bildirim Kanalları",
"emailNotification": "E-posta Bildirimi",
"finance": "Finans",
"login": "Giriş",
"notificationSettings": "Bildirim Ayarları",
"notificationTypes": "Bildirim Türleri",
"save": "Değişiklikleri Kaydet",
"subscribe": "Abone Ol",
"telegramIdPlaceholder": "Telegram Kimliği girin",
"telegramNotification": "Telegram Bildirimi",
"unbind": "Bağlamayı Kaldır",
"updateSuccess": "Güncelleme Başarılı"
},
"thirdParty": {
-5
View File
@@ -9,18 +9,13 @@
},
"notify": {
"balanceChange": "Зміна балансу",
"bind": "Перейти до прив'язки",
"channels": "Канали сповіщень",
"emailNotification": "Сповіщення електронною поштою",
"finance": "Фінанси",
"login": "Увійти",
"notificationSettings": "Налаштування сповіщень",
"notificationTypes": "Типи сповіщень",
"save": "Зберегти зміни",
"subscribe": "Підписатися",
"telegramIdPlaceholder": "Введіть Telegram ID",
"telegramNotification": "Сповіщення Telegram",
"unbind": "Відв'язати",
"updateSuccess": "Оновлення успішне"
},
"thirdParty": {
-5
View File
@@ -9,18 +9,13 @@
},
"notify": {
"balanceChange": "Thay Đổi Số Dư",
"bind": "Đi đến Liên kết",
"channels": "Kênh Thông Báo",
"emailNotification": "Thông báo Email",
"finance": "Tài Chính",
"login": "Đăng Nhập",
"notificationSettings": "Cài đặt Thông báo",
"notificationTypes": "Loại Thông Báo",
"save": "Lưu Thay Đổi",
"subscribe": "Đăng Ký",
"telegramIdPlaceholder": "Nhập Telegram ID",
"telegramNotification": "Thông báo Telegram",
"unbind": "Hủy liên kết",
"updateSuccess": "Cập nhật thành công"
},
"thirdParty": {
-5
View File
@@ -9,18 +9,13 @@
},
"notify": {
"balanceChange": "余额变动",
"bind": "去绑定",
"channels": "通知渠道",
"emailNotification": "邮件通知",
"finance": "财务相关",
"login": "登录",
"notificationSettings": "通知设置",
"notificationTypes": "通知类型",
"save": "保存更改",
"subscribe": "订阅",
"telegramIdPlaceholder": "输入 Telegram ID",
"telegramNotification": "Telegram 通知",
"unbind": "解除绑定",
"updateSuccess": "更新成功"
},
"thirdParty": {
-5
View File
@@ -9,18 +9,13 @@
},
"notify": {
"balanceChange": "餘額變更",
"bind": "前往綁定",
"channels": "通知渠道",
"emailNotification": "郵件通知",
"finance": "財務",
"login": "登錄",
"notificationSettings": "通知設定",
"notificationTypes": "通知類型",
"save": "保存更改",
"subscribe": "訂閱",
"telegramIdPlaceholder": "輸入 Telegram ID",
"telegramNotification": "Telegram 通知",
"unbind": "解除綁定",
"updateSuccess": "更新成功"
},
"thirdParty": {
+1 -1
View File
@@ -1,5 +1,5 @@
// @ts-ignore
// API 更新时间:
// API 唯一标识:
import * as auth from './auth';
-1
View File
@@ -32,7 +32,6 @@ export async function appleLoginCallback(
return request<API.Response & { data?: any }>('/v1/auth/oauth/callback/apple', {
method: 'POST',
data: formData,
requestType: 'form',
...(options || {}),
});
}
+7 -3
View File
@@ -152,6 +152,7 @@ declare namespace API {
invite: InviteConfig;
currency: CurrencyConfig;
subscribe: SubscribeConfig;
verify_code: VerifyCodeConfig;
oauth_methods: string[];
};
@@ -579,9 +580,6 @@ declare namespace API {
referer_id: number;
enable: boolean;
is_admin?: boolean;
valid_email: boolean;
enable_email_notify: boolean;
enable_telegram_notify: boolean;
enable_balance_notify: boolean;
enable_login_notify: boolean;
enable_subscribe_notify: boolean;
@@ -686,6 +684,12 @@ declare namespace API {
enable_reset_password_verify: boolean;
};
type VerifyCodeConfig = {
verify_code_expire_time: number;
verify_code_limit: number;
verify_code_interval: number;
};
type VerifyConfig = {
turnstile_site_key: string;
turnstile_secret: string;
+6 -5
View File
@@ -754,8 +754,6 @@ declare namespace API {
};
type UpdateUserNotifyRequest = {
enable_email_notify: boolean;
enable_telegram_notify: boolean;
enable_balance_notify: boolean;
enable_login_notify: boolean;
enable_subscribe_notify: boolean;
@@ -782,9 +780,6 @@ declare namespace API {
referer_id: number;
enable: boolean;
is_admin?: boolean;
valid_email: boolean;
enable_email_notify: boolean;
enable_telegram_notify: boolean;
enable_balance_notify: boolean;
enable_login_notify: boolean;
enable_subscribe_notify: boolean;
@@ -868,6 +863,12 @@ declare namespace API {
created_at: number;
};
type VerifyCodeConfig = {
verify_code_expire_time: number;
verify_code_limit: number;
verify_code_interval: number;
};
type VerifyConfig = {
turnstile_site_key: string;
turnstile_secret: string;