From dd3d66fe85794ce97960cb9d2b609792ac71fee8 Mon Sep 17 00:00:00 2001 From: cretadn22 Date: Thu, 24 Oct 2024 00:02:18 +0700 Subject: [PATCH 1/4] remove state on modal --- .../Security/AddDelegate/ConfirmDelegatePage.tsx | 13 ++++++------- .../Security/AddDelegate/DelegateMagicCodeModal.tsx | 5 +++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/pages/settings/Security/AddDelegate/ConfirmDelegatePage.tsx b/src/pages/settings/Security/AddDelegate/ConfirmDelegatePage.tsx index c769734688c6..bc6f79d40777 100644 --- a/src/pages/settings/Security/AddDelegate/ConfirmDelegatePage.tsx +++ b/src/pages/settings/Security/AddDelegate/ConfirmDelegatePage.tsx @@ -72,13 +72,12 @@ function ConfirmDelegatePage({route}: ConfirmDelegatePageProps) { onPress={() => Navigation.navigate(ROUTES.SETTINGS_DELEGATE_ROLE.getRoute(login, role))} shouldShowRightIcon /> - - {isValidateCodeActionModalVisible && ( - - )} + ); } diff --git a/src/pages/settings/Security/AddDelegate/DelegateMagicCodeModal.tsx b/src/pages/settings/Security/AddDelegate/DelegateMagicCodeModal.tsx index 64b8d27dfd73..d456902c9b3a 100644 --- a/src/pages/settings/Security/AddDelegate/DelegateMagicCodeModal.tsx +++ b/src/pages/settings/Security/AddDelegate/DelegateMagicCodeModal.tsx @@ -14,12 +14,13 @@ import ROUTES from '@src/ROUTES'; type DelegateMagicCodeModalProps = { login: string; role: ValueOf; + isValidateCodeActionModalVisible: boolean; + setIsValidateCodeActionModalVisible: (isValidateCodeActionModalVisible: boolean) => void; }; -function DelegateMagicCodeModal({login, role}: DelegateMagicCodeModalProps) { +function DelegateMagicCodeModal({login, role, isValidateCodeActionModalVisible, setIsValidateCodeActionModalVisible}: DelegateMagicCodeModalProps) { const {translate} = useLocalize(); const [account] = useOnyx(ONYXKEYS.ACCOUNT); - const [isValidateCodeActionModalVisible, setIsValidateCodeActionModalVisible] = useState(true); const currentDelegate = account?.delegatedAccess?.delegates?.find((d) => d.email === login); const validateLoginError = ErrorUtils.getLatestErrorField(currentDelegate, 'addDelegate'); From baa476f5e8728a928ee2f9fed7089a91cf96cf48 Mon Sep 17 00:00:00 2001 From: cretadn22 Date: Thu, 24 Oct 2024 00:20:32 +0700 Subject: [PATCH 2/4] minor update --- src/libs/Permissions.ts | 2 +- .../settings/Security/AddDelegate/DelegateMagicCodeModal.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/Permissions.ts b/src/libs/Permissions.ts index 8de3de347f7e..24de2e612208 100644 --- a/src/libs/Permissions.ts +++ b/src/libs/Permissions.ts @@ -4,7 +4,7 @@ import type {IOUType} from '@src/CONST'; import type Beta from '@src/types/onyx/Beta'; function canUseAllBetas(betas: OnyxEntry): boolean { - return true || !!betas?.includes(CONST.BETAS.ALL); + return !!betas?.includes(CONST.BETAS.ALL); } function canUseDefaultRooms(betas: OnyxEntry): boolean { diff --git a/src/pages/settings/Security/AddDelegate/DelegateMagicCodeModal.tsx b/src/pages/settings/Security/AddDelegate/DelegateMagicCodeModal.tsx index 0dfd30d06b49..9f5b46726502 100644 --- a/src/pages/settings/Security/AddDelegate/DelegateMagicCodeModal.tsx +++ b/src/pages/settings/Security/AddDelegate/DelegateMagicCodeModal.tsx @@ -1,4 +1,4 @@ -import React, {useEffect, useState} from 'react'; +import React, {useEffect} from 'react'; import {useOnyx} from 'react-native-onyx'; import type {ValueOf} from 'type-fest'; import ValidateCodeActionModal from '@components/ValidateCodeActionModal'; From d37bdb29e89315a4c52713f0b89010a8196dc62b Mon Sep 17 00:00:00 2001 From: cretadn22 Date: Tue, 29 Oct 2024 18:13:06 +0700 Subject: [PATCH 3/4] adjust --- .../settings/Security/AddDelegate/ConfirmDelegatePage.tsx | 2 +- .../settings/Security/AddDelegate/DelegateMagicCodeModal.tsx | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/pages/settings/Security/AddDelegate/ConfirmDelegatePage.tsx b/src/pages/settings/Security/AddDelegate/ConfirmDelegatePage.tsx index 4874485c1bf6..5fcdb9ad6c93 100644 --- a/src/pages/settings/Security/AddDelegate/ConfirmDelegatePage.tsx +++ b/src/pages/settings/Security/AddDelegate/ConfirmDelegatePage.tsx @@ -77,13 +77,13 @@ function ConfirmDelegatePage({route}: ConfirmDelegatePageProps) { login={login} role={role} onClose={() => { + setIsValidateCodeActionModalVisible(false); if (!showValidateActionModal) { return; } Navigation.navigate(ROUTES.SETTINGS_SECURITY); }} isValidateCodeActionModalVisible={isValidateCodeActionModalVisible} - setIsValidateCodeActionModalVisible={setIsValidateCodeActionModalVisible} /> ); diff --git a/src/pages/settings/Security/AddDelegate/DelegateMagicCodeModal.tsx b/src/pages/settings/Security/AddDelegate/DelegateMagicCodeModal.tsx index 9f5b46726502..76c96d9121b1 100644 --- a/src/pages/settings/Security/AddDelegate/DelegateMagicCodeModal.tsx +++ b/src/pages/settings/Security/AddDelegate/DelegateMagicCodeModal.tsx @@ -15,11 +15,10 @@ type DelegateMagicCodeModalProps = { login: string; role: ValueOf; isValidateCodeActionModalVisible: boolean; - setIsValidateCodeActionModalVisible: (isValidateCodeActionModalVisible: boolean) => void; onClose?: () => void; }; -function DelegateMagicCodeModal({login, role, onClose, isValidateCodeActionModalVisible, setIsValidateCodeActionModalVisible}: DelegateMagicCodeModalProps) { +function DelegateMagicCodeModal({login, role, onClose, isValidateCodeActionModalVisible}: DelegateMagicCodeModalProps) { const {translate} = useLocalize(); const [account] = useOnyx(ONYXKEYS.ACCOUNT); @@ -37,7 +36,6 @@ function DelegateMagicCodeModal({login, role, onClose, isValidateCodeActionModal const onBackButtonPress = () => { onClose?.(); - setIsValidateCodeActionModalVisible(false); }; const clearError = () => { From a06770065da2a8b4a28f62198aa667d0d0e1c487 Mon Sep 17 00:00:00 2001 From: cretadn22 Date: Thu, 31 Oct 2024 00:20:16 +0700 Subject: [PATCH 4/4] fix comment --- src/pages/settings/Security/AddDelegate/ConfirmDelegatePage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/settings/Security/AddDelegate/ConfirmDelegatePage.tsx b/src/pages/settings/Security/AddDelegate/ConfirmDelegatePage.tsx index 5fcdb9ad6c93..8dd3996a769a 100644 --- a/src/pages/settings/Security/AddDelegate/ConfirmDelegatePage.tsx +++ b/src/pages/settings/Security/AddDelegate/ConfirmDelegatePage.tsx @@ -77,8 +77,8 @@ function ConfirmDelegatePage({route}: ConfirmDelegatePageProps) { login={login} role={role} onClose={() => { - setIsValidateCodeActionModalVisible(false); if (!showValidateActionModal) { + setIsValidateCodeActionModalVisible(false); return; } Navigation.navigate(ROUTES.SETTINGS_SECURITY);