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(
@@ -37,17 +47,17 @@ function NoticeManager(props){
您可以通过通知管理来选择接受通知的方式 - {settingTypes && settingTypes.map((item,key)=>{ + {settingTypes && userNotification && userEmail && settingTypes.map((item,key)=>{ return( - item.type_name &&
+ item.type_name &&
{item.type_name}
{item.settings.map((i, k) => { - // console.log(userEmail[item.type.substring(item.type.indexOf("::")+2)+"::"+i.key]); + const setting = item.type.substring(item.type.indexOf("::")+2)+"::"+i.key; return ( -
+
{i.name}
- 站内信 - 邮件 + {onChange(true,e,setting)}}>站内信 + {onChange(false,e,setting)}}>邮件
) })} diff --git a/src/forge/users/Material/Base.jsx b/src/forge/users/Material/Base.jsx index f9707ab0d..61a9d6f1c 100644 --- a/src/forge/users/Material/Base.jsx +++ b/src/forge/users/Material/Base.jsx @@ -11,7 +11,6 @@ export default Form.create()( const { getFieldDecorator, validateFields , setFieldsValue } = props && props.form; // const { username } = props && props.match && props.match.params; const { resetUserInfo , current_user } = props; - console.log(props); useEffect(()=>{ if(current_user && current_user.login){