fix(pos-selfpay): direct payment + confirm from modal, no partial payments
This commit is contained in:
@@ -793,6 +793,7 @@ export default function RegisterPage() {
|
|||||||
setShowClearConfirm(false);
|
setShowClearConfirm(false);
|
||||||
setSelfpayPaymentReady(false);
|
setSelfpayPaymentReady(false);
|
||||||
setSelfpayEmail('');
|
setSelfpayEmail('');
|
||||||
|
setShowSelfpayPaymentMethods(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
const searchCustomers = async (query: string) => {
|
const searchCustomers = async (query: string) => {
|
||||||
@@ -1674,17 +1675,8 @@ export default function RegisterPage() {
|
|||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{/* POS-SELFPAY-FLOW: confirm button after payment added in selfpay */}
|
{/* POS-SELFPAY-FLOW: confirm button no longer needed — direct flow */}
|
||||||
{isSelfpayMode && selfpayPaymentReady && !paymentMethod && !showSelfpayPaymentMethods && (
|
{/* (Removed: payment directly triggers confirmSale from the modal) */}
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
onClick={() => void confirmSale()}
|
|
||||||
disabled={processing || cart.length === 0 || paidCents <= 0 || paidCents > totals.total}
|
|
||||||
className="mt-3 w-full min-h-16 rounded-xl bg-[#1B4332] text-lg font-bold text-white disabled:opacity-40"
|
|
||||||
>
|
|
||||||
{processing ? 'Confirmando…' : '✅ Confirmar e imprimir'}
|
|
||||||
</button>
|
|
||||||
)}
|
|
||||||
<div className="mt-3 grid grid-cols-2 gap-2">
|
<div className="mt-3 grid grid-cols-2 gap-2">
|
||||||
{!isSelfpayMode && (
|
{!isSelfpayMode && (
|
||||||
<button
|
<button
|
||||||
@@ -1854,8 +1846,19 @@ export default function RegisterPage() {
|
|||||||
key={method.id}
|
key={method.id}
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
// POS-SELFPAY-FLOW: no partial payments — directly add full payment and confirm
|
||||||
setShowSelfpayPaymentMethods(false);
|
setShowSelfpayPaymentMethods(false);
|
||||||
setPaymentMethod(method);
|
const allocation: PaymentAllocation = {
|
||||||
|
id: generateIdempotencyKey(),
|
||||||
|
methodCode: method.code,
|
||||||
|
methodLabel: method.label,
|
||||||
|
kind: method.kind,
|
||||||
|
amountCents: remainingCents,
|
||||||
|
...(method.kind === 'cash' ? { tenderedCents: remainingCents } : {}),
|
||||||
|
changeCents: 0,
|
||||||
|
};
|
||||||
|
setPayments([allocation]);
|
||||||
|
void confirmSale();
|
||||||
}}
|
}}
|
||||||
disabled={remainingCents === 0}
|
disabled={remainingCents === 0}
|
||||||
className={`min-h-16 rounded-xl px-2 font-bold text-white disabled:opacity-40 ${method.kind === 'cash' ? 'bg-green-600' : method.kind === 'card' ? 'bg-blue-600' : 'bg-slate-700'}`}
|
className={`min-h-16 rounded-xl px-2 font-bold text-white disabled:opacity-40 ${method.kind === 'cash' ? 'bg-green-600' : method.kind === 'card' ? 'bg-blue-600' : 'bg-slate-700'}`}
|
||||||
|
|||||||
Reference in New Issue
Block a user