ui(admin): add 'root_admin' field to UserForm
This commit is contained in:
parent
fc2f8744da
commit
1ead83383d
|
@ -6,6 +6,7 @@ export interface Values {
|
||||||
email: string;
|
email: string;
|
||||||
password: string;
|
password: string;
|
||||||
adminRoleId: number | null;
|
adminRoleId: number | null;
|
||||||
|
rootAdmin: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default (id: number, values: Partial<Values>, include: string[] = []): Promise<User> => {
|
export default (id: number, values: Partial<Values>, include: string[] = []): Promise<User> => {
|
||||||
|
|
|
@ -43,6 +43,7 @@ const UserAboutContainer = () => {
|
||||||
email: user.email,
|
email: user.email,
|
||||||
adminRoleId: user.adminRoleId,
|
adminRoleId: user.adminRoleId,
|
||||||
password: '',
|
password: '',
|
||||||
|
rootAdmin: user.rootAdmin,
|
||||||
}}
|
}}
|
||||||
onSubmit={submit}
|
onSubmit={submit}
|
||||||
role={user?.relationships.role || null}
|
role={user?.relationships.role || null}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import FormikSwitch from '@/components/elements/FormikSwitch';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import tw from 'twin.macro';
|
import tw from 'twin.macro';
|
||||||
import { action, Action, createContextStore } from 'easy-peasy';
|
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 AdminBox from '@/components/admin/AdminBox';
|
||||||
import SpinnerOverlay from '@/components/elements/SpinnerOverlay';
|
import SpinnerOverlay from '@/components/elements/SpinnerOverlay';
|
||||||
import { Form, Formik, FormikHelpers } from 'formik';
|
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 { Role } from '@/api/admin/roles/getRoles';
|
||||||
import { Values } from '@/api/admin/users/updateUser';
|
import { Values } from '@/api/admin/users/updateUser';
|
||||||
import Button from '@/components/elements/Button';
|
import Button from '@/components/elements/Button';
|
||||||
|
@ -47,6 +48,7 @@ export default function UserForm ({ title, initialValues, children, onSubmit, ex
|
||||||
email: '',
|
email: '',
|
||||||
password: '',
|
password: '',
|
||||||
adminRoleId: 0,
|
adminRoleId: 0,
|
||||||
|
rootAdmin: false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,6 +60,7 @@ export default function UserForm ({ title, initialValues, children, onSubmit, ex
|
||||||
username: string().min(1).max(32),
|
username: string().min(1).max(32),
|
||||||
email: string(),
|
email: string(),
|
||||||
password: exists ? string() : string().required(),
|
password: exists ? string() : string().required(),
|
||||||
|
rootAdmin: bool().required(),
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
{
|
{
|
||||||
|
@ -104,6 +107,16 @@ export default function UserForm ({ title, initialValues, children, onSubmit, ex
|
||||||
</div>
|
</div>
|
||||||
</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`}>
|
<div css={tw`w-full flex flex-row items-center mt-6`}>
|
||||||
{children}
|
{children}
|
||||||
<div css={tw`flex ml-auto`}>
|
<div css={tw`flex ml-auto`}>
|
||||||
|
|
Loading…
Reference in New Issue