Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…into fix/update-i18next-version
  • Loading branch information
ektaghag-eaton committed Sep 27, 2023
2 parents 593cdd0 + 45d0d7e commit b642941
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ export const ChangePasswordDialog: React.FC<ChangePasswordDialogProps> = (props)
ErrorDialogProps,
loading,
currentPasswordTextFieldProps,
slots = {},
slotProps = {},
} = props;

const [currentInput, setCurrentInput] = useState('');
Expand Down Expand Up @@ -156,6 +158,7 @@ export const ChangePasswordDialog: React.FC<ChangePasswordDialogProps> = (props)
onSubmit={async (): Promise<void> => {
await changePasswordSubmit();
}}
slots={slots}
slotProps={{
SuccessScreen: {
icon: <CheckCircle color="primary" sx={{ fontSize: 100 }} />,
Expand All @@ -173,6 +176,7 @@ export const ChangePasswordDialog: React.FC<ChangePasswordDialogProps> = (props)
onFinish?.();
},
},
...slotProps.SuccessScreen,
},
}}
showSuccessScreen={showSuccessScreen}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export const ChangePasswordDialogBase: React.FC<ChangePasswordDialogProps> = (pr
<DialogActions
sx={{
justifyContent: 'flex-end',
p: { md: 3, sm: 2 },
p: { xs: 2, md: 3 },
}}
>
<Grid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { useAuthContext } from '../../contexts';
import { ForgotPasswordScreenBase } from './ForgotPasswordScreenBase';
import { ForgotPasswordScreenProps } from './types';
import Typography from '@mui/material/Typography';
import { SuccessScreenBase } from '../SuccessScreen';
import CheckCircle from '@mui/icons-material/CheckCircle';
import { LinkStyles } from '../../styles';
import { useErrorManager } from '../../contexts/ErrorContext/useErrorManager';
Expand Down Expand Up @@ -76,8 +75,8 @@ export const ForgotPasswordScreen: React.FC<ForgotPasswordScreenProps> = (props)
WorkflowCardInstructionProps,
WorkflowCardActionsProps,
showSuccessScreen: enableSuccessScreen = true,
slotProps = { SuccessScreen: {} },
slots,
slots = {},
slotProps = {},
emailTextFieldProps,
} = props;

Expand Down Expand Up @@ -141,49 +140,39 @@ export const ForgotPasswordScreen: React.FC<ForgotPasswordScreenProps> = (props)
emailValidator={emailValidator}
emailTextFieldProps={emailTextFieldProps}
showSuccessScreen={enableSuccessScreen && showSuccessScreen}
slots={{
SuccessScreen:
slots?.SuccessScreen ??
((): JSX.Element => (
<SuccessScreenBase
icon={<CheckCircle color={'primary'} sx={{ fontSize: 100, mb: 5 }} />}
messageTitle={t('bluiCommon:MESSAGES.EMAIL_SENT')}
message={
<Box
sx={{
overflow: 'hidden',
whiteSpace: 'normal',
wordBreak: 'break-word',
}}
component={'span'}
>
<Trans
i18nKey={'bluiAuth:FORGOT_PASSWORD.LINK_SENT_ALT'}
values={{ email: emailInput }}
>
Link has been sent to <b>{emailInput}</b>.
</Trans>
</Box>
}
{...slotProps.SuccessScreen}
WorkflowCardHeaderProps={{
title: t('bluiAuth:HEADER.FORGOT_PASSWORD'),
...slotProps?.SuccessScreen?.WorkflowCardHeaderProps,
slots={slots}
slotProps={{
SuccessScreen: {
icon: <CheckCircle color={'primary'} sx={{ fontSize: 100, mb: 5 }} />,
messageTitle: t('bluiCommon:MESSAGES.EMAIL_SENT'),
message: (
<Box
sx={{
overflow: 'hidden',
whiteSpace: 'normal',
wordBreak: 'break-word',
}}
WorkflowCardActionsProps={{
showNext: true,
nextLabel: t('bluiCommon:ACTIONS.DONE'),
canGoNext: true,
fullWidthButton: true,
...slotProps?.SuccessScreen?.WorkflowCardActionsProps,
onNext: (): void => {
navigate(routeConfig.LOGIN as string);
if (slotProps?.SuccessScreen?.WorkflowCardActionsProps)
slotProps?.SuccessScreen?.WorkflowCardActionsProps?.onNext?.();
},
}}
/>
)),
component={'span'}
>
<Trans i18nKey={'bluiAuth:FORGOT_PASSWORD.LINK_SENT_ALT'} values={{ email: emailInput }}>
Link has been sent to <b>{emailInput}</b>.
</Trans>
</Box>
),
WorkflowCardHeaderProps: {
title: t('bluiAuth:HEADER.FORGOT_PASSWORD'),
},
WorkflowCardActionsProps: {
showNext: true,
nextLabel: t('bluiCommon:ACTIONS.DONE'),
canGoNext: true,
fullWidthButton: true,
onNext: (): void => {
navigate(routeConfig.LOGIN as string);
},
},
...slotProps.SuccessScreen,
},
}}
errorDisplayConfig={errorDisplayConfig}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,9 @@ import {
WorkflowCardInstructions,
} from '../../components';
import { ForgotPasswordScreenProps } from './types';
import { SuccessScreenProps } from '../SuccessScreen';
import { SuccessScreenBase, SuccessScreenProps } from '../SuccessScreen';
import ErrorManager from '../../components/Error/ErrorManager';

type ForgotPasswordScreenBaseProps = Omit<ForgotPasswordScreenProps, 'slots'> & {
slots: { SuccessScreen: (props: SuccessScreenProps) => JSX.Element };
};

/**
* Component renders a screen with forgot password for support with the application.
*
Expand All @@ -35,7 +31,7 @@ type ForgotPasswordScreenBaseProps = Omit<ForgotPasswordScreenProps, 'slots'> &
* @category Component
*/

export const ForgotPasswordScreenBase: React.FC<React.PropsWithChildren<ForgotPasswordScreenBaseProps>> = (props) => {
export const ForgotPasswordScreenBase: React.FC<React.PropsWithChildren<ForgotPasswordScreenProps>> = (props) => {
const [emailInput, setEmailInput] = useState(props.initialEmailValue ?? '');

const {
Expand Down Expand Up @@ -79,10 +75,15 @@ export const ForgotPasswordScreenBase: React.FC<React.PropsWithChildren<ForgotPa
}
};

const getSuccessScreen = (
_props: SuccessScreenProps,
SuccessScreen?: (props: SuccessScreenProps) => JSX.Element
): JSX.Element => (SuccessScreen ? SuccessScreen(_props) : <SuccessScreenBase {..._props} />);

return (
<>
{showSuccessScreen ? (
<slots.SuccessScreen {...slotProps.SuccessScreen} />
getSuccessScreen(slotProps?.SuccessScreen, slots?.SuccessScreen)
) : (
<WorkflowCard {...cardBaseProps}>
<WorkflowCardHeader {...headerProps} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ export const ResetPasswordScreen: React.FC<ResetPasswordScreenProps> = (props) =
WorkflowCardActionsProps,
PasswordProps,
errorDisplayConfig = errorManagerConfig,
slots,
slotProps,
slots = {},
slotProps = {},
} = props;

const [passwordInput, setPasswordInput] = useState(PasswordProps?.initialNewPasswordValue ?? '');
Expand Down Expand Up @@ -184,8 +184,8 @@ export const ResetPasswordScreen: React.FC<ResetPasswordScreenProps> = (props) =
navigate(routeConfig.LOGIN as string);
},
},
...slotProps.SuccessScreen,
},
...slotProps,
}}
errorDisplayConfig={{
...errorDisplayConfig,
Expand Down

0 comments on commit b642941

Please sign in to comment.