diff --git a/CustomerApp/app.json b/CustomerApp/app.json index ca35c33..c1217fa 100644 --- a/CustomerApp/app.json +++ b/CustomerApp/app.json @@ -1,7 +1,7 @@ { "expo": { "name": "Enatega", - "version": "1.0.19", + "version": "1.0.20", "scheme": "enategasinglevendor", "description": "Enatega is a starter kit food ordering app built in React Native using Expo for IOS and Android. It's made keeping good aesthetics in mind as well keeping the best coding practices in mind. Its fully customisable to easily help you in your next food delivery project. https://market.nativebase.io/view/react-native-food-delivery-backend-app", "slug": "enategasinglevendor", diff --git a/CustomerApp/src/.gitignore b/CustomerApp/src/.gitignore new file mode 100644 index 0000000..30bc162 --- /dev/null +++ b/CustomerApp/src/.gitignore @@ -0,0 +1 @@ +/node_modules \ No newline at end of file diff --git a/CustomerApp/src/screens/CreateAccount/CreateAccount.js b/CustomerApp/src/screens/CreateAccount/CreateAccount.js index c72bb6c..4276ae9 100644 --- a/CustomerApp/src/screens/CreateAccount/CreateAccount.js +++ b/CustomerApp/src/screens/CreateAccount/CreateAccount.js @@ -62,19 +62,26 @@ const CreateAccount = () => { } async function onCompleted(data) { - try { - const trackingOpts = { - id: data.login.userId, - usernameOrEmail: data.login.email, - }; - Analytics.identify(data.login.userId, trackingOpts); - Analytics.track(Analytics.events.USER_CREATED_ACCOUNT, trackingOpts); - setTokenAsync(data.login.token); - navigation.navigate(NAVIGATION_SCREEN.Menu); - } catch (e) { - console.log(e); - } finally { + if (!data.login.is_active) { + FlashMessage({ + message: "Can't Login,This Account is Deleted!", + }); setLoading(false); + } else { + try { + const trackingOpts = { + id: data.login.userId, + usernameOrEmail: data.login.email, + }; + Analytics.identify(data.login.userId, trackingOpts); + Analytics.track(Analytics.events.USER_CREATED_ACCOUNT, trackingOpts); + setTokenAsync(data.login.token); + navigation.navigate(NAVIGATION_SCREEN.Menu); + } catch (e) { + console.log(e); + } finally { + setLoading(false); + } } } function onError(error) { @@ -139,6 +146,7 @@ const CreateAccount = () => { }; mutateLogin(user); } + loginButtonSetter("Apple"); // signed in } catch (e) { diff --git a/CustomerApp/src/screens/Login/Login.js b/CustomerApp/src/screens/Login/Login.js index d3ee6c9..952bc2c 100755 --- a/CustomerApp/src/screens/Login/Login.js +++ b/CustomerApp/src/screens/Login/Login.js @@ -49,7 +49,7 @@ function Login() { const [loading, setLoading] = useState(false); const [password, setPassword] = useState("123123"); const [emailError, setEmailError] = useState(""); - const { setTokenAsync } = useContext(UserContext); + const { setTokenAsync, logout } = useContext(UserContext); const [passwordError, setPasswordError] = useState(null); const [mutate] = useMutation(LOGIN, { onCompleted, onError }); @@ -99,34 +99,28 @@ function Login() { return result; } async function onCompleted(data) { - try { - const trackingOpts = { - id: data.login.userId, - usernameOrEmail: data.login.email, - }; - - Analytics.identify(data.login.userId, trackingOpts); - Analytics.track(Analytics.events.USER_LOGGED_IN, trackingOpts); - setTokenAsync(data.login.token); - console.log("Data Before Navigation:", data.login.is_active); - if (!data.login.is_active) { - FlashMessage({ - message: "Can't Login,This Account is Deleted!", - }); - } - { - data.login.is_active && navigation.navigate(NAVIGATION_SCREEN.Menu); - } - - // { - // FlashMessage({ - // message: "Can't Login,This Account is Deleted!", - // }); - // } - } catch (e) { - console.log(e); - } finally { + if (!data.login.is_active) { + FlashMessage({ + message: "Can't Login,This Account is Deleted!", + }); setLoading(false); + } else { + try { + const trackingOpts = { + id: data.login.userId, + usernameOrEmail: data.login.email, + }; + + Analytics.identify(data.login.userId, trackingOpts); + Analytics.track(Analytics.events.USER_LOGGED_IN, trackingOpts); + setTokenAsync(data.login.token); + console.log("Data Before Navigation:", data.login.is_active); + navigation.navigate(NAVIGATION_SCREEN.Menu); + } catch (e) { + console.log(e); + } finally { + setLoading(false); + } } } function onError(error) { diff --git a/CustomerApp/src/screens/Profile/Profile.js b/CustomerApp/src/screens/Profile/Profile.js index 55d4925..77a14b5 100644 --- a/CustomerApp/src/screens/Profile/Profile.js +++ b/CustomerApp/src/screens/Profile/Profile.js @@ -1,139 +1,139 @@ -import { useMutation } from '@apollo/react-hooks' -import { MaterialCommunityIcons } from '@expo/vector-icons' -import { useNavigation, useRoute, useTheme } from '@react-navigation/native' -import gql from 'graphql-tag' +import { useMutation } from "@apollo/react-hooks"; +import { MaterialCommunityIcons } from "@expo/vector-icons"; +import { useNavigation, useRoute, useTheme } from "@react-navigation/native"; +import gql from "graphql-tag"; import React, { useContext, useEffect, useLayoutEffect, useRef, - useState -} from 'react' + useState, +} from "react"; import { KeyboardAvoidingView, Platform, ScrollView, TouchableOpacity, - View -} from 'react-native' -import { TextField } from 'react-native-material-textfield' -import i18n from '../../../i18n' -import { updateUser } from '../../apollo/server' + View, +} from "react-native"; +import { TextField } from "react-native-material-textfield"; +import i18n from "../../../i18n"; +import { updateUser } from "../../apollo/server"; import { FlashMessage, RightButton, TextDefault, - WrapperView -} from '../../components' -import UserContext from '../../context/User' -import { alignment } from '../../utils/alignment' -import { ICONS_NAME } from '../../utils/constant' -import { moderateScale, scale } from '../../utils/scaling' -import { textStyles } from '../../utils/textStyles' -import ChangePassword from './ChangePassword' -import useStyle from './styles' + WrapperView, +} from "../../components"; +import UserContext from "../../context/User"; +import { alignment } from "../../utils/alignment"; +import { ICONS_NAME } from "../../utils/constant"; +import { moderateScale, scale } from "../../utils/scaling"; +import { textStyles } from "../../utils/textStyles"; +import ChangePassword from "./ChangePassword"; +import useStyle from "./styles"; const UPDATEUSER = gql` ${updateUser} -` +`; function Profile() { - const refName = useRef() - const route = useRoute() - const styles = useStyle() - const refPhone = useRef(null) - const { colors } = useTheme() - const navigation = useNavigation() + const refName = useRef(); + const route = useRoute(); + const styles = useStyle(); + const refPhone = useRef(null); + const { colors } = useTheme(); + const navigation = useNavigation(); - const [nameError, setNameError] = useState('') - const [phoneError, setPhoneError] = useState('') - const [toggleView, setToggleView] = useState(true) - const [modelVisible, setModalVisible] = useState(false) + const [nameError, setNameError] = useState(""); + const [phoneError, setPhoneError] = useState(""); + const [toggleView, setToggleView] = useState(true); + const [modelVisible, setModalVisible] = useState(false); - const { profile } = useContext(UserContext) - const backScreen = route.params ? route.params.backScreen : null + const { profile } = useContext(UserContext); + const backScreen = route.params ? route.params.backScreen : null; const [mutate, { loading: loadingMutation }] = useMutation(UPDATEUSER, { onCompleted, - onError - }) + onError, + }); useLayoutEffect(() => { navigation.setOptions({ - title: 'Profile', + title: "Profile", headerRight: () => ( - ) - }) - }, [navigation, toggleView]) + ), + }); + }, [navigation, toggleView]); useEffect(() => { if (backScreen) { - viewHideAndShow() - setPhoneError('Phone number is required') + viewHideAndShow(); + setPhoneError("Phone number is required"); FlashMessage({ - message: 'Phone Number is missing' - }) + message: "Phone Number is missing", + }); } - }, [backScreen]) + }, [backScreen]); function viewHideAndShow() { - setToggleView(prev => !prev) + setToggleView((prev) => !prev); } function onCompleted({ updateUser }) { if (updateUser) { FlashMessage({ - message: "User's Info Updated" - }) + message: "User's Info Updated", + }); if (backScreen) { - navigation.goBack() + navigation.goBack(); } } } function validateInfo() { // clear errors - setNameError('') - setPhoneError('') + setNameError(""); + setPhoneError(""); - const name = refName.current.value() - const phone = refPhone.current.value() + const name = refName.current.value(); + const phone = refPhone.current.value(); if (name === profile.name && phone === profile.phone && phone.length > 0) { - return + return; } - let res = true + let res = true; if (!name.trim()) { - refName.current.focus() - setNameError('Name is required') - res = false + refName.current.focus(); + setNameError("Name is required"); + res = false; } - const num = phone.trim().replace('.', '') + const num = phone.trim().replace(".", ""); if (num.length < 11 || num.length > 15 || isNaN(num)) { - setPhoneError('Minimum 11 and maximum 15 characters allowed') + setPhoneError("Minimum 11 and maximum 15 characters allowed"); if (res) { - refPhone.current.focus() + refPhone.current.focus(); } - res = false + res = false; } - return res + return res; } function onError(error) { try { if (error.graphQLErrors) { FlashMessage({ - message: error.graphQLErrors[0].message - }) + message: error.graphQLErrors[0].message, + }); } else if (error.networkError) { FlashMessage({ - message: error.networkError.result.errors[0].message - }) + message: error.networkError.result.errors[0].message, + }); } } catch (err) {} } @@ -142,7 +142,7 @@ function Profile() { return ( setModalVisible(true)} - style={styles.changePassword}> + style={styles.changePassword} + > Change Password - ) + ); } return ( @@ -230,29 +231,31 @@ function Profile() { { - setModalVisible(false) + setModalVisible(false); }} /> + behavior={Platform.OS === "ios" ? "padding" : null} + style={styles.flex} + > + borderStyle: "dashed", + }} + > {profile.name.substr(0, 1).toUpperCase()} @@ -266,13 +269,13 @@ function Profile() { @@ -344,29 +347,34 @@ function Profile() { mutate({ variables: { name: refName.current.value(), - phone: refPhone.current.value() - } - }) + phone: refPhone.current.value(), + is_active: true, + }, + }); } - }}> + }} + > - {i18n.t('saveBtn')} + style={[alignment.MTsmall, alignment.MBsmall]} + > + {i18n.t("saveBtn")} + onPress={viewHideAndShow} + > - {'Cancel'} + style={[alignment.MTsmall, alignment.MBsmall]} + > + {"Cancel"} @@ -375,14 +383,15 @@ function Profile() { + style={alignment.MBsmall} + > All rights are reserved by Enatega - ) + ); } -export default Profile +export default Profile; diff --git a/CustomerApp/src/screens/Settings/Settings.js b/CustomerApp/src/screens/Settings/Settings.js index 9e3bf82..e0504e5 100644 --- a/CustomerApp/src/screens/Settings/Settings.js +++ b/CustomerApp/src/screens/Settings/Settings.js @@ -70,8 +70,12 @@ function Settings() { const { profile, logout } = useContext(UserContext); const [languageName, languageNameSetter] = useState("English"); - const [offerNotification, offerNotificationSetter] = useState(); - const [orderNotification, orderNotificationSetter] = useState(); + const [offerNotification, offerNotificationSetter] = useState( + profile.is_offer_notification + ); + const [orderNotification, orderNotificationSetter] = useState( + profile.is_order_notification + ); const [activeRadio, activeRadioSetter] = useState(languageTypes[0].index); // eslint-disable-next-line no-unused-vars const [appState, setAppState] = useState(AppState.currentState); @@ -207,19 +211,14 @@ function Settings() { }, }); } - // console.log(profile.name); - // console.log(profile.phone); - // console.log(profile.is_active); - //console.log(profile.is_activated); + async function updateUserInformation() { + console.log("profile data", profile); updateUserInfo({ variables: { - //updateUserInput: { name: profile.name, phone: profile.phone, is_active: false, - //is_activated: false, - // }, }, }); }