diff --git a/src/AppRouter.js b/src/AppRouter.js index 83b85a9..5532938 100644 --- a/src/AppRouter.js +++ b/src/AppRouter.js @@ -66,9 +66,10 @@ class AppRouter extends Component { render() { const mobile = window.innerWidth < 1000 ? true : false; + let status = proxy.status(); let home = mobile ? ( - {proxy.status() ? ( + {status ? ( this.props.profile.status ? ( ) : ( @@ -89,105 +90,26 @@ class AppRouter extends Component { {home} - {mobile ? ( - proxy.status() ? ( - - ) : ( - - ) - ) : proxy.status() ? ( - - ) : ( - - )} + - {mobile ? ( - proxy.status() ? ( - - ) : ( - - ) - ) : ( - - )} + - {mobile ? ( - proxy.status() ? ( - - ) : ( - - ) - ) : ( - - )} - {mobile ? ( - proxy.status() ? ( - - ) : ( - - ) - ) : ( - - )} + - {mobile ? ( - proxy.status() ? ( - - ) : ( - - ) - ) : ( - - )} + - {mobile ? ( - proxy.status() ? ( - - ) : ( - - ) - ) : ( - - )} + {mobile ? ( - proxy.status() ? ( + status ? ( ) : ( {mobile ? ( - proxy.status() ? ( + status ? ( ) : ( - {mobile ? ( - proxy.status() ? ( - - ) : ( - - ) - ) : ( - - )} + - {mobile ? ( - proxy.status() ? ( - - ) : ( - - ) - ) : ( - - )} + - {proxy.status() ? ( + {status ? ( {mobile ? ( - proxy.status() ? ( + status ? ( ) : ( ) - ) : proxy.status() ? ( + ) : status ? ( ) : ( {mobile ? ( - proxy.status() ? ( + status ? ( ) : ( ) - ) : proxy.status() ? ( + ) : status ? ( ) : ( {mobile ? ( - proxy.status() ? ( + status ? ( ) : ( ) - ) : proxy.status() ? ( + ) : status ? ( ) : ( {mobile ? ( - proxy.status() ? ( + status ? ( ) : ( ) - ) : proxy.status() ? ( + ) : status ? ( ) : ( {mobile ? ( - proxy.status() ? ( + status ? ( this.props.userProductList.length > 0 || !this.state.cartControll ? ( @@ -364,7 +262,7 @@ class AppRouter extends Component { }} /> ) - ) : proxy.status() ? ( + ) : status ? ( !this.state.cartControll || this.props.userProductList.length > 0 ? ( @@ -386,7 +284,7 @@ class AppRouter extends Component { {mobile ? ( - proxy.status() ? ( + status ? ( ) : ( ) - ) : proxy.status() ? ( + ) : status ? ( ) : ( {mobile ? ( - proxy.status() ? ( + status ? ( ) : ( ) - ) : proxy.status() ? ( + ) : status ? ( ) : ( {mobile ? ( - proxy.status() ? ( + status ? ( ) : ( ) - ) : proxy.status() ? ( + ) : status ? ( ) : ( - {proxy.status() ? ( - - ) : ( - - )} + diff --git a/src/Redux/actions/userFactor.js b/src/Redux/actions/userFactor.js index e579261..fbb560c 100644 --- a/src/Redux/actions/userFactor.js +++ b/src/Redux/actions/userFactor.js @@ -18,6 +18,11 @@ const userFactor = { async (dispatch) => { await proxy.post("userFactor/payment", data, { dispatch }); }, + verify: + (data = {}) => + async (dispatch) => { + await proxy.post("userFactor/verify", data, { dispatch }); + }, add: (data = {}, data2 = {}) => async (dispatch) => { diff --git a/src/Redux/reducers/userFactor.js b/src/Redux/reducers/userFactor.js index 0866c5e..db3a6d1 100644 --- a/src/Redux/reducers/userFactor.js +++ b/src/Redux/reducers/userFactor.js @@ -7,6 +7,7 @@ const initialState = { info: null, sum: null, checkEmpty: false, + isVerified: null, }; export default function userFactor(state = initialState, action) { let { type, data, message } = action; @@ -33,7 +34,9 @@ export default function userFactor(state = initialState, action) { return { ...state, loading: false, error: null }; case "userFactor/payment": window.location.replace(data); - return { ...state, loading: false, error: null }; + return { ...state, loading: false, error: null, isVerified: false }; + case "userFactor/verify": + return { ...state, loading: false, error: null, isVerified: true }; case "loading": return { ...state, loading: true }; case "error": diff --git a/src/views/Cart/DeliveryMethod/index.scss b/src/views/Cart/DeliveryMethod/index.scss index 7f960da..78ebf0c 100644 --- a/src/views/Cart/DeliveryMethod/index.scss +++ b/src/views/Cart/DeliveryMethod/index.scss @@ -20,7 +20,7 @@ h3, span { color: #02a255; - font-family: numeralMedium; + font-family: numeralLight; } } diff --git a/src/views/Cart/Discount/index.js b/src/views/Cart/Discount/index.js index 13b4243..2a13f79 100644 --- a/src/views/Cart/Discount/index.js +++ b/src/views/Cart/Discount/index.js @@ -24,7 +24,7 @@ const fontSize = { const DiscoutCode = ({ codeId, setCodeId, userId, factorId }) => { const [value, setValue] = React.useState(codeId || ""); function setOff() { - setCodeId({ offCodeValue: value, userId: userId, id: factorId }); + setCodeId({ offCodeValue: value, userId: userId, id: factorId || null }); } return ( <> @@ -77,9 +77,9 @@ const DiscoutCode = ({ codeId, setCodeId, userId, factorId }) => { export default connect( (state) => ({ - codeId: state.userFactor.info.codeId, + codeId: state.userFactor.info?.codeId, userId: state.user.status.id, - factorId: state.userFactor.info.id, + factorId: state.userFactor.info?.id, }), { setCodeId: userFactor.update, diff --git a/src/views/Cart/index.js b/src/views/Cart/index.js index ca43bff..8604b4f 100644 --- a/src/views/Cart/index.js +++ b/src/views/Cart/index.js @@ -9,6 +9,7 @@ import DiscoutCode from "./Discount/index"; import DeliveryMethod from "./DeliveryMethod/index"; import Factor from "./Factor/index"; import Loader from "~/components/Loader/index"; +import { Link } from "react-router-dom"; import sciense_6 from "../../assets/images/sciense-6.png"; @@ -47,20 +48,26 @@ class Cart extends Component { }; componentDidUpdate(prevProps, prevState) { - if (this.props.list.length > 0) { - console.log("h1", this.props.factorInfo); - if ( - this.props.factorInfo === null && - this.state.controlFactorInfoRepeat - ) { - this.props.getFactorInfo({ id: this.props.list[0].factorId }); - this.setState({ - controlFactorInfoRepeat: false, - }); + if (window.location.search) + if (!window.location.search.includes("NOK") && !window.location.hash) { + let Authority = window.location.search + .slice(1) + .split("&")[0] + .split("=")[1]; + this.props.getVerify({ Authority }); + window.location.hash = "verified"; } + + if (this.props.factorInfo === null && this.state.controlFactorInfoRepeat) { + this.props.getFactorInfo({}); + this.setState({ + controlFactorInfoRepeat: false, + }); + } + if (this.props.list.length > 0) { let wantedId; //should be zero for (let item of this.props.list) { - if (item.condition) { + if (item.condition == 2) { wantedId = item.id; break; } @@ -112,6 +119,34 @@ class Cart extends Component { render() { const { list, payPrice, payMethods, factorInfo, userId, hasPhysical } = this.props; + if (!this.props.factorInfo) + return ( +
+ +
+ هیچ محصولی در سبد خرید شما وجود ندارد +
+
+ + فروشگاه + +
+ ); return ( <> {window.innerWidth > 1000 ? ( @@ -119,6 +154,10 @@ class Cart extends Component { <>
+ {window.location.search.includes("NOK") || + this.props.isVerified == false ? ( +
پرداخت شما با خطا مواجه شد ، لطفا مجدد تلاش نمایید
+ ) : null}
0 ? (
+ {window.location.search.includes("NOK") ? ( +
پرداخت شما با خطا مواجه شد ، لطفا مجدد تلاش نمایید
+ ) : null}

سبد خرید