From 07fe2219a938f897b96ac4e1ad4245a25fb1a505 Mon Sep 17 00:00:00 2001 From: Reza_ashrafi Date: Sun, 17 Apr 2022 14:22:38 +0430 Subject: [PATCH] reza fixed error before 21 --- src/components/Search.js | 26 +- src/redux/reducers/userProduct.js | 12 +- src/screens/Address/index.js | 379 ++++++++++++++++-------------- 3 files changed, 222 insertions(+), 195 deletions(-) diff --git a/src/components/Search.js b/src/components/Search.js index 0abd6f7..141ce42 100644 --- a/src/components/Search.js +++ b/src/components/Search.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} /> @@ -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); diff --git a/src/redux/reducers/userProduct.js b/src/redux/reducers/userProduct.js index 146cbda..66e8832 100644 --- a/src/redux/reducers/userProduct.js +++ b/src/redux/reducers/userProduct.js @@ -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": diff --git a/src/screens/Address/index.js b/src/screens/Address/index.js index c101479..b173178 100644 --- a/src/screens/Address/index.js +++ b/src/screens/Address/index.js @@ -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 = ({ - - - - {/* */} -
- - profilePage - ? setProfileFields({ ...profileFields, firstName: value }) - : onChange(name, value) - } - autoFocus={false} - regex={(val) => val} - /> - - profilePage - ? setProfileFields({ ...profileFields, lastName: value }) - : onChange(name, value) - } - autoFocus={false} - regex={(val) => val} - /> - {profilePage && ( - - setProfileFields({ ...profileFields, nationalId: value }) - } - autoFocus={false} - regex={onInput.numberOnly} - /> - )} - -
+ + + + +
+ + profilePage + ? setProfileFields({ ...profileFields, firstName: value }) + : onChange(name, value) + } + autoFocus={false} + regex={(val) => val} + /> + + profilePage + ? setProfileFields({ ...profileFields, lastName: value }) + : onChange(name, value) + } + autoFocus={false} + regex={(val) => val} + /> + {profilePage && ( + + setProfileFields({ ...profileFields, nationalId: value }) + } + autoFocus={false} + regex={(text) => onInput.numberOnly(text)} + /> + )} + +
- - profilePage - ? setProfileFields({ ...profileFields, cellphone: value }) - : onChange(name, value) - } - autoFocus={false} - regex={onInput.phonenumber} - /> - - profilePage - ? setProfileFields({ ...profileFields, phone: value }) - : onChange(name, value) - } - autoFocus={false} - regex={onInput.phonenumber} - /> - -
+ profilePage + ? setProfileFields({ ...profileFields, cellphone: value }) + : onChange(name, value) + } + autoFocus={false} + regex={(text) => onInput.numberOnly(text)} + /> + + profilePage + ? setProfileFields({ ...profileFields, phone: value }) + : onChange(name, value) + } + autoFocus={false} + regex={(text) => onInput.numberOnly(text)} + /> + +
- - city.id === profileFields.cityId - )[0]?.name || city[0] - : city[0] - } - onChange={(name, value) => - value === "شهر" ? {} : onChange(name, value) - } - options={city} - width={"100%"} - name="cityId" - /> - - - - profilePage - ? setProfileFields({ ...profileFields, postalCode: value }) - : onChange(name, value) - } - autoFocus={false} - regex={(val) => val} - /> - + /> + + city.id === profileFields.cityId + )[0]?.name || city[0] + : city[0] + } + onChange={(name, value) => + value === "شهر" ? {} : onChange(name, value) + } + options={city} + width={"100%"} + name="cityId" + /> + + + + profilePage + ? setProfileFields({ + ...profileFields, + postalCode: value, + }) + : onChange(name, value) + } + autoFocus={false} + regex={(text) => onInput.numberOnly(text)} + /> + - (profilePage ? submitProfile() : submit())} - /> - + (profilePage ? submitProfile() : submit())} + /> + + + ); @@ -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, }, });