import React, { useState } from 'react' import { CEditAvatar } from '../../components/EditAvatar' import { CustomInput } from '../../components/Input' import { message, Button } from 'antd' import { connect } from 'react-redux' import { actionChangePassword } from '../../actions/query/aboutMeQuery' import { actionClearPromiseForName } from '../../actions/types/promiseTypes' import { Basic, ConstructorModal } from '../../helpers' import { SpoilerButton } from '../../components/comment/SpoilerButton' import { actionUserUpdateTypeSaga } from '../../actions/typeSaga/myDataTypesSaga' import { EyeOutlined, EyeInvisibleOutlined } from '@ant-design/icons' export const EditAccount = ({ showModalEdit }) => { return ( ) } const EditSetting = ({ info, myId, onSaveUserUpsert, onSaveNewPassword, changePassword, }) => { const [state, setState] = useState(info) const [changePass, setChangePass] = useState(changePassword) const [isModalVisibleEdit, setIsModalVisibleEdit] = useState(false) const [checked1, setChecked1] = useState(true) const [checked2, setChecked2] = useState(true) const showModalEdit = () => { setIsModalVisibleEdit(true) } const handleCancelEdit = () => { setIsModalVisibleEdit(false) } const onChangeLogin = (event) => setState({ ...state, login: event.target.value, }) const onChangeNick = (event) => setState({ ...state, nick: event.target.value, }) const onChangePassLogin = (event) => setChangePass({ ...changePass, login: event.target.value, }) const onChangePassPassword = (event) => setChangePass({ ...changePass, password: event.target.value, }) const onChangePassNew = (event) => setChangePass({ ...changePass, newPassword: event.target.value, }) const saveChange = () => { onSaveUserUpsert(state, myId) && message.success(`Successfully saved changed new login!`) && setIsModalVisibleEdit(false) } const saveNewPassword = () => { onSaveNewPassword( changePass.login, changePass.password, changePass.newPassword, ) if (changePassword?.payload == null && changePass.login != info?.login) { message.error(`You entered wrong login/password! Try again!`) } else { message.success(`Successfully saved changed new password!`) && setIsModalVisibleEdit(false) } } console.log('save pass', changePass?.login != info?.login) return (

Edit avatar

Edit login

Edit nick

Edit password

Login

Old password

{checked1 ? ( setChecked1(!checked1)} style={{ marginLeft: '5px', fontSize: 'xx-large' }} /> ) : ( setChecked1(!checked1)} style={{ marginLeft: '5px', fontSize: 'xx-large' }} /> )}

New password

{checked2 ? ( setChecked2(!checked2)} style={{ marginLeft: '5px', fontSize: 'xx-large' }} /> ) : ( setChecked2(!checked2)} style={{ marginLeft: '5px', fontSize: 'xx-large' }} /> )}
) } export const CEditSetting = connect( (state) => ({ myId: state?.auth.payload.sub?.id, info: state?.myData?.aboutMe, changePassword: state.promise?.newPassword, }), { onSaveUserUpsert: actionUserUpdateTypeSaga, onSaveNewPassword: actionChangePassword, onClearPromise: actionClearPromiseForName, }, )(EditSetting)