通知管理+删除基本资料页面的consolo语句
This commit is contained in:
parent
11b92ac52b
commit
fe1bacb984
|
@ -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(
|
||||
<div className="notice01">
|
||||
<div className="sshHead">
|
||||
|
@ -37,17 +47,17 @@ function NoticeManager(props){
|
|||
</div>
|
||||
<div>
|
||||
<span className="notice-manager-tip">您可以通过通知管理来选择接受通知的方式</span>
|
||||
{settingTypes && settingTypes.map((item,key)=>{
|
||||
{settingTypes && userNotification && userEmail && settingTypes.map((item,key)=>{
|
||||
return(
|
||||
item.type_name && <div>
|
||||
item.type_name && <div key={key}>
|
||||
<div className="manager-cont-top">{item.type_name}</div>
|
||||
{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 (
|
||||
<div className="manager-cont">
|
||||
<div className="manager-cont" key={k}>
|
||||
<div className="manager-cont-title">{i.name}</div>
|
||||
<Checkbox defaultChecked='true' defaultChecked = {i.notification_disabled} checked={userNotification[item.type.substring(item.type.indexOf("::")+2)+"::"+i.key]}>站内信</Checkbox>
|
||||
<Checkbox disabled = {i.email_disabled} defaultChecked={userEmail[item.type.substring(item.type.indexOf("::")+2)+"::"+i.key]}>邮件</Checkbox>
|
||||
<Checkbox disabled = {i.notification_disabled} defaultChecked={userNotification[setting]} onChange={(e)=>{onChange(true,e,setting)}}>站内信</Checkbox>
|
||||
<Checkbox disabled = {i.email_disabled} defaultChecked={userEmail[setting]} onChange={(e)=>{onChange(false,e,setting)}}>邮件</Checkbox>
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
|
|
|
@ -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){
|
||||
|
|
Loading…
Reference in New Issue