/* eslint-disable prettier/prettier */ import React, { useState } from 'react'; import Button from '@webapp/ui/Button'; import { useAppDispatch } from '@webapp/redux/hooks'; import { editMe, withCurrentUser } from '@webapp/redux/reducers/user'; import { addNotification } from '@webapp/redux/reducers/notifications'; import StatusMessage from '@webapp/ui/StatusMessage'; import InputField from '@webapp/ui/InputField'; function Preferences(props: ShamefulAny) { const { currentUser } = props; const dispatch = useAppDispatch(); const [form, setForm] = useState(currentUser); const handleFormSubmit = (evt: ShamefulAny) => { evt.preventDefault(); dispatch(editMe(form)) .unwrap() .then(() => { dispatch( addNotification({ type: 'success', title: 'Success', message: 'User has been successfully edited', }) ); }); return false; }; const handleFormChange = (event: ShamefulAny) => { const { name } = event.target; const { value } = event.target; setForm({ ...form, [name]: value }); }; const isEditDisabled = !!(currentUser && currentUser.isExternal); if (!currentUser) return <>>; return ( <>