change the custom value as initialValue

This commit is contained in:
Simone Taeggi 2022-09-08 08:57:33 +02:00
parent 79000ad133
commit c86c5a62bf

View File

@ -294,17 +294,13 @@ const ApiTokenCreateView = () => {
initialValues={{ initialValues={{
name: apiToken?.name || '', name: apiToken?.name || '',
description: apiToken?.description || '', description: apiToken?.description || '',
type: apiToken?.type, type: state.selectedActions.length > 0 && !apiToken?.type ? 'custom' : apiToken?.type,
lifespan: apiToken?.lifespan, lifespan: apiToken?.lifespan,
}} }}
enableReinitialize enableReinitialize
onSubmit={(body, actions) => handleSubmit(body, actions)} onSubmit={(body, actions) => handleSubmit(body, actions)}
> >
{({ errors, handleChange, isSubmitting, values }) => { {({ errors, handleChange, isSubmitting, values }) => {
if (state.selectedActions.length > 0 && !values?.type) {
values.type = 'custom';
}
return ( return (
<Form> <Form>
<HeaderLayout <HeaderLayout