reza fixed error before 21

master
Reza_ashrafi 3 years ago
parent 24b1dba5d4
commit 07fe2219a9
  1. 26
      src/components/Search.js
  2. 12
      src/redux/reducers/userProduct.js
  3. 53
      src/screens/Address/index.js

@ -1,11 +1,6 @@
import React, { useState } from "react"; import React, { useState } from "react";
import { import { TextInput, View, StyleSheet, Pressable } from "react-native";
TextInput, import { connect } from "react-redux";
View,
StyleSheet,
Pressable,
} from "react-native";
import {connect} from "react-redux";
import tw from "tailwind-rn"; import tw from "tailwind-rn";
import { AntDesign } from "@expo/vector-icons"; import { AntDesign } from "@expo/vector-icons";
@ -13,13 +8,20 @@ import { AntDesign } from "@expo/vector-icons";
import Colors from "../constants/Colors"; import Colors from "../constants/Colors";
import fontSize from "../constants/fontSize"; import fontSize from "../constants/fontSize";
const Search = ({ placeholder, textAlign, direction, onChange, value, theme }) => { const Search = ({
placeholder,
textAlign,
direction,
onChange,
value,
theme,
}) => {
const styles = StyleSheet.create({ const styles = StyleSheet.create({
inputStyle: { inputStyle: {
fontSize: fontSize.tiny, fontSize: fontSize.tiny,
color: Colors.theme1[theme].gray2077, color: Colors.theme1[theme].gray2077,
borderWidth: 0.5, borderWidth: 0.5,
borderColor: Colors.theme1[theme].gray20 + '88', borderColor: Colors.theme1[theme].gray20 + "88",
paddingVertical: 10, paddingVertical: 10,
paddingHorizontal: 10, paddingHorizontal: 10,
direction: direction, direction: direction,
@ -34,7 +36,7 @@ const Search = ({ placeholder, textAlign, direction, onChange, value, theme }) =
style={[styles.inputStyle, tw("rounded-sm")]} style={[styles.inputStyle, tw("rounded-sm")]}
onChangeText={(text) => onChange(text)} onChangeText={(text) => onChange(text)}
placeholder={placeholder} placeholder={placeholder}
placeholderTextColor={Colors.theme1[theme].gray20 + '88'} placeholderTextColor={Colors.theme1[theme].gray20}
value={value} value={value}
/> />
<Pressable style={tw("absolute left-3 top-3")}> <Pressable style={tw("absolute left-3 top-3")}>
@ -45,8 +47,8 @@ const Search = ({ placeholder, textAlign, direction, onChange, value, theme }) =
}; };
const mapStateToProps = (state) => ({ const mapStateToProps = (state) => ({
theme : state.publicApi.theme, theme: state.publicApi.theme,
}) });
export default connect(mapStateToProps)(Search); export default connect(mapStateToProps)(Search);

@ -1,4 +1,4 @@
import {asyncAwesomeAlert} from '../../utils/AsyncWrappers'; import { asyncAwesomeAlert } from "../../utils/AsyncWrappers";
const initialState = { const initialState = {
loading: false, loading: false,
@ -23,7 +23,6 @@ export default function userFactor(state = initialState, action) {
data.filter((item) => item.product.productType === 2).length > 0 data.filter((item) => item.product.productType === 2).length > 0
? true ? true
: false; : false;
console.log('list fetched!');
return { return {
...state, ...state,
loading: false, loading: false,
@ -37,7 +36,14 @@ export default function userFactor(state = initialState, action) {
case "userProduct/update": case "userProduct/update":
return { ...state, loading: false, error: null }; return { ...state, loading: false, error: null };
case "userProduct/add": case "userProduct/add":
return { ...state, loading: false, error: null, sum: data.payPrice }; console.log(data);
return {
...state,
loading: false,
error: null,
list: data.products,
sum: data.payPrice,
};
case "userProduct/delete": case "userProduct/delete":
return { ...state, loading: false, error: null }; return { ...state, loading: false, error: null };
case "userProduct/loading": case "userProduct/loading":

@ -8,6 +8,8 @@ import {
Platform, Platform,
Dimensions, Dimensions,
Appearance, Appearance,
KeyboardAvoidingView,
TouchableWithoutFeedback,
} from "react-native"; } from "react-native";
import React, { useEffect, useState } from "react"; import React, { useEffect, useState } from "react";
import { connect } from "react-redux"; import { connect } from "react-redux";
@ -28,7 +30,9 @@ import tw from "tailwind-rn";
import Colors from "../../constants/Colors"; import Colors from "../../constants/Colors";
import fontSize from "../../constants/fontSize"; import fontSize from "../../constants/fontSize";
//variables
const ios = Platform.OS === "ios"; const ios = Platform.OS === "ios";
const { height } = Dimensions.get("window");
const Address = ({ const Address = ({
user, user,
@ -243,9 +247,14 @@ const Address = ({
<SafeAreaView <SafeAreaView
style={{ style={{
paddingTop: Platform.OS === "android" ? StatusBar.currentHeight : 0, paddingTop: Platform.OS === "android" ? StatusBar.currentHeight : 0,
position: "relative", // position: "relative",
flex: 1,
}} }}
> >
<ScrollView style={tw("flex-1 px-4")}>
<KeyboardAvoidingView behavior={"padding"} style={[{ height }]}>
<TouchableWithoutFeedback>
<View style={tw("flex-1")}>
<Navbar <Navbar
headerOptions={{ headerOptions={{
logo: false, logo: false,
@ -257,12 +266,6 @@ const Address = ({
back: true, back: true,
}} }}
/> />
<ScrollView
contentContainerStyle={styles.contentContainerStyle}
style={styles.container}
>
<View style={tw("w-full flex pb-4")}>
{/* <MapSelector /> */}
<Header <Header
title="اطلاعات هویتی" title="اطلاعات هویتی"
text="( لطفا نام و نام خانوادگی خود را به طور کامل وارد نمایید )" text="( لطفا نام و نام خانوادگی خود را به طور کامل وارد نمایید )"
@ -274,7 +277,9 @@ const Address = ({
name="firstName" name="firstName"
maxlength="40" maxlength="40"
value={ value={
profilePage ? profileFields.firstName : addressFields?.firstName profilePage
? profileFields.firstName
: addressFields?.firstName
} }
onChange={(name, value) => onChange={(name, value) =>
profilePage profilePage
@ -303,6 +308,7 @@ const Address = ({
/> />
{profilePage && ( {profilePage && (
<CustomTextInput <CustomTextInput
keyboardType="numeric"
label="کد ملی" label="کد ملی"
placeholder="" placeholder=""
textAlign="left" textAlign="left"
@ -313,7 +319,7 @@ const Address = ({
setProfileFields({ ...profileFields, nationalId: value }) setProfileFields({ ...profileFields, nationalId: value })
} }
autoFocus={false} autoFocus={false}
regex={onInput.numberOnly} regex={(text) => onInput.numberOnly(text)}
/> />
)} )}
<View style={tw("mt-4")}></View> <View style={tw("mt-4")}></View>
@ -323,13 +329,16 @@ const Address = ({
به همراه پیش شماره وارد کنید )" به همراه پیش شماره وارد کنید )"
/> />
<CustomTextInput <CustomTextInput
keyboardType="numeric"
label="شماره موبایل" label="شماره موبایل"
placeholder="" placeholder=""
textAlign="left" textAlign="left"
name="cellphone" name="cellphone"
maxlength="11" maxlength="11"
value={ value={
profilePage ? profileFields.cellphone : addressFields?.cellphone profilePage
? profileFields.cellphone
: addressFields?.cellphone
} }
onChange={(name, value) => onChange={(name, value) =>
profilePage profilePage
@ -337,9 +346,10 @@ const Address = ({
: onChange(name, value) : onChange(name, value)
} }
autoFocus={false} autoFocus={false}
regex={onInput.phonenumber} regex={(text) => onInput.numberOnly(text)}
/> />
<CustomTextInput <CustomTextInput
keyboardType="numeric"
label="شماره تلفن" label="شماره تلفن"
placeholder="" placeholder=""
textAlign="left" textAlign="left"
@ -352,7 +362,7 @@ const Address = ({
: onChange(name, value) : onChange(name, value)
} }
autoFocus={false} autoFocus={false}
regex={onInput.phonenumber} regex={(text) => onInput.numberOnly(text)}
/> />
<View style={tw("mt-4")}></View> <View style={tw("mt-4")}></View>
<Header <Header
@ -396,11 +406,12 @@ const Address = ({
</View> </View>
<View style={tw("mb-4")}> <View style={tw("mb-4")}>
<CustomTextInput <CustomTextInput
keyboardType="numeric"
label="کد پستی" label="کد پستی"
placeholder="" placeholder=""
textAlign="left" textAlign="left"
name="postalCode" name="postalCode"
maxlength="60" maxlength="10"
value={ value={
profilePage profilePage
? profileFields.postalCode ? profileFields.postalCode
@ -408,17 +419,22 @@ const Address = ({
} }
onChange={(name, value) => onChange={(name, value) =>
profilePage profilePage
? setProfileFields({ ...profileFields, postalCode: value }) ? setProfileFields({
...profileFields,
postalCode: value,
})
: onChange(name, value) : onChange(name, value)
} }
autoFocus={false} autoFocus={false}
regex={(val) => val} regex={(text) => onInput.numberOnly(text)}
/> />
</View> </View>
<CustomPressable <CustomPressable
title={ title={
profilePage ? "ذخیره اطلاعات و بازگشت به صفحه قبل" : "ثبت آدرس" profilePage
? "ذخیره اطلاعات و بازگشت به صفحه قبل"
: "ثبت آدرس"
} }
backgroundColor={Colors.theme1[colorScheme].greenCF} backgroundColor={Colors.theme1[colorScheme].greenCF}
color={"white"} color={"white"}
@ -427,6 +443,8 @@ const Address = ({
onPress={() => (profilePage ? submitProfile() : submit())} onPress={() => (profilePage ? submitProfile() : submit())}
/> />
</View> </View>
</TouchableWithoutFeedback>
</KeyboardAvoidingView>
</ScrollView> </ScrollView>
</SafeAreaView> </SafeAreaView>
); );
@ -434,13 +452,14 @@ const Address = ({
const styles = StyleSheet.create({ const styles = StyleSheet.create({
contentContainerStyle: { contentContainerStyle: {
paddingBottom: 100, paddingBottom: 0,
}, },
container: { container: {
backgroundColor: "white", backgroundColor: "white",
flexDirection: "column", flexDirection: "column",
paddingVertical: 5, paddingVertical: 5,
paddingHorizontal: 16, paddingHorizontal: 16,
flex: 1,
}, },
}); });

Loading…
Cancel
Save