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

import { ApolloError } from '@apollo/client';
import { useUpdateEffect } from 'react-use';
import { Alert, Linking } from 'react-native';
import Config from 'react-native-config';
import buildURL from 'utils/buildURL';
export type NetworkConnectionAlertProps = {
error?: ApolloError;
};
const NetworkConnectionAlert = ({ error }: NetworkConnectionAlertProps) => {
useUpdateEffect(() => {
if (!error || !error.networkError) {
return;
}
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',
onPress: () =>
Linking.openURL(buildURL('email', Config.CONTACT_EMAIL)),
},
{ text: 'OK' },
],
);
}, [error]);
return null;
};
export default NetworkConnectionAlert;