feat(pos): POS v2 feature parity + promote to default /pos
CI/CD / CI · API (dotnet build + test) (push) Successful in 45s
CI/CD / CI · Admin API (dotnet build) (push) Successful in 32s
CI/CD / CI · Dashboard (tsc) (push) Successful in 1m7s
CI/CD / CI · Admin Web (tsc) (push) Successful in 38s
CI/CD / CI · Website (tsc) (push) Successful in 45s
CI/CD / CI · Koja (tsc) (push) Successful in 49s
CI/CD / Deploy · all services (push) Successful in 2m46s

Completes the four POS v2 roadmap items:

1. Real split payments — split tab records N separate payment rows (equal split,
   last row takes the remainder), each row toggles Cash/Card; posts payments[].
2. Card-terminal push — confirmPay sums Card amounts and calls requestPosPayment
   (POS device) before recording; surfaces POS_DEVICE_* errors.
3. Customer + coupons + loyalty — reuses PosCustomerPicker (attach/search/create)
   and validates coupons via /coupons/validate (discount in totals). Pay sheet
   offers loyalty redemption (1 point = 100 toman) when a customer is attached.
4. Promote to default — /pos now renders POS v2 (full-screen, café-themed); the
   classic terminal moves to /pos-classic with its sidebar+topbar chrome. The
   "نسخه کلاسیک" link points there.

Order submission already carried customerId/guestName/guestPhone/couponId via the
shared cart store, so customer + coupon flow straight through send + pay.
tsc --noEmit clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
soroush.asadi
2026-06-04 05:16:52 +03:30
parent 75a0a1c834
commit 6778c32028
5 changed files with 332 additions and 108 deletions
@@ -0,0 +1,50 @@
"use client";
import { useLocale } from "next-intl";
import { Sidebar } from "@/components/layout/sidebar";
import { Topbar } from "@/components/layout/topbar";
import { CafeThemeProvider } from "@/components/theme/cafe-theme-provider";
/**
* Classic POS route layout — wraps the terminal in the standard dashboard
* chrome (collapsible sidebar + topbar) but keeps the main content area
* overflow-hidden so PosScreen can manage its own internal scrolling.
*/
export default function PosClassicLayout({
children,
}: {
children: React.ReactNode;
}) {
const locale = useLocale();
const isRtl = locale !== "en";
const mainColumn = (
<div className="flex min-h-0 min-w-0 flex-1 flex-col">
<Topbar />
<main className="min-h-0 flex-1 overflow-hidden bg-background p-3 md:p-4">
{children}
</main>
</div>
);
return (
<CafeThemeProvider>
<div
className="flex h-screen min-h-0 overflow-hidden bg-background"
dir={isRtl ? "rtl" : "ltr"}
>
{isRtl ? (
<>
<Sidebar side="right" />
{mainColumn}
</>
) : (
<>
<Sidebar side="left" />
{mainColumn}
</>
)}
</div>
</CafeThemeProvider>
);
}
@@ -0,0 +1,12 @@
import { Suspense } from "react";
import { PosScreen } from "@/components/pos/pos-screen";
/** Classic POS terminal — chrome (sidebar + topbar) is provided by layout.tsx.
* Kept as a fallback while POS v2 (at /pos) is piloted. */
export default function PosClassicPage() {
return (
<Suspense fallback={null}>
<PosScreen />
</Suspense>
);
}
@@ -1,50 +1,13 @@
"use client";
import { useLocale } from "next-intl";
import { Sidebar } from "@/components/layout/sidebar";
import { Topbar } from "@/components/layout/topbar";
import { CafeThemeProvider } from "@/components/theme/cafe-theme-provider";
/**
* POS route layout — wraps the terminal in the standard dashboard chrome
* (collapsible sidebar + topbar) but keeps the main content area
* overflow-hidden so PosScreen can manage its own internal scrolling.
* POS v2 layout — the redesigned terminal is full-screen (its own topbar +
* order ticket), so no dashboard sidebar/topbar chrome here. Café theming
* still applies. Auth guarding comes from the parent (fullscreen) layout.
* The classic POS keeps its chrome under /pos-classic.
*/
export default function PosLayout({
children,
}: {
children: React.ReactNode;
}) {
const locale = useLocale();
const isRtl = locale !== "en";
const mainColumn = (
<div className="flex min-h-0 min-w-0 flex-1 flex-col">
<Topbar />
<main className="min-h-0 flex-1 overflow-hidden bg-background p-3 md:p-4">
{children}
</main>
</div>
);
return (
<CafeThemeProvider>
<div
className="flex h-screen min-h-0 overflow-hidden bg-background"
dir={isRtl ? "rtl" : "ltr"}
>
{isRtl ? (
<>
<Sidebar side="right" />
{mainColumn}
</>
) : (
<>
<Sidebar side="left" />
{mainColumn}
</>
)}
</div>
</CafeThemeProvider>
);
export default function PosLayout({ children }: { children: React.ReactNode }) {
return <CafeThemeProvider>{children}</CafeThemeProvider>;
}
@@ -1,11 +1,8 @@
import { Suspense } from "react";
import { PosScreen } from "@/components/pos/pos-screen";
import { Pos2Screen } from "@/components/pos2/pos2-screen";
/** POS terminal — chrome (sidebar + topbar) is provided by layout.tsx */
/** Default POS terminal — redesigned v2, wired to live data (menu, tables,
* orders, payments) via the shared cart store + offline submit pipeline.
* The classic POS remains available at /[locale]/pos-classic. */
export default function PosPage() {
return (
<Suspense fallback={null}>
<PosScreen />
</Suspense>
);
return <Pos2Screen />;
}