Changeset 057453c for src/sections/invoice/view/invoice-list-view.tsx
- Timestamp:
- 02/26/25 10:05:32 (5 weeks ago)
- Branches:
- main
- Children:
- 299af01
- Parents:
- 5d6f37a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sections/invoice/view/invoice-list-view.tsx
r5d6f37a r057453c 36 36 } from 'src/components/table'; 37 37 // types 38 import { 39 Invoice, 40 InvoiceStatus, 41 InvoiceTableFilters, 42 InvoiceTableFilterValue, 43 } from 'mvpmasters-shared'; 38 import { Invoice, InvoiceStatus, InvoiceTableFilters, InvoiceTableFilterValue } from 'src/schemas'; 44 39 // 45 40 import deleteFromFirebaseStorage from 'src/utils/delete-from-firebase-storage'; 46 41 // fetch 47 import { use GetInvoices } from 'src/api/invoice';42 import { useDeleteInvoice, useGetInvoices } from 'src/api/invoice'; 48 43 import { collections, removeDocument } from 'src/lib/firestore'; 49 44 import { mutate } from 'swr'; … … 163 158 const [filters, setFilters] = useState(defaultFilters); 164 159 165 const { invoices: tableData } = useGetInvoices({ 166 where: [['createDate', '>=', filters.startDate]], 167 orderBy: 'createDate', 168 direction: 'desc', 169 }); 160 const { invoices: tableData } = useGetInvoices({ startDate: filters.startDate?.toISOString() }); 170 161 171 162 const invoiceMutationKey = useMemo( … … 269 260 ); 270 261 262 const { deleteInvoiceMutation } = useDeleteInvoice(); 263 271 264 const handleDeleteRow = useCallback( 272 265 async (invoice: Invoice) => { … … 275 268 orderBy: 'createDate', 276 269 direction: 'desc', 277 }); // Get the same params as used in useGetInvoices 278 279 // Optimistically update the cache before the deletion 280 // mutate( 281 // [collections.invoice, serializedParams], 282 // (invoices: Invoice[] = []) => invoices.filter((row) => row.id !== invoice.id), 283 // false 284 // ); 285 286 await removeDocument(collections.invoice, invoice.id); 270 }); 271 272 await deleteInvoiceMutation(invoice.id); 287 273 await deleteFromFirebaseStorage( 288 274 `invoices/${invoice.invoiceTo.name}/${invoice.id}-${invoice.invoiceNumber}.pdf` 289 275 ); 290 276 291 // Optionally, rollback optimistic update or refetch data292 277 mutate(invoiceMutationKey); 293 278 }, … … 672 657 inputData = inputData.filter( 673 658 (invoice) => 674 fTimestamp(invoice.createDate. toMillis()) >= fTimestamp(startDate) &&675 fTimestamp(invoice.createDate. toMillis()) <= fTimestamp(endDate)659 fTimestamp(invoice.createDate.getTime()) >= fTimestamp(startDate.getTime()) && 660 fTimestamp(invoice.createDate.getTime()) <= fTimestamp(endDate.getTime()) 676 661 ); 677 662 }
Note:
See TracChangeset
for help on using the changeset viewer.