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 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,190 +247,204 @@ 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,
}} }}
> >
<Navbar <ScrollView style={tw("flex-1 px-4")}>
headerOptions={{ <KeyboardAvoidingView behavior={"padding"} style={[{ height }]}>
logo: false, <TouchableWithoutFeedback>
menu: profilePage ? false : false, <View style={tw("flex-1")}>
hamburgerMenu: false, <Navbar
title: profilePage ? "اطلاعات کاربری" : "", headerOptions={{
bookmark: profilePage ? false : false, logo: false,
qr: false, menu: profilePage ? false : false,
back: true, hamburgerMenu: false,
}} title: profilePage ? "اطلاعات کاربری" : "",
/> bookmark: profilePage ? false : false,
<ScrollView qr: false,
contentContainerStyle={styles.contentContainerStyle} back: true,
style={styles.container} }}
> />
<View style={tw("w-full flex pb-4")}> <Header
{/* <MapSelector /> */} title="اطلاعات هویتی"
<Header text="( لطفا نام و نام خانوادگی خود را به طور کامل وارد نمایید )"
title="اطلاعات هویتی" />
text="( لطفا نام و نام خانوادگی خود را به طور کامل وارد نمایید )" <CustomTextInput
/> label="نام"
<CustomTextInput placeholder=""
label="نام" textAlign="right"
placeholder="" name="firstName"
textAlign="right" maxlength="40"
name="firstName" value={
maxlength="40" profilePage
value={ ? profileFields.firstName
profilePage ? profileFields.firstName : addressFields?.firstName : addressFields?.firstName
} }
onChange={(name, value) => onChange={(name, value) =>
profilePage profilePage
? setProfileFields({ ...profileFields, firstName: value }) ? setProfileFields({ ...profileFields, firstName: value })
: onChange(name, value) : onChange(name, value)
} }
autoFocus={false} autoFocus={false}
regex={(val) => val} regex={(val) => val}
/> />
<CustomTextInput <CustomTextInput
label="نام خانوادگی" label="نام خانوادگی"
placeholder="" placeholder=""
textAlign="right" textAlign="right"
name="lastName" name="lastName"
maxlength="60" maxlength="60"
value={ value={
profilePage ? profileFields.lastName : addressFields?.lastName profilePage ? profileFields.lastName : addressFields?.lastName
} }
onChange={(name, value) => onChange={(name, value) =>
profilePage profilePage
? setProfileFields({ ...profileFields, lastName: value }) ? setProfileFields({ ...profileFields, lastName: value })
: onChange(name, value) : onChange(name, value)
} }
autoFocus={false} autoFocus={false}
regex={(val) => val} regex={(val) => val}
/> />
{profilePage && ( {profilePage && (
<CustomTextInput <CustomTextInput
label="کد ملی" keyboardType="numeric"
placeholder="" label="کد ملی"
textAlign="left" placeholder=""
name="nationalId" textAlign="left"
maxlength="10" name="nationalId"
value={profileFields.nationalId} maxlength="10"
onChange={(name, value) => value={profileFields.nationalId}
setProfileFields({ ...profileFields, nationalId: value }) onChange={(name, value) =>
} setProfileFields({ ...profileFields, nationalId: value })
autoFocus={false} }
regex={onInput.numberOnly} autoFocus={false}
/> regex={(text) => onInput.numberOnly(text)}
)} />
<View style={tw("mt-4")}></View> )}
<Header <View style={tw("mt-4")}></View>
title="شماره تماس" <Header
text="( شماره موبایل و شماره تلفن ثابت خود را title="شماره تماس"
text="( شماره موبایل و شماره تلفن ثابت خود را
به همراه پیش شماره وارد کنید )" به همراه پیش شماره وارد کنید )"
/> />
<CustomTextInput <CustomTextInput
label="شماره موبایل" keyboardType="numeric"
placeholder="" label="شماره موبایل"
textAlign="left" placeholder=""
name="cellphone" textAlign="left"
maxlength="11" name="cellphone"
value={ maxlength="11"
profilePage ? profileFields.cellphone : addressFields?.cellphone value={
} profilePage
onChange={(name, value) => ? profileFields.cellphone
profilePage : addressFields?.cellphone
? setProfileFields({ ...profileFields, cellphone: value }) }
: onChange(name, value) onChange={(name, value) =>
} profilePage
autoFocus={false} ? setProfileFields({ ...profileFields, cellphone: value })
regex={onInput.phonenumber} : onChange(name, value)
/> }
<CustomTextInput autoFocus={false}
label="شماره تلفن" regex={(text) => onInput.numberOnly(text)}
placeholder="" />
textAlign="left" <CustomTextInput
name="phone" keyboardType="numeric"
maxlength="11" label="شماره تلفن"
value={profilePage ? profileFields.phone : addressFields?.phone} placeholder=""
onChange={(name, value) => textAlign="left"
profilePage name="phone"
? setProfileFields({ ...profileFields, phone: value }) maxlength="11"
: onChange(name, value) value={profilePage ? profileFields.phone : addressFields?.phone}
} onChange={(name, value) =>
autoFocus={false} profilePage
regex={onInput.phonenumber} ? setProfileFields({ ...profileFields, phone: value })
/> : onChange(name, value)
<View style={tw("mt-4")}></View> }
<Header autoFocus={false}
title="آدرس" regex={(text) => onInput.numberOnly(text)}
text="( لطفا نام استان و شهرستان و آدرس />
<View style={tw("mt-4")}></View>
<Header
title="آدرس"
text="( لطفا نام استان و شهرستان و آدرس
خود را با دقت تکمیل نمایید )" خود را با دقت تکمیل نمایید )"
/> />
<View style={tw("w-full mt-4")}> <View style={tw("w-full mt-4")}>
<Select <Select
defaultValue={ defaultValue={
profilePage profilePage
? provinces?.filter( ? provinces?.filter(
(province) => province.id === profileFields.provinceId (province) => province.id === profileFields.provinceId
)[0]?.name || province[0] )[0]?.name || province[0]
: city[0] : city[0]
} }
onChange={(name, value) => onChange={(name, value) =>
value === "استان" ? {} : onChange(name, value) value === "استان" ? {} : onChange(name, value)
} }
options={province} options={province}
width={"100%"} width={"100%"}
name="provinceId" name="provinceId"
/> />
</View> </View>
<View style={tw("w-full mt-4")}> <View style={tw("w-full mt-4")}>
<Select <Select
defaultValue={ defaultValue={
profilePage profilePage
? cities?.filter( ? cities?.filter(
(city) => city.id === profileFields.cityId (city) => city.id === profileFields.cityId
)[0]?.name || city[0] )[0]?.name || city[0]
: city[0] : city[0]
} }
onChange={(name, value) => onChange={(name, value) =>
value === "شهر" ? {} : onChange(name, value) value === "شهر" ? {} : onChange(name, value)
} }
options={city} options={city}
width={"100%"} width={"100%"}
name="cityId" name="cityId"
/> />
</View> </View>
<View style={tw("mb-4")}> <View style={tw("mb-4")}>
<CustomTextInput <CustomTextInput
label="کد پستی" keyboardType="numeric"
placeholder="" label="کد پستی"
textAlign="left" placeholder=""
name="postalCode" textAlign="left"
maxlength="60" name="postalCode"
value={ maxlength="10"
profilePage value={
? profileFields.postalCode profilePage
: addressFields?.postalCode ? profileFields.postalCode
} : addressFields?.postalCode
onChange={(name, value) => }
profilePage onChange={(name, value) =>
? setProfileFields({ ...profileFields, postalCode: value }) profilePage
: onChange(name, value) ? setProfileFields({
} ...profileFields,
autoFocus={false} postalCode: value,
regex={(val) => val} })
/> : onChange(name, value)
</View> }
autoFocus={false}
regex={(text) => onInput.numberOnly(text)}
/>
</View>
<CustomPressable <CustomPressable
title={ title={
profilePage ? "ذخیره اطلاعات و بازگشت به صفحه قبل" : "ثبت آدرس" profilePage
} ? "ذخیره اطلاعات و بازگشت به صفحه قبل"
backgroundColor={Colors.theme1[colorScheme].greenCF} : "ثبت آدرس"
color={"white"} }
border={{ color: "#196EC0", width: 0 }} backgroundColor={Colors.theme1[colorScheme].greenCF}
width={"100%"} color={"white"}
onPress={() => (profilePage ? submitProfile() : submit())} border={{ color: "#196EC0", width: 0 }}
/> width={"100%"}
</View> onPress={() => (profilePage ? submitProfile() : submit())}
/>
</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