feat: paginate customer orders and polish the dashboard hero
Add paged orders API and infinite scroll, short order numbers, and align the guest invite card with the logged-in hero shell. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -32,12 +32,28 @@ export const useCatalogStore = defineStore('catalog', () => {
|
||||
// reason to keep loading the full catalogue.
|
||||
|
||||
async function load(force = false): Promise<ProductSummary[]> {
|
||||
const list = await cache.fetch(KEYS.catalog, api.listProducts, { force })
|
||||
// Prefer a bounded page when a caller still uses the unpaged helper — the
|
||||
// real catalogue reaches ~16k rows (STUB-03). Screens that need filters or
|
||||
// infinite scroll should call api.listProductsPaged directly.
|
||||
const list = await cache.fetch(
|
||||
KEYS.catalog,
|
||||
async () => {
|
||||
const page = await api.listProductsPaged({ page: 1, limit: 100, sort: 'newest' })
|
||||
return page.rows
|
||||
},
|
||||
{ force },
|
||||
)
|
||||
products.value = list
|
||||
loaded.value = true
|
||||
return list
|
||||
}
|
||||
|
||||
/** Replace the in-memory slice (home rails, after a paged fetch). */
|
||||
function replace(list: ProductSummary[]) {
|
||||
products.value = list
|
||||
loaded.value = true
|
||||
}
|
||||
|
||||
function byId(id: string): ProductSummary | null {
|
||||
return products.value.find((p) => p.id === id) ?? null
|
||||
}
|
||||
@@ -47,5 +63,5 @@ export const useCatalogStore = defineStore('catalog', () => {
|
||||
cache.invalidate(KEYS.catalog)
|
||||
}
|
||||
|
||||
return { products, loaded, categories, load, byId, invalidate }
|
||||
return { products, loaded, categories, load, replace, byId, invalidate }
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user