Delete Button working on both Android and ios
This commit is contained in:
parent
c441ebfd13
commit
de0c5dd168
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"expo": {
|
"expo": {
|
||||||
"name": "Enatega",
|
"name": "Enatega",
|
||||||
"version": "1.0.19",
|
"version": "1.0.20",
|
||||||
"scheme": "enategasinglevendor",
|
"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",
|
"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",
|
"slug": "enategasinglevendor",
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
/node_modules
|
|
@ -62,19 +62,26 @@ const CreateAccount = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onCompleted(data) {
|
async function onCompleted(data) {
|
||||||
try {
|
if (!data.login.is_active) {
|
||||||
const trackingOpts = {
|
FlashMessage({
|
||||||
id: data.login.userId,
|
message: "Can't Login,This Account is Deleted!",
|
||||||
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);
|
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) {
|
function onError(error) {
|
||||||
|
@ -139,6 +146,7 @@ const CreateAccount = () => {
|
||||||
};
|
};
|
||||||
mutateLogin(user);
|
mutateLogin(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
loginButtonSetter("Apple");
|
loginButtonSetter("Apple");
|
||||||
// signed in
|
// signed in
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
@ -49,7 +49,7 @@ function Login() {
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [password, setPassword] = useState("123123");
|
const [password, setPassword] = useState("123123");
|
||||||
const [emailError, setEmailError] = useState("");
|
const [emailError, setEmailError] = useState("");
|
||||||
const { setTokenAsync } = useContext(UserContext);
|
const { setTokenAsync, logout } = useContext(UserContext);
|
||||||
const [passwordError, setPasswordError] = useState(null);
|
const [passwordError, setPasswordError] = useState(null);
|
||||||
|
|
||||||
const [mutate] = useMutation(LOGIN, { onCompleted, onError });
|
const [mutate] = useMutation(LOGIN, { onCompleted, onError });
|
||||||
|
@ -99,34 +99,28 @@ function Login() {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
async function onCompleted(data) {
|
async function onCompleted(data) {
|
||||||
try {
|
if (!data.login.is_active) {
|
||||||
const trackingOpts = {
|
FlashMessage({
|
||||||
id: data.login.userId,
|
message: "Can't Login,This Account is Deleted!",
|
||||||
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 {
|
|
||||||
setLoading(false);
|
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) {
|
function onError(error) {
|
||||||
|
|
|
@ -1,139 +1,139 @@
|
||||||
import { useMutation } from '@apollo/react-hooks'
|
import { useMutation } from "@apollo/react-hooks";
|
||||||
import { MaterialCommunityIcons } from '@expo/vector-icons'
|
import { MaterialCommunityIcons } from "@expo/vector-icons";
|
||||||
import { useNavigation, useRoute, useTheme } from '@react-navigation/native'
|
import { useNavigation, useRoute, useTheme } from "@react-navigation/native";
|
||||||
import gql from 'graphql-tag'
|
import gql from "graphql-tag";
|
||||||
import React, {
|
import React, {
|
||||||
useContext,
|
useContext,
|
||||||
useEffect,
|
useEffect,
|
||||||
useLayoutEffect,
|
useLayoutEffect,
|
||||||
useRef,
|
useRef,
|
||||||
useState
|
useState,
|
||||||
} from 'react'
|
} from "react";
|
||||||
import {
|
import {
|
||||||
KeyboardAvoidingView,
|
KeyboardAvoidingView,
|
||||||
Platform,
|
Platform,
|
||||||
ScrollView,
|
ScrollView,
|
||||||
TouchableOpacity,
|
TouchableOpacity,
|
||||||
View
|
View,
|
||||||
} from 'react-native'
|
} from "react-native";
|
||||||
import { TextField } from 'react-native-material-textfield'
|
import { TextField } from "react-native-material-textfield";
|
||||||
import i18n from '../../../i18n'
|
import i18n from "../../../i18n";
|
||||||
import { updateUser } from '../../apollo/server'
|
import { updateUser } from "../../apollo/server";
|
||||||
import {
|
import {
|
||||||
FlashMessage,
|
FlashMessage,
|
||||||
RightButton,
|
RightButton,
|
||||||
TextDefault,
|
TextDefault,
|
||||||
WrapperView
|
WrapperView,
|
||||||
} from '../../components'
|
} from "../../components";
|
||||||
import UserContext from '../../context/User'
|
import UserContext from "../../context/User";
|
||||||
import { alignment } from '../../utils/alignment'
|
import { alignment } from "../../utils/alignment";
|
||||||
import { ICONS_NAME } from '../../utils/constant'
|
import { ICONS_NAME } from "../../utils/constant";
|
||||||
import { moderateScale, scale } from '../../utils/scaling'
|
import { moderateScale, scale } from "../../utils/scaling";
|
||||||
import { textStyles } from '../../utils/textStyles'
|
import { textStyles } from "../../utils/textStyles";
|
||||||
import ChangePassword from './ChangePassword'
|
import ChangePassword from "./ChangePassword";
|
||||||
import useStyle from './styles'
|
import useStyle from "./styles";
|
||||||
|
|
||||||
const UPDATEUSER = gql`
|
const UPDATEUSER = gql`
|
||||||
${updateUser}
|
${updateUser}
|
||||||
`
|
`;
|
||||||
|
|
||||||
function Profile() {
|
function Profile() {
|
||||||
const refName = useRef()
|
const refName = useRef();
|
||||||
const route = useRoute()
|
const route = useRoute();
|
||||||
const styles = useStyle()
|
const styles = useStyle();
|
||||||
const refPhone = useRef(null)
|
const refPhone = useRef(null);
|
||||||
const { colors } = useTheme()
|
const { colors } = useTheme();
|
||||||
const navigation = useNavigation()
|
const navigation = useNavigation();
|
||||||
|
|
||||||
const [nameError, setNameError] = useState('')
|
const [nameError, setNameError] = useState("");
|
||||||
const [phoneError, setPhoneError] = useState('')
|
const [phoneError, setPhoneError] = useState("");
|
||||||
const [toggleView, setToggleView] = useState(true)
|
const [toggleView, setToggleView] = useState(true);
|
||||||
const [modelVisible, setModalVisible] = useState(false)
|
const [modelVisible, setModalVisible] = useState(false);
|
||||||
|
|
||||||
const { profile } = useContext(UserContext)
|
const { profile } = useContext(UserContext);
|
||||||
const backScreen = route.params ? route.params.backScreen : null
|
const backScreen = route.params ? route.params.backScreen : null;
|
||||||
|
|
||||||
const [mutate, { loading: loadingMutation }] = useMutation(UPDATEUSER, {
|
const [mutate, { loading: loadingMutation }] = useMutation(UPDATEUSER, {
|
||||||
onCompleted,
|
onCompleted,
|
||||||
onError
|
onError,
|
||||||
})
|
});
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
navigation.setOptions({
|
navigation.setOptions({
|
||||||
title: 'Profile',
|
title: "Profile",
|
||||||
headerRight: () => (
|
headerRight: () => (
|
||||||
<RightButton
|
<RightButton
|
||||||
icon={toggleView ? ICONS_NAME.Pencil : ICONS_NAME.Cross}
|
icon={toggleView ? ICONS_NAME.Pencil : ICONS_NAME.Cross}
|
||||||
onPress={viewHideAndShow}
|
onPress={viewHideAndShow}
|
||||||
iconSize={scale(18)}
|
iconSize={scale(18)}
|
||||||
/>
|
/>
|
||||||
)
|
),
|
||||||
})
|
});
|
||||||
}, [navigation, toggleView])
|
}, [navigation, toggleView]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (backScreen) {
|
if (backScreen) {
|
||||||
viewHideAndShow()
|
viewHideAndShow();
|
||||||
setPhoneError('Phone number is required')
|
setPhoneError("Phone number is required");
|
||||||
FlashMessage({
|
FlashMessage({
|
||||||
message: 'Phone Number is missing'
|
message: "Phone Number is missing",
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
}, [backScreen])
|
}, [backScreen]);
|
||||||
|
|
||||||
function viewHideAndShow() {
|
function viewHideAndShow() {
|
||||||
setToggleView(prev => !prev)
|
setToggleView((prev) => !prev);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onCompleted({ updateUser }) {
|
function onCompleted({ updateUser }) {
|
||||||
if (updateUser) {
|
if (updateUser) {
|
||||||
FlashMessage({
|
FlashMessage({
|
||||||
message: "User's Info Updated"
|
message: "User's Info Updated",
|
||||||
})
|
});
|
||||||
if (backScreen) {
|
if (backScreen) {
|
||||||
navigation.goBack()
|
navigation.goBack();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function validateInfo() {
|
function validateInfo() {
|
||||||
// clear errors
|
// clear errors
|
||||||
setNameError('')
|
setNameError("");
|
||||||
setPhoneError('')
|
setPhoneError("");
|
||||||
|
|
||||||
const name = refName.current.value()
|
const name = refName.current.value();
|
||||||
const phone = refPhone.current.value()
|
const phone = refPhone.current.value();
|
||||||
|
|
||||||
if (name === profile.name && phone === profile.phone && phone.length > 0) {
|
if (name === profile.name && phone === profile.phone && phone.length > 0) {
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
let res = true
|
let res = true;
|
||||||
if (!name.trim()) {
|
if (!name.trim()) {
|
||||||
refName.current.focus()
|
refName.current.focus();
|
||||||
setNameError('Name is required')
|
setNameError("Name is required");
|
||||||
res = false
|
res = false;
|
||||||
}
|
}
|
||||||
const num = phone.trim().replace('.', '')
|
const num = phone.trim().replace(".", "");
|
||||||
if (num.length < 11 || num.length > 15 || isNaN(num)) {
|
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) {
|
if (res) {
|
||||||
refPhone.current.focus()
|
refPhone.current.focus();
|
||||||
}
|
}
|
||||||
res = false
|
res = false;
|
||||||
}
|
}
|
||||||
return res
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
function onError(error) {
|
function onError(error) {
|
||||||
try {
|
try {
|
||||||
if (error.graphQLErrors) {
|
if (error.graphQLErrors) {
|
||||||
FlashMessage({
|
FlashMessage({
|
||||||
message: error.graphQLErrors[0].message
|
message: error.graphQLErrors[0].message,
|
||||||
})
|
});
|
||||||
} else if (error.networkError) {
|
} else if (error.networkError) {
|
||||||
FlashMessage({
|
FlashMessage({
|
||||||
message: error.networkError.result.errors[0].message
|
message: error.networkError.result.errors[0].message,
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
} catch (err) {}
|
} catch (err) {}
|
||||||
}
|
}
|
||||||
|
@ -142,7 +142,7 @@ function Profile() {
|
||||||
return (
|
return (
|
||||||
<View style={styles.containerInfo}>
|
<View style={styles.containerInfo}>
|
||||||
<TextField
|
<TextField
|
||||||
label={i18n.t('name')}
|
label={i18n.t("name")}
|
||||||
ref={refName}
|
ref={refName}
|
||||||
editable={false}
|
editable={false}
|
||||||
defaultValue={profile.name}
|
defaultValue={profile.name}
|
||||||
|
@ -151,27 +151,27 @@ function Profile() {
|
||||||
style={{
|
style={{
|
||||||
...textStyles.Medium,
|
...textStyles.Medium,
|
||||||
...textStyles.H5,
|
...textStyles.H5,
|
||||||
color: colors.fontMainColor
|
color: colors.fontMainColor,
|
||||||
}}
|
}}
|
||||||
maxLength={20}
|
maxLength={20}
|
||||||
textColor={colors.fontMainColor}
|
textColor={colors.fontMainColor}
|
||||||
baseColor={colors.fontSecondColor}
|
baseColor={colors.fontSecondColor}
|
||||||
errorColor={colors.errorColor}
|
errorColor={colors.errorColor}
|
||||||
tintColor={!nameError ? colors.tagColor : 'red'}
|
tintColor={!nameError ? colors.tagColor : "red"}
|
||||||
labelTextStyle={{
|
labelTextStyle={{
|
||||||
...textStyles.Normal,
|
...textStyles.Normal,
|
||||||
paddingTop: scale(1)
|
paddingTop: scale(1),
|
||||||
}}
|
}}
|
||||||
error={nameError}
|
error={nameError}
|
||||||
/>
|
/>
|
||||||
<View style={{ ...alignment.MTxSmall }}></View>
|
<View style={{ ...alignment.MTxSmall }}></View>
|
||||||
<TextField
|
<TextField
|
||||||
keyboardType={'email-address'}
|
keyboardType={"email-address"}
|
||||||
label={i18n.t('email')}
|
label={i18n.t("email")}
|
||||||
style={{
|
style={{
|
||||||
...textStyles.Medium,
|
...textStyles.Medium,
|
||||||
...textStyles.H5,
|
...textStyles.H5,
|
||||||
color: colors.fontMainColor
|
color: colors.fontMainColor,
|
||||||
}}
|
}}
|
||||||
editable={false}
|
editable={false}
|
||||||
defaultValue={profile.email}
|
defaultValue={profile.email}
|
||||||
|
@ -183,20 +183,20 @@ function Profile() {
|
||||||
tintColor={colors.tagColor}
|
tintColor={colors.tagColor}
|
||||||
labelTextStyle={{
|
labelTextStyle={{
|
||||||
...textStyles.Normal,
|
...textStyles.Normal,
|
||||||
paddingTop: scale(1)
|
paddingTop: scale(1),
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<View style={{ ...alignment.MTxSmall }}></View>
|
<View style={{ ...alignment.MTxSmall }}></View>
|
||||||
<TextField
|
<TextField
|
||||||
keyboardType={'phone-pad'}
|
keyboardType={"phone-pad"}
|
||||||
label={i18n.t('phone')}
|
label={i18n.t("phone")}
|
||||||
ref={refPhone}
|
ref={refPhone}
|
||||||
editable={false}
|
editable={false}
|
||||||
defaultValue={profile.phone}
|
defaultValue={profile.phone}
|
||||||
style={{
|
style={{
|
||||||
...textStyles.Medium,
|
...textStyles.Medium,
|
||||||
...textStyles.H5,
|
...textStyles.H5,
|
||||||
color: colors.fontMainColor
|
color: colors.fontMainColor,
|
||||||
}}
|
}}
|
||||||
labelFontSize={scale(12)}
|
labelFontSize={scale(12)}
|
||||||
fontSize={scale(12)}
|
fontSize={scale(12)}
|
||||||
|
@ -204,25 +204,26 @@ function Profile() {
|
||||||
textColor={colors.fontMainColor}
|
textColor={colors.fontMainColor}
|
||||||
baseColor={colors.fontSecondColor}
|
baseColor={colors.fontSecondColor}
|
||||||
errorColor={colors.errorColor}
|
errorColor={colors.errorColor}
|
||||||
tintColor={!phoneError ? colors.tagColor : 'red'}
|
tintColor={!phoneError ? colors.tagColor : "red"}
|
||||||
labelTextStyle={{
|
labelTextStyle={{
|
||||||
...textStyles.Normal,
|
...textStyles.Normal,
|
||||||
paddingTop: scale(1)
|
paddingTop: scale(1),
|
||||||
}}
|
}}
|
||||||
error={phoneError}
|
error={phoneError}
|
||||||
/>
|
/>
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
onPress={() => setModalVisible(true)}
|
onPress={() => setModalVisible(true)}
|
||||||
style={styles.changePassword}>
|
style={styles.changePassword}
|
||||||
|
>
|
||||||
<TextDefault>Change Password</TextDefault>
|
<TextDefault>Change Password</TextDefault>
|
||||||
<MaterialCommunityIcons
|
<MaterialCommunityIcons
|
||||||
name={'pencil'}
|
name={"pencil"}
|
||||||
size={20}
|
size={20}
|
||||||
color={colors.tagColor}
|
color={colors.tagColor}
|
||||||
/>
|
/>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
</View>
|
</View>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -230,29 +231,31 @@ function Profile() {
|
||||||
<ChangePassword
|
<ChangePassword
|
||||||
modalVisible={modelVisible}
|
modalVisible={modelVisible}
|
||||||
hideModal={() => {
|
hideModal={() => {
|
||||||
setModalVisible(false)
|
setModalVisible(false);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<View style={styles.formContainer}>
|
<View style={styles.formContainer}>
|
||||||
<KeyboardAvoidingView
|
<KeyboardAvoidingView
|
||||||
behavior={Platform.OS === 'ios' ? 'padding' : null}
|
behavior={Platform.OS === "ios" ? "padding" : null}
|
||||||
style={styles.flex}>
|
style={styles.flex}
|
||||||
|
>
|
||||||
<ScrollView style={styles.flex}>
|
<ScrollView style={styles.flex}>
|
||||||
<View style={[styles.formSubContainer]}>
|
<View style={[styles.formSubContainer]}>
|
||||||
<View
|
<View
|
||||||
style={{
|
style={{
|
||||||
width: scale(100),
|
width: scale(100),
|
||||||
paddingTop: scale(10),
|
paddingTop: scale(10),
|
||||||
position: 'absolute',
|
position: "absolute",
|
||||||
alignItems: 'center',
|
alignItems: "center",
|
||||||
justifyContent: 'center',
|
justifyContent: "center",
|
||||||
height: scale(100),
|
height: scale(100),
|
||||||
top: moderateScale(-50),
|
top: moderateScale(-50),
|
||||||
borderColor: colors.buttonBackground,
|
borderColor: colors.buttonBackground,
|
||||||
borderWidth: 2,
|
borderWidth: 2,
|
||||||
borderRadius: scale(10),
|
borderRadius: scale(10),
|
||||||
borderStyle: 'dashed'
|
borderStyle: "dashed",
|
||||||
}}>
|
}}
|
||||||
|
>
|
||||||
<View style={styles.imgContainer}>
|
<View style={styles.imgContainer}>
|
||||||
<TextDefault textColor={colors.tagColor} bold H1>
|
<TextDefault textColor={colors.tagColor} bold H1>
|
||||||
{profile.name.substr(0, 1).toUpperCase()}
|
{profile.name.substr(0, 1).toUpperCase()}
|
||||||
|
@ -266,13 +269,13 @@ function Profile() {
|
||||||
<View>
|
<View>
|
||||||
<View style={{ margin: scale(0) }}></View>
|
<View style={{ margin: scale(0) }}></View>
|
||||||
<TextField
|
<TextField
|
||||||
label={i18n.t('name')}
|
label={i18n.t("name")}
|
||||||
ref={refName}
|
ref={refName}
|
||||||
defaultValue={profile.name}
|
defaultValue={profile.name}
|
||||||
style={{
|
style={{
|
||||||
...textStyles.Bold,
|
...textStyles.Bold,
|
||||||
...textStyles.H5,
|
...textStyles.H5,
|
||||||
color: colors.fontMainColor
|
color: colors.fontMainColor,
|
||||||
}}
|
}}
|
||||||
labelFontSize={scale(12)}
|
labelFontSize={scale(12)}
|
||||||
fontSize={scale(12)}
|
fontSize={scale(12)}
|
||||||
|
@ -280,21 +283,21 @@ function Profile() {
|
||||||
textColor={colors.fontMainColor}
|
textColor={colors.fontMainColor}
|
||||||
baseColor={colors.fontSecondColor}
|
baseColor={colors.fontSecondColor}
|
||||||
errorColor={colors.errorColor}
|
errorColor={colors.errorColor}
|
||||||
tintColor={!nameError ? colors.buttonBackground : 'red'}
|
tintColor={!nameError ? colors.buttonBackground : "red"}
|
||||||
labelTextStyle={{
|
labelTextStyle={{
|
||||||
...textStyles.Normal,
|
...textStyles.Normal,
|
||||||
paddingTop: scale(1)
|
paddingTop: scale(1),
|
||||||
}}
|
}}
|
||||||
error={nameError}
|
error={nameError}
|
||||||
/>
|
/>
|
||||||
<View style={{ ...alignment.MTxSmall }}></View>
|
<View style={{ ...alignment.MTxSmall }}></View>
|
||||||
<TextField
|
<TextField
|
||||||
keyboardType={'email-address'}
|
keyboardType={"email-address"}
|
||||||
label={i18n.t('email')}
|
label={i18n.t("email")}
|
||||||
style={{
|
style={{
|
||||||
...textStyles.Bold,
|
...textStyles.Bold,
|
||||||
...textStyles.H5,
|
...textStyles.H5,
|
||||||
color: colors.fontMainColor
|
color: colors.fontMainColor,
|
||||||
}}
|
}}
|
||||||
editable={false}
|
editable={false}
|
||||||
defaultValue={profile.email}
|
defaultValue={profile.email}
|
||||||
|
@ -306,17 +309,17 @@ function Profile() {
|
||||||
tintColor={colors.buttonBackground}
|
tintColor={colors.buttonBackground}
|
||||||
labelTextStyle={{
|
labelTextStyle={{
|
||||||
...textStyles.Normal,
|
...textStyles.Normal,
|
||||||
paddingTop: scale(1)
|
paddingTop: scale(1),
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<View style={{ ...alignment.MTxSmall }}></View>
|
<View style={{ ...alignment.MTxSmall }}></View>
|
||||||
<TextField
|
<TextField
|
||||||
keyboardType={'phone-pad'}
|
keyboardType={"phone-pad"}
|
||||||
label={i18n.t('phone')}
|
label={i18n.t("phone")}
|
||||||
style={{
|
style={{
|
||||||
...textStyles.Bold,
|
...textStyles.Bold,
|
||||||
...textStyles.H5,
|
...textStyles.H5,
|
||||||
color: colors.fontMainColor
|
color: colors.fontMainColor,
|
||||||
}}
|
}}
|
||||||
ref={refPhone}
|
ref={refPhone}
|
||||||
defaultValue={profile.phone}
|
defaultValue={profile.phone}
|
||||||
|
@ -326,10 +329,10 @@ function Profile() {
|
||||||
textColor={colors.fontMainColor}
|
textColor={colors.fontMainColor}
|
||||||
baseColor={colors.fontSecondColor}
|
baseColor={colors.fontSecondColor}
|
||||||
errorColor={colors.errorColor}
|
errorColor={colors.errorColor}
|
||||||
tintColor={!phoneError ? colors.buttonBackground : 'red'}
|
tintColor={!phoneError ? colors.buttonBackground : "red"}
|
||||||
labelTextStyle={{
|
labelTextStyle={{
|
||||||
...textStyles.Normal,
|
...textStyles.Normal,
|
||||||
paddingTop: scale(1)
|
paddingTop: scale(1),
|
||||||
}}
|
}}
|
||||||
error={phoneError}
|
error={phoneError}
|
||||||
/>
|
/>
|
||||||
|
@ -344,29 +347,34 @@ function Profile() {
|
||||||
mutate({
|
mutate({
|
||||||
variables: {
|
variables: {
|
||||||
name: refName.current.value(),
|
name: refName.current.value(),
|
||||||
phone: refPhone.current.value()
|
phone: refPhone.current.value(),
|
||||||
}
|
is_active: true,
|
||||||
})
|
},
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}}>
|
}}
|
||||||
|
>
|
||||||
<TextDefault
|
<TextDefault
|
||||||
textColor={colors.buttonText}
|
textColor={colors.buttonText}
|
||||||
H5
|
H5
|
||||||
bold
|
bold
|
||||||
style={[alignment.MTsmall, alignment.MBsmall]}>
|
style={[alignment.MTsmall, alignment.MBsmall]}
|
||||||
{i18n.t('saveBtn')}
|
>
|
||||||
|
{i18n.t("saveBtn")}
|
||||||
</TextDefault>
|
</TextDefault>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
style={{ alignSelf: 'center', ...alignment.MTsmall }}
|
style={{ alignSelf: "center", ...alignment.MTsmall }}
|
||||||
activeOpacity={0.7}
|
activeOpacity={0.7}
|
||||||
onPress={viewHideAndShow}>
|
onPress={viewHideAndShow}
|
||||||
|
>
|
||||||
<TextDefault
|
<TextDefault
|
||||||
textColor={colors.fontMainColor}
|
textColor={colors.fontMainColor}
|
||||||
H5
|
H5
|
||||||
bold
|
bold
|
||||||
style={[alignment.MTsmall, alignment.MBsmall]}>
|
style={[alignment.MTsmall, alignment.MBsmall]}
|
||||||
{'Cancel'}
|
>
|
||||||
|
{"Cancel"}
|
||||||
</TextDefault>
|
</TextDefault>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
</View>
|
</View>
|
||||||
|
@ -375,14 +383,15 @@ function Profile() {
|
||||||
<TextDefault
|
<TextDefault
|
||||||
center
|
center
|
||||||
textColor={colors.fontSecondColor}
|
textColor={colors.fontSecondColor}
|
||||||
style={alignment.MBsmall}>
|
style={alignment.MBsmall}
|
||||||
|
>
|
||||||
All rights are reserved by Enatega
|
All rights are reserved by Enatega
|
||||||
</TextDefault>
|
</TextDefault>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
</KeyboardAvoidingView>
|
</KeyboardAvoidingView>
|
||||||
</View>
|
</View>
|
||||||
</WrapperView>
|
</WrapperView>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Profile
|
export default Profile;
|
||||||
|
|
|
@ -70,8 +70,12 @@ function Settings() {
|
||||||
const { profile, logout } = useContext(UserContext);
|
const { profile, logout } = useContext(UserContext);
|
||||||
|
|
||||||
const [languageName, languageNameSetter] = useState("English");
|
const [languageName, languageNameSetter] = useState("English");
|
||||||
const [offerNotification, offerNotificationSetter] = useState();
|
const [offerNotification, offerNotificationSetter] = useState(
|
||||||
const [orderNotification, orderNotificationSetter] = useState();
|
profile.is_offer_notification
|
||||||
|
);
|
||||||
|
const [orderNotification, orderNotificationSetter] = useState(
|
||||||
|
profile.is_order_notification
|
||||||
|
);
|
||||||
const [activeRadio, activeRadioSetter] = useState(languageTypes[0].index);
|
const [activeRadio, activeRadioSetter] = useState(languageTypes[0].index);
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
const [appState, setAppState] = useState(AppState.currentState);
|
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() {
|
async function updateUserInformation() {
|
||||||
|
console.log("profile data", profile);
|
||||||
updateUserInfo({
|
updateUserInfo({
|
||||||
variables: {
|
variables: {
|
||||||
//updateUserInput: {
|
|
||||||
name: profile.name,
|
name: profile.name,
|
||||||
phone: profile.phone,
|
phone: profile.phone,
|
||||||
is_active: false,
|
is_active: false,
|
||||||
//is_activated: false,
|
|
||||||
// },
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue