master
amir hosein gorji 3 years ago
parent e6ced3736d
commit 98221e85ae
  1. 188
      src/AppRouter.js
  2. 5
      src/Redux/actions/userFactor.js
  3. 5
      src/Redux/reducers/userFactor.js
  4. 2
      src/views/Cart/DeliveryMethod/index.scss
  5. 6
      src/views/Cart/Discount/index.js
  6. 66
      src/views/Cart/index.js

@ -66,9 +66,10 @@ class AppRouter extends Component {
render() {
const mobile = window.innerWidth < 1000 ? true : false;
let status = proxy.status();
let home = mobile ? (
<Route exact path={"/"}>
{proxy.status() ? (
{status ? (
this.props.profile.status ? (
<Home />
) : (
@ -89,105 +90,26 @@ class AppRouter extends Component {
<Switch>
{home}
<Route exact path={"/faq"}>
{mobile ? (
proxy.status() ? (
<Faq />
) : (
<Redirect
to={{
pathname: "/",
}}
/>
)
) : proxy.status() ? (
<Faq />
) : (
<Redirect
to={{
pathname: "/auth",
}}
/>
)}
<Faq />
</Route>
<Route exact path={"/contact"}>
{mobile ? (
proxy.status() ? (
<Contact />
) : (
<Redirect
to={{
pathname: "/",
}}
/>
)
) : (
<Contact />
)}
<Contact />
</Route>
<Route exact path={"/blogs"}>
{mobile ? (
proxy.status() ? (
<Blogs />
) : (
<Redirect
to={{
pathname: "/",
}}
/>
)
) : (
<Blogs />
)}
<Blogs />
</Route>
<Route exact path={"/blogs/:id"}>
{mobile ? (
proxy.status() ? (
<Blog />
) : (
<Redirect
to={{
pathname: "/",
}}
/>
)
) : (
<Blog />
)}
<Blog />
</Route>
<Route exact path={"/about"}>
{mobile ? (
proxy.status() ? (
<About />
) : (
<Redirect
to={{
pathname: "/",
}}
/>
)
) : (
<About />
)}
<About />
</Route>
<Route exact path={"/products"}>
{mobile ? (
proxy.status() ? (
<Products />
) : (
<Redirect
to={{
pathname: "/",
}}
/>
)
) : (
<Products />
)}
<Products />
</Route>
<Route exact path={"/newProfile"}>
{mobile ? (
proxy.status() ? (
status ? (
<NewProfile />
) : (
<Redirect
@ -202,7 +124,7 @@ class AppRouter extends Component {
</Route>
<Route exact path={"/support"}>
{mobile ? (
proxy.status() ? (
status ? (
<Support />
) : (
<Redirect
@ -216,40 +138,16 @@ class AppRouter extends Component {
)}
</Route>
<Route exact path={"/products/digital/:id"}>
{mobile ? (
proxy.status() ? (
<Product page="digital" />
) : (
<Redirect
to={{
pathname: "/",
}}
/>
)
) : (
<Product page="digital" />
)}
<Product page="digital" />
</Route>
<Route exact path={"/products/physical/:id"}>
{mobile ? (
proxy.status() ? (
<Product page="physical" />
) : (
<Redirect
to={{
pathname: "/",
}}
/>
)
) : (
<Product page="physical" />
)}
<Product page="physical" />
</Route>
<Route exact path={"/qr"}>
<QR />
</Route>
<Route exact path={"/auth"}>
{proxy.status() ? (
{status ? (
<Redirect
to={{
pathname: "/",
@ -261,7 +159,7 @@ class AppRouter extends Component {
</Route>
<Route exact path={"/profile"}>
{mobile ? (
proxy.status() ? (
status ? (
<Auth page={"profile"} />
) : (
<Redirect
@ -270,7 +168,7 @@ class AppRouter extends Component {
}}
/>
)
) : proxy.status() ? (
) : status ? (
<Auth page={"profile"} />
) : (
<Redirect
@ -282,7 +180,7 @@ class AppRouter extends Component {
</Route>
<Route exact path={"/qr-scan"}>
{mobile ? (
proxy.status() ? (
status ? (
<QRScan />
) : (
<Redirect
@ -291,7 +189,7 @@ class AppRouter extends Component {
}}
/>
)
) : proxy.status() ? (
) : status ? (
<QRScan />
) : (
<Redirect
@ -303,7 +201,7 @@ class AppRouter extends Component {
</Route>
<Route exact path={"/activation"}>
{mobile ? (
proxy.status() ? (
status ? (
<Activation />
) : (
<Redirect
@ -312,7 +210,7 @@ class AppRouter extends Component {
}}
/>
)
) : proxy.status() ? (
) : status ? (
<Activation />
) : (
<Redirect
@ -324,7 +222,7 @@ class AppRouter extends Component {
</Route>
<Route exact path={"/chatroom"}>
{mobile ? (
proxy.status() ? (
status ? (
<ChatList />
) : (
<Redirect
@ -333,7 +231,7 @@ class AppRouter extends Component {
}}
/>
)
) : proxy.status() ? (
) : status ? (
<ChatList />
) : (
<Redirect
@ -345,7 +243,7 @@ class AppRouter extends Component {
</Route>
<Route exact path={"/cart"}>
{mobile ? (
proxy.status() ? (
status ? (
this.props.userProductList.length > 0 ||
!this.state.cartControll ? (
<Cart />
@ -364,7 +262,7 @@ class AppRouter extends Component {
}}
/>
)
) : proxy.status() ? (
) : status ? (
!this.state.cartControll ||
this.props.userProductList.length > 0 ? (
<Cart />
@ -386,7 +284,7 @@ class AppRouter extends Component {
</Route>
<Route exact path={"/mybooks"}>
{mobile ? (
proxy.status() ? (
status ? (
<MyBooks />
) : (
<Redirect
@ -395,7 +293,7 @@ class AppRouter extends Component {
}}
/>
)
) : proxy.status() ? (
) : status ? (
<MyBooks />
) : (
<Redirect
@ -407,7 +305,7 @@ class AppRouter extends Component {
</Route>
<Route exact path={"/ar"}>
{mobile ? (
proxy.status() ? (
status ? (
<AR />
) : (
<Redirect
@ -416,7 +314,7 @@ class AppRouter extends Component {
}}
/>
)
) : proxy.status() ? (
) : status ? (
<AR />
) : (
<Redirect
@ -431,7 +329,7 @@ class AppRouter extends Component {
</Route>
<Route exact path={"/chatroom/:id"}>
{mobile ? (
proxy.status() ? (
status ? (
<Chatroom />
) : (
<Redirect
@ -440,7 +338,7 @@ class AppRouter extends Component {
}}
/>
)
) : proxy.status() ? (
) : status ? (
<Chatroom />
) : (
<Redirect
@ -451,25 +349,17 @@ class AppRouter extends Component {
)}
</Route>
<Route path={""}>
{proxy.status() ? (
<Redirect
to={{
pathname: "/qr",
search:
"?id=" +
window.location.pathname.slice(
window.location.pathname.lastIndexOf("/") + 1,
window.location.pathname.length
),
}}
/>
) : (
<Redirect
to={{
pathname: "/auth",
}}
/>
)}
<Redirect
to={{
pathname: "/qr",
search:
"?id=" +
window.location.pathname.slice(
window.location.pathname.lastIndexOf("/") + 1,
window.location.pathname.length
),
}}
/>
</Route>
</Switch>
</Router>

@ -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) => {

@ -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":

@ -20,7 +20,7 @@
h3,
span {
color: #02a255;
font-family: numeralMedium;
font-family: numeralLight;
}
}

@ -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,

@ -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 (
<div
align="center"
className={window.innerWidth < 1000 ? "mobile-cart" : "cart "}
>
<Navbar />
<div align="center" style={{ marginTop: 50 }}>
هیچ محصولی در سبد خرید شما وجود ندارد
</div>
<br />
<Link
to="/products"
style={{
textDecoration: "none",
width: "80%",
textAlign: "center",
backgroundColor: "green",
color: "white",
borderRadius: "10px",
padding: "5px 10px",
margin: "10 auto",
}}
>
فروشگاه
</Link>
</div>
);
return (
<>
{window.innerWidth > 1000 ? (
@ -119,6 +154,10 @@ class Cart extends Component {
<>
<div className="cart d-flex flex-column">
<Navbar />
{window.location.search.includes("NOK") ||
this.props.isVerified == false ? (
<div>پرداخت شما با خطا مواجه شد ، لطفا مجدد تلاش نمایید</div>
) : null}
<div
className="d-flex"
style={{ width: "100%", flex: 1, marginBottom: 10 }}
@ -216,6 +255,9 @@ class Cart extends Component {
list.length > 0 ? (
<div className="mobile-cart d-flex flex-column">
<Navbar />
{window.location.search.includes("NOK") ? (
<div>پرداخت شما با خطا مواجه شد ، لطفا مجدد تلاش نمایید</div>
) : null}
<h1 style={{ fontSize: fontSize.mobile.h1 }}>سبد خرید</h1>
<div className="d-flex">
<Table
@ -304,6 +346,7 @@ export default connect(
factorInfo: state.userFactor.info,
userId: state.user.status.id,
hasPhysical: state.userProduct.hasPhysical,
isVerified: state.userFactor.isVerified,
}),
{
getList: userProduct.list,
@ -311,5 +354,6 @@ export default connect(
getTransportList: transport.list,
getFactorInfo: userFactor.info,
payFactor: userFactor.payment,
getVerify: userFactor.verify,
}
)(Cart);

Loading…
Cancel
Save