feat: initial commit

This commit is contained in:
s.esmaeili
2026-09-09 06:46:27 +03:30
commit 0ed6bed028
214 changed files with 20177 additions and 0 deletions
@@ -0,0 +1,32 @@
// Adapted from legacy singleProduct.vue's own fetch (GET /product/:id).
// The new API has no single-product-detail endpoint (only GET
// /catalog/products, the flat list) — apps/api is out of scope for this port,
// so this fetches the full list and finds the matching product client-side.
// Wasteful for a large catalog, but honest: no fabricated endpoint, no silent
// behavior change.
import { ref } from 'vue'
import { api, type ProductSummary } from '../api/client'
export function useProductDetail(id: string) {
const loading = ref(false)
const flag = ref(false)
const notFound = ref(false)
const productRef = ref<ProductSummary | null>(null)
const load = async () => {
loading.value = true
try {
const products = await api.listProducts()
const found = products.find((p) => p.id === id) ?? null
productRef.value = found
notFound.value = !found
flag.value = true
} catch (e) {
console.log(e)
} finally {
loading.value = false
}
}
return { loading, flag, notFound, productRef, load }
}