Skip to content

Commit

Permalink
Merge pull request #117 from thisyahlen-deriv/thisyahlen/clear-jurisd…
Browse files Browse the repository at this point in the history
…iction-on-modal-close

fix: clear jurisdiction on modal close
  • Loading branch information
thisyahlen-deriv authored Apr 22, 2024
2 parents d3aeb8f + de41ecd commit a7d3a95
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/cfd/screens/Jurisdiction/JurisdictionScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { twMerge } from 'tailwind-merge';

import { Jurisdiction } from '@cfd/constants';

import { useAvailableMT5Accounts, useMT5AccountsList } from '@/hooks';
import { useAvailableMT5Accounts, useMT5AccountsList, useQueryParams } from '@/hooks';
import { useCFDContext, useDynamicLeverageModalState } from '@/providers';

import { JurisdictionCard } from './JurisdictionCard';
Expand All @@ -14,6 +14,7 @@ type TJurisdictionScreenProps = {

export const JurisdictionScreen = ({ setIsCheckBoxChecked }: TJurisdictionScreenProps) => {
const { cfdState, setCfdState } = useCFDContext();
const { closeModal } = useQueryParams();
const { data: availableMT5Accounts } = useAvailableMT5Accounts();
const { data: mt5AccountsList } = useMT5AccountsList();
const { marketType, selectedJurisdiction } = cfdState;
Expand All @@ -37,6 +38,12 @@ export const JurisdictionScreen = ({ setIsCheckBoxChecked }: TJurisdictionScreen
setIsCheckBoxChecked(false);
}, [selectedJurisdiction, setIsCheckBoxChecked]);

useEffect(() => {
if (typeof closeModal === 'function') {
setCfdState({ selectedJurisdiction: '' });
}
}, [closeModal, setCfdState]);

return (
<div
className={twMerge(
Expand Down

0 comments on commit a7d3a95

Please sign in to comment.