Step 3 of docs/CATALOG-PAGINATION-PLAN.md. Step 2 added the targeted routes; these are the five callers that were fetching all ~16k products to find a handful of rows: product screen whole catalogue, then find(id) -> GET /products/:id cart re-sync whole catalogue for 2-3 lines -> ?ids= favourites whole catalogue, filtered here -> ?ids= home categories categories derived from it -> /products/facets order row labels joined on variantId -> included with the order Three of these were not merely slow, they were going to be wrong. Favourites filtered the loaded catalogue, so once the list pages a favourite outside the loaded slice silently disappears. Home categories were derived the same way, so a category whose products all sit further down would vanish from the home screen. Order rows looked their title up in the catalogue, which ALREADY failed for a product that had since left the storefront — exactly the old orders history exists for — and rendered a blank row. Order labels went to the server rather than to another id lookup: the item carries productVariantId, not a product id, so ?ids= could not answer it. One nested include in getOrders returns the variant, its product and the product's first image. Deliberately NOT filtered by storefront visibility, so a de-listed product still shows what was bought; asserted in the new spec. OrderItemCard is synchronous now — no fetch, no onMounted, the row renders complete on its first frame. variantLookup is deleted from catalogStore rather than left behind: it existed only to label order rows, and keeping it would have kept a reason to load the full catalogue. getProductsByIds chunks at 100 because the route caps ids there and drops the rest. A partial answer reads to callers as "these products are no longer on the storefront" — the cart would silently drop valid lines. Favourites already run to 874 rows in the imported data (FAV-01). A failed cart re-sync now leaves the cart alone: it is the person's own data in localStorage, and dropping lines because the network blinked is worse than a slightly stale price. The product screen tells a real 404 from a failed request, so only the former renders the not-found page. One bug introduced and caught while doing this: moving the home categories to /facets meant memory.init() no longer loaded the catalogue as a side effect, and the home rails read catalog.products — the home screen would have rendered empty rails. HomeView now loads it explicitly. Found by grepping every caller of configStore.init, which is also how I know HomeView is the only one. Still on the unpaged list by design: the home rails and the search/newest lists. Moving those onto paged reads is step 4, kept separate because it is the risky part — debounce, loading state, and telling "no results" from "still loading". api 334/334 across 30 suites; both apps vue-tsc clean. getOrders has a spec now (3 cases) because its include is a contract both apps depend on and the method had no test at all. Nothing click-tested — the cart re-sync and the favourites screen are the two worth a manual pass. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
153 lines
3.6 KiB
Vue
153 lines
3.6 KiB
Vue
<!--
|
|
One line of an order's contents, restyled into the redesigned design
|
|
language (see components/home/* and HomeView). Ported originally from
|
|
legacy henza_pwa/src/components/product/orderItem.vue.
|
|
|
|
The product/variant title and photo come WITH the order (the server includes
|
|
each item's variant and product). They used to be looked up in the browser
|
|
against the whole catalogue, which downloaded ~16k products to label a few
|
|
rows and left the row blank for a product that had since left the storefront.
|
|
|
|
DROPPED the "توضیحات: -" row the previous version rendered: our OrderItem
|
|
schema has no note field (legacy's per-item note was a real column there;
|
|
ours isn't), so it could only ever print a dash. An always-empty row is
|
|
noise, not information.
|
|
-->
|
|
<template>
|
|
<article class="oi">
|
|
<div class="oi__art">
|
|
<img v-if="lookup?.imageUrl" v-lazy="lookup.imageUrl" :alt="lookup?.productTitle ?? ''" />
|
|
<div v-else class="oi__artEmpty" aria-hidden="true">
|
|
<Icon icon="vuesax-linear:diamonds" size="18" />
|
|
</div>
|
|
</div>
|
|
|
|
<div class="oi__main">
|
|
<div class="oi__head">
|
|
<h4 class="oi__title">{{ lookup?.productTitle ?? '—' }}</h4>
|
|
<span v-if="lookup?.variantTitle" class="oi__variant">{{ lookup.variantTitle }}</span>
|
|
</div>
|
|
|
|
<div class="oi__figures">
|
|
<span class="oi__figure">
|
|
{{ value.quantity }}
|
|
<i>عدد</i>
|
|
</span>
|
|
<span class="oi__figure">
|
|
{{ value.computedWeightGrams }}
|
|
<i>گرم</i>
|
|
</span>
|
|
<span class="oi__figure">
|
|
{{ value.wagePercentSnapshot }}
|
|
<i>٪ اجرت</i>
|
|
</span>
|
|
</div>
|
|
</div>
|
|
</article>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { computed } from 'vue'
|
|
import Icon from '../icon/Icon.vue'
|
|
import { orderItemLookup } from '../../composables/useOrderItemProduct'
|
|
import type { OrderItemDetail } from '../../api/client'
|
|
|
|
const props = defineProps<{ value: OrderItemDetail }>()
|
|
|
|
// The server sends these with the order, so there is nothing to fetch and
|
|
// nothing to wait for — the row renders complete on its first frame instead of
|
|
// filling in after a catalogue download.
|
|
const lookup = computed(() => orderItemLookup(props.value))
|
|
</script>
|
|
|
|
<style scoped lang="less">
|
|
.oi {
|
|
display: flex;
|
|
gap: 11px;
|
|
padding: 11px;
|
|
background: @canvas;
|
|
border: 1px solid @hairline;
|
|
border-radius: 16px;
|
|
}
|
|
|
|
.oi__art {
|
|
flex: 0 0 62px;
|
|
width: 62px;
|
|
height: 62px;
|
|
border-radius: 12px;
|
|
overflow: hidden;
|
|
background: @hairlineSoft;
|
|
}
|
|
|
|
.oi__art img {
|
|
width: 100%;
|
|
height: 100%;
|
|
object-fit: cover;
|
|
display: block;
|
|
}
|
|
|
|
// Dark mode: product photos are shot on white, so they sit on a light mat
|
|
// instead of showing as white boxes on a dark card (@photoMat — transparent,
|
|
// i.e. no change, in light mode).
|
|
html.theme-dark .oi__art img {
|
|
background: @photoMat;
|
|
border-radius: 12px;
|
|
}
|
|
|
|
.oi__artEmpty {
|
|
width: 100%;
|
|
height: 100%;
|
|
display: grid;
|
|
place-items: center;
|
|
color: @inkFaint;
|
|
}
|
|
|
|
.oi__main {
|
|
flex: 1;
|
|
min-width: 0;
|
|
}
|
|
|
|
.oi__head {
|
|
display: flex;
|
|
align-items: baseline;
|
|
gap: 7px;
|
|
min-width: 0;
|
|
}
|
|
|
|
.oi__title {
|
|
margin: 0;
|
|
font-size: 12.5px;
|
|
font-weight: 700;
|
|
color: @ink;
|
|
white-space: nowrap;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
}
|
|
|
|
.oi__variant {
|
|
flex: 0 0 auto;
|
|
font-size: 10.5px;
|
|
color: @inkFaint;
|
|
}
|
|
|
|
.oi__figures {
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
gap: 14px;
|
|
padding-top: 9px;
|
|
}
|
|
|
|
.oi__figure {
|
|
font-size: 12px;
|
|
font-weight: 700;
|
|
color: @inkSoft;
|
|
}
|
|
.oi__figure i {
|
|
font-style: normal;
|
|
font-size: 10px;
|
|
font-weight: 600;
|
|
color: @inkFaint;
|
|
padding-inline-start: 2px;
|
|
}
|
|
</style>
|