|
|
@ -2,7 +2,10 @@ import React, { useEffect } from "react"; |
|
|
|
import separate from "../../../utils/separate"; |
|
|
|
import separate from "../../../utils/separate"; |
|
|
|
import { connect } from "react-redux"; |
|
|
|
import { connect } from "react-redux"; |
|
|
|
import { transport } from "../../../redux/actions"; |
|
|
|
import { transport } from "../../../redux/actions"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//components
|
|
|
|
import Loading from "../../../components/Loading"; |
|
|
|
import Loading from "../../../components/Loading"; |
|
|
|
|
|
|
|
import ButtonBetween from "../../../components/ButtonBetween"; |
|
|
|
|
|
|
|
|
|
|
|
function TransportMethod({ |
|
|
|
function TransportMethod({ |
|
|
|
list, |
|
|
|
list, |
|
|
@ -13,23 +16,18 @@ function TransportMethod({ |
|
|
|
userId, |
|
|
|
userId, |
|
|
|
loading, |
|
|
|
loading, |
|
|
|
}) { |
|
|
|
}) { |
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
useEffect(() => { |
|
|
|
if (list.length === 0) { |
|
|
|
if (list.length === 0) { |
|
|
|
getList(); |
|
|
|
getList(); |
|
|
|
} |
|
|
|
} |
|
|
|
}, []); |
|
|
|
}, []); |
|
|
|
|
|
|
|
|
|
|
|
const Method = ({ method }) => { |
|
|
|
const Method = ({ method, active }) => { |
|
|
|
return isMobile ? ( |
|
|
|
return isMobile ? ( |
|
|
|
<button |
|
|
|
<ButtonBetween |
|
|
|
className={`flex flex-col border-2 border-solid items-center w-full px-2 py-2 rounded-md mt-4 relative transition-all duration-500 ${ |
|
|
|
width={"100%"} |
|
|
|
factorInfo?.transportId === method?.id |
|
|
|
|
|
|
|
? "bg-blueC0 border-blueC0 bg-opacity-5 dark:bg-opacity-5" |
|
|
|
|
|
|
|
: "bg-grayF9 border-gray-200 dark:border-gray-500 dark:bg-opacity-5" |
|
|
|
|
|
|
|
}`}
|
|
|
|
|
|
|
|
onClick={() => |
|
|
|
onClick={() => |
|
|
|
factorInfo?.transportId !== method?.id |
|
|
|
!active |
|
|
|
? setTransport( |
|
|
|
? setTransport( |
|
|
|
{ factorId: factorInfo?.id, transportId: method?.id }, |
|
|
|
{ factorId: factorInfo?.id, transportId: method?.id }, |
|
|
|
{ userId }, |
|
|
|
{ userId }, |
|
|
@ -37,42 +35,11 @@ function TransportMethod({ |
|
|
|
) |
|
|
|
) |
|
|
|
: {} |
|
|
|
: {} |
|
|
|
} |
|
|
|
} |
|
|
|
> |
|
|
|
item={"ارسال با" + " " + method.name} |
|
|
|
{loading && factorInfo?.transportId !== method?.id ? ( |
|
|
|
status={separate(method.price) + " " + "تومان"} |
|
|
|
<Loading |
|
|
|
active={active} |
|
|
|
size={2} |
|
|
|
toggle={true} |
|
|
|
color={ |
|
|
|
/> |
|
|
|
factorInfo?.transportId === method?.id |
|
|
|
|
|
|
|
? "bg-green-500" |
|
|
|
|
|
|
|
: "bg-gray-500" |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
) : ( |
|
|
|
|
|
|
|
<strong |
|
|
|
|
|
|
|
className={`text-tiny transition-all duration-500 ${ |
|
|
|
|
|
|
|
factorInfo?.transportId === method?.id |
|
|
|
|
|
|
|
? "text-green7B dark:text-blueC0" |
|
|
|
|
|
|
|
: "text-blue52 dark:text-gray-400" |
|
|
|
|
|
|
|
}`}
|
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
{method.name} |
|
|
|
|
|
|
|
</strong> |
|
|
|
|
|
|
|
)} |
|
|
|
|
|
|
|
<span |
|
|
|
|
|
|
|
className={`lg:text-xs text-tiny mt-2 transition-all duration-500 ${ |
|
|
|
|
|
|
|
factorInfo?.transportId === method?.id |
|
|
|
|
|
|
|
? "text-green7B dark:text-blueC0" |
|
|
|
|
|
|
|
: "text-blue52 dark:text-gray-400" |
|
|
|
|
|
|
|
}`}
|
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
هزینه ارسال {separate(method.price)} |
|
|
|
|
|
|
|
</span> |
|
|
|
|
|
|
|
{/* <img |
|
|
|
|
|
|
|
src={method.icon} |
|
|
|
|
|
|
|
alt={method.name} |
|
|
|
|
|
|
|
className="w-7 absolute left-3 top-1/2 transform -translate-y-1/2" |
|
|
|
|
|
|
|
/> */} |
|
|
|
|
|
|
|
</button> |
|
|
|
|
|
|
|
) : ( |
|
|
|
) : ( |
|
|
|
<button |
|
|
|
<button |
|
|
|
className={`flex flex-col border border-solid items-center px-2 py-3 rounded-md mt-4 relative transition-all duration-500 w-2/5 ${ |
|
|
|
className={`flex flex-col border border-solid items-center px-2 py-3 rounded-md mt-4 relative transition-all duration-500 w-2/5 ${ |
|
|
@ -81,7 +48,7 @@ function TransportMethod({ |
|
|
|
: "bg-grayF9 border-grayDB dark:bg-opacity-5" |
|
|
|
: "bg-grayF9 border-grayDB dark:bg-opacity-5" |
|
|
|
}`}
|
|
|
|
}`}
|
|
|
|
onClick={() => |
|
|
|
onClick={() => |
|
|
|
factorInfo?.transportId !== method?.id |
|
|
|
!active |
|
|
|
? setTransport( |
|
|
|
? setTransport( |
|
|
|
{ factorId: factorInfo?.id, transportId: method?.id }, |
|
|
|
{ factorId: factorInfo?.id, transportId: method?.id }, |
|
|
|
{ userId }, |
|
|
|
{ userId }, |
|
|
@ -90,19 +57,12 @@ function TransportMethod({ |
|
|
|
: {} |
|
|
|
: {} |
|
|
|
} |
|
|
|
} |
|
|
|
> |
|
|
|
> |
|
|
|
{loading && factorInfo?.transportId !== method?.id ? ( |
|
|
|
{loading && !active ? ( |
|
|
|
<Loading |
|
|
|
<Loading size={4} color={active ? "bg-green-500" : "bg-gray-500"} /> |
|
|
|
size={4} |
|
|
|
|
|
|
|
color={ |
|
|
|
|
|
|
|
factorInfo?.transportId === method?.id |
|
|
|
|
|
|
|
? "bg-green-500" |
|
|
|
|
|
|
|
: "bg-gray-500" |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
) : ( |
|
|
|
) : ( |
|
|
|
<strong |
|
|
|
<strong |
|
|
|
className={`text-tiny transition-all duration-500 ${ |
|
|
|
className={`text-tiny transition-all duration-500 ${ |
|
|
|
factorInfo?.transportId === method?.id |
|
|
|
active |
|
|
|
? "text-green7B dark:text-white" |
|
|
|
? "text-green7B dark:text-white" |
|
|
|
: "text-blue52 dark:text-white" |
|
|
|
: "text-blue52 dark:text-white" |
|
|
|
}`}
|
|
|
|
}`}
|
|
|
@ -113,7 +73,7 @@ function TransportMethod({ |
|
|
|
|
|
|
|
|
|
|
|
<span |
|
|
|
<span |
|
|
|
className={`text-sm transition-all duration-500 mt-2 ${ |
|
|
|
className={`text-sm transition-all duration-500 mt-2 ${ |
|
|
|
factorInfo?.transportId === method?.id |
|
|
|
active |
|
|
|
? "text-green7B dark:text-white" |
|
|
|
? "text-green7B dark:text-white" |
|
|
|
: "text-blue52 dark:text-white" |
|
|
|
: "text-blue52 dark:text-white" |
|
|
|
}`}
|
|
|
|
}`}
|
|
|
@ -128,9 +88,13 @@ function TransportMethod({ |
|
|
|
<strong className="text-green7B font-bold dark:text-white text-base"> |
|
|
|
<strong className="text-green7B font-bold dark:text-white text-base"> |
|
|
|
لطفا یک روش ارسال انتخاب کنید |
|
|
|
لطفا یک روش ارسال انتخاب کنید |
|
|
|
</strong> |
|
|
|
</strong> |
|
|
|
<ul className="list-none p-0 m-0 flex flex-col w-full"> |
|
|
|
<ul className="list-none p-0 m-0 flex flex-col gap-4 w-full mt-5"> |
|
|
|
{list.map((method, index) => ( |
|
|
|
{list.map((method, index) => ( |
|
|
|
<Method method={method} key={index} /> |
|
|
|
<Method |
|
|
|
|
|
|
|
method={method} |
|
|
|
|
|
|
|
key={index} |
|
|
|
|
|
|
|
active={factorInfo?.transportId === method?.id} |
|
|
|
|
|
|
|
/> |
|
|
|
))} |
|
|
|
))} |
|
|
|
</ul> |
|
|
|
</ul> |
|
|
|
</section> |
|
|
|
</section> |
|
|
@ -141,7 +105,11 @@ function TransportMethod({ |
|
|
|
</strong> |
|
|
|
</strong> |
|
|
|
<ul className="list-none p-0 m-0 flex flex-row gap-5 flex-wrap"> |
|
|
|
<ul className="list-none p-0 m-0 flex flex-row gap-5 flex-wrap"> |
|
|
|
{list.map((method, index) => ( |
|
|
|
{list.map((method, index) => ( |
|
|
|
<Method method={method} key={index} /> |
|
|
|
<Method |
|
|
|
|
|
|
|
method={method} |
|
|
|
|
|
|
|
key={index} |
|
|
|
|
|
|
|
active={factorInfo?.transportId === method?.id} |
|
|
|
|
|
|
|
/> |
|
|
|
))} |
|
|
|
))} |
|
|
|
</ul> |
|
|
|
</ul> |
|
|
|
</section> |
|
|
|
</section> |
|
|
|