کار های اولیه فاکتور

master
Gorji 3 years ago
parent ba0f1125b9
commit b6c32a8dfa
  1. 1
      src/Redux/actions/index.js
  2. 31
      src/Redux/actions/userFactor.js
  3. 1
      src/Redux/reducers/index.js
  4. 44
      src/Redux/reducers/userFactor.js
  5. 42
      src/views/Cart/Discount/index.js
  6. 17
      src/views/Cart/Factor/index.js
  7. 39
      src/views/Cart/Table/index.js
  8. 4
      src/views/Cart/Table/index.scss
  9. 45
      src/views/Cart/index.js
  10. 4
      src/views/Cart/index.scss
  11. 2
      src/views/Home/Navbar/Laptop/index.scss

@ -7,5 +7,6 @@ export { default as user } from "./user.js";
export { default as qr } from "./qr.js";
export { default as book } from "./book.js";
export { default as userProduct } from "./userProduct.js";
export { default as userFactor } from "./userFactor.js";
export { default as transport } from "./transport.js";
export { default as comment } from "./comment.js";

@ -0,0 +1,31 @@
import proxy from "../proxy";
const userFactor = {
list:
(data = {}) =>
async (dispatch) =>
await proxy.get("userFactor/list", data, { dispatch }),
info:
(data = {}) =>
async (dispatch) =>
await proxy.get("userFactor/info", data, { dispatch }),
update:
(data = {}, data2 = {}) =>
async (dispatch) => {
await proxy.put("userFactor/update", data);
await proxy.get("userFactor/list", data2, { dispatch });
},
add:
(data = {}, data2 = {}) =>
async (dispatch) => {
await proxy.post("userFactor/add", data, { dispatch });
await proxy.get("userFactor/list", data2, { dispatch });
},
del:
(data = {}, data2 = {}) =>
async (dispatch) => {
await proxy.delete("userFactor/delete", data);
await proxy.get("userFactor/list", data2, { dispatch });
},
};
export default userFactor;

@ -7,5 +7,6 @@ export { default as user } from "./user.js";
export { default as qr } from "./qr.js";
export { default as book } from "./book.js";
export { default as userProduct } from "./userProduct.js";
export { default as userFactor } from "./userFactor.js";
export { default as transport } from "./transport.js";
export { default as comment } from "./comment.js";

@ -0,0 +1,44 @@
import { toast } from "react-toastify";
const initialState = {
loading: false,
error: null,
list: [],
info: null,
sum: null,
checkEmpty: false,
};
export default function userFactor(state = initialState, action) {
let { type, data, message } = action;
switch (type) {
case "userFactor/list":
const checkEmpty = data.filter(
(item) => item.condition === 2 && item.product.productType === (1 || 3)
);
return {
...state,
loading: false,
list: data,
checkEmpty: checkEmpty.length > 0 ? false : true,
error: null,
};
case "userFactor/info":
return { ...state, loading: false, info: data, error: null };
case "userFactor/update":
return { ...state, loading: false, error: null };
case "userFactor/add":
console.log(data);
toast.success("درخواست شما با موفقیت انجام شد.");
return { ...state, loading: false, error: null, sum: data.payPrice };
case "userFactor/delete":
return { ...state, loading: false, error: null };
/////////////
case "loading":
return { ...state, loading: true };
case "error":
toast.error(data.message);
return { ...state, loading: false, error: data.message };
default:
return state;
}
}

@ -1,5 +1,7 @@
import React from "react";
import "./index.scss";
import { connect } from "react-redux";
import { userFactor } from "~/Redux/actions";
const maxDesktopSize = 1250;
const maxMobileSize = 550;
@ -19,19 +21,29 @@ const fontSize = {
},
};
const DiscoutCode = (props) => {
const DiscoutCode = ({ codeId, setCodeId }) => {
const [value, setValue] = React.useState(codeId || "");
function setOff() {
setCodeId({ codeId: value });
}
return (
<>
{window.innerWidth > 1000 ? (
<div className="discount-code d-flex flex-column">
<h2 style={{ fontSize: fontSize.desktop.h2 }}>کد تخفیف</h2>
<p style={{ fontSize: fontSize.desktop.p }}>
اگر کد تخفیفی دارید آن را در کادر زیر وارد نمائید و دکمه ثبت کد را
بزنید
اگر کد تخفیفی دارید آن را در کادر زیر وارد نمائید
</p>
<div className="discount-code__box d-flex align-items-center">
<input style={{ fontSize: fontSize.desktop.input }} type="text" />
<button style={{ fontSize: fontSize.desktop.button }}>
<input
style={{ fontSize: fontSize.desktop.input }}
type="text"
onChange={(e) => setValue(e.target.value)}
/>
<button
style={{ fontSize: fontSize.desktop.button }}
onClick={setOff}
>
ثبت کد
</button>
</div>
@ -41,12 +53,20 @@ const DiscoutCode = (props) => {
<div className="mobile-discount-code d-flex flex-column">
<h2 style={{ fontSize: fontSize.mobile.h2 }}>کد تخفیف</h2>
<p style={{ fontSize: fontSize.mobile.p }}>
اگر کد تخفیفی دارید آن را در کادر زیر وارد نمائید و دکمه ثبت کد را
بزنید
اگر کد تخفیفی دارید آن را در کادر زیر وارد نمائید{" "}
</p>
<div className="mobile-discount-code__box d-flex align-items-center">
<input style={{ fontSize: fontSize.mobile.input }} type="text" />
<button style={{ fontSize: fontSize.mobile.button }}>ثبت کد</button>
<input
style={{ fontSize: fontSize.mobile.input }}
type="text"
onChange={(e) => setValue(e.target.value)}
/>
<button
style={{ fontSize: fontSize.mobile.button }}
onClick={setOff}
>
ثبت کد
</button>
</div>
</div>
) : null}
@ -54,4 +74,6 @@ const DiscoutCode = (props) => {
);
};
export default DiscoutCode;
export default connect((state) => ({ codeId: state.userFactor.codeId }), {
setCodeId: userFactor.update,
})(DiscoutCode);

@ -26,11 +26,10 @@ const fontSize = {
const Factor = (props) => {
const { list, parent } = props;
const totalPrice = () => {
let total = 0;
for (let i = 0; i < parent.state.list.length; i++) {
total += parent.state.list[i].price * parent.state.list[i].number;
for (let i = 0; i < list.length; i++) {
total += list[i].product.price * list[i].count;
}
return total;
};
@ -44,7 +43,12 @@ const Factor = (props) => {
</div>
<div className="d-flex justify-content-between">
<strong>هزینه ارسال</strong>
<span>{props.parent.state.selectedDelivery.price} تومان</span>
<span>
{props.parent.props.list.length
? props.parent.state.selectedDelivery.price
: 0}{" "}
تومان
</span>
</div>
<div className="d-flex justify-content-between">
<strong>میزان تخفیف</strong>
@ -67,7 +71,10 @@ const Factor = (props) => {
هزینه ارسال
</strong>
<span style={{ fontSize: fontSize.desktop.span }}>
{props.parent.state.selectedDelivery.price} تومان
{props.parent.props.list.length
? props.parent.state.selectedDelivery.price
: 0}{" "}
تومان
</span>
</div>
<div className="d-flex justify-content-between">

@ -111,7 +111,7 @@ function BasicTable(props) {
<TableRow>
<TableCell align="center">
<span style={{ color: "grey" }}>
مبلغ کل {props.payPrice}
مبلغ کل {Math.round(props.payPrice)}
</span>
</TableCell>
<TableCell align="right" component="th" scope="row">
@ -153,7 +153,7 @@ function BasicTable(props) {
</TableCell>
<TableCell align="center">
<span style={{ color: "grey" }}>
مبلغ کل {props.payPrice}
مبلغ کل {Math.round(props.payPrice)}
</span>
</TableCell>
<TableCell align="center" component="th" scope="row">
@ -186,7 +186,7 @@ const Item = (props) => {
<div className="mobile-cart-table-product__info d-flex flex-column p-1">
<strong style={{ fontSize: fontSize.mobile.info.strong }}>
{`کتاب ${
data.product.productType === "1" ? "دیجیتال" : "فیزیکی"
+data.product.productType === 1 ? "دیجیتال" : "فیزیکی"
}` +
" " +
data.product.book.name}
@ -195,16 +195,28 @@ const Item = (props) => {
{data.product.book.category}
</p>
<span style={{ fontSize: fontSize.mobile.info.span }}>
{data.product.book.item || "هیچی"}
{data.product.book.item || ""}
</span>
{route !== "callback" ? (
<div className="mobile-cart-table-product__info--delete d-flex align-items-center align-self-end">
<DeleteOutlineOutlinedIcon
style={{ color: "#FC120A", fontSize: 25, marginLeft: 0 }}
onClick={() => handleDelete(data.id)}
onClick={() =>
pushToCart({
productId: data.productId,
userId: id,
count: -data.count,
})
}
/>
<span
onClick={() => handleDelete(data.id)}
onClick={() =>
pushToCart({
productId: data.productId,
userId: id,
count: -data.count,
})
}
style={{
fontSize: fontSize.mobile.delete.span,
color: "#FC120A",
@ -221,11 +233,11 @@ const Item = (props) => {
<div className="mobile-cart-table-price d-flex flex-column align-items-center">
<div className="mobile-cart-table-price__price d-flex flex-column justify-content-center align-items-center">
<strong style={{ fontSize: fontSize.mobile.price.strong }}>
{data.product.book.price || "1000"}
{data.product.price * data.count || "1000"}
</strong>
{route !== "callback" ? (
<span style={{ fontSize: fontSize.mobile.price.span }}>
{data.product.book.subPrice || "100"} قیمت هر واحد
{data.product.price || "100"} قیمت هر واحد
</span>
) : null}
</div>
@ -271,6 +283,7 @@ const Item = (props) => {
) : null}
</TableRow>
) : null}
{console.log(data)}
{window.innerWidth > 1000 ? (
<TableRow key={data.product.book.name}>
<TableCell align="right" component="th" scope="row">
@ -282,7 +295,7 @@ const Item = (props) => {
<div className="d-flex flex-column justify-content-center">
<strong style={{ fontSize: fontSize.desktop.info.strong }}>
{`کتاب ${
data.product.productType === "1" ? "دیجیتال" : "فیزیکی"
+data.product.productType === 1 ? "دیجیتال" : "فیزیکی"
}` +
" " +
data.product.book.name}
@ -299,10 +312,12 @@ const Item = (props) => {
<TableCell>
<div className="cart-item__price d-flex flex-column justify-content-center align-items-center">
<strong style={{ fontSize: fontSize.desktop.price.strong }}>
{data.product.book.price || "1000"} تومان
{data.product.price * data.count || "1000"} تومان
</strong>
<span style={{ fontSize: fontSize.desktop.price.span }}>
{data.product.book.subPrice || "100"} قیمت هر واحد
قیمت هر عدد
{data.product.price || "100"}
تومان
</span>
</div>
</TableCell>
@ -365,5 +380,5 @@ export default connect(
info: state.book.info,
id: state.user.status.id,
}),
{ pushToCart: userProduct.add }
{ pushToCart: userProduct.update }
)(BasicTable);

@ -95,7 +95,7 @@
}
div {
strong {
font-family: numeralBold;
font-family: numeralLight;
color: #373737;
}
p {
@ -114,7 +114,7 @@
&__price {
color: #4d4d4f;
strong {
font-family: numeralBold;
font-family: numeralLight;
}
span {
font-family: numeralLight;

@ -43,38 +43,7 @@ class Cart extends Component {
selectedDelivery: { name: "", price: 0 },
discount: 0,
totalPrice: null,
list: [
{
id: 0,
title: " گسسته ",
subTitle: " گیرد",
options: "بپشتی",
image: sciense_6,
slicePrice: 200000,
number: 1,
price: 1899900,
},
{
id: 1,
title: "ریاضیات گسسته خیلی پیشرفته",
subTitle: "در این قسمت توضیح بسیار کوتاهی قرار می گیرد",
options: "بستههای الحاقی: کیف، کفش و کوله پشتی",
image: sciense_6,
slicePrice: 300000,
number: 1,
price: 2500000,
},
{
id: 2,
title: "ریاضیات گسسته خیلی پیشرفته",
subTitle: "در این قسمت توضیح بسیار کوتاهی قرار می گیرد",
options: "بستههای الحاقی: کیف، کفش و کوله پشتی",
image: sciense_6,
slicePrice: 150000,
number: 1,
price: 1000000,
},
],
list: this.props.list,
};
componentDidUpdate(prevProps, prevState) {
@ -165,7 +134,7 @@ class Cart extends Component {
</div>
</header>
<DiscoutCode />
<Factor parent={this} />
<Factor parent={this} list={list} />
<div className="cart__totalPrice d-flex align-items-center justify-content-center">
<h3 style={{ fontSize: fontSize.mobile.h2 }}>
جمع کل
@ -181,7 +150,7 @@ class Cart extends Component {
</span>
</div>
</div>
<div className="cart__left--header d-flex flex-column mt-3">
{/* <div className="cart__left--header d-flex flex-column mt-3">
<h2 style={{ fontSize: fontSize.desktop.h2 }}>
روشهای ارسال
</h2>
@ -193,7 +162,7 @@ class Cart extends Component {
<DeliveryMethod data={item} key={i} parent={this} />
))}
</div>
</div>
</div> */}
<button className="cart__left--submit">پرداخت</button>
</section>
</div>
@ -236,7 +205,7 @@ class Cart extends Component {
</div>
</div>
<DiscoutCode parent={this} />
<Factor parent={this} />
<Factor parent={this} list={list} />
<div className="mobile-cart__totalPrice d-flex align-items-center justify-content-center">
<h3 style={{ fontSize: fontSize.mobile.h2 }}>
جمع کل
@ -250,7 +219,7 @@ class Cart extends Component {
<span style={{ fontSize: fontSize.mobile.h3 }}>تومان</span>
</div>
</div>
<div className="mobile-cart__payMethods d-flex flex-column">
{/* <div className="mobile-cart__payMethods d-flex flex-column">
<h2 style={{ fontSize: fontSize.mobile.h2 }}>روشهای ارسال</h2>
<p style={{ fontSize: fontSize.mobile.p }}>
با توجه به شرایط یکی از دو گزینه زیر را انتخاب کنید
@ -261,7 +230,7 @@ class Cart extends Component {
<DeliveryMethod data={item} key={i} parent={this} />
))}
</div>
</div>
</div> */}
<button className="mobile-cart__submit">پرداخت</button>
</div>
) : (

@ -18,7 +18,7 @@
div {
margin-right: 20px;
strong {
font-family: numeralBold;
font-family: numeralLight;
color: #4d4d4f;
margin-left: 5px;
}
@ -40,7 +40,7 @@
&--header {
h2 {
font-family: numeralBold;
font-family: numeralLight;
color: #2580ec;
}
p {

@ -20,7 +20,7 @@
position: relative;
left: 14px;
img {
max-height: 88%;
max-height: 60px;
}
}
&__list {

Loading…
Cancel
Save