feat: catalog read cache (api + user apps) and clearer Zarrin accounting errors
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -3,7 +3,8 @@
|
||||
// localStorage key), just via Pinia's own state instead of @vueuse's
|
||||
// useStorage wrapping a hand-rolled class.
|
||||
import { defineStore } from 'pinia'
|
||||
import { api, type ProductSummary } from '../api/client'
|
||||
import type { ProductSummary } from '../api/client'
|
||||
import { useCatalogStore } from './catalogStore'
|
||||
|
||||
export interface CartItem {
|
||||
pid: string
|
||||
@@ -36,9 +37,9 @@ export const useCartStore = defineStore('cart', {
|
||||
// Re-syncs cart entries against fresh product data (e.g. price/weight
|
||||
// changes since the item was added), dropping entries whose
|
||||
// product/variant no longer exists — same intent as legacy's init().
|
||||
async init() {
|
||||
async init(force = false) {
|
||||
try {
|
||||
const products = await api.listProducts()
|
||||
const products = await useCatalogStore().load(force)
|
||||
const refreshed: CartItem[] = []
|
||||
for (const item of this.items) {
|
||||
const product = products.find((p) => p.id === item.pid)
|
||||
|
||||
Reference in New Issue
Block a user