fix(twenty-front): error on captcha initialisation (#11039)

This commit is contained in:
Antoine Moreaux
2025-03-19 17:09:35 +01:00
committed by GitHub
parent cfdb3f5778
commit 28028ca4c0
6 changed files with 72 additions and 69 deletions

View File

@ -6,6 +6,7 @@ import { isCaptchaRequiredForPath } from '@/captcha/utils/isCaptchaRequiredForPa
import { captchaState } from '@/client-config/states/captchaState';
import { CaptchaDriverType } from '~/generated-metadata/graphql';
import { isUndefinedOrNull } from '~/utils/isUndefinedOrNull';
import { useLocation } from 'react-router-dom';
declare global {
interface Window {
@ -20,10 +21,12 @@ export const useRequestFreshCaptchaToken = () => {
isRequestingCaptchaTokenState,
);
const location = useLocation();
const requestFreshCaptchaToken = useRecoilCallback(
({ snapshot }) =>
async () => {
if (!isCaptchaRequiredForPath(window.location.pathname)) {
if (!isCaptchaRequiredForPath(location.pathname)) {
return;
}
@ -62,7 +65,7 @@ export const useRequestFreshCaptchaToken = () => {
});
}
},
[setCaptchaToken, setIsRequestingCaptchaToken],
[location.pathname, setCaptchaToken, setIsRequestingCaptchaToken],
);
return { requestFreshCaptchaToken };