ui(admin): add 'root_admin' field to UserForm
This commit is contained in:
parent
fc2f8744da
commit
1ead83383d
3 changed files with 16 additions and 1 deletions
|
@ -6,6 +6,7 @@ export interface Values {
|
|||
email: string;
|
||||
password: string;
|
||||
adminRoleId: number | null;
|
||||
rootAdmin: boolean;
|
||||
}
|
||||
|
||||
export default (id: number, values: Partial<Values>, include: string[] = []): Promise<User> => {
|
||||
|
|
|
@ -43,6 +43,7 @@ const UserAboutContainer = () => {
|
|||
email: user.email,
|
||||
adminRoleId: user.adminRoleId,
|
||||
password: '',
|
||||
rootAdmin: user.rootAdmin,
|
||||
}}
|
||||
onSubmit={submit}
|
||||
role={user?.relationships.role || null}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import FormikSwitch from '@/components/elements/FormikSwitch';
|
||||
import React from 'react';
|
||||
import tw from 'twin.macro';
|
||||
import { action, Action, createContextStore } from 'easy-peasy';
|
||||
|
@ -5,7 +6,7 @@ import { User } from '@/api/admin/users/getUsers';
|
|||
import AdminBox from '@/components/admin/AdminBox';
|
||||
import SpinnerOverlay from '@/components/elements/SpinnerOverlay';
|
||||
import { Form, Formik, FormikHelpers } from 'formik';
|
||||
import { object, string } from 'yup';
|
||||
import { bool, object, string } from 'yup';
|
||||
import { Role } from '@/api/admin/roles/getRoles';
|
||||
import { Values } from '@/api/admin/users/updateUser';
|
||||
import Button from '@/components/elements/Button';
|
||||
|
@ -47,6 +48,7 @@ export default function UserForm ({ title, initialValues, children, onSubmit, ex
|
|||
email: '',
|
||||
password: '',
|
||||
adminRoleId: 0,
|
||||
rootAdmin: false,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -58,6 +60,7 @@ export default function UserForm ({ title, initialValues, children, onSubmit, ex
|
|||
username: string().min(1).max(32),
|
||||
email: string(),
|
||||
password: exists ? string() : string().required(),
|
||||
rootAdmin: bool().required(),
|
||||
})}
|
||||
>
|
||||
{
|
||||
|
@ -104,6 +107,16 @@ export default function UserForm ({ title, initialValues, children, onSubmit, ex
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div css={tw`w-full flex flex-row mb-6`}>
|
||||
<div css={tw`w-full bg-neutral-800 border border-neutral-900 shadow-inner mt-6 p-4 rounded`}>
|
||||
<FormikSwitch
|
||||
name={'rootAdmin'}
|
||||
label={'Root Admin'}
|
||||
description={'Should this user be a root administrator?'}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div css={tw`w-full flex flex-row items-center mt-6`}>
|
||||
{children}
|
||||
<div css={tw`flex ml-auto`}>
|
||||
|
|
Loading…
Reference in a new issue