feat: customer lookup from POS with order history and item search

- Customer dialog in cart panel: search accounts by name, phone, email, account #
- Selected customer shown with name, phone, email in cart header
- accountId passed when creating transactions
- Order history view: tap a transaction to expand and see line items
- Item search in history (e.g. "strings") — filters orders containing that item
- Backend: add accountId and itemSearch filters to transaction list endpoint
- itemSearch uses EXISTS subquery on line item descriptions (ILIKE)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
ryan
2026-04-04 21:07:24 +00:00
parent cf299ac1d2
commit d21972212b
7 changed files with 310 additions and 5 deletions

View File

@@ -16,12 +16,18 @@ interface POSState {
cashier: POSUser | null
token: string | null
lastActivity: number
accountId: string | null
accountName: string | null
accountPhone: string | null
accountEmail: string | null
setTransaction: (id: string | null) => void
setLocation: (id: string) => void
setDrawerSession: (id: string | null) => void
unlock: (user: POSUser, token: string) => void
lock: () => void
touchActivity: () => void
setAccount: (id: string, name: string, phone?: string | null, email?: string | null) => void
clearAccount: () => void
reset: () => void
}
@@ -33,11 +39,17 @@ export const usePOSStore = create<POSState>((set) => ({
cashier: null,
token: null,
lastActivity: Date.now(),
accountId: null,
accountName: null,
accountPhone: null,
accountEmail: null,
setTransaction: (id) => set({ currentTransactionId: id }),
setLocation: (id) => set({ locationId: id }),
setDrawerSession: (id) => set({ drawerSessionId: id }),
unlock: (user, token) => set({ locked: false, cashier: user, token, lastActivity: Date.now() }),
lock: () => set({ locked: true, currentTransactionId: null }),
touchActivity: () => set({ lastActivity: Date.now() }),
reset: () => set({ currentTransactionId: null }),
setAccount: (id, name, phone, email) => set({ accountId: id, accountName: name, accountPhone: phone ?? null, accountEmail: email ?? null }),
clearAccount: () => set({ accountId: null, accountName: null, accountPhone: null, accountEmail: null }),
reset: () => set({ currentTransactionId: null, accountId: null, accountName: null, accountPhone: null, accountEmail: null }),
}))