fix(pos): hide selfpay controls and normalize trend labels
This commit is contained in:
4
project/apps/pos/package-lock.json
generated
4
project/apps/pos/package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "mercadodevida-pos",
|
||||
"version": "0.2.2",
|
||||
"version": "0.2.3",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "mercadodevida-pos",
|
||||
"version": "0.2.2",
|
||||
"version": "0.2.3",
|
||||
"dependencies": {
|
||||
"next": "^16.3.1",
|
||||
"react": "^19.2.8",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "mercadodevida-pos",
|
||||
"version": "0.2.2",
|
||||
"version": "0.2.3",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev --port 3002",
|
||||
|
||||
@@ -65,7 +65,7 @@ interface Config {
|
||||
terminal: {
|
||||
id: string;
|
||||
name: string;
|
||||
settings?: { lineDiscountsEnabled?: boolean } & Record<string, unknown>;
|
||||
settings?: { lineDiscountsEnabled?: boolean; selfpayMode?: boolean } & Record<string, unknown>;
|
||||
};
|
||||
store: { id: string; name: string };
|
||||
paymentMethods: PaymentMethod[];
|
||||
@@ -439,7 +439,8 @@ export default function RegisterPage() {
|
||||
}, [cart]);
|
||||
const paidCents = payments.reduce((sum, payment) => sum + payment.amountCents, 0);
|
||||
const remainingCents = Math.max(0, totals.total - paidCents);
|
||||
const lineDiscountsEnabled = config?.terminal.settings?.lineDiscountsEnabled !== false;
|
||||
const isSelfpayMode = config?.terminal.settings?.selfpayMode === true;
|
||||
const lineDiscountsEnabled = !isSelfpayMode && config?.terminal.settings?.lineDiscountsEnabled !== false;
|
||||
|
||||
const applyDiscount = (lineId: string, discountCents: number) => {
|
||||
setCart((current) =>
|
||||
@@ -921,7 +922,7 @@ export default function RegisterPage() {
|
||||
|
||||
return (
|
||||
<div className="flex h-screen" style={{ '--color-primary': '#2D6A4F' } as React.CSSProperties}>
|
||||
{showSidebar && (
|
||||
{!isSelfpayMode && showSidebar && (
|
||||
<aside
|
||||
className="hidden w-[380px] shrink-0 flex-col border-r bg-gray-50 p-3 lg:flex"
|
||||
aria-label="Pedidos"
|
||||
@@ -1200,17 +1201,19 @@ export default function RegisterPage() {
|
||||
<div className="mb-3">
|
||||
<div className="mb-2 flex items-center gap-3">
|
||||
{/* Panel toggle button - LEFT */}
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setShowSidebar((v) => !v)}
|
||||
title={showSidebar ? 'Ocultar panel' : 'Mostrar panel'}
|
||||
className="flex items-center gap-1.5 rounded-lg border border-gray-300 bg-white px-2.5 py-1.5 text-xs font-medium text-gray-600 hover:bg-gray-50 transition-colors"
|
||||
>
|
||||
<svg className="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2}>
|
||||
<path strokeLinecap="round" strokeLinejoin="round" d={showSidebar ? "M4 6h16M4 12h16M4 18h7" : "M4 6h16M4 12h16M4 18h16"} />
|
||||
</svg>
|
||||
{showSidebar ? 'Ocultar' : 'Panel'}
|
||||
</button>
|
||||
{!isSelfpayMode && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setShowSidebar((v) => !v)}
|
||||
title={showSidebar ? 'Ocultar panel' : 'Mostrar panel'}
|
||||
className="flex items-center gap-1.5 rounded-lg border border-gray-300 bg-white px-2.5 py-1.5 text-xs font-medium text-gray-600 hover:bg-gray-50 transition-colors"
|
||||
>
|
||||
<svg className="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2}>
|
||||
<path strokeLinecap="round" strokeLinejoin="round" d={showSidebar ? "M4 6h16M4 12h16M4 18h7" : "M4 6h16M4 12h16M4 18h16"} />
|
||||
</svg>
|
||||
{showSidebar ? 'Ocultar' : 'Panel'}
|
||||
</button>
|
||||
)}
|
||||
|
||||
{/* Store name */}
|
||||
<span className="text-sm font-bold text-[#2D6A4F]">{config.store.name}</span>
|
||||
@@ -1234,7 +1237,7 @@ export default function RegisterPage() {
|
||||
{currentTime.toLocaleDateString('es-ES', { day: '2-digit', month: 'short', year: 'numeric' })}
|
||||
</span>
|
||||
|
||||
{!config?.terminal?.settings?.selfpayMode && (
|
||||
{!isSelfpayMode && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => {
|
||||
@@ -1588,7 +1591,7 @@ export default function RegisterPage() {
|
||||
<span>Subtotal</span>
|
||||
<span>{formatPrice(totals.subtotal)}</span>
|
||||
</div>
|
||||
{totals.discount > 0 && (
|
||||
{!isSelfpayMode && totals.discount > 0 && (
|
||||
<div className="flex justify-between text-red-600">
|
||||
<span>Descuentos</span>
|
||||
<span>−{formatPrice(totals.discount)}</span>
|
||||
@@ -1689,7 +1692,7 @@ export default function RegisterPage() {
|
||||
</button>
|
||||
</aside>
|
||||
|
||||
{showDiscountPanel && selectedItem && (
|
||||
{!isSelfpayMode && showDiscountPanel && selectedItem && (
|
||||
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black/30">
|
||||
<DiscountPanel
|
||||
unitPriceCents={selectedItem.unitPriceCents}
|
||||
|
||||
Reference in New Issue
Block a user