add a new type to the 'buildURL' util (mail)
This commit is contained in:
parent
95f0e7402e
commit
7f13c9e8f9
|
@ -1,8 +1,9 @@
|
|||
import React from 'react';
|
||||
import { EMAIL, WEBSITE } from 'config/app';
|
||||
import buildURL from 'utils/buildURL';
|
||||
|
||||
import { ActionSheet, Icon, NativeBase } from 'native-base';
|
||||
import { Linking, StyleSheet } from 'react-native';
|
||||
import { ActionSheet, Icon, NativeBase } from 'native-base';
|
||||
|
||||
export interface MenuProps
|
||||
extends Omit<NativeBase.Icon, 'onPress' | 'type' | 'name'> {}
|
||||
|
@ -25,7 +26,7 @@ const Menu = ({ style, ...rest }: MenuProps) => {
|
|||
Linking.openURL(WEBSITE);
|
||||
break;
|
||||
case CONTACT_OPT_INDEX:
|
||||
Linking.openURL(`mailto:${EMAIL}`);
|
||||
Linking.openURL(buildURL('mail', EMAIL));
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
|
|
@ -7,6 +7,7 @@ import { useSavedQualifications } from 'libs/savedqualifications';
|
|||
import { Query, QueryProfessionsArgs } from 'libs/graphql';
|
||||
import { EMAIL } from 'config/app';
|
||||
import { QUERY_PROFESSIONS } from './queries';
|
||||
import buildURL from 'utils/buildURL';
|
||||
|
||||
import { Alert, Linking } from 'react-native';
|
||||
import { Container, Content, Spinner } from 'native-base';
|
||||
|
@ -60,7 +61,7 @@ const HomeScreen = () => {
|
|||
[
|
||||
{
|
||||
text: 'Zgłoś problem',
|
||||
onPress: () => Linking.openURL(`mailto:${EMAIL}`),
|
||||
onPress: () => Linking.openURL(buildURL('mail', EMAIL)),
|
||||
},
|
||||
{ text: 'OK' },
|
||||
],
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import React, { useRef } from 'react';
|
||||
import { createStackNavigator } from '@react-navigation/stack';
|
||||
import analytics from '@react-native-firebase/analytics';
|
||||
import { AppStackParamList, Screen } from 'config/routing';
|
||||
|
||||
|
@ -7,6 +6,7 @@ import {
|
|||
NavigationContainer,
|
||||
NavigationContainerRef,
|
||||
} from '@react-navigation/native';
|
||||
import { createStackNavigator } from '@react-navigation/stack';
|
||||
import HomeScreen from './HomeScreen/HomeScreen';
|
||||
import TestScreen from './TestScreen/TestScreen';
|
||||
|
||||
|
@ -22,7 +22,7 @@ const AppScreens = () => (
|
|||
</AppStack.Navigator>
|
||||
);
|
||||
|
||||
export default function Navigation() {
|
||||
const Navigation = () => {
|
||||
const routeNameRef = useRef<string>('');
|
||||
const navigationRef = useRef<NavigationContainerRef>(null);
|
||||
|
||||
|
@ -59,4 +59,6 @@ export default function Navigation() {
|
|||
<AppScreens />
|
||||
</NavigationContainer>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
export default Navigation;
|
||||
|
|
|
@ -2,6 +2,7 @@ import React, { Fragment } from 'react';
|
|||
import { Answer, Question as QuestionT } from 'libs/graphql';
|
||||
import { useVariables } from 'libs/native-base';
|
||||
import { EMAIL } from 'config/app';
|
||||
import buildURL from 'utils/buildURL';
|
||||
|
||||
import { Linking, StyleSheet } from 'react-native';
|
||||
import { Button, H1, Text } from 'native-base';
|
||||
|
@ -36,7 +37,7 @@ const Question = ({
|
|||
<Button
|
||||
dark
|
||||
danger
|
||||
onPress={() => Linking.openURL(`mailto:${EMAIL}`)}
|
||||
onPress={() => Linking.openURL(buildURL('mail', EMAIL))}
|
||||
>
|
||||
<Text>Zgłoś go.</Text>
|
||||
</Button>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { CDN_URI, IMAGE_RESIZING_SERVICE } from 'config/cdn';
|
||||
|
||||
const buildURL = (type: 'cdn' | 'cdnimg', path: string): string => {
|
||||
const buildURL = (type: 'cdn' | 'cdnimg' | 'mail', path: string): string => {
|
||||
switch (type) {
|
||||
case 'cdn':
|
||||
return CDN_URI + path;
|
||||
|
@ -9,6 +9,8 @@ const buildURL = (type: 'cdn' | 'cdnimg', path: string): string => {
|
|||
IMAGE_RESIZING_SERVICE +
|
||||
`?url=${CDN_URI + encodeURIComponent(path)}&w=640&q=75`
|
||||
);
|
||||
case 'mail':
|
||||
return `mailto:${path}`;
|
||||
}
|
||||
return path;
|
||||
};
|
||||
|
|
Reference in New Issue