More fixes/patches
This commit is contained in:
parent
1f90ca2575
commit
c02ad19f2b
18 changed files with 582 additions and 239 deletions
35
utils/index.js
Normal file
35
utils/index.js
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
/**
|
||||
* Utils
|
||||
*
|
||||
* Various utilities used throughout the app. A kitchen junk drawer, if you will.
|
||||
*
|
||||
* @copyright Ryan McGrath 2018
|
||||
*/
|
||||
|
||||
import {Linking} from 'react-native';
|
||||
|
||||
export const parseSlugs = (tournament, evt) => {
|
||||
const evtSlugs = evt && evt.slug.split('/');
|
||||
const evtSlug = evt && evtSlugs.length > 0 ? evtSlugs[evtSlugs.length - 1] : null;
|
||||
const tournamentSlug = (
|
||||
tournament.slug ? tournament.slug :
|
||||
tournament.slugs && tournament.slugs.length ? tournament.slugs[0] : ''
|
||||
).replace('tournament/', '');
|
||||
|
||||
const slugs = {tournamentSlug: null, evtSlug: null};
|
||||
|
||||
if(tournamentSlug && tournamentSlug !== '')
|
||||
slugs.tournament = tournamentSlug;
|
||||
|
||||
if(evtSlug && evtSlug !== '')
|
||||
slugs.evt = evtSlug;
|
||||
|
||||
return slugs;
|
||||
};
|
||||
|
||||
export const openURL = (url) => {
|
||||
return Linking.canOpenURL(url).then(supported => {
|
||||
if(supported) Linking.openURL(url);
|
||||
else console.warn('Cannot open URL: ' + url);
|
||||
});
|
||||
};
|
||||
Reference in a new issue