feat: 修改代码结构
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user