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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user