feat: 修改代码结构

This commit is contained in:
2025-08-15 09:16:02 -07:00
parent 5524d25d9a
commit 525e305f1d
17 changed files with 256 additions and 63 deletions
@@ -5,6 +5,7 @@ import { updateUserNotify } from '@/services/user/user';
import { zodResolver } from '@hookform/resolvers/zod';
import { Button } from '@workspace/airo-ui/components/button';
import { Card } from '@workspace/airo-ui/components/card';
import { useEffect } from 'react';
import { AiroButton } from '@workspace/airo-ui/components/AiroButton';
import {
@@ -39,6 +40,17 @@ export default function NotifySettings() {
enable_trade_notify: user?.enable_trade_notify ?? false,
},
});
// 监听 user 变化,更新表单
useEffect(() => {
if (user) {
form.reset({
enable_balance_notify: user.enable_balance_notify ?? false,
enable_login_notify: user.enable_login_notify ?? false,
enable_subscribe_notify: user.enable_subscribe_notify ?? false,
enable_trade_notify: user.enable_trade_notify ?? false,
});
}
}, [user, form]);
async function onSubmit(data: z.infer<typeof FormSchema>) {
await updateUserNotify(data);