diff --git a/domains/Auth/SignIn/SignInFailedModal/index.js b/domains/Auth/SignIn/SignInFailedModal/index.js deleted file mode 100644 index c6d50a559..000000000 --- a/domains/Auth/SignIn/SignInFailedModal/index.js +++ /dev/null @@ -1,26 +0,0 @@ -import * as React from 'react'; -import { View } from 'react-native'; -import { Button, Paragraph, Dialog, Portal } from 'react-native-paper'; - -const SignInFailedModal = ({ - visible, setVisible -}) => { - - return ( - - - - Failed Sign In - - Your username or password may be incorrect, please try again. - - - - - - - - ); -}; - -export default SignInFailedModal; \ No newline at end of file diff --git a/domains/Auth/SignIn/index.js b/domains/Auth/SignIn/index.js index d915f3785..e33a12285 100644 --- a/domains/Auth/SignIn/index.js +++ b/domains/Auth/SignIn/index.js @@ -14,21 +14,22 @@ import { import { Checkbox, Button, } from 'react-native-paper'; + +import * as Network from 'expo-network'; + import { Formik } from 'formik'; import * as yup from 'yup'; -import * as Network from 'expo-network'; + import { retrieveSignInFunction, retrieveCurrentUserFunction } from '../../../services/parse/auth'; -import FormInput from '../../../components/FormikFields/FormInput'; -import LanguagePicker from '../../../components/LanguagePicker'; -import CredentialsModal from './CredentialsModal'; -import { storeData, getData, deleteData } from '../../../modules/async-storage'; -import SignInFailedModal from './SignInFailedModal'; +import { storeData, getData, deleteData } from '../../../modules/async-storage'; import I18n from '../../../modules/i18n'; - -// STYLING import { theme } from '../../../modules/theme'; +import FormInput from '../../../components/FormikFields/FormInput'; +import LanguagePicker from '../../../components/LanguagePicker'; +import CredentialsModal from './CredentialsModal'; + const validationSchema = yup.object().shape({ username: yup .string() @@ -42,26 +43,13 @@ const validationSchema = yup.object().shape({ }); const SignIn = ({ navigation }) => { - const [checked, setChecked] = React.useState(false); + const [checked, setChecked] = useState(false); const [modalVisible, setModalVisible] = useState(false); const [user, setUser] = useState(null); const [language, setLanguage] = useState('en'); - const [failedModalVisible, setFailedModalVisible] = useState(false); - const load = false; - /* - THIS FUNCTION WILL CHANGE failedModalVisible to true to display the modal. - IT IS BEING CALLED ON LINE 161 of this file - */ - const handleFailedAttempt = () => { - if (failedModalVisible === false) { - console.log("SETTING") - setFailedModalVisible(true); - } - } - useEffect(() => { getData('credentials').then((values) => { setUser(values); @@ -71,6 +59,14 @@ const SignIn = ({ navigation }) => { }); }, [load]); + const handleFailedAttempt = (err) => { + const errorMsg = err.toString().slice(-26) || ''; + Alert.alert( + `${errorMsg}`, + 'Your username or password may be incorrect, please try again.', + { cancelable: true } + ); + }; const handleSignUp = () => { navigation.navigate('Sign Up'); }; @@ -101,7 +97,6 @@ const SignIn = ({ navigation }) => { I18n.locale = lang; }; - // checks whether user is connected to internet, return true if connected, false otherwise async function checkOnlineStatus() { const status = await Network.getNetworkStateAsync(); const { isConnected } = status; @@ -154,14 +149,8 @@ const SignIn = ({ navigation }) => { handleSaveCredentials(values); }); navigation.navigate('Root'); - }, (error) => { - // eslint-disable-next-line - console.log(error); - // handleFailedAttempt(setTest, test) - handleFailedAttempt(); - console.log(failedModalVisible) - - // console.log(visible) + }, (err) => { + handleFailedAttempt(err); }); } else { // offline @@ -202,13 +191,13 @@ const SignIn = ({ navigation }) => { secureTextEntry /> ) : ( - - )} + + )} { {formikProps.isSubmitting ? ( ) : ( - - )} + + )} @@ -237,10 +226,7 @@ const SignIn = ({ navigation }) => { setModalVisible={setModalVisible} navigation={navigation} /> - + )} diff --git a/domains/DataCollection/FormGallery/index.js b/domains/DataCollection/FormGallery/index.js index 74ecf4c20..de3afd82c 100644 --- a/domains/DataCollection/FormGallery/index.js +++ b/domains/DataCollection/FormGallery/index.js @@ -80,5 +80,5 @@ const styles = StyleSheet.create({ buttonTextBig: { fontSize: 16 } -}) +}); export default FormGallery; diff --git a/domains/DataCollection/index.js b/domains/DataCollection/index.js index 7827b8189..69931c897 100644 --- a/domains/DataCollection/index.js +++ b/domains/DataCollection/index.js @@ -20,7 +20,7 @@ import { getData } from '../../modules/async-storage'; import FindResidents from '../../components/FindResidents'; import { retrieveCurrentUserFunction } from '../../services/parse/auth'; -import { customQueryService } from '../../services/parse/crud'; +import customQueryService from '../../services/parse/crud'; import ComingSoonSVG from '../../assets/graphics/static/Adventurer.svg'; import FindRecordSVG from '../../assets/graphics/static/Find-Record-Icon.svg'; diff --git a/services/parse/crud/custom-queries/index.js b/services/parse/crud/custom-queries/index.js index cbdc0ebe1..e256e5786 100644 --- a/services/parse/crud/custom-queries/index.js +++ b/services/parse/crud/custom-queries/index.js @@ -37,4 +37,4 @@ function customQueryService(offset, limit, parseModel, parseColumn, parseParam) }); } -export { customQueryService }; +export default customQueryService; diff --git a/services/parse/crud/index.js b/services/parse/crud/index.js index aad8964b0..2848867bd 100644 --- a/services/parse/crud/index.js +++ b/services/parse/crud/index.js @@ -1,5 +1,5 @@ import { Parse } from 'parse/react-native'; -import { customQueryService } from './custom-queries'; +import customQueryService from './custom-queries'; function retrieveHelloFunction() { Parse.Cloud.run('hello').then((result) => result);