diff --git a/packages/react-material-ui/src/components/submodules/AuthForm/index.tsx b/packages/react-material-ui/src/components/submodules/AuthForm/index.tsx index 3fe11be3..4d11bf03 100644 --- a/packages/react-material-ui/src/components/submodules/AuthForm/index.tsx +++ b/packages/react-material-ui/src/components/submodules/AuthForm/index.tsx @@ -33,6 +33,8 @@ const widgets = { TextWidget: CustomTextFieldWidget, }; +type Route = 'signIn' | 'signUp' | 'forgotPassword' | 'resetPassword'; + type Query = { uri?: string; method?: string; @@ -40,8 +42,8 @@ type Query = { onError?: (error: unknown) => void; }; -interface AuthFormSubmoduleProps { - route: string; +export interface AuthFormSubmoduleProps { + route: Route; query?: Query; title?: string | ReactNode; hideTitle?: boolean; @@ -149,92 +151,94 @@ const AuthFormSubmodule = (props: AuthFormSubmoduleProps) => { }[props.route] || {}; return ( - + {!props.hideLogo && ( logo )} {props.headerComponent || null} - - {!props.hideTitle && renderTitle(props.title ?? defaultRouteTitle)} - - setFormData(formData)} - onSubmit={handleSubmit} - noHtml5Validate={true} - showErrorList={false} - advancedProperties={props.advancedProperties} - customValidate={(formData, errors) => - validateForm(formData, errors, props.customValidation || []) - } - widgets={widgets} - > - {props.forgotPasswordPath ? ( - - - Forgot your password? + + + {!props.hideTitle && renderTitle(props.title ?? defaultRouteTitle)} + + setFormData(formData)} + onSubmit={handleSubmit} + noHtml5Validate={true} + showErrorList={false} + advancedProperties={props.advancedProperties} + customValidate={(formData, errors) => + validateForm(formData, errors, props.customValidation || []) + } + widgets={widgets} + > + {props.forgotPasswordPath ? ( + + + Forgot your password? + + + ) : null} + + + + + + + {props.signInPath ? ( + + + Already have an account? Sign in ) : null} - - - - - - {props.signInPath ? ( - - - Already have an account? Sign in - - - ) : null} - - {props.signUpPath ? ( - - - No account? Sign up - - - ) : null} - + {props.signUpPath ? ( + + + No account? Sign up + + + ) : null} + + ); }; diff --git a/packages/react-material-ui/src/modules/auth/index.tsx b/packages/react-material-ui/src/modules/auth/index.tsx index 628cb68c..7f1dbc71 100644 --- a/packages/react-material-ui/src/modules/auth/index.tsx +++ b/packages/react-material-ui/src/modules/auth/index.tsx @@ -1,10 +1,8 @@ -import React, { ReactNode } from 'react'; +import React from 'react'; -import type { RJSFSchema, UiSchema } from '@rjsf/utils'; - -import type { ValidationRule } from '../../utils/form/validation'; - -import AuthFormSubmodule from '../../components/submodules/AuthForm'; +import AuthFormSubmodule, { + AuthFormSubmoduleProps, +} from '../../components/submodules/AuthForm'; import { signInModuleProps, @@ -13,36 +11,8 @@ import { resetPasswordModuleProps, } from './constants'; -type Route = 'signIn' | 'signUp' | 'forgotPassword' | 'resetPassword'; - -type Query = { - uri?: string; - method?: string; - onSuccess?: (data: unknown) => void; - onError?: (error: unknown) => void; -}; - -interface FormProps { - title?: string | ReactNode; - hideTitle?: boolean; - formSchema?: RJSFSchema; - formUiSchema?: UiSchema; - customValidation?: ValidationRule>[]; - overrideDefaults?: boolean; - submitButtonTitle?: string; -} - -export interface AuthModuleProps { - route: Route; - query?: Query; - headerComponent?: ReactNode; - signInRequestPath?: string; - forgotPasswordPath?: string; - signUpPath?: string; - signInPath?: string; - logoSrc?: string; - hideLogo?: boolean; - formProps?: FormProps; +export interface AuthModuleProps extends AuthFormSubmoduleProps { + formProps?: Omit; } export const AuthModule = (props: AuthModuleProps) => {