bugfix : remove orphan
This commit is contained in:
@@ -27,6 +27,13 @@ type PaymentRow = {
|
||||
amount: string;
|
||||
};
|
||||
|
||||
type BranchPrintSettings = {
|
||||
receiptHeader?: string | null;
|
||||
receiptFooter?: string | null;
|
||||
wifiPassword?: string | null;
|
||||
paperWidthMm?: number;
|
||||
};
|
||||
|
||||
type PosPayPanelProps = {
|
||||
cafeId: string;
|
||||
numberLocale: string;
|
||||
@@ -48,6 +55,7 @@ export function PosPayPanel({ cafeId, numberLocale, branchId = null }: PosPayPan
|
||||
const [debouncedSearch, setDebouncedSearch] = useState("");
|
||||
const [payMessage, setPayMessage] = useState<string | null>(null);
|
||||
const [receiptOrder, setReceiptOrder] = useState<Order | null>(null);
|
||||
const printSettingsBranchId = receiptOrder?.branchId ?? branchId ?? null;
|
||||
const [lastPaidOrderId, setLastPaidOrderId] = useState<string | null>(null);
|
||||
const [paymentRows, setPaymentRows] = useState<PaymentRow[]>([
|
||||
{ method: "Cash", amount: "" },
|
||||
@@ -79,6 +87,16 @@ export function PosPayPanel({ cafeId, numberLocale, branchId = null }: PosPayPan
|
||||
enabled: !!cafeId,
|
||||
});
|
||||
|
||||
const { data: printSettings } = useQuery({
|
||||
queryKey: ["branch-print-settings", cafeId, printSettingsBranchId],
|
||||
queryFn: () =>
|
||||
apiGet<BranchPrintSettings>(
|
||||
`/api/cafes/${cafeId}/branches/${printSettingsBranchId}/print-settings`
|
||||
),
|
||||
enabled: !!cafeId && !!printSettingsBranchId,
|
||||
staleTime: 5 * 60 * 1000,
|
||||
});
|
||||
|
||||
const displayedOrders = useMemo(() => {
|
||||
if (!filterTableId) return openOrders;
|
||||
return openOrders.filter((o) => o.tableId === filterTableId);
|
||||
@@ -630,6 +648,10 @@ export function PosPayPanel({ cafeId, numberLocale, branchId = null }: PosPayPan
|
||||
.filter(Boolean)
|
||||
.join(" • ") || undefined
|
||||
}
|
||||
receiptHeader={printSettings?.receiptHeader}
|
||||
receiptFooter={printSettings?.receiptFooter}
|
||||
wifiPassword={printSettings?.wifiPassword}
|
||||
paperWidthMm={printSettings?.paperWidthMm}
|
||||
onClose={() => setReceiptOrder(null)}
|
||||
/>
|
||||
) : null}
|
||||
|
||||
@@ -23,6 +23,14 @@ type PosSlipModalProps = {
|
||||
logoUrl?: string;
|
||||
/** Address / phone line shown under the café name on the bill. */
|
||||
tagline?: string;
|
||||
/** Custom header note from branch print settings (bill only). */
|
||||
receiptHeader?: string | null;
|
||||
/** Custom footer note from branch print settings (bill only). */
|
||||
receiptFooter?: string | null;
|
||||
/** WiFi password printed near the bill footer. */
|
||||
wifiPassword?: string | null;
|
||||
/** Paper width in mm — 58 or 80 (default 80). */
|
||||
paperWidthMm?: number;
|
||||
onClose: () => void;
|
||||
/** Full order for customer bill */
|
||||
order?: Order;
|
||||
@@ -39,6 +47,10 @@ export function PosSlipModal({
|
||||
cafeName,
|
||||
logoUrl,
|
||||
tagline,
|
||||
receiptHeader,
|
||||
receiptFooter,
|
||||
wifiPassword,
|
||||
paperWidthMm,
|
||||
onClose,
|
||||
order,
|
||||
kitchenLines = [],
|
||||
@@ -103,6 +115,9 @@ export function PosSlipModal({
|
||||
cafeName,
|
||||
logoUrl: resolveMediaUrl(logoUrl),
|
||||
tagline,
|
||||
header: receiptHeader?.trim() || undefined,
|
||||
wifi: wifiPassword?.trim() || undefined,
|
||||
paperWidthMm,
|
||||
title: t("billTitle"),
|
||||
date: formattedDate,
|
||||
metaRow,
|
||||
@@ -118,7 +133,7 @@ export function PosSlipModal({
|
||||
amount: formatCurrency(p.amount, numberLocale),
|
||||
})),
|
||||
},
|
||||
footer: t("thankYou"),
|
||||
footer: receiptFooter?.trim() || t("thankYou"),
|
||||
locale,
|
||||
};
|
||||
|
||||
@@ -147,6 +162,11 @@ export function PosSlipModal({
|
||||
{variant === "bill" && tagline && (
|
||||
<div className="text-center text-[10px] text-muted-foreground">{tagline}</div>
|
||||
)}
|
||||
{variant === "bill" && receiptHeader?.trim() && (
|
||||
<div className="whitespace-pre-line text-center text-[11px] font-medium text-foreground/80">
|
||||
{receiptHeader.trim()}
|
||||
</div>
|
||||
)}
|
||||
<div className="mb-1 mt-1.5 border-y border-foreground/60 py-0.5 text-center text-xs font-bold">
|
||||
{variant === "kitchen" ? t("kitchenTitle") : t("billTitle")}
|
||||
</div>
|
||||
@@ -191,7 +211,14 @@ export function PosSlipModal({
|
||||
</div>
|
||||
))}
|
||||
<div className="receipt-divider" />
|
||||
<div className="mt-2 text-center text-xs">{t("thankYou")}</div>
|
||||
{wifiPassword?.trim() && (
|
||||
<div className="text-center text-[11px]" dir="ltr">
|
||||
WiFi: {wifiPassword.trim()}
|
||||
</div>
|
||||
)}
|
||||
<div className="mt-2 text-center text-xs">
|
||||
{receiptFooter?.trim() || t("thankYou")}
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user