master
amir hosein gorji 3 years ago
parent e6ced3736d
commit 98221e85ae
  1. 152
      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. 60
      src/views/Cart/index.js

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

@ -18,6 +18,11 @@ const userFactor = {
async (dispatch) => { async (dispatch) => {
await proxy.post("userFactor/payment", data, { dispatch }); await proxy.post("userFactor/payment", data, { dispatch });
}, },
verify:
(data = {}) =>
async (dispatch) => {
await proxy.post("userFactor/verify", data, { dispatch });
},
add: add:
(data = {}, data2 = {}) => (data = {}, data2 = {}) =>
async (dispatch) => { async (dispatch) => {

@ -7,6 +7,7 @@ const initialState = {
info: null, info: null,
sum: null, sum: null,
checkEmpty: false, checkEmpty: false,
isVerified: null,
}; };
export default function userFactor(state = initialState, action) { export default function userFactor(state = initialState, action) {
let { type, data, message } = action; let { type, data, message } = action;
@ -33,7 +34,9 @@ export default function userFactor(state = initialState, action) {
return { ...state, loading: false, error: null }; return { ...state, loading: false, error: null };
case "userFactor/payment": case "userFactor/payment":
window.location.replace(data); 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": case "loading":
return { ...state, loading: true }; return { ...state, loading: true };
case "error": case "error":

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

@ -24,7 +24,7 @@ const fontSize = {
const DiscoutCode = ({ codeId, setCodeId, userId, factorId }) => { const DiscoutCode = ({ codeId, setCodeId, userId, factorId }) => {
const [value, setValue] = React.useState(codeId || ""); const [value, setValue] = React.useState(codeId || "");
function setOff() { function setOff() {
setCodeId({ offCodeValue: value, userId: userId, id: factorId }); setCodeId({ offCodeValue: value, userId: userId, id: factorId || null });
} }
return ( return (
<> <>
@ -77,9 +77,9 @@ const DiscoutCode = ({ codeId, setCodeId, userId, factorId }) => {
export default connect( export default connect(
(state) => ({ (state) => ({
codeId: state.userFactor.info.codeId, codeId: state.userFactor.info?.codeId,
userId: state.user.status.id, userId: state.user.status.id,
factorId: state.userFactor.info.id, factorId: state.userFactor.info?.id,
}), }),
{ {
setCodeId: userFactor.update, setCodeId: userFactor.update,

@ -9,6 +9,7 @@ import DiscoutCode from "./Discount/index";
import DeliveryMethod from "./DeliveryMethod/index"; import DeliveryMethod from "./DeliveryMethod/index";
import Factor from "./Factor/index"; import Factor from "./Factor/index";
import Loader from "~/components/Loader/index"; import Loader from "~/components/Loader/index";
import { Link } from "react-router-dom";
import sciense_6 from "../../assets/images/sciense-6.png"; import sciense_6 from "../../assets/images/sciense-6.png";
@ -47,20 +48,26 @@ class Cart extends Component {
}; };
componentDidUpdate(prevProps, prevState) { componentDidUpdate(prevProps, prevState) {
if (this.props.list.length > 0) { if (window.location.search)
console.log("h1", this.props.factorInfo); if (!window.location.search.includes("NOK") && !window.location.hash) {
if ( let Authority = window.location.search
this.props.factorInfo === null && .slice(1)
this.state.controlFactorInfoRepeat .split("&")[0]
) { .split("=")[1];
this.props.getFactorInfo({ id: this.props.list[0].factorId }); this.props.getVerify({ Authority });
window.location.hash = "verified";
}
if (this.props.factorInfo === null && this.state.controlFactorInfoRepeat) {
this.props.getFactorInfo({});
this.setState({ this.setState({
controlFactorInfoRepeat: false, controlFactorInfoRepeat: false,
}); });
} }
if (this.props.list.length > 0) {
let wantedId; //should be zero let wantedId; //should be zero
for (let item of this.props.list) { for (let item of this.props.list) {
if (item.condition) { if (item.condition == 2) {
wantedId = item.id; wantedId = item.id;
break; break;
} }
@ -112,6 +119,34 @@ class Cart extends Component {
render() { render() {
const { list, payPrice, payMethods, factorInfo, userId, hasPhysical } = const { list, payPrice, payMethods, factorInfo, userId, hasPhysical } =
this.props; 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 ( return (
<> <>
{window.innerWidth > 1000 ? ( {window.innerWidth > 1000 ? (
@ -119,6 +154,10 @@ class Cart extends Component {
<> <>
<div className="cart d-flex flex-column"> <div className="cart d-flex flex-column">
<Navbar /> <Navbar />
{window.location.search.includes("NOK") ||
this.props.isVerified == false ? (
<div>پرداخت شما با خطا مواجه شد ، لطفا مجدد تلاش نمایید</div>
) : null}
<div <div
className="d-flex" className="d-flex"
style={{ width: "100%", flex: 1, marginBottom: 10 }} style={{ width: "100%", flex: 1, marginBottom: 10 }}
@ -216,6 +255,9 @@ class Cart extends Component {
list.length > 0 ? ( list.length > 0 ? (
<div className="mobile-cart d-flex flex-column"> <div className="mobile-cart d-flex flex-column">
<Navbar /> <Navbar />
{window.location.search.includes("NOK") ? (
<div>پرداخت شما با خطا مواجه شد ، لطفا مجدد تلاش نمایید</div>
) : null}
<h1 style={{ fontSize: fontSize.mobile.h1 }}>سبد خرید</h1> <h1 style={{ fontSize: fontSize.mobile.h1 }}>سبد خرید</h1>
<div className="d-flex"> <div className="d-flex">
<Table <Table
@ -304,6 +346,7 @@ export default connect(
factorInfo: state.userFactor.info, factorInfo: state.userFactor.info,
userId: state.user.status.id, userId: state.user.status.id,
hasPhysical: state.userProduct.hasPhysical, hasPhysical: state.userProduct.hasPhysical,
isVerified: state.userFactor.isVerified,
}), }),
{ {
getList: userProduct.list, getList: userProduct.list,
@ -311,5 +354,6 @@ export default connect(
getTransportList: transport.list, getTransportList: transport.list,
getFactorInfo: userFactor.info, getFactorInfo: userFactor.info,
payFactor: userFactor.payment, payFactor: userFactor.payment,
getVerify: userFactor.verify,
} }
)(Cart); )(Cart);

Loading…
Cancel
Save