diff --git a/src/App.js b/src/App.js index 1a25560..48c40aa 100644 --- a/src/App.js +++ b/src/App.js @@ -3,6 +3,7 @@ import AppRouter from "./AppRouter"; import store from "./Redux/store"; import { Provider } from "react-redux"; import "bootstrap/dist/css/bootstrap.min.css"; +import "react-toastify/dist/ReactToastify.css"; class App extends Component { render() { diff --git a/src/AppRouter.js b/src/AppRouter.js index 95fa4aa..acd8785 100644 --- a/src/AppRouter.js +++ b/src/AppRouter.js @@ -89,8 +89,11 @@ class AppRouter extends Component { - - + + + + + diff --git a/src/Redux/actions/public.js b/src/Redux/actions/public.js index b02d22b..61eec87 100644 --- a/src/Redux/actions/public.js +++ b/src/Redux/actions/public.js @@ -8,6 +8,10 @@ const publicApi = { await dispatch({ type: "public/faq/activate", data: data }), searchFaq: (data) => async (dispatch) => await dispatch({ type: "public/faq/search", data: data }), + getContactData: + (data = {}, history) => + async (dispatch) => + await proxy.get("public/contact", data, { history, dispatch }), }; export default publicApi; diff --git a/src/Redux/actions/userProduct.js b/src/Redux/actions/userProduct.js index 0959bcd..ddac3f5 100644 --- a/src/Redux/actions/userProduct.js +++ b/src/Redux/actions/userProduct.js @@ -17,7 +17,7 @@ const userProduct = { add: (data = {}, data2 = {}) => async (dispatch) => { - await proxy.post("userProduct/add", data); + await proxy.post("userProduct/add", data, { dispatch }); await proxy.get("userProduct/list", data2, { dispatch }); }, del: diff --git a/src/Redux/reducers/public.js b/src/Redux/reducers/public.js index bff629d..600b457 100644 --- a/src/Redux/reducers/public.js +++ b/src/Redux/reducers/public.js @@ -1,9 +1,10 @@ const initialState = { homeData: [], faqList: [], - loading: false, + loading: true, error: null, searchResult: [], + contactData: null, }; export default function publicApi(state = initialState, action) { let { type, data } = action; @@ -35,10 +36,13 @@ export default function publicApi(state = initialState, action) { item.description.indexOf(data) !== -1 ), }; + case "public/contact": + return { ...state, loading: false, error: null, contactData: data }; case "loading": return { ...state, loading: true }; case "error": return { ...state, loading: false, error: data.message }; + default: return state; } diff --git a/src/Redux/reducers/userProduct.js b/src/Redux/reducers/userProduct.js index 44b2323..6715457 100644 --- a/src/Redux/reducers/userProduct.js +++ b/src/Redux/reducers/userProduct.js @@ -1,11 +1,14 @@ +import { toast } from "react-toastify"; + const initialState = { loading: false, error: null, list: null, info: null, + sum: null, }; export default function userProduct(state = initialState, action) { - let { type, data } = action; + let { type, data, message } = action; switch (type) { case "userProduct/list": return { ...state, loading: false, list: data, error: null }; @@ -14,13 +17,16 @@ export default function userProduct(state = initialState, action) { case "userProduct/update": return { ...state, loading: false, error: null }; case "userProduct/add": - return { ...state, loading: false, error: null }; + console.log(data); + toast.success("درخواست شما با موفقیت انجام شد."); + return { ...state, loading: false, error: null, sum: data.payPrice }; case "userProduct/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; diff --git a/src/views/Cart/Table/index.js b/src/views/Cart/Table/index.js index e0086c5..da03c18 100644 --- a/src/views/Cart/Table/index.js +++ b/src/views/Cart/Table/index.js @@ -1,4 +1,7 @@ import React from "react"; +import { connect } from "react-redux"; +import { userProduct } from "~/Redux/actions"; + import { makeStyles } from "@material-ui/core/styles"; import Table from "@material-ui/core/Table"; import TableBody from "@material-ui/core/TableBody"; @@ -56,7 +59,7 @@ const fontSize = { }, }; -export default function BasicTable(props) { +function BasicTable(props) { const classes = useStyles(); const { list, handleCounter, handleDelete } = props; const sum = () => { @@ -91,7 +94,10 @@ export default function BasicTable(props) { ))} @@ -100,7 +106,9 @@ export default function BasicTable(props) { {sum()} محصول - مبلغ کل {totalPrice()} + + مبلغ کل {props.payPrice} + @@ -123,7 +131,10 @@ export default function BasicTable(props) { ))} @@ -132,7 +143,9 @@ export default function BasicTable(props) { - مبلغ کل {totalPrice()} + + مبلغ کل {props.payPrice} + {sum()} محصول @@ -149,33 +162,31 @@ export default function BasicTable(props) { ); } -// id: 1, -// title: "ریاضیات گسسته خیلی پیشرفته", -// subTitle: "در این قسمت توضیح بسیار کوتاهی قرار می گیرد", -// options: "بسته‌های الحاقی: کیف، کفش و کوله پشتی", -// image: book1, -// slicePrice: 300000, -// number: 1, -// price: 2500000, - const Item = (props) => { - const { data, handleCounter, handleDelete } = props; + const { data, pushToCart, handleDelete, info, id } = props; return ( <> {window.innerWidth < 1000 ? ( - +
- {data.title} + {data.product.book.name}
- {data.title} + {`کتاب ${ + data.product.productType === "1" ? "دیجیتال" : "فیزیکی" + }` + + " " + + data.product.book.name}

- {data.subTitle} + {data.product.book.category}

- {data.options} + {data.product.book.item || "هیچی"}
{
- {data.price} + {data.product.book.price || "1000"} - {data.slicePrice} قیمت هر واحد + {data.product.book.subPrice || "100"} قیمت هر واحد
- {data.number} + {data.count} - {data.number} + {data.count}