UNPKG

@brightlayer-ui/react-auth-workflow

Version:

Re-usable workflow components for Authentication and Registration within Eaton applications.

29 lines (28 loc) 2.06 kB
/* eslint-disable @typescript-eslint/explicit-function-return-type */ import React from 'react'; import { WorkflowCard, WorkflowCardHeader, WorkflowCardBody, WorkflowCardInstructions, SetPassword, WorkflowCardActions, } from '../../components/index.js'; import ErrorManager from '../../components/Error/ErrorManager.js'; import { SuccessScreenBase } from '../SuccessScreen/index.js'; /** * Component that renders a ResetPassword screen that allows a user to reset their password and shows a success message upon a successful password reset.. * * @param {ResetPasswordScreenProps} props - props of ResetPasswordScreen base component * @returns a React JSX Element that renders a ResetPassword screen * * @category Component * */ export const ResetPasswordScreenBase = (props) => { const passwordProps = props.PasswordProps || { onPasswordChange: () => ({}) }; const { showSuccessScreen, slots, slotProps = {}, errorDisplayConfig, WorkflowCardBaseProps: cardBaseProps = {}, WorkflowCardInstructionProps: instructionsProps = {}, WorkflowCardActionsProps: actionsProps = {}, WorkflowCardHeaderProps: headerProps = {}, ...otherProps } = props; const getSuccessScreen = (_props, // eslint-disable-next-line @typescript-eslint/naming-convention SuccessScreen) => (SuccessScreen ? SuccessScreen(_props || {}) : React.createElement(SuccessScreenBase, { ..._props })); return (React.createElement(React.Fragment, null, showSuccessScreen ? (getSuccessScreen(slotProps?.SuccessScreen, slots?.SuccessScreen)) : (React.createElement(WorkflowCard, { ...cardBaseProps, ...otherProps }, React.createElement(WorkflowCardHeader, { ...headerProps }), React.createElement(WorkflowCardInstructions, { ...instructionsProps, divider: true }), React.createElement(WorkflowCardBody, null, React.createElement(ErrorManager, { ...errorDisplayConfig }, React.createElement(SetPassword, { ...passwordProps }))), React.createElement(WorkflowCardActions, { ...actionsProps, divider: true }))))); };