diff --git a/src/pages/cart/components/CarPlateCard.tsx b/src/pages/cart/components/CarPlateCard.tsx index cb5024c..9debadd 100644 --- a/src/pages/cart/components/CarPlateCard.tsx +++ b/src/pages/cart/components/CarPlateCard.tsx @@ -6,16 +6,20 @@ import { useAppDispatch, useAppSelector } from "redux/hooks"; export default function CarPlateCard() { const { t } = useTranslation(); - const dispatch = useAppDispatch() + const dispatch = useAppDispatch(); - const {plateCar} = useAppSelector(state => state.order) + const plateCar = useAppSelector((state) => state.order.plateCar); return ( <> - + [t("order.reserved"), t("order.prepare"), t("order.ready")], + [t], + ); + + const activeIndex = useMemo(() => { + const reachedStatuses = statuses.length > 0 ? statuses.length - 1 : 0; + return Math.min(Math.max(reachedStatuses, 0), 2); + }, [statuses.length]); + + const steps = useMemo( + () => + Array.from({ length: 3 }, (_, index) => { + const status = statuses[index]; + const label = status?.name || status?.alias || labels[index] || ""; + const isPending = index > activeIndex; + return { + key: status ? `status-${status.id}` : `placeholder-${index}`, + label, + isPending, + }; + }), + [activeIndex, labels, statuses], + ); + return ( <>
- -
- - -
- - -
- - -
- - - {" "} -
- + {steps.map((step, index) => { + const circleStyle: CSSProperties = step.isPending + ? { + width: 12, + height: 12, + borderRadius: "50%", + backgroundColor: "#FFF", + border: "2px solid #BDBDBD", + } + : { + width: 12, + height: 12, + borderRadius: "50%", + backgroundColor: colors.primary, + }; + + const lineStyle: CSSProperties = { + height: 1.5, + backgroundColor: step.isPending ? "#BDBDBD" : colors.primary, + margin: "0 8px", + }; + + return ( + + +
+ + {index < steps.length - 1 && ( + +
+ + )} +
+ ); + })}
- {" "} - - {t("order.reserved")} - - - - {t("order.prepare")} - - - - {t("order.ready")} - + {steps.map((step, index) => ( + + + + {step.label} + + + {index < steps.length - 1 && } + + ))}
diff --git a/src/pages/order/page.tsx b/src/pages/order/page.tsx index 2abae8a..c97ff90 100644 --- a/src/pages/order/page.tsx +++ b/src/pages/order/page.tsx @@ -30,6 +30,9 @@ export default function OrderPage() { }, { skip: !orderId, + // return it t0 60000 after finish testing + pollingInterval: 10000, + refetchOnMountOrArgChange: true, }, ); @@ -114,7 +117,7 @@ export default function OrderPage() { - +