diff --git a/src/forge/SecuritySetting/notice/manager/Index.jsx b/src/forge/SecuritySetting/notice/manager/Index.jsx index d45dc3713..ca16f25ec 100644 --- a/src/forge/SecuritySetting/notice/manager/Index.jsx +++ b/src/forge/SecuritySetting/notice/manager/Index.jsx @@ -10,26 +10,36 @@ function NoticeManager(props){ const [userNotification, setUserNotification] = useState(); const [userEmail, setUserEmail] = useState(); - function getUserSettings(){ + function onChange(type,e,setting){ + let notification_body = userNotification; + let email_body = userEmail; + if(type){//站内信 + notification_body[setting] = e.target.checked; + }else{//邮件 + email_body[setting] = e.target.checked; + } + axios.post(`/users/${current_user.login}/template_message_settings/update_setting.json`,{ + setting:{ + notification_body:notification_body, + email_body:email_body + } + }) + } + + useEffect(()=>{ + axios.get("/template_message_settings.json").then(response => { + if (response && response.status === 200) { + setSettingTypes(response.data.setting_types); + } + }) axios.get(`/users/${current_user.login}/template_message_settings.json`).then((response)=>{ if(response && response.status === 200 ){ setUserEmail(response.data.email_body); setUserNotification(response.data.notification_body); } }) - } - - useEffect(()=>{ - axios.get("/template_message_settings.json").then((response)=>{ - if(response && response.status === 200 ){ - setSettingTypes(response.data.setting_types); - } - }) - getUserSettings(); },[]) - console.log('settingTypes',settingTypes); - console.log('userNotification',userNotification,'userEmail',userEmail); return(