diff --git a/src/components/BookTravelButton.tsx b/src/components/BookTravelButton.tsx index 5df89fdb1450..c757fc41e209 100644 --- a/src/components/BookTravelButton.tsx +++ b/src/components/BookTravelButton.tsx @@ -17,6 +17,7 @@ import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; +import isLoadingOnyxValue from '@src/types/utils/isLoadingOnyxValue'; import Button from './Button'; import ConfirmModal from './ConfirmModal'; import DotIndicatorMessage from './DotIndicatorMessage'; @@ -48,10 +49,11 @@ function BookTravelButton({text, shouldRenderErrorMessageBelowButton = false, se const styles = useThemeStyles(); const StyleUtils = useStyleUtils(); const {translate} = useLocalize(); - const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID, {canBeMissing: false}); + const [activePolicyID, activePolicyIDMetadata] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID, {canBeMissing: true}); const [account] = useOnyx(ONYXKEYS.ACCOUNT, {canBeMissing: true}); const isUserValidated = account?.validated ?? false; const primaryLogin = account?.primaryLogin ?? ''; + const isLoading = isLoadingOnyxValue(activePolicyIDMetadata); const policy = usePolicy(activePolicyID); const [errorMessage, setErrorMessage] = useState(''); @@ -172,6 +174,8 @@ function BookTravelButton({text, shouldRenderErrorMessageBelowButton = false, se onPress={bookATrip} accessibilityLabel={translate('travel.bookTravel')} style={styles.w100} + isLoading={isLoading} + isDisabled={!isLoading && !activePolicyID} success large />