Skip to content

Commit

Permalink
added password protection page for change password flow (#1007)
Browse files Browse the repository at this point in the history
  • Loading branch information
ost-ptk committed Jun 13, 2024
1 parent 5adb184 commit bed07d0
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/apps/popup/pages/change-password/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React from 'react';
import React, { useCallback, useState } from 'react';
import { useWatch } from 'react-hook-form';
import { Trans, useTranslation } from 'react-i18next';

import { ChangePasswordPageContent } from '@popup/pages/change-password/content';
import { PasswordProtectionPage } from '@popup/pages/password-protection-page';
import { RouterPath, useTypedNavigate } from '@popup/router';

import { changePassword } from '@background/redux/sagas/actions';
Expand All @@ -22,6 +23,9 @@ import {
import { calculateSubmitButtonDisabled } from '@libs/ui/forms/get-submit-button-state-from-validation';

export const ChangePasswordPage = () => {
const [isPasswordConfirmed, setIsPasswordConfirmed] =
useState<boolean>(false);

const { t } = useTranslation();
const navigate = useTypedNavigate();

Expand All @@ -37,6 +41,10 @@ export const ChangePasswordPage = () => {
name: 'password'
});

const setPasswordConfirmed = useCallback(() => {
setIsPasswordConfirmed(true);
}, []);

const isSubmitButtonDisabled = calculateSubmitButtonDisabled({
isDirty
});
Expand All @@ -46,6 +54,12 @@ export const ChangePasswordPage = () => {
navigate(RouterPath.Home);
};

if (!isPasswordConfirmed) {
return (
<PasswordProtectionPage setPasswordConfirmed={setPasswordConfirmed} />
);
}

return (
<PopupLayout
variant="form"
Expand Down

0 comments on commit bed07d0

Please sign in to comment.