From be780c908ebdf55118aefb1965be3aeb9580ed8f Mon Sep 17 00:00:00 2001 From: Reza_ashrafi Date: Thu, 12 May 2022 12:06:06 +0430 Subject: [PATCH] reza fixed address delete --- src/redux/actions/userAddress.js | 5 ++--- src/redux/proxy.js | 4 +++- src/redux/reducers/userAddress.js | 2 +- src/screens/Profile/components/ProfileAddress/index.js | 6 ++---- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/redux/actions/userAddress.js b/src/redux/actions/userAddress.js index e2cf14c..891b995 100644 --- a/src/redux/actions/userAddress.js +++ b/src/redux/actions/userAddress.js @@ -14,7 +14,7 @@ const userAddress = { update: (data = {}, data2 = {}) => async (dispatch) => { - await proxy.put("userAddress/update", data); + await proxy.put("userAddress/update", data, {dispatch }); }, add: (data = {}, data2 = {}, data3 = {}) => @@ -24,8 +24,7 @@ const userAddress = { del: (data = {}, data2 = {}) => async (dispatch) => { - console.log(data); - await proxy.delete("userAddress/delete2", data); + await proxy.delete("userAddress/delete", data, {dispatch }); }, }; diff --git a/src/redux/proxy.js b/src/redux/proxy.js index 588b221..9237955 100644 --- a/src/redux/proxy.js +++ b/src/redux/proxy.js @@ -50,7 +50,9 @@ class Proxy { () => Axios.delete(url, { ...opt, data: params }), data || params ); - } catch (error) {} + } catch (error) { + console.log('error "proxy.js" axios.delete'); + } }; check = async (url, { dispatch }, fetch, params) => { diff --git a/src/redux/reducers/userAddress.js b/src/redux/reducers/userAddress.js index 52c4fb8..0cf9a58 100644 --- a/src/redux/reducers/userAddress.js +++ b/src/redux/reducers/userAddress.js @@ -21,7 +21,7 @@ export default function userAddress(state = initialState, action) { return { ...state, loading: false, list: data, error: null }; case "userAddress/add": return { ...state, loading: false, list: data.list, error: null }; - case "userAddress/delete2": + case "userAddress/delete": return { ...state, loading: false, list: data, error: null }; case "userAddress/loading": return { ...state, loading: true }; diff --git a/src/screens/Profile/components/ProfileAddress/index.js b/src/screens/Profile/components/ProfileAddress/index.js index e536cfa..019ae56 100644 --- a/src/screens/Profile/components/ProfileAddress/index.js +++ b/src/screens/Profile/components/ProfileAddress/index.js @@ -14,13 +14,11 @@ import React from "react"; import { connect } from "react-redux"; import { asyncAwesomeAlert } from "../../../../utils/AsyncWrappers"; import { useNavigation } from "@react-navigation/native"; -import { Ionicons, Entypo } from "@expo/vector-icons"; +import { Ionicons } from "@expo/vector-icons"; import { userAddress, userFactor } from "../../../../redux/actions"; -import Svg, { G, Path } from "react-native-svg"; //components import Navbar from "../../../../components/Navbar"; -import CustomPressable from "../../../../components/Pressable"; import Empty from "../../../../components/Empty"; //style @@ -248,7 +246,7 @@ const ProfileAddress = ({ showCancelButton: true, confirmText: "بله", cancelText: "لغو", - onConfirm: () => deleteItem({ id: address?.id }), + onConfirm: () => deleteItem({ id : address?.id }), }) } >