import { useModalSearchParams } from '@/hooks/useModalSearchParams' import { Button } from '@/shared/Button/Button' import { Modal } from '@/shared/Modal/Modal' import { MODAL_PARAMS_KEYS } from '@/types/modal' import { Box, IconButton, Stack, Typography } from '@mui/material' import { StyledButton, StyledSettingContainer, StyledSynchedText, } from './styled' import { SectionTitle } from '@/shared/SectionTitle/SectionTitle' import { CheckmarkIcon } from '@/assets' import { Input } from '@/shared/Input/Input' import VisibilityOffOutlinedIcon from '@mui/icons-material/VisibilityOffOutlined' import VisibilityOutlinedIcon from '@mui/icons-material/VisibilityOutlined' import { ChangeEvent, useState } from 'react' import { Checkbox } from '@/shared/Checkbox/Checkbox' export const ModalSettings = () => { const { getModalOpened, handleClose } = useModalSearchParams() const isModalOpened = getModalOpened(MODAL_PARAMS_KEYS.SETTINGS) const handleCloseModal = handleClose(MODAL_PARAMS_KEYS.SETTINGS) const [enteredPassword, setEnteredPassword] = useState('') const [isPasswordShown, setIsPasswordShown] = useState(false) const [isPasswordInvalid, setIsPasswordInvalid] = useState(false) const [isPasswordSynched, setIsPasswordSynched] = useState(false) const handlePasswordChange = (e: ChangeEvent) => { setEnteredPassword(e.target.value) } const handlePasswordTypeChange = () => setIsPasswordShown((prevState) => !prevState) const handleSync = () => { setIsPasswordInvalid(false) if (enteredPassword.trim().length < 6) { return setIsPasswordInvalid(true) } setIsPasswordSynched(true) } const onClose = () => { handleCloseModal() setEnteredPassword('') setIsPasswordInvalid(false) setIsPasswordSynched(false) } return ( Cloud sync {isPasswordSynched && ( Synched )} Use this login on multiple devices {isPasswordShown ? ( ) : ( )} } type={isPasswordShown ? 'password' : 'text'} onChange={handlePasswordChange} value={enteredPassword} helperText={isPasswordInvalid ? 'Invalid password' : ''} helperTextProps={{ sx: { '&.helper_text': { color: 'red', }, }, }} /> Sync ) }