import { Dropdown, Item, Form, FormRow, FormButtons, FormInput, TextField, SubmitButton, PasswordField, } from 'react-basics'; import { useIntl } from 'react-intl'; import useApi from 'hooks/useApi'; import { ROLES } from 'lib/constants'; import { labels, messages } from 'components/messages'; export default function UserEditForm({ userId, data, onSave }) { const { formatMessage } = useIntl(); const { post, useMutation } = useApi(); const { mutate, error } = useMutation(({ username }) => post(`/users/${userId}`, { username })); const handleSubmit = async data => { mutate(data, { onSuccess: async () => { onSave(data); }, }); }; const renderValue = value => { if (value === ROLES.user) { return formatMessage(labels.user); } if (value === ROLES.admin) { return formatMessage(labels.admin); } }; return (
{formatMessage(labels.user)} {formatMessage(labels.admin)} {formatMessage(labels.save)}
); }