This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
mobile-app/src/screens/HomeScreen/components/Professions/NetworkConnectionAlert.tsx

35 lines
900 B
TypeScript
Raw Normal View History

2021-04-21 17:55:26 +00:00
import { ApolloError } from '@apollo/client';
import { useUpdateEffect } from 'react-use';
import { Alert, Linking } from 'react-native';
2021-11-07 10:11:51 +00:00
import Config from 'react-native-config';
2021-04-21 17:55:26 +00:00
import buildURL from 'utils/buildURL';
export type NetworkConnectionAlertProps = {
2021-04-21 17:55:26 +00:00
error?: ApolloError;
};
2021-04-21 17:55:26 +00:00
const NetworkConnectionAlert = ({ error }: NetworkConnectionAlertProps) => {
useUpdateEffect(() => {
if (!error || !error.networkError) {
return;
2021-04-21 17:55:26 +00:00
}
Alert.alert(
'Problem z połączeniem',
'Prosimy o sprawdzenie połączenia z internetem / spróbowanie ponownie później. Przepraszamy za utrudnienia.',
[
{
text: 'Zgłoś problem',
2021-11-07 10:11:51 +00:00
onPress: () =>
Linking.openURL(buildURL('email', Config.CONTACT_EMAIL)),
},
{ text: 'OK' },
],
);
2021-04-21 17:55:26 +00:00
}, [error]);
return null;
};
export default NetworkConnectionAlert;