diff --git a/src/components/Settings/EditOidcModal/index.tsx b/src/components/Settings/EditOidcModal/index.tsx index 0735178a..f698c296 100644 --- a/src/components/Settings/EditOidcModal/index.tsx +++ b/src/components/Settings/EditOidcModal/index.tsx @@ -7,9 +7,9 @@ import { Transition } from '@headlessui/react'; import { ChevronRightIcon } from '@heroicons/react/20/solid'; import { MagnifyingGlassIcon } from '@heroicons/react/24/solid'; import type { OidcProvider } from '@server/lib/settings'; -import axios from 'axios'; // <-- Import axios +import axios from 'axios'; import { - ErrorMessage, + // ErrorMessage has been removed from the import Field, Formik, useFormikContext, @@ -132,8 +132,10 @@ export default function EditOidcModal(props: EditOidcModalProps) { }} validationSchema={oidcSettingsSchema} onSubmit={onSubmit} + enableReinitialize > - {({ handleSubmit, isValid }) => ( + {/* Get errors and touched from Formik render props */} + {({ handleSubmit, isValid, errors, touched }) => (
- + {/* Replaced ErrorMessage component with manual div */} + {errors.name && + touched.name && + typeof errors.name === 'string' && ( +
{errors.name}
+ )}
@@ -187,7 +194,11 @@ export default function EditOidcModal(props: EditOidcModalProps) {
- + {errors.logo && + touched.logo && + typeof errors.logo === 'string' && ( +
{errors.logo}
+ )}
@@ -200,11 +211,11 @@ export default function EditOidcModal(props: EditOidcModalProps) {
- + {errors.issuerUrl && + touched.issuerUrl && + typeof errors.issuerUrl === 'string' && ( +
{errors.issuerUrl}
+ )}
@@ -217,11 +228,11 @@ export default function EditOidcModal(props: EditOidcModalProps) {
- + {errors.clientId && + touched.clientId && + typeof errors.clientId === 'string' && ( +
{errors.clientId}
+ )}
@@ -241,11 +252,11 @@ export default function EditOidcModal(props: EditOidcModalProps) { autoComplete="new-password" />
- + {errors.clientSecret && + touched.clientSecret && + typeof errors.clientSecret === 'string' && ( +
{errors.clientSecret}
+ )} @@ -281,17 +292,15 @@ export default function EditOidcModal(props: EditOidcModalProps) { id="oidcSlug" name="slug" type="text" - // prevent editing of slug if editing an existing provider, - // to avoid invalidating existing linked accounts readOnly={props.provider != null} disabled={props.provider != null} className={props.provider != null ? 'opacity-50' : ''} /> - + {errors.slug && + touched.slug && + typeof errors.slug === 'string' && ( +
{errors.slug}
+ )}
@@ -303,11 +312,11 @@ export default function EditOidcModal(props: EditOidcModalProps) {
- + {errors.scopes && + touched.scopes && + typeof errors.scopes === 'string' && ( +
{errors.scopes}
+ )}
@@ -326,11 +335,11 @@ export default function EditOidcModal(props: EditOidcModalProps) { name="requiredClaims" type="text" /> - + {errors.requiredClaims && + touched.requiredClaims && + typeof errors.requiredClaims === 'string' && ( +
{errors.requiredClaims}
+ )}
@@ -346,11 +355,11 @@ export default function EditOidcModal(props: EditOidcModalProps) { name="newUserLogin" type="checkbox" /> - + {errors.newUserLogin && + touched.newUserLogin && + typeof errors.newUserLogin === 'string' && ( +
{errors.newUserLogin}
+ )}