diff --git a/src/components/ButtonBetween/index.js b/src/components/ButtonBetween/index.js index 36bb3ec..be9ec0c 100644 --- a/src/components/ButtonBetween/index.js +++ b/src/components/ButtonBetween/index.js @@ -1,14 +1,39 @@ import React from "react"; import { connect } from "react-redux"; -export const ButtonBetween = ({ item, status, onClick, width }) => { - return ( +export const ButtonBetween = ({ item, status, onClick, width, active, toggle }) => { + return toggle ? ( onClick()} - style={{ width, padding : '18px 8px' }} + style={{ width, padding: "18px 8px" }} + > + + {item} + + {status && ( + + {status} + + )} + + ) : ( + onClick()} + style={{ width, padding: "18px 8px" }} > {item} {status && ( diff --git a/src/views/DeliveryForm/Address/index.js b/src/views/DeliveryForm/Address/index.js index a142a13..c1c7b68 100644 --- a/src/views/DeliveryForm/Address/index.js +++ b/src/views/DeliveryForm/Address/index.js @@ -86,7 +86,7 @@ function Address({ ); }; return isMobile ? ( - + انتخاب آدرس @@ -101,7 +101,7 @@ function Address({ setPhase("address")} diff --git a/src/views/DeliveryForm/TransportDate/index.js b/src/views/DeliveryForm/TransportDate/index.js index ea2edf7..36a18c4 100644 --- a/src/views/DeliveryForm/TransportDate/index.js +++ b/src/views/DeliveryForm/TransportDate/index.js @@ -1,40 +1,21 @@ import React, { useState } from "react"; import { connect } from "react-redux"; +//components +import ButtonBetween from "../../../components/ButtonBetween"; + function TransportDate({ transportDate, isMobile }) { const [activeDate, setActiveDate] = useState(transportDate?.times[0]); const Time = ({ time }) => { return isMobile ? ( - setActiveDate(time)} - style={{ width: "48%" }} - > - - {time.time} - - {time.status === "completed" && ( - - تکمیل ظرفیت - - )} - + active={activeDate === time} + toggle={true} + /> ) : ( زمان ارسال را انتخاب کنید - + {transportDate.times.map((time, index) => ( ))} diff --git a/src/views/DeliveryForm/TransportMethod/index.js b/src/views/DeliveryForm/TransportMethod/index.js index 037e127..ac86924 100644 --- a/src/views/DeliveryForm/TransportMethod/index.js +++ b/src/views/DeliveryForm/TransportMethod/index.js @@ -2,7 +2,10 @@ import React, { useEffect } from "react"; import separate from "../../../utils/separate"; import { connect } from "react-redux"; import { transport } from "../../../redux/actions"; + +//components import Loading from "../../../components/Loading"; +import ButtonBetween from "../../../components/ButtonBetween"; function TransportMethod({ list, @@ -13,23 +16,18 @@ function TransportMethod({ userId, loading, }) { - useEffect(() => { if (list.length === 0) { getList(); } }, []); - const Method = ({ method }) => { + const Method = ({ method, active }) => { return isMobile ? ( - - factorInfo?.transportId !== method?.id + !active ? setTransport( { factorId: factorInfo?.id, transportId: method?.id }, { userId }, @@ -37,42 +35,11 @@ function TransportMethod({ ) : {} } - > - {loading && factorInfo?.transportId !== method?.id ? ( - - ) : ( - - {method.name} - - )} - - هزینه ارسال {separate(method.price)} - - {/* */} - + item={"ارسال با" + " " + method.name} + status={separate(method.price) + " " + "تومان"} + active={active} + toggle={true} + /> ) : ( - factorInfo?.transportId !== method?.id + !active ? setTransport( { factorId: factorInfo?.id, transportId: method?.id }, { userId }, @@ -90,19 +57,12 @@ function TransportMethod({ : {} } > - {loading && factorInfo?.transportId !== method?.id ? ( - + {loading && !active ? ( + ) : ( لطفا یک روش ارسال انتخاب کنید - + {list.map((method, index) => ( - + ))} @@ -141,7 +105,11 @@ function TransportMethod({ {list.map((method, index) => ( - + ))} diff --git a/src/views/ShoppingCart/index.js b/src/views/ShoppingCart/index.js index 6dc71e8..c005cdf 100644 --- a/src/views/ShoppingCart/index.js +++ b/src/views/ShoppingCart/index.js @@ -197,17 +197,17 @@ function ShoppingCart({ @@ -216,7 +216,7 @@ function ShoppingCart({ جمع کل سبد خرید - {separate(factorInfo?.payPrice) + " " + "تومان"} + {separate(productsLength ? factorInfo?.payPrice : 0) + " " + "تومان"}
- {separate(factorInfo?.payPrice) + " " + "تومان"} + {separate(productsLength ? factorInfo?.payPrice : 0) + " " + "تومان"}