17 lines
675 B
TypeScript
17 lines
675 B
TypeScript
// 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
|
|
// than touching apps/api to add an include.
|
|
import { useCatalogStore, type VariantLookup } from '../stores/catalogStore'
|
|
|
|
export type { VariantLookup }
|
|
|
|
export function useOrderItemProduct() {
|
|
const catalog = useCatalogStore()
|
|
const lookup = async (productVariantId: string): Promise<VariantLookup | undefined> => {
|
|
if (!catalog.loaded) await catalog.load()
|
|
return catalog.variantLookup.get(productVariantId)
|
|
}
|
|
return { lookup }
|
|
}
|