diff --git a/project/apps/pos/src/components/ReceiptModal.tsx b/project/apps/pos/src/components/ReceiptModal.tsx index a96ade4..5f3c21b 100644 --- a/project/apps/pos/src/components/ReceiptModal.tsx +++ b/project/apps/pos/src/components/ReceiptModal.tsx @@ -64,6 +64,11 @@ export default function ReceiptModal({
+ {/* Timestamp */} +
+ Ticket #{receipt.receiptNumber} + {new Date(receipt.createdAt).toLocaleString('es-ES', { dateStyle: 'short', timeStyle: 'short' })} +
{/* Logo */}
{ + pgm.addColumn('store_settings', { + twitter_url: { type: 'text', notNull: false, default: null }, + pinterest_url: { type: 'text', notNull: false, default: null }, + }); +}; -migrate().catch(e => { console.error(e); process.exit(1); }); +/** @param {import('pg-migrate').MigrationBuilder} pgm */ +export const down = (pgm) => { + pgm.dropColumn('store_settings', 'twitter_url'); + pgm.dropColumn('store_settings', 'pinterest_url'); +}; diff --git a/project/storefront/src/app/api/catalog-proxy/[...path]/route.ts b/project/storefront/src/app/api/catalog-proxy/[...path]/route.ts new file mode 100644 index 0000000..caac200 --- /dev/null +++ b/project/storefront/src/app/api/catalog-proxy/[...path]/route.ts @@ -0,0 +1,34 @@ +import { NextRequest, NextResponse } from 'next/server'; + +const API = process.env.NEXT_PUBLIC_API_URL ?? 'http://127.0.0.1:3000'; + +export async function GET(req: NextRequest) { + const path = req.nextUrl.pathname.replace('/api/catalog-proxy/', ''); + const cookies = req.headers.get('cookie') ?? ''; + try { + const res = await fetch(`${API}/${path}${req.nextUrl.search}`, { + headers: { accept: 'application/json', cookie: cookies }, + }); + const data = await res.json().catch(() => ({})); + return NextResponse.json(data, { status: res.status }); + } catch (err) { + return NextResponse.json({ error: String(err) }, { status: 502 }); + } +} + +export async function POST(req: NextRequest) { + const path = req.nextUrl.pathname.replace('/api/catalog-proxy/', ''); + const cookies = req.headers.get('cookie') ?? ''; + const body = await req.text(); + try { + const res = await fetch(`${API}/${path}${req.nextUrl.search}`, { + method: 'POST', + headers: { 'Content-Type': 'application/json', cookie: cookies }, + body, + }); + const data = await res.json().catch(() => ({})); + return NextResponse.json(data, { status: res.status }); + } catch (err) { + return NextResponse.json({ error: String(err) }, { status: 502 }); + } +} diff --git a/project/storefront/src/app/productos/[slug]/page.tsx b/project/storefront/src/app/productos/[slug]/page.tsx index bf5110d..4895c71 100644 --- a/project/storefront/src/app/productos/[slug]/page.tsx +++ b/project/storefront/src/app/productos/[slug]/page.tsx @@ -102,6 +102,18 @@ export default async function ProductPage({ params }: PageProps) {
Estado
{product.state}
+ {product.expirationDate && ( +
+
Caducidad
+
{new Date(product.expirationDate).toLocaleDateString('es-ES', { year: 'numeric', month: 'long', day: 'numeric' })}
+
+ )} + {product.unitWeightKg && ( +
+
Peso
+
{product.unitWeightKg >= 1 ? `${product.unitWeightKg} kg` : `${Math.round(product.unitWeightKg * 1000)} g`}
+
+ )}