Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fallback primaryLogin with session's email for Book Travel #57560

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/components/BookTravelButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ function BookTravelButton({text}: BookTravelButtonProps) {
const policy = usePolicy(activePolicyID);
const [errorMessage, setErrorMessage] = useState('');
const [travelSettings] = useOnyx(ONYXKEYS.NVP_TRAVEL_SETTINGS);
const [account] = useOnyx(ONYXKEYS.ACCOUNT);
const primaryLogin = account?.primaryLogin;
const [primaryLogin] = useOnyx(ONYXKEYS.ACCOUNT, {selector: (account) => account?.primaryLogin});
const [sessionEmail] = useOnyx(ONYXKEYS.SESSION, {selector: (session) => session?.email});
const primaryContactMethod = primaryLogin ?? sessionEmail ?? '';
const {setRootStatusBarEnabled} = useContext(CustomStatusBarAndBackgroundContext);
const [isMaintenanceModalVisible, setMaintenanceModalVisibility] = useState(false);

Expand All @@ -61,7 +62,7 @@ function BookTravelButton({text}: BookTravelButtonProps) {
}

// The primary login of the user is where Spotnana sends the emails with booking confirmations, itinerary etc. It can't be a phone number.
if (!primaryLogin || Str.isSMSLogin(primaryLogin)) {
if (!primaryContactMethod || Str.isSMSLogin(primaryContactMethod)) {
setErrorMessage(translate('travel.phoneError'));
return;
}
Expand Down Expand Up @@ -111,7 +112,7 @@ function BookTravelButton({text}: BookTravelButtonProps) {
Navigation.navigate(ROUTES.TRAVEL_DOMAIN_SELECTOR);
}
}
}, [policy, wasNewDotLaunchedJustForTravel, travelSettings, translate, primaryLogin, setRootStatusBarEnabled]);
}, [policy, wasNewDotLaunchedJustForTravel, travelSettings, translate, primaryContactMethod, setRootStatusBarEnabled]);

return (
<>
Expand Down
Loading