Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions messages/bg.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@
"title": "Сигурни ли сте, че искате да платите?",
"description": "Изберете вашата банка, за да платите"
},
"selfServicePayment": {
"title": "Плащане",
"description": "Може да заплатите брой/карта на бара"
},
"splitAndPay": "Раздели и плати",
"ratingDialog": {
"title": "Хареса ли ви {productName}?",
Expand Down
4 changes: 4 additions & 0 deletions messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@
"title": "Are you sure you want to pay?",
"description": "Select your bank to pay"
},
"selfServicePayment": {
"title": "Payment",
"description": "You can pay cash/card at the bar"
},
"splitAndPay": "Split and Pay",
"ratingDialog": {
"title": "How did you like {productName}?",
Expand Down
23 changes: 19 additions & 4 deletions src/app/order/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { useSockJS } from "@/hooks/use-sockjs"

import { Product } from "@/models/product"
import { WSSendMessageItems, WSSendMessagePayload } from "@/models/websocket"
import { useRestaurantStore } from "@/store/restaurant"
import { useTranslations } from "next-intl"
import { useCallback, useEffect, useMemo, useRef, useState } from "react"
import { v4 as uuidv4 } from "uuid"
Expand Down Expand Up @@ -40,7 +41,10 @@ export default function OrderPage() {
const [splitBill, setSplitBill] = useState(false)
const [tipDialogOpen, setTipDialogOpen] = useState(false)
const [confirmDialogOpen, setConfirmDialogOpen] = useState(false)
const [selfServiceDialogOpen, setSelfServiceDialogOpen] = useState(false)
const { tableOrder } = useTableOrderContext()
const { restaurantData } = useRestaurantStore()
const isSelfService = !!restaurantData?.selfService

const [topic, setTopic] = useState(order ? `/topic/orders/${order.orderId}` : null)

Expand Down Expand Up @@ -175,7 +179,13 @@ export default function OrderPage() {
<TipDialog
open={tipDialogOpen}
onOpenChange={setTipDialogOpen}
onConfirm={handleConfirmTip}
onConfirm={() => {
if (isSelfService && tip === 0) {
setSelfServiceDialogOpen(true)
} else {
handleConfirmTip()
}
}}
tip={tip}
setTip={setTip}
setInputTip={setInputTip}
Expand All @@ -193,6 +203,13 @@ export default function OrderPage() {
cancelTitle={tCommon("no")}
shouldConfirm
/>
<DialogPopUp
isOpen={selfServiceDialogOpen}
onConfirm={() => setSelfServiceDialogOpen(false)}
title={tOrder("selfServicePayment.title")}
description={tOrder("selfServicePayment.description")}
defaultTitle={tCommon("ok")}
/>
<div className='w-full gap-4 p-4'>
<Button
className='bg-lightBg mb-4 w-full gap-2 py-6 text-base font-medium transition-transform ease-in-out active:scale-75'
Expand All @@ -204,9 +221,7 @@ export default function OrderPage() {
{splitBill ? tCommon("back") : tOrder("splitAndPay")}{" "}
</Button>
<Button
onClick={() => {
handleConfirmTip()
}}
onClick={() => setTipDialogOpen(true)}
disabled={isPaymentDisabled}
className='text-lightBg w-full gap-2 py-6 text-base font-medium transition-transform ease-in-out active:scale-75'
type='button'
Expand Down