import { useState } from 'react'; import { useHistory } from 'react-router-dom'; import useForm from '../../../hooks/useForm'; import { EmployeeEditWrapper, Title, RowWrapper, LabelAndInputWrapper, Label, StandardInputField, Dropdown, DropdownOption, SwitchRowWrapper, SwitchTitle, SwitchLabelAndInputWrapper, AccountSwitch, BackButton, SaveChangesButton, VisibilityIcon, VisibilityOffIcon, } from './styles'; import IconButton from '@mui/material/IconButton'; import { employeeStatus } from '../../../config/enums'; import { defaultUser } from '../../../config/defaultUser'; const EmployeeCreate = () => { const [isPasswordVisible, setIsPasswordVisible] = useState(false); let history = useHistory(); const { data: employeeEditableData, onFormChange: setEmployeeEditableData } = useForm({ ...defaultUser, confirmPassword: defaultUser.password }); const [accStatus, setAccStatus] = useState(defaultUser.accountActive); const zoneOptions = [ { text: 'Nitu edna zona', value: 'none', }, { text: 'Zona 1', value: 'zone1', }, { text: 'Zona 2', value: 'zone2', }, { text: 'Zona 3', value: 'zone3', }, { text: 'Zona 4', value: 'zone4', }, { text: 'Zona 5', value: 'zone5', }, ]; const statusOptions = Object.keys(employeeStatus).map((key) => { return { text: employeeStatus[key], value: key, }; }); const onCreateEmployee = () => { const changedEmployee = { ...employeeEditableData, accountActive: accStatus, }; console.log('Created employee: ', changedEmployee); }; return ( Создади вработен setIsPasswordVisible(!isPasswordVisible)} > {isPasswordVisible ? : } {zoneOptions.map((option) => ( {option.text} ))} {statusOptions.map((option) => ( {option.text} ))} Акаунт setAccStatus(!accStatus)} /> history.push('/employees')}> Врати се назад Создади вработен ); }; export default EmployeeCreate;