ffdedf7af3
Fixes https://github.com/twentyhq/core-team-issues/issues/950 This issue was due to the memoization inside `useIsMatchingLocation`, which was rerendered only if the pathname changed but not the search params. After discussion with @lucasbordeau, we decided to remove the hook `useIsMatchingLocation` and to create an equivalent util function which takes the location as an argument. --------- Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
30 lines
1021 B
TypeScript
30 lines
1021 B
TypeScript
import { useMemo } from 'react';
|
|
|
|
import { AppPath } from '@/types/AppPath';
|
|
import { useLocation } from 'react-router-dom';
|
|
import { isMatchingLocation } from '~/utils/isMatchingLocation';
|
|
|
|
export const useShowAuthModal = () => {
|
|
const location = useLocation();
|
|
|
|
return useMemo(() => {
|
|
if (
|
|
isMatchingLocation(location, AppPath.Invite) ||
|
|
isMatchingLocation(location, AppPath.InviteTeam) ||
|
|
isMatchingLocation(location, AppPath.CreateProfile) ||
|
|
isMatchingLocation(location, AppPath.SyncEmails) ||
|
|
isMatchingLocation(location, AppPath.ResetPassword) ||
|
|
isMatchingLocation(location, AppPath.VerifyEmail) ||
|
|
isMatchingLocation(location, AppPath.Verify) ||
|
|
isMatchingLocation(location, AppPath.SignInUp) ||
|
|
isMatchingLocation(location, AppPath.CreateWorkspace) ||
|
|
isMatchingLocation(location, AppPath.PlanRequired) ||
|
|
isMatchingLocation(location, AppPath.PlanRequiredSuccess)
|
|
) {
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}, [location]);
|
|
};
|