diff --git a/src/components/Input/index.js b/src/components/Input/index.js index 7c3e46e..f8be420 100644 --- a/src/components/Input/index.js +++ b/src/components/Input/index.js @@ -49,7 +49,7 @@ export default function Input(props) { return (
)} */} - {/*
- {video?.price} + {separate(video?.price) + ' '} تومان -
*/} + {/* add to cart */} {addToCartHolder && ( diff --git a/src/redux/actions/index.js b/src/redux/actions/index.js index cc0da2a..d6f4ab0 100644 --- a/src/redux/actions/index.js +++ b/src/redux/actions/index.js @@ -6,6 +6,7 @@ export { default as blog } from "./blog"; export { default as product } from "./product"; export { default as userFactor } from "./userFactor"; export { default as userProduct } from "./userProduct"; +export { default as userAddress } from "./userAddress"; export { default as content } from "./content"; export { default as faq } from "./faq"; export { default as file } from "./file"; diff --git a/src/redux/actions/user.js b/src/redux/actions/user.js index 31fe949..b470f8f 100644 --- a/src/redux/actions/user.js +++ b/src/redux/actions/user.js @@ -1,11 +1,11 @@ import proxy from "../proxy"; const user = { - otp: (data) => async (dispatch) => + otp: (data = {}) => async (dispatch) => await proxy.post("public/sendOTP", data, { dispatch }), otp_login: (data) => async (dispatch) => - await proxy.login("user/otp/login", data, { dispatch }), + await proxy.login("user/otp/login", data, { dispatch }), //{cellphone, otp} login: (data) => async (dispatch) => await proxy.login("user/login", data, { dispatch }), diff --git a/src/redux/actions/userAddress.js b/src/redux/actions/userAddress.js new file mode 100644 index 0000000..fc5e4cb --- /dev/null +++ b/src/redux/actions/userAddress.js @@ -0,0 +1,33 @@ +import proxy from "../proxy"; +const userAddress = { + list: + (data = {}) => + async (dispatch) => { + await proxy.get("userAddress/list", data, { dispatch }); + }, + info: + (data = {}) => + async (dispatch) => { + await dispatch({ type: "userAddress/info", data }); + }, + update: + (data = {}, data2 = {}) => + async (dispatch) => { + await proxy.put("userAddress/update", data); + await proxy.get("userAddress/list", data2, { dispatch }); + }, + add: + (data = {}, data2 = {}, data3 = {}) => + async (dispatch) => { + await proxy.post("userAddress/add", data, { dispatch }); + await proxy.get("userAddress/list", data2, { dispatch }); + }, + del: + (data = {}, data2 = {}) => + async (dispatch) => { + await proxy.delete("userAddress/delete", data); + await proxy.get("userAddress/list", data2, { dispatch }); + }, +}; + +export default userAddress; diff --git a/src/redux/reducers/index.js b/src/redux/reducers/index.js index 584b6eb..c84ef6b 100644 --- a/src/redux/reducers/index.js +++ b/src/redux/reducers/index.js @@ -4,6 +4,7 @@ export { default as user } from "./user"; export { default as book } from "./book"; export { default as blog } from "./blog"; export { default as product } from "./product"; +export { default as userAddress } from "./userAddress"; export { default as faq } from "./faq"; export { default as file } from "./file"; export { default as userFactor } from "./userFactor"; diff --git a/src/redux/reducers/user.js b/src/redux/reducers/user.js index 3b6ff71..dc1b4b8 100644 --- a/src/redux/reducers/user.js +++ b/src/redux/reducers/user.js @@ -19,7 +19,7 @@ export default function user(state = initialState, action) { // case "user/register": // case "user/switchRole": case "public/sendOTP": - return { ...state, loading: false, status: data.profile, error: null }; + return { ...state, loading: false, error: null }; case "user/login": case "user/otp/login": return { diff --git a/src/redux/reducers/userAddress.js b/src/redux/reducers/userAddress.js new file mode 100644 index 0000000..f866776 --- /dev/null +++ b/src/redux/reducers/userAddress.js @@ -0,0 +1,35 @@ +import { toast } from "react-toastify"; + +const initialState = { + loading: false, + error: null, + list: [], + info : null, +}; +export default function userAddress(state = initialState, action) { + let { type, data } = action; + switch (type) { + case "userAddress/list": + return { + ...state, + loading: false, + list: data, + error: null, + }; + case "userAddress/info": + return { ...state, loading: false, info: data, error: null }; + case "userAddress/update": + return { ...state, loading: false, error: null }; + case "userAddress/add": + return { ...state, loading: false, error: null, sum: data.payPrice }; + case "userAddress/delete": + return { ...state, loading: false, error: null }; + case "userAddress/loading": + return { ...state, loading: true }; + case "userAddress/error": + toast.error(data.message); + return { ...state, loading: false, error: data.message }; + default: + return state; + } +} diff --git a/src/utils/onInput.js b/src/utils/onInput.js index 0a45958..c9867d3 100644 --- a/src/utils/onInput.js +++ b/src/utils/onInput.js @@ -80,16 +80,16 @@ class onInput { englishAndNumberWithoutSpace = (txt) => { let newText = txt; newText = newText.replace(/`/g, ""); - newText = newText.replace(/0/g, "0"); - newText = newText.replace(/1/g, "1"); - newText = newText.replace(/2/g, "2"); - newText = newText.replace(/3/g, "3"); - newText = newText.replace(/4/g, "4"); - newText = newText.replace(/5/g, "5"); - newText = newText.replace(/6/g, "6"); - newText = newText.replace(/7/g, "7"); - newText = newText.replace(/8/g, "8"); - newText = newText.replace(/9/g, "9"); + newText = newText.replace(/۰/g, "0"); + newText = newText.replace(/۱/g, "1"); + newText = newText.replace(/۲/g, "2"); + newText = newText.replace(/۳/g, "3"); + newText = newText.replace(/۴/g, "4"); + newText = newText.replace(/۵/g, "5"); + newText = newText.replace(/۶/g, "6"); + newText = newText.replace(/۷/g, "7"); + newText = newText.replace(/۸/g, "8"); + newText = newText.replace(/۹/g, "9"); newText = newText.replace(/ا/g, ""); newText = newText.replace(/ب/g, ""); newText = newText.replace(/پ/g, ""); @@ -149,6 +149,16 @@ class onInput { newText = newText.replace(/7/g, "7"); newText = newText.replace(/8/g, "8"); newText = newText.replace(/9/g, "9"); + newText = newText.replace(/۰/g, "0"); + newText = newText.replace(/۱/g, "1"); + newText = newText.replace(/۲/g, "2"); + newText = newText.replace(/۳/g, "3"); + newText = newText.replace(/۴/g, "4"); + newText = newText.replace(/۵/g, "5"); + newText = newText.replace(/۶/g, "6"); + newText = newText.replace(/۷/g, "7"); + newText = newText.replace(/۸/g, "8"); + newText = newText.replace(/۹/g, "9"); newText = newText.replace(/ا/g, ""); newText = newText.replace(/ب/g, ""); newText = newText.replace(/پ/g, ""); diff --git a/src/views/Address/index.js b/src/views/Address/index.js new file mode 100644 index 0000000..d24dcae --- /dev/null +++ b/src/views/Address/index.js @@ -0,0 +1,61 @@ +import React, {useState} from "react"; +import { connect } from "react-redux"; + +import Input from "../../components/Input"; + +export const Address = ({}) => { + const [addressFields, setAddressFields] = useState({}); + const onChange = (name, value) => { + + } + + const Header = ({ title, text }) => { + return ( +{text}
+لطفا نام و نام خانوادگی خود را به طور کامل وارد نمایید
+- {factorInfo?.payPrice} - تومان -
-- هزینه ارسال کالا پس از تعیین محل آدرس مشخص میشود -
-