Skip to content

Commit

Permalink
An error is displayed when there is a problem connecting to the backend
Browse files Browse the repository at this point in the history
  • Loading branch information
tortuvshin committed Mar 25, 2024
1 parent 155d7f1 commit 6ea9414
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/features/Core/screens/BootScreen.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect } from 'react';
import React, { useEffect, useState } from 'react';
import { SafeAreaView, View, ActivityIndicator } from 'react-native';
import { initStripe } from '@stripe/stripe-react-native';
import { hasRequiredKeys, logError } from 'utils';
Expand All @@ -20,6 +20,7 @@ const { STRIPE_KEY, APP_IDENTIFIER } = config;
* @component
*/
const BootScreen = ({ navigation }) => {
const [error, setError] = useState(null);
// If the required keys are not provided display the setup warning screen
if (!hasRequiredKeys()) {
return <SetupWarningScreen />;
Expand Down Expand Up @@ -54,6 +55,7 @@ const BootScreen = ({ navigation }) => {
}
})
.catch((error) => {
setError(error);
logError(error, '[ Error fetching storefront info! ]');
})
.finally(() => {
Expand All @@ -62,6 +64,10 @@ const BootScreen = ({ navigation }) => {
}, 300);
});

if (error) {
return <SetupWarningScreen error={error} />;
}

return (
<SafeAreaView style={tailwind('bg-white')}>
<View style={tailwind('flex items-center justify-center w-full h-full bg-white')}>
Expand Down

0 comments on commit 6ea9414

Please sign in to comment.