fix(pos-selfpay): hide payment methods until email step completes
This commit is contained in:
4
project/apps/admin/next-env.d.ts
vendored
4
project/apps/admin/next-env.d.ts
vendored
@@ -1,7 +1,7 @@
|
||||
/// <reference types="next" />
|
||||
/// <reference types="next/image-types/global" />
|
||||
import "./.next/types/routes.d.ts";
|
||||
import "./.next/types/root-params.d.ts";
|
||||
import "./.next/dev/types/routes.d.ts";
|
||||
import "./.next/dev/types/root-params.d.ts";
|
||||
|
||||
// NOTE: This file should not be edited
|
||||
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
|
||||
|
||||
@@ -143,6 +143,7 @@ export default function RegisterPage() {
|
||||
// POS-SELFPAY-FLOW: optional email for receipt before payment
|
||||
const [showSelfpayEmail, setShowSelfpayEmail] = useState(false);
|
||||
const [selfpayEmail, setSelfpayEmail] = useState('');
|
||||
const [selfpayPaymentReady, setSelfpayPaymentReady] = useState(false);
|
||||
let toastTimer: ReturnType<typeof setTimeout> | undefined;
|
||||
const showAddedToast = (name: string) => {
|
||||
clearTimeout(toastTimer);
|
||||
@@ -509,6 +510,12 @@ export default function RegisterPage() {
|
||||
});
|
||||
setReceipt(result.receipt);
|
||||
setRestPaymentFor(null);
|
||||
// POS-SELFPAY-FLOW: send receipt by email if provided
|
||||
if (isSelfpayMode && selfpayEmail.trim()) {
|
||||
void posApi.emailReceipt(result.receipt.orderId, selfpayEmail.trim()).catch(() => {
|
||||
// Non-blocking: email failure shouldn't interrupt the sale
|
||||
});
|
||||
}
|
||||
void loadPendingSales();
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : 'No se pudo confirmar la venta');
|
||||
@@ -783,6 +790,8 @@ export default function RegisterPage() {
|
||||
setError('');
|
||||
setSearch('');
|
||||
setShowClearConfirm(false);
|
||||
setSelfpayPaymentReady(false);
|
||||
setSelfpayEmail('');
|
||||
};
|
||||
|
||||
const searchCustomers = async (query: string) => {
|
||||
@@ -1649,7 +1658,7 @@ export default function RegisterPage() {
|
||||
</p>
|
||||
)}
|
||||
{/* POS-SELFPAY-FLOW: in selfpay mode, hide payment methods until email is captured */}
|
||||
{(!isSelfpayMode || selfpayEmail !== undefined) && (
|
||||
{(!isSelfpayMode || selfpayPaymentReady) && (
|
||||
<div className="mt-3 grid grid-cols-2 gap-2">
|
||||
{config.paymentMethods.map((method) => (
|
||||
<button
|
||||
@@ -1683,8 +1692,9 @@ export default function RegisterPage() {
|
||||
: void confirmSale()
|
||||
}
|
||||
disabled={
|
||||
!isSelfpayMode &&
|
||||
(processing || cart.length === 0 || payments.length === 0 || paidCents <= 0 || paidCents > totals.total)
|
||||
processing ||
|
||||
cart.length === 0 ||
|
||||
(!isSelfpayMode && (payments.length === 0 || paidCents <= 0 || paidCents > totals.total))
|
||||
}
|
||||
className={`min-h-16 rounded-xl bg-[#1B4332] text-lg font-bold text-white disabled:opacity-40 ${
|
||||
isSelfpayMode ? 'col-span-2' : ''
|
||||
@@ -1758,6 +1768,7 @@ export default function RegisterPage() {
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
setShowSelfpayEmail(false);
|
||||
setSelfpayPaymentReady(true);
|
||||
}}
|
||||
className="space-y-4"
|
||||
>
|
||||
@@ -1785,6 +1796,7 @@ export default function RegisterPage() {
|
||||
onClick={() => {
|
||||
setSelfpayEmail('');
|
||||
setShowSelfpayEmail(false);
|
||||
setSelfpayPaymentReady(true);
|
||||
}}
|
||||
className="w-full rounded-xl border border-gray-300 py-2 text-sm font-medium text-gray-500"
|
||||
>
|
||||
|
||||
4
project/storefront/next-env.d.ts
vendored
4
project/storefront/next-env.d.ts
vendored
@@ -1,7 +1,7 @@
|
||||
/// <reference types="next" />
|
||||
/// <reference types="next/image-types/global" />
|
||||
import "./.next/types/routes.d.ts";
|
||||
import "./.next/types/root-params.d.ts";
|
||||
import "./.next/dev/types/routes.d.ts";
|
||||
import "./.next/dev/types/root-params.d.ts";
|
||||
|
||||
// NOTE: This file should not be edited
|
||||
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
|
||||
|
||||
Reference in New Issue
Block a user