Compare commits
2 Commits
6bf4cb6399
...
179bca3e9f
| Author | SHA1 | Date | |
|---|---|---|---|
| 179bca3e9f | |||
| e87c3e0783 |
@@ -115,15 +115,16 @@ export default function useOrder() {
|
|||||||
? `${location?.lat},${location?.lng}`
|
? `${location?.lat},${location?.lng}`
|
||||||
: "",
|
: "",
|
||||||
delivery_address: location?.address,
|
delivery_address: location?.address,
|
||||||
vatvalue: restaurant?.vat || 0,
|
vatvalue: ((restaurant?.vat || 0) / 100) * (subtotal - discountAmount),
|
||||||
taxes:
|
taxes:
|
||||||
restaurant?.taxes?.map((t) => ({
|
restaurant?.taxes
|
||||||
tax_id: t.id,
|
?.filter((t) => t.is_active === 1)
|
||||||
percentage: t.percentage,
|
.map((t) => ({
|
||||||
amount:
|
tax_id: t.id,
|
||||||
((typeof t.percentage === "number" ? t.percentage : 0) as number) *
|
percentage: t.percentage,
|
||||||
Number(subtotal - discountAmount),
|
amount:
|
||||||
})) || [],
|
((Number(t.percentage) || 0) / 100) * (subtotal - discountAmount),
|
||||||
|
})) || [],
|
||||||
...(orderType === OrderType.Gift
|
...(orderType === OrderType.Gift
|
||||||
? {
|
? {
|
||||||
receiverName: giftDetails?.receiverName,
|
receiverName: giftDetails?.receiverName,
|
||||||
|
|||||||
@@ -49,7 +49,10 @@ export default function OrderPage() {
|
|||||||
const hasRefetchedRef = useRef(false);
|
const hasRefetchedRef = useRef(false);
|
||||||
const [isOpen, setIsOpen] = useState(false);
|
const [isOpen, setIsOpen] = useState(false);
|
||||||
const [isRateOrderOpen, setIsRateOrderOpen] = useState(false);
|
const [isRateOrderOpen, setIsRateOrderOpen] = useState(false);
|
||||||
const [isSplitBillParticipantsBottomSheetOpen, setIsSplitBillParticipantsBottomSheetOpen] = useState(false);
|
const [
|
||||||
|
isSplitBillParticipantsBottomSheetOpen,
|
||||||
|
setIsSplitBillParticipantsBottomSheetOpen,
|
||||||
|
] = useState(false);
|
||||||
const { data: orderDetails } = useGetOrderDetailsQuery(
|
const { data: orderDetails } = useGetOrderDetailsQuery(
|
||||||
{
|
{
|
||||||
orderID: orderId || "",
|
orderID: orderId || "",
|
||||||
@@ -75,6 +78,10 @@ export default function OrderPage() {
|
|||||||
(status) => status?.alias === "closed",
|
(status) => status?.alias === "closed",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const hasCanceledByCustomerStatus = orderDetails?.status?.some(
|
||||||
|
(status) => status?.alias === "canceled_by_customer",
|
||||||
|
);
|
||||||
|
|
||||||
// Reset refetch flag when orderId changes
|
// Reset refetch flag when orderId changes
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
hasRefetchedRef.current = false;
|
hasRefetchedRef.current = false;
|
||||||
@@ -508,7 +515,7 @@ export default function OrderPage() {
|
|||||||
display: "flex",
|
display: "flex",
|
||||||
flexDirection: "column",
|
flexDirection: "column",
|
||||||
marginBottom: 9,
|
marginBottom: 9,
|
||||||
gap: 2 ,
|
gap: 2,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<ProText
|
<ProText
|
||||||
@@ -539,8 +546,10 @@ export default function OrderPage() {
|
|||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<div className={styles.inviteToBill}
|
<div
|
||||||
onClick={() => setIsSplitBillParticipantsBottomSheetOpen(true)}>
|
className={styles.inviteToBill}
|
||||||
|
onClick={() => setIsSplitBillParticipantsBottomSheetOpen(true)}
|
||||||
|
>
|
||||||
<Button
|
<Button
|
||||||
shape="circle"
|
shape="circle"
|
||||||
iconPlacement="start"
|
iconPlacement="start"
|
||||||
@@ -662,24 +671,30 @@ export default function OrderPage() {
|
|||||||
onClose={() => setIsRateOrderOpen(false)}
|
onClose={() => setIsRateOrderOpen(false)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{!hasClosedStatus && <CancelOrderBottomSheet />}
|
{!hasClosedStatus ||
|
||||||
|
(hasCanceledByCustomerStatus && <CancelOrderBottomSheet />)}
|
||||||
</Layout.Content>
|
</Layout.Content>
|
||||||
{hasClosedStatus && (
|
|
||||||
<Layout.Footer className={styles.checkoutButtonContainer}>
|
{hasClosedStatus ||
|
||||||
<Button
|
(hasCanceledByCustomerStatus && (
|
||||||
type="primary"
|
<Layout.Footer className={styles.checkoutButtonContainer}>
|
||||||
shape="round"
|
<Button
|
||||||
className={styles.checkoutButton}
|
type="primary"
|
||||||
onClick={() => {
|
shape="round"
|
||||||
navigate(`/${restaurant?.subdomain}/menu`);
|
className={styles.checkoutButton}
|
||||||
}}
|
onClick={() => {
|
||||||
>
|
navigate(`/${restaurant?.subdomain}/menu`);
|
||||||
{t("order.newOrder")}
|
}}
|
||||||
</Button>
|
>
|
||||||
</Layout.Footer>
|
{t("order.newOrder")}
|
||||||
)}
|
</Button>
|
||||||
|
</Layout.Footer>
|
||||||
|
))}
|
||||||
</Layout>
|
</Layout>
|
||||||
<SplitBillParticipantsBottomSheet isOpen={isSplitBillParticipantsBottomSheetOpen} onClose={() => setIsSplitBillParticipantsBottomSheetOpen(false)} />
|
<SplitBillParticipantsBottomSheet
|
||||||
|
isOpen={isSplitBillParticipantsBottomSheetOpen}
|
||||||
|
onClose={() => setIsSplitBillParticipantsBottomSheetOpen(false)}
|
||||||
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user