aboutsummaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorGravatar piotrruss <mail@pruss.it> 2022-05-22 18:11:30 +0100
committerGravatar piotrruss <mail@pruss.it> 2022-05-22 18:11:30 +0100
commit1173480fd93a56fa60333c01ffc70b67db82826a (patch)
tree9f4732cc671be49aece29d6bdfbcdc77b211dd67 /utils
parent994bc43d488eefc0ee39f39dd7fae5515322b17b (diff)
downloadnotes_mobile-1173480fd93a56fa60333c01ffc70b67db82826a.tar.gz
notes_mobile-1173480fd93a56fa60333c01ffc70b67db82826a.tar.bz2
notes_mobile-1173480fd93a56fa60333c01ffc70b67db82826a.zip
added loader
Diffstat (limited to 'utils')
-rw-r--r--utils/helpers.jsx4
1 files changed, 3 insertions, 1 deletions
diff --git a/utils/helpers.jsx b/utils/helpers.jsx
index 9e130dc..62d740c 100644
--- a/utils/helpers.jsx
+++ b/utils/helpers.jsx
@@ -2,7 +2,8 @@ import AsyncStorage from '@react-native-async-storage/async-storage'
import { Alert } from 'react-native';
import { login, getNote, editNote, createNote, removeNote } from './api'
-export const handleLogin = async ({ email, password, setSession, showError }) => {
+export const handleLogin = async ({ email, password, setSession, setLoading, showError }) => {
+ setLoading(true)
try {
const response = await login({ email, password })
const cookies = response.headers?.map?.['set-cookie']
@@ -12,6 +13,7 @@ export const handleLogin = async ({ email, password, setSession, showError }) =>
setSession({ ...data, cookies })
}
} catch(e) {
+ setLoading(false)
showError('Error while logging in')
}
}