import React, { useState } from 'react'; import { useDispatch, useSelector } from 'react-redux'; import { ROUTER } from 'app/common/routes'; import Dropdown from 'app/shared/components/dropdown/dropdown'; import Flag from 'app/shared/components/flag/flag'; import { userDataUpdate } from 'app/modules/user/store'; import { countries } from 'app/modules/account/store/settings.constants'; import { selectUserData, selectUserUpdating } from 'app/modules/user/store/user.selectors'; import { SubHeader } from 'app/shared/components/topBar/subHeader'; import { Link } from 'react-router-dom'; import { SettingsThumbnail } from './settings.page'; import * as Text from 'app/shared/components/text/text'; import LockedText from 'app/shared/components/lockedText/lockedText'; import Input from 'app/shared/components/input/input'; import ResetPasswordModal from '../components/resetPasswordModal'; export const AccountSettingsEditPage = () => { const dispatch = useDispatch(); const { name, company, phone, avatar, email, country } = useSelector(selectUserData); const userCountry = countries.find((countryItem) => country === countryItem.code); const [ newName, setNewName ] = useState(name); const [ newPhone, setNewPhone ] = useState(phone); const [ newCountryId, setNewCountryId ] = useState(userCountry?.value ?? null); const [ isModalOpened, setIsModalOpened ] = useState(false); const companyNames = (company && company.length > 0) ? company.join(', ') : null; const thumbnail = avatar ?? ''; const isSubmitDisabled = useSelector(selectUserUpdating); const handleSubmit = (event) => { event.preventDefault(); const data = { name: newName, phone: newPhone, country: newCountryId ? countries.find((country) => newCountryId === country.value)?.code : null, }; dispatch(userDataUpdate(data)); }; const handleInputChange = (handler, event) => { const target = event.target; const value = target.value; handler(value); }; const createCountryLabel = (country) => { return

{country.name}

; }; const handleCountryChange = (value) => { setNewCountryId(value); }; return ( <>
handleSubmit(e)}>
Name
handleInputChange(setNewName, e)} name='name' />
Company
COMPANY
To edit company you should contact your partner manager.
}/>
Email
EMAIL
To edit the email you should contact your partner manager.
}/>
Password

setIsModalOpened(true)} className="u-cursor--pointer u-font--clear-spacings">********

setIsModalOpened(false)} />
Phone
handleInputChange(setNewPhone, e)} />
Country
handleCountryChange(value)} />
Cancel
); };