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. 379
      src/screens/Address/index.js

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

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

@ -8,6 +8,8 @@ import {
Platform,
Dimensions,
Appearance,
KeyboardAvoidingView,
TouchableWithoutFeedback,
} from "react-native";
import React, { useEffect, useState } from "react";
import { connect } from "react-redux";
@ -28,7 +30,9 @@ import tw from "tailwind-rn";
import Colors from "../../constants/Colors";
import fontSize from "../../constants/fontSize";
//variables
const ios = Platform.OS === "ios";
const { height } = Dimensions.get("window");
const Address = ({
user,
@ -243,190 +247,204 @@ const Address = ({
<SafeAreaView
style={{
paddingTop: Platform.OS === "android" ? StatusBar.currentHeight : 0,
position: "relative",
// position: "relative",
flex: 1,
}}
>
<Navbar
headerOptions={{
logo: false,
menu: profilePage ? false : false,
hamburgerMenu: false,
title: profilePage ? "اطلاعات کاربری" : "",
bookmark: profilePage ? false : false,
qr: false,
back: true,
}}
/>
<ScrollView
contentContainerStyle={styles.contentContainerStyle}
style={styles.container}
>
<View style={tw("w-full flex pb-4")}>
{/* <MapSelector /> */}
<Header
title="اطلاعات هویتی"
text="( لطفا نام و نام خانوادگی خود را به طور کامل وارد نمایید )"
/>
<CustomTextInput
label="نام"
placeholder=""
textAlign="right"
name="firstName"
maxlength="40"
value={
profilePage ? profileFields.firstName : addressFields?.firstName
}
onChange={(name, value) =>
profilePage
? setProfileFields({ ...profileFields, firstName: value })
: onChange(name, value)
}
autoFocus={false}
regex={(val) => val}
/>
<CustomTextInput
label="نام خانوادگی"
placeholder=""
textAlign="right"
name="lastName"
maxlength="60"
value={
profilePage ? profileFields.lastName : addressFields?.lastName
}
onChange={(name, value) =>
profilePage
? setProfileFields({ ...profileFields, lastName: value })
: onChange(name, value)
}
autoFocus={false}
regex={(val) => val}
/>
{profilePage && (
<CustomTextInput
label="کد ملی"
placeholder=""
textAlign="left"
name="nationalId"
maxlength="10"
value={profileFields.nationalId}
onChange={(name, value) =>
setProfileFields({ ...profileFields, nationalId: value })
}
autoFocus={false}
regex={onInput.numberOnly}
/>
)}
<View style={tw("mt-4")}></View>
<Header
title="شماره تماس"
text="( شماره موبایل و شماره تلفن ثابت خود را
<ScrollView style={tw("flex-1 px-4")}>
<KeyboardAvoidingView behavior={"padding"} style={[{ height }]}>
<TouchableWithoutFeedback>
<View style={tw("flex-1")}>
<Navbar
headerOptions={{
logo: false,
menu: profilePage ? false : false,
hamburgerMenu: false,
title: profilePage ? "اطلاعات کاربری" : "",
bookmark: profilePage ? false : false,
qr: false,
back: true,
}}
/>
<Header
title="اطلاعات هویتی"
text="( لطفا نام و نام خانوادگی خود را به طور کامل وارد نمایید )"
/>
<CustomTextInput
label="نام"
placeholder=""
textAlign="right"
name="firstName"
maxlength="40"
value={
profilePage
? profileFields.firstName
: addressFields?.firstName
}
onChange={(name, value) =>
profilePage
? setProfileFields({ ...profileFields, firstName: value })
: onChange(name, value)
}
autoFocus={false}
regex={(val) => val}
/>
<CustomTextInput
label="نام خانوادگی"
placeholder=""
textAlign="right"
name="lastName"
maxlength="60"
value={
profilePage ? profileFields.lastName : addressFields?.lastName
}
onChange={(name, value) =>
profilePage
? setProfileFields({ ...profileFields, lastName: value })
: onChange(name, value)
}
autoFocus={false}
regex={(val) => val}
/>
{profilePage && (
<CustomTextInput
keyboardType="numeric"
label="کد ملی"
placeholder=""
textAlign="left"
name="nationalId"
maxlength="10"
value={profileFields.nationalId}
onChange={(name, value) =>
setProfileFields({ ...profileFields, nationalId: value })
}
autoFocus={false}
regex={(text) => onInput.numberOnly(text)}
/>
)}
<View style={tw("mt-4")}></View>
<Header
title="شماره تماس"
text="( شماره موبایل و شماره تلفن ثابت خود را
به همراه پیش شماره وارد کنید )"
/>
<CustomTextInput
label="شماره موبایل"
placeholder=""
textAlign="left"
name="cellphone"
maxlength="11"
value={
profilePage ? profileFields.cellphone : addressFields?.cellphone
}
onChange={(name, value) =>
profilePage
? setProfileFields({ ...profileFields, cellphone: value })
: onChange(name, value)
}
autoFocus={false}
regex={onInput.phonenumber}
/>
<CustomTextInput
label="شماره تلفن"
placeholder=""
textAlign="left"
name="phone"
maxlength="11"
value={profilePage ? profileFields.phone : addressFields?.phone}
onChange={(name, value) =>
profilePage
? setProfileFields({ ...profileFields, phone: value })
: onChange(name, value)
}
autoFocus={false}
regex={onInput.phonenumber}
/>
<View style={tw("mt-4")}></View>
<Header
title="آدرس"
text="( لطفا نام استان و شهرستان و آدرس
/>
<CustomTextInput
keyboardType="numeric"
label="شماره موبایل"
placeholder=""
textAlign="left"
name="cellphone"
maxlength="11"
value={
profilePage
? profileFields.cellphone
: addressFields?.cellphone
}
onChange={(name, value) =>
profilePage
? setProfileFields({ ...profileFields, cellphone: value })
: onChange(name, value)
}
autoFocus={false}
regex={(text) => onInput.numberOnly(text)}
/>
<CustomTextInput
keyboardType="numeric"
label="شماره تلفن"
placeholder=""
textAlign="left"
name="phone"
maxlength="11"
value={profilePage ? profileFields.phone : addressFields?.phone}
onChange={(name, value) =>
profilePage
? setProfileFields({ ...profileFields, phone: value })
: onChange(name, value)
}
autoFocus={false}
regex={(text) => onInput.numberOnly(text)}
/>
<View style={tw("mt-4")}></View>
<Header
title="آدرس"
text="( لطفا نام استان و شهرستان و آدرس
خود را با دقت تکمیل نمایید )"
/>
<View style={tw("w-full mt-4")}>
<Select
defaultValue={
profilePage
? provinces?.filter(
(province) => province.id === profileFields.provinceId
)[0]?.name || province[0]
: city[0]
}
onChange={(name, value) =>
value === "استان" ? {} : onChange(name, value)
}
options={province}
width={"100%"}
name="provinceId"
/>
</View>
<View style={tw("w-full mt-4")}>
<Select
defaultValue={
profilePage
? cities?.filter(
(city) => city.id === profileFields.cityId
)[0]?.name || city[0]
: city[0]
}
onChange={(name, value) =>
value === "شهر" ? {} : onChange(name, value)
}
options={city}
width={"100%"}
name="cityId"
/>
</View>
<View style={tw("mb-4")}>
<CustomTextInput
label="کد پستی"
placeholder=""
textAlign="left"
name="postalCode"
maxlength="60"
value={
profilePage
? profileFields.postalCode
: addressFields?.postalCode
}
onChange={(name, value) =>
profilePage
? setProfileFields({ ...profileFields, postalCode: value })
: onChange(name, value)
}
autoFocus={false}
regex={(val) => val}
/>
</View>
/>
<View style={tw("w-full mt-4")}>
<Select
defaultValue={
profilePage
? provinces?.filter(
(province) => province.id === profileFields.provinceId
)[0]?.name || province[0]
: city[0]
}
onChange={(name, value) =>
value === "استان" ? {} : onChange(name, value)
}
options={province}
width={"100%"}
name="provinceId"
/>
</View>
<View style={tw("w-full mt-4")}>
<Select
defaultValue={
profilePage
? cities?.filter(
(city) => city.id === profileFields.cityId
)[0]?.name || city[0]
: city[0]
}
onChange={(name, value) =>
value === "شهر" ? {} : onChange(name, value)
}
options={city}
width={"100%"}
name="cityId"
/>
</View>
<View style={tw("mb-4")}>
<CustomTextInput
keyboardType="numeric"
label="کد پستی"
placeholder=""
textAlign="left"
name="postalCode"
maxlength="10"
value={
profilePage
? profileFields.postalCode
: addressFields?.postalCode
}
onChange={(name, value) =>
profilePage
? setProfileFields({
...profileFields,
postalCode: value,
})
: onChange(name, value)
}
autoFocus={false}
regex={(text) => onInput.numberOnly(text)}
/>
</View>
<CustomPressable
title={
profilePage ? "ذخیره اطلاعات و بازگشت به صفحه قبل" : "ثبت آدرس"
}
backgroundColor={Colors.theme1[colorScheme].greenCF}
color={"white"}
border={{ color: "#196EC0", width: 0 }}
width={"100%"}
onPress={() => (profilePage ? submitProfile() : submit())}
/>
</View>
<CustomPressable
title={
profilePage
? "ذخیره اطلاعات و بازگشت به صفحه قبل"
: "ثبت آدرس"
}
backgroundColor={Colors.theme1[colorScheme].greenCF}
color={"white"}
border={{ color: "#196EC0", width: 0 }}
width={"100%"}
onPress={() => (profilePage ? submitProfile() : submit())}
/>
</View>
</TouchableWithoutFeedback>
</KeyboardAvoidingView>
</ScrollView>
</SafeAreaView>
);
@ -434,13 +452,14 @@ const Address = ({
const styles = StyleSheet.create({
contentContainerStyle: {
paddingBottom: 100,
paddingBottom: 0,
},
container: {
backgroundColor: "white",
flexDirection: "column",
paddingVertical: 5,
paddingHorizontal: 16,
flex: 1,
},
});

Loading…
Cancel
Save