修复关闭通知

This commit is contained in:
hanhh
2021-09-18 02:09:06 +08:00
parent 0a9e9e972d
commit 6c87634bb3
5 changed files with 17 additions and 15 deletions
+12 -11
View File
@@ -7,22 +7,25 @@ const { Option } = Select;
const NotificationSetting = ({ data }: any) => {
const [loading, setLoading] = useState(false);
const [notificationMode, setNotificationMode] = useState<string>('');
const [notificationMode, setNotificationMode] = useState<string>('closed');
const [fields, setFields] = useState<any[]>([]);
const [form] = Form.useForm();
const handleOk = (values: any) => {
if (values.type == 'closed') {
values.type = '';
}
request
.put(`${config.apiPrefix}user/notification`, {
data: {
...values,
},
})
.then((data: any) => {
if (data && data.code === 200) {
message.success('通知发送成功');
.then((_data: any) => {
if (_data && _data.code === 200) {
message.success(values.type ? '通知发送成功' : '通知关闭成功');
} else {
message.error(data.data);
message.error(_data.data);
}
})
.catch((error: any) => {
@@ -33,7 +36,7 @@ const NotificationSetting = ({ data }: any) => {
const notificationModeChange = (value: string) => {
setNotificationMode(value);
const _fields = (config.notificationModeMap as any)[value];
setFields(_fields);
setFields(_fields || []);
};
useEffect(() => {
@@ -70,11 +73,9 @@ const NotificationSetting = ({ data }: any) => {
<Input.TextArea autoSize={true} placeholder={`请输入${x.label}`} />
</Form.Item>
))}
{notificationMode !== '' && (
<Button type="primary" htmlType="submit">
</Button>
)}
<Button type="primary" htmlType="submit">
</Button>
</Form>
</div>
);