added baha anyklmak, attributes
This commit is contained in:
@@ -5,79 +5,15 @@ import { useTranslation } from "react-i18next";
|
||||
import { useGetOrdersQuery } from "../../app/api/orderApi";
|
||||
import EmptyOrderState from "./emptyOrder";
|
||||
import Loader from "../../components/Loader/index";
|
||||
import { Result, Button, Modal } from "antd";
|
||||
import { Result, Button } from "antd";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import PendingPriceBadge from "../../components/PendingPriceBadge";
|
||||
|
||||
const isPriceZero = (price) => !price || parseFloat(price) === 0;
|
||||
|
||||
const orderHasZeroPrice = (orderItems) =>
|
||||
orderItems?.some((item) => isPriceZero(item.unit_price_amount));
|
||||
|
||||
const PendingPriceModal = ({ open, onClose, t }) => (
|
||||
<Modal
|
||||
open={open}
|
||||
onOk={onClose}
|
||||
onCancel={onClose}
|
||||
okText={t("common.ok")}
|
||||
cancelButtonProps={{ style: { display: "none" } }}
|
||||
centered
|
||||
title="Bahasy anyklamaly"
|
||||
className="pending-price-modal"
|
||||
width={400}
|
||||
>
|
||||
<p>
|
||||
Bu sargytdaky bir ýa-da birnäçe harydyň bahasy entek kesgitlenmedik.
|
||||
Operatorymyz siziň bilen habarlaşyp, goşmaça maglumat berer.
|
||||
</p>
|
||||
</Modal>
|
||||
);
|
||||
|
||||
const PendingPriceBadge = ({ t }) => {
|
||||
const [tooltipVisible, setTooltipVisible] = useState(false);
|
||||
const [modalVisible, setModalVisible] = useState(false);
|
||||
const [isMobile] = useState(() => /Mobi|Android/i.test(navigator.userAgent));
|
||||
|
||||
const handleClick = (e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
if (isMobile) setModalVisible(true);
|
||||
};
|
||||
|
||||
const stopPropagation = (e) => {
|
||||
e.stopPropagation();
|
||||
};
|
||||
|
||||
return (
|
||||
<span onClick={stopPropagation}>
|
||||
<span
|
||||
className={styles.pendingPriceBadgeWrapper}
|
||||
onMouseEnter={() => !isMobile && setTooltipVisible(true)}
|
||||
onMouseLeave={() => setTooltipVisible(false)}
|
||||
onClick={handleClick}
|
||||
onTouchEnd={(e) => {
|
||||
e.stopPropagation();
|
||||
}}
|
||||
>
|
||||
<span className={styles.pendingPriceBadge}>!</span>
|
||||
|
||||
{tooltipVisible && (
|
||||
<span className={styles.pendingPriceTooltip}>
|
||||
<strong>Bahasyny anyklamaly</strong>
|
||||
Bu sargytdaky harydyň bahasy kesgitlenmedik. Operator size jaň edip
|
||||
goşmaça maglumat berer.
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
|
||||
<PendingPriceModal
|
||||
open={modalVisible}
|
||||
onClose={() => setModalVisible(false)}
|
||||
t={t}
|
||||
/>
|
||||
</span>
|
||||
);
|
||||
};
|
||||
|
||||
const Orders = () => {
|
||||
const { t } = useTranslation();
|
||||
const { data: orders, isLoading, error } = useGetOrdersQuery();
|
||||
@@ -154,7 +90,7 @@ const Orders = () => {
|
||||
gap: 6,
|
||||
}}
|
||||
>
|
||||
Bahasyny anyklamaly <PendingPriceBadge t={t} />
|
||||
{t("cart.pendingPriceTitle")} <PendingPriceBadge />
|
||||
</span>
|
||||
) : (
|
||||
`${totalAmount.toFixed(2)} m.`
|
||||
@@ -224,7 +160,7 @@ const Orders = () => {
|
||||
gap: 6,
|
||||
}}
|
||||
>
|
||||
Bahasyny anyklamaly <PendingPriceBadge t={t} />
|
||||
{t("cart.pendingPriceTitle")} <PendingPriceBadge />
|
||||
</span>
|
||||
) : (
|
||||
`${totalAmount.toFixed(2)} m.`
|
||||
|
||||
Reference in New Issue
Block a user