mirror of
https://github.com/graphql-hive/console
synced 2026-05-24 09:38:26 +00:00
Fix missing validation error message when creating an organization (#4024)
This commit is contained in:
parent
a5bdcf632a
commit
946445a142
2 changed files with 17 additions and 4 deletions
|
|
@ -96,7 +96,7 @@ export const resolvers: OrganizationModule.Resolvers = {
|
|||
error: {
|
||||
message: 'Please check your input.',
|
||||
inputErrors: {
|
||||
name: organizationNameResult.error.formErrors.fieldErrors?.[0]?.[0] ?? null,
|
||||
name: organizationNameResult.error.issues[0].message ?? null,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -31,11 +31,18 @@ export const CreateOrganizationMutation = graphql(`
|
|||
export const CreateOrganizationForm = () => {
|
||||
const [mutation, mutate] = useMutation(CreateOrganizationMutation);
|
||||
const { push } = useRouter();
|
||||
const { handleSubmit, values, handleChange, handleBlur, isSubmitting, errors, touched } =
|
||||
const { handleSubmit, values, handleChange, handleBlur, isSubmitting, errors, touched, isValid } =
|
||||
useFormik({
|
||||
initialValues: { name: '' },
|
||||
validationSchema: Yup.object().shape({
|
||||
name: Yup.string().required('Organization name is required'),
|
||||
name: Yup.string()
|
||||
.min(2, 'Name must be at least 2 characters long')
|
||||
.max(50, 'Name must be at most 50 characters long')
|
||||
.matches(
|
||||
/^([a-z]|[0-9]|\s|\.|,|_|-|\/|&)+$/i,
|
||||
'Name restricted to alphanumerical characters, spaces and . , _ - / &',
|
||||
)
|
||||
.required('Organization name is required'),
|
||||
}),
|
||||
async onSubmit(values) {
|
||||
const mutation = await mutate({
|
||||
|
|
@ -78,7 +85,13 @@ export const CreateOrganizationForm = () => {
|
|||
</div>
|
||||
)}
|
||||
<div className="flex gap-2">
|
||||
<Button type="submit" size="large" block variant="primary" disabled={isSubmitting}>
|
||||
<Button
|
||||
type="submit"
|
||||
size="large"
|
||||
block
|
||||
variant="primary"
|
||||
disabled={isSubmitting || !isValid}
|
||||
>
|
||||
{isSubmitting ? (
|
||||
<>
|
||||
<Spinner className="size-6 text-white" />
|
||||
|
|
|
|||
Loading…
Reference in a new issue