Added useApi hook.

This commit is contained in:
Mike Cao 2022-02-22 23:52:31 -08:00
parent 7bd49e6caf
commit d19b6b5a82
22 changed files with 59 additions and 59 deletions

View file

@ -8,7 +8,7 @@ import FormLayout, {
FormMessage,
FormRow,
} from 'components/layout/FormLayout';
import usePost from 'hooks/usePost';
import useApi from 'hooks/useApi';
const initialValues = {
username: '',
@ -29,11 +29,11 @@ const validate = ({ user_id, username, password }) => {
};
export default function AccountEditForm({ values, onSave, onClose }) {
const post = usePost();
const { post } = useApi();
const [message, setMessage] = useState();
const handleSubmit = async values => {
const { ok, data } = await post('/api/account', values);
const { ok, data } = await post('/account', values);
if (ok) {
onSave();