fix: customer history query, seed transactions tied to accounts

- Fix customerHistoryOptions closure bug (historySearch was inaccessible)
- Pass itemSearch as parameter instead of capturing from outer scope
- Seed 5 completed transactions tied to accounts (Smith, Johnson, Garcia, Chen)
- Seed admin user with employee number 1001 and PIN 1234

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
ryan
2026-04-04 21:15:53 +00:00
parent d21972212b
commit 0fd73015f7
2 changed files with 64 additions and 5 deletions

View File

@@ -46,15 +46,15 @@ function accountSearchOptions(search: string) {
})
}
function customerHistoryOptions(accountId: string | null) {
function customerHistoryOptions(accountId: string | null, itemSearch?: string) {
return queryOptions({
queryKey: ['pos', 'customer-history', accountId],
queryKey: ['pos', 'customer-history', accountId, itemSearch ?? ''],
queryFn: () => api.get<{ data: Transaction[] }>('/v1/transactions', {
accountId,
limit: 10,
sort: 'created_at',
order: 'desc',
...(historySearch ? { itemSearch: historySearch } : {}),
...(itemSearch ? { itemSearch } : {}),
}),
enabled: !!accountId,
})
@@ -74,7 +74,7 @@ export function POSCustomerDialog({ open, onOpenChange }: POSCustomerDialogProps
const { data: searchData, isLoading } = useQuery(accountSearchOptions(search))
const accounts = searchData?.data ?? []
const { data: historyData } = useQuery(customerHistoryOptions(showHistory ? accountId : null))
const { data: historyData } = useQuery(customerHistoryOptions(showHistory ? accountId : null, historySearch || undefined))
const history = historyData?.data ?? []
function handleSelect(account: Account) {