Skip to content

Commit 4cceff3

Browse files
Test
1 parent 1f87740 commit 4cceff3

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

pages/settings.tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { AdminMessage } from "@/submodules/react-components/types/admin-messages
1818
import { postProcessAdminMessages } from "@/submodules/react-components/helpers/admin-messages-helper"
1919
import AdminMessages from "@/submodules/react-components/components/AdminMessages"
2020
import { useTranslation } from "react-i18next"
21+
import { useConsoleLog } from "@/submodules/react-components/hooks/useConsoleLog"
2122

2223
const Settings: NextPage = () => {
2324
const [initialFlow, setInitialFlow]: any = useState<SettingsFlow>()
@@ -154,6 +155,7 @@ const Settings: NextPage = () => {
154155
}, [initialFlow])
155156

156157
useEffect(() => {
158+
console.log(loadPage);
157159
if (!changedFlow || !initialFlow || !loadPage) return;
158160
setTimeout(() => {
159161
const firstNameButtonVal = (document.querySelector('input[name="traits.name.first"]') as HTMLInputElement)?.value;
@@ -175,14 +177,15 @@ const Settings: NextPage = () => {
175177
setShowAuthenticator(true);
176178
}
177179

180+
console.log(firstNameButtonVal, lastNameButtonVal, emailButtonVal, passwordButtonVal, flowId);
178181
if ((firstNameButtonVal === "" || lastNameButtonVal === "" || emailButtonVal === "" || passwordButtonVal === "" || firstNameButtonVal === undefined || lastNameButtonVal === undefined || emailButtonVal === undefined || passwordButtonVal === undefined) && flowId) {
179182
setBackButtonDisabled(true);
180183
} else {
181184
setBackButtonDisabled(false);
182185
}
183186
}
184187
}, 0); // Wait for the page to load
185-
}, [isOidc, isOidcInvitation, initialFlow, changedFlow, loadPage]);
188+
}, [isOidc, isOidcInvitation, initialFlow, changedFlow, loadPage, flowId]);
186189

187190
useEffect(() => {
188191
if (!changedFlow) return;
@@ -229,18 +232,24 @@ const Settings: NextPage = () => {
229232
return Promise.reject(err)
230233
})
231234

235+
useConsoleLog(showPassword, 'showPassword');
236+
useConsoleLog(backButtonDisabled, 'backButtonDisabled');
237+
238+
232239
useEffect(() => {
240+
console.log('useEffect triggered for messages update', backButtonDisabled, changedFlow, flowId, isOidc, showPassword);
233241
if (backButtonDisabled || !changedFlow || !changedFlow.ui.messages || !flowId) return;
234242
const messagesCopy = [...changedFlow.ui.messages];
235243
const messagesMapped = messagesCopy.map((message: any) => {
236-
if (message.id === 1060001 && !isOidc) {
244+
console.log(message.id, isOidc, showPassword, backButtonDisabled, message.id === 1060001 && !isOidc && showPassword && backButtonDisabled);
245+
if (message.id === 1060001 && !isOidc && showPassword && !backButtonDisabled) {
237246
router.push('/cognition');
238247
return { ...message, id: '1050001ab' };
239248
}
240249
return message;
241250
});
242251
setMessages(messagesMapped);
243-
}, [backButtonDisabled, changedFlow, flowId, isOidc]);
252+
}, [backButtonDisabled, changedFlow, flowId, isOidc, showPassword]);
244253

245254

246255
return (

0 commit comments

Comments
 (0)