Files
tehran_tala/apps/user-app/src/composables/useOrderItemProduct.ts
T

17 lines
675 B
TypeScript
Raw Normal View History

2026-09-09 06:46:27 +03:30
// The real GET /customers/:id/orders endpoint returns OrderItem rows with
// only `productVariantId` (no nested product/variant title) — this joins
// against the shared catalogue (stores/catalogStore.ts) client-side rather
2026-09-09 06:46:27 +03:30
// than touching apps/api to add an include.
import { useCatalogStore, type VariantLookup } from '../stores/catalogStore'
2026-09-09 06:46:27 +03:30
export type { VariantLookup }
2026-09-09 06:46:27 +03:30
export function useOrderItemProduct() {
const catalog = useCatalogStore()
2026-09-09 06:46:27 +03:30
const lookup = async (productVariantId: string): Promise<VariantLookup | undefined> => {
if (!catalog.loaded) await catalog.load()
return catalog.variantLookup.get(productVariantId)
2026-09-09 06:46:27 +03:30
}
return { lookup }
}