-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Guilherme Banci <guibanci@gmail.com>
- Loading branch information
Showing
6 changed files
with
129 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* eslint-disable no-param-reassign */ | ||
const phoneMask = (text) => { | ||
text = text.replace(/\D/g, ''); | ||
text = text.replace(/^(\d{2})(\d)/g, '($1) $2'); | ||
text = text.replace(/(\d)(\d{4})$/, '$1-$2'); | ||
return text; | ||
}; | ||
|
||
export default phoneMask; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import axios from 'axios'; | ||
import AsyncStorage from '@react-native-community/async-storage'; | ||
import Config from 'react-native-config'; | ||
|
||
const instance = axios.create({ | ||
baseURL: Config.API, | ||
}); | ||
|
||
instance.interceptors.request.use(async (config) => ({ | ||
...config, | ||
headers: { | ||
...config.headers, | ||
Authorization: await AsyncStorage.getItem('access_token'), | ||
}, | ||
})); | ||
|
||
export default instance; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import axios from 'axios'; | ||
import AsyncStorage from '@react-native-community/async-storage'; | ||
import Config from 'react-native-config'; | ||
|
||
const instance = axios.create({ | ||
baseURL: Config.API2, | ||
}); | ||
|
||
instance.interceptors.request.use(async (config) => ({ | ||
...config, | ||
headers: { | ||
...config.headers, | ||
Authorization: await AsyncStorage.getItem('access_token'), | ||
}, | ||
})); | ||
|
||
export default instance; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
export default { | ||
font: { | ||
family: '', | ||
sizes: { | ||
S: 12, | ||
SM: 14, | ||
M: 17, | ||
ML: 20, | ||
L: 22, | ||
LX: 25, | ||
X: 28, | ||
}, | ||
}, | ||
colors: { | ||
primary: '#448AFF', | ||
red: '#ff0000', | ||
grey: '#9E9E9E', | ||
white: '#ffffff', | ||
black: '#000000', | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import lodashIsEmpty from 'lodash/isEmpty'; | ||
|
||
/** | ||
* Validate if value is a valid date | ||
* @param {String} value Param to do valid | ||
* @return {Object} | ||
* @property {Boolean} isValid `true` if value is a valid value | ||
* @property {String} errorText message of an invalid rule | ||
* */ | ||
const phone = (value) => { | ||
const errorObject = { | ||
isValid: false, | ||
errorText: 'Telefone em formato inválido', | ||
}; | ||
|
||
const successObject = { | ||
isValid: true, | ||
}; | ||
|
||
if (lodashIsEmpty(value)) { | ||
return successObject; | ||
} | ||
|
||
const regex = /\d+/g; | ||
|
||
let phoneNumber = value.match(regex); | ||
|
||
phoneNumber = phoneNumber ? phoneNumber.join('') : ''; | ||
|
||
// Length including region identifier | ||
if (phoneNumber.length !== 11 && phoneNumber.length !== 13) { | ||
return errorObject; | ||
} | ||
|
||
return successObject; | ||
}; | ||
|
||
export default phone; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import lodashIsEmpty from 'lodash/isEmpty'; | ||
|
||
/** | ||
* Validate if value is true | ||
* @param {String} value Param to do valid | ||
* | ||
* @return {Object} | ||
* @property {Boolean} isValid `true` if value is a valid value | ||
* @property {String} errorText message of an invalid rule | ||
* */ | ||
const required = (value, errorMessage) => { | ||
const errorText = errorMessage || 'Este campo é obrigatório'; | ||
const errorObject = { | ||
isValid: false, | ||
errorText, | ||
}; | ||
|
||
if (lodashIsEmpty(value)) { | ||
return errorObject; | ||
} | ||
|
||
return { | ||
isValid: true, | ||
}; | ||
}; | ||
|
||
export default required; |