fix: drawer open/close updates UI immediately without refresh
- Return null instead of throwing on 404 for drawer current query - Sync drawer session ID to null when drawer closes - Await query invalidation before closing dialog - Fix unused approvedBy lint error Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -43,9 +43,9 @@ export function POSDrawerDialog({ open, onOpenChange, drawer }: POSDrawerDialogP
|
||||
locationId: locationId ?? undefined,
|
||||
openingBalance: parseFloat(openingBalance) || 0,
|
||||
}),
|
||||
onSuccess: (session) => {
|
||||
onSuccess: async (session) => {
|
||||
setDrawerSession(session.id)
|
||||
queryClient.invalidateQueries({ queryKey: posKeys.drawer(locationId ?? '') })
|
||||
await queryClient.invalidateQueries({ queryKey: posKeys.drawer(locationId ?? '') })
|
||||
toast.success('Drawer opened')
|
||||
onOpenChange(false)
|
||||
},
|
||||
@@ -58,9 +58,8 @@ export function POSDrawerDialog({ open, onOpenChange, drawer }: POSDrawerDialogP
|
||||
closingBalance: parseFloat(closingBalance) || 0,
|
||||
notes: notes || undefined,
|
||||
}),
|
||||
onSuccess: (session) => {
|
||||
onSuccess: async (session) => {
|
||||
setDrawerSession(null)
|
||||
queryClient.invalidateQueries({ queryKey: posKeys.drawer(locationId ?? '') })
|
||||
const overShort = parseFloat(session.overShort ?? '0')
|
||||
if (Math.abs(overShort) < 0.01) {
|
||||
toast.success('Drawer closed - balanced')
|
||||
@@ -68,6 +67,7 @@ export function POSDrawerDialog({ open, onOpenChange, drawer }: POSDrawerDialogP
|
||||
toast.warning(`Drawer closed - ${overShort > 0 ? 'over' : 'short'} $${Math.abs(overShort).toFixed(2)}`)
|
||||
}
|
||||
onOpenChange(false)
|
||||
await queryClient.invalidateQueries({ queryKey: posKeys.drawer(locationId ?? '') })
|
||||
},
|
||||
onError: (err) => toast.error(err.message),
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user