@@ -61,7 +60,7 @@
:min="0"
:step="50000"
addon-after="ریال"
- placeholder="نداشت: صفر"
+ placeholder="اختیاری"
:formatter="formatThousands"
:parser="parseThousands"
/>
diff --git a/apps/admin-panel/src/views/apps/product/variant.ts b/apps/admin-panel/src/views/apps/product/variant.ts
index c838206b..38e97f84 100644
--- a/apps/admin-panel/src/views/apps/product/variant.ts
+++ b/apps/admin-panel/src/views/apps/product/variant.ts
@@ -111,7 +111,7 @@ export function validateVariant(v: VariantRow): VariantErrors {
else if (Number(v.grams) <= 0) e.grams = 'وزن باید بیشتر از صفر باشد';
if (!isBlank(v.qty) && Number(v.qty) < 0) e.qty = 'تعداد منفی نمیشود';
if (isBlank(v.percentage_pay)) e.percentage_pay = 'اجرت درصدی را وارد کنید';
- if (isBlank(v.rial_pay)) e.rial_pay = 'اجرت ریالی را وارد کنید؛ اگر ندارد صفر بزنید';
+ if (!isBlank(v.rial_pay) && Number(v.rial_pay) < 0) e.rial_pay = 'اجرت ریالی منفی نمیشود';
return e;
}
diff --git a/apps/user-app-v2/src/assets/img/Vector.svg b/apps/user-app-v2/src/assets/img/Vector.svg
deleted file mode 100644
index 733693aa..00000000
--- a/apps/user-app-v2/src/assets/img/Vector.svg
+++ /dev/null
@@ -1,3 +0,0 @@
-
diff --git a/apps/user-app-v2/src/components/home/ProductCarousel.vue b/apps/user-app-v2/src/components/home/ProductCarousel.vue
index 2a877033..c34ee9d6 100644
--- a/apps/user-app-v2/src/components/home/ProductCarousel.vue
+++ b/apps/user-app-v2/src/components/home/ProductCarousel.vue
@@ -69,6 +69,13 @@ const dragging = ref(false)
const drag = ref(0)
let startX = 0
let pointerId: number | null = null
+// The cell under the finger at pointerdown. Pointer capture retargets
+// pointerup (and therefore click) onto the stage, so the card's own click
+// never runs — a tap has to be resolved from this index instead.
+let pressedIndex: number | null = null
+// Set when pointerup already handled the tap, so a click that does arrive
+// afterwards does not open the product a second time.
+let tapHandled = false
const SWIPE_THRESHOLD = 46
@@ -153,12 +160,23 @@ function prev() {
go(index.value - 1)
}
+function indexFromEvent(e: Event): number | null {
+ const target = e.target
+ if (!(target instanceof Element) || !stage.value) return null
+ const cell = target.closest('.reel__cell')
+ if (!cell) return null
+ const i = [...stage.value.querySelectorAll('.reel__cell')].indexOf(cell)
+ return i >= 0 ? i : null
+}
+
function onDown(e: PointerEvent) {
if (count.value < 2) return
dragging.value = true
startX = e.clientX
drag.value = 0
pointerId = e.pointerId
+ pressedIndex = indexFromEvent(e)
+ tapHandled = false
;(e.currentTarget as HTMLElement).setPointerCapture?.(e.pointerId)
}
@@ -171,33 +189,57 @@ function onMove(e: PointerEvent) {
function onUp(e: PointerEvent) {
if (!dragging.value) return
const moved = e.clientX - startX
+ const pressed = pressedIndex
dragging.value = false
drag.value = 0
pointerId = null
+ pressedIndex = null
// RTL: dragging right pushes the stack toward the previous card.
- if (moved > SWIPE_THRESHOLD) prev()
- else if (moved < -SWIPE_THRESHOLD) next()
+ if (moved > SWIPE_THRESHOLD) {
+ prev()
+ return
+ }
+ if (moved < -SWIPE_THRESHOLD) {
+ next()
+ return
+ }
+
+ // A tap. Pointer capture delivers this pointerup to the stage, so the
+ // card's click listener never runs; the cell recorded on pointerdown is
+ // what was actually tapped.
+ tapHandled = true
+ activate(pressed)
}
-// A tap on a side card centres it instead of opening it, and a tap that ended
-// a drag does neither.
-function onOpen(i: number, product: ProductSummary) {
- if (Math.abs(drag.value) > 1) return
+// A tap on a side card centres it instead of opening it. The centred card
+// opens, and the trailing tile goes to the full newest-products list.
+function activate(i: number | null) {
+ if (i == null) return
+ const slot = slots.value[i]
+ if (!slot) return
if (i !== index.value) {
go(i)
return
}
- emit('open', product)
+ if (slot.kind === 'product' && slot.product) emit('open', slot.product)
+ else emit('all')
+}
+
+function onOpen(i: number, _product: ProductSummary) {
+ if (tapHandled) {
+ tapHandled = false
+ return
+ }
+ activate(i)
}
function onAll(i: number) {
- if (Math.abs(drag.value) > 1) return
- if (i !== index.value) {
- go(i)
+ if (tapHandled) {
+ tapHandled = false
return
}
- emit('all')
+ activate(i)
}
diff --git a/apps/user-app-v2/src/components/home/ProductPanel.vue b/apps/user-app-v2/src/components/home/ProductPanel.vue
index 55496c55..a7415b6c 100644
--- a/apps/user-app-v2/src/components/home/ProductPanel.vue
+++ b/apps/user-app-v2/src/components/home/ProductPanel.vue
@@ -82,14 +82,30 @@ function format(v: number) {
display: block;
}
+// The stand-in is the brand mark, not a photo, so it stays a mark in the
+// middle of the frame instead of filling the slot the piece will occupy.
+.panel__art img[lazy='loading'],
+.panel__art img[lazy='error'] {
+ max-width: 62%;
+ max-height: 52%;
+}
+
// 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).
+// i.e. no change, in light mode). The brand mark that stands in while a photo
+// loads is black line art, so it stays on the card and is drawn light, the
+// same way the header logo is.
html.theme-dark .panel__art img {
background: @photoMat;
border-radius: 12px;
}
+html.theme-dark .panel__art img[lazy='loading'],
+html.theme-dark .panel__art img[lazy='error'] {
+ background: transparent;
+ filter: invert(1);
+}
+
.panel__title {
margin: 14px 0 0;
font-size: 14px;
diff --git a/apps/user-app-v2/src/components/product/CartItem.vue b/apps/user-app-v2/src/components/product/CartItem.vue
index 7e3fa535..f6416561 100644
--- a/apps/user-app-v2/src/components/product/CartItem.vue
+++ b/apps/user-app-v2/src/components/product/CartItem.vue
@@ -11,8 +11,8 @@
field existed; that was wrong, and the customer was charged a figure the cart
never showed.
- All cart behaviour is unchanged: quantity increment/decrement, remove at
- qty 1, and the note affordance that opens the parent's drawer.
+ All cart behaviour for a line: it is one piece, so the row can be removed,
+ noted, or moved to buy-later. There is no quantity.
-->
@@ -32,41 +32,11 @@
اجرت ریالی {{ price(rialWage) }} ریال
-
- جمع اجرت {{ price(rialWage * value.qty) }} ریال
-
-
-
-
-
- {{ value.qty }}
-
-
-
+
-
+
{{ value.quantity }}
عدد
diff --git a/apps/user-app-v2/src/components/product/ProductCard.vue b/apps/user-app-v2/src/components/product/ProductCard.vue
index 030d878b..f219c6a9 100644
--- a/apps/user-app-v2/src/components/product/ProductCard.vue
+++ b/apps/user-app-v2/src/components/product/ProductCard.vue
@@ -135,14 +135,30 @@ function wageLabel(v: number) {
display: block;
}
+// The stand-in is the brand mark, not a photo, so it stays a mark in the
+// middle of the frame instead of filling the slot the piece will occupy.
+.pc__art img[lazy='loading'],
+.pc__art img[lazy='error'] {
+ max-width: 62%;
+ max-height: 52%;
+}
+
// 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).
+// i.e. no change, in light mode). The brand mark that stands in while a photo
+// loads is black line art, so it stays on the card and is drawn light, the
+// same way the header logo is.
html.theme-dark .pc__art img {
background: @photoMat;
border-radius: 12px;
}
+html.theme-dark .pc__art img[lazy='loading'],
+html.theme-dark .pc__art img[lazy='error'] {
+ background: transparent;
+ filter: invert(1);
+}
+
.pc__artEmpty {
width: 100%;
height: 100%;
diff --git a/apps/user-app-v2/src/components/product/SingleProduct.vue b/apps/user-app-v2/src/components/product/SingleProduct.vue
index b7491016..65467a06 100644
--- a/apps/user-app-v2/src/components/product/SingleProduct.vue
+++ b/apps/user-app-v2/src/components/product/SingleProduct.vue
@@ -212,32 +212,7 @@
-
-
-
-
- {{ cartQty }}
-
-
-
- مشاهده سبد خرید
+ در سبد خرید
@@ -475,7 +450,7 @@ const wageLabel = computed(() => {
})
const stockLabel = computed(() => {
- if (qty.value > 0) return `${qty.value} عدد موجود`
+ if (qty.value > 0) return 'موجود'
return isPreOrder.value ? 'پیشسفارش' : 'ناموجود'
})
const stockClass = computed(() => {
@@ -491,27 +466,7 @@ const storeProduct = computed(() => ({
qty: 1,
}))
-// Quantity control reuses the store's updateFeild(...,'qty') path, the same one
-// CartItem uses; the store has no dedicated increment/decrement.
const inCart = computed(() => cart.isInCart(storeProduct.value))
-const cartIndex = computed(() => cart.find_index(storeProduct.value))
-const cartQty = computed(() => (cartIndex.value > -1 ? cart.items[cartIndex.value].qty : 0))
-
-// Stock ceiling: a pre-order variant may exceed what is on hand, anything else
-// stops at its qty. The store clamps too — this just keeps the button honest.
-const cartMaxQty = computed(() => cart.maxQty(storeProduct.value))
-const canIncrement = computed(() => cartMaxQty.value === null || cartQty.value < cartMaxQty.value)
-const increment = () => {
- if (!canIncrement.value) return
- cart.updateFeild(cartQty.value + 1, cartIndex.value, storeProduct.value, 'qty')
-}
-const decrement = () => {
- if (cartQty.value <= 1) {
- cart.remove(storeProduct.value)
- return
- }
- cart.updateFeild(cartQty.value - 1, cartIndex.value, storeProduct.value, 'qty')
-}
const isOrderable = (v: Parameters[0]) => isVariantOrderable(v)
@@ -1295,40 +1250,6 @@ onBeforeUnmount(() => {
text-overflow: ellipsis;
}
-.pd__qty {
- flex-shrink: 0;
- height: 48px;
- padding: 0 6px;
- display: inline-flex;
- align-items: center;
- gap: 4px;
- border-radius: 999px;
- border: 1px solid @hairline;
- background: @canvas;
-}
-.pd__qtyBtn {
- width: 32px;
- height: 32px;
- display: grid;
- place-items: center;
- border: 0;
- border-radius: 50%;
- cursor: pointer;
- color: @ink;
- background: @hairlineSoft;
- transition: transform 0.18s ease;
-}
-.pd__qtyBtn:active {
- transform: scale(0.9);
-}
-.pd__qtyValue {
- min-width: 20px;
- text-align: center;
- font-size: 13px;
- font-weight: 800;
- color: @ink;
-}
-
.pd__cta {
flex: 1;
min-width: 0;
diff --git a/apps/user-app-v2/src/main.ts b/apps/user-app-v2/src/main.ts
index 4f9397e0..c4a504ad 100644
--- a/apps/user-app-v2/src/main.ts
+++ b/apps/user-app-v2/src/main.ts
@@ -9,7 +9,7 @@ import { setUnauthorizedHandler } from './api/client';
import { useSessionStore } from './stores/session';
import { useAppearanceStore } from './stores/appearanceStore';
import Container from './components/ui/Container.vue';
-import Vector from './assets/img/Vector.svg';
+import brandLogo from './assets/img/brand-logo.svg';
// Vant defaults to zh-CN. Every view in this app is Persian (RTL), so any
// Vant component rendering its own built-in text (PullRefresh's
@@ -48,12 +48,11 @@ setUnauthorizedHandler(() => {
void router.replace({ name: 'login' });
}
});
-// Ported from legacy main.ts:32-46 — Vector.svg is both the while-loading and
-// the on-error placeholder, so a missing/failed image paints the brand mark
-// instead of collapsing the layout.
+// While a catalogue photo is still loading, and if it fails, the brand mark
+// stands in the frame. Same file the header and the login screen use.
app.use(VueLazyLoad, {
- loading: Vector,
- error: Vector,
+ loading: brandLogo,
+ error: brandLogo,
});
app.component('container', Container);
app.mount('#app');
diff --git a/apps/user-app-v2/src/stores/buyLaterStore.ts b/apps/user-app-v2/src/stores/buyLaterStore.ts
index 2185b60f..d02f565b 100644
--- a/apps/user-app-v2/src/stores/buyLaterStore.ts
+++ b/apps/user-app-v2/src/stores/buyLaterStore.ts
@@ -6,7 +6,7 @@
* (cart never reserved stock; this list also never reserves).
* - Move here → cart: uses cart.addToCart stock guards; on failure the line
* stays here so an out-of-stock deferral is not lost.
- * - Qty/note editable here without stock ceiling (desired qty for later).
+ * - One of each variant. A line is the piece itself; qty stays 1.
* - Survives daily cart expiry and successful order (active cart only clears).
* - Guest: localStorage; logged-in: debounced PUT /cart/buy-later.
* - Acting-as / logout: list is cleared in memory like the active cart.
@@ -26,8 +26,8 @@ function loadStored(): CartItem[] {
const raw = localStorage.getItem(STORAGE_KEY)
if (!raw) return []
const parsed = JSON.parse(raw)
- if (Array.isArray(parsed)) return parsed
- return Array.isArray(parsed?.items) ? parsed.items : []
+ if (Array.isArray(parsed)) return parsed.map((item) => ({ ...item, qty: 1 }))
+ return Array.isArray(parsed?.items) ? parsed.items.map((item: CartItem) => ({ ...item, qty: 1 })) : []
} catch {
return []
}
@@ -41,7 +41,7 @@ function toServerItems(items: CartItem[]) {
return items.map((i) => ({
pid: i.pid,
vid: i.vid,
- qty: i.qty,
+ qty: 1,
note: i.note ?? null,
}))
}
@@ -115,7 +115,7 @@ export const useBuyLaterStore = defineStore('buyLater', {
next.push({
pid: line.pid,
vid: line.vid,
- qty: Math.max(1, Math.floor(line.qty) || 1),
+ qty: 1,
note: line.note ?? null,
product: blob,
})
@@ -143,17 +143,16 @@ export const useBuyLaterStore = defineStore('buyLater', {
return this.items.findIndex((i) => i.pid === item.pid && i.vid === item.vid)
},
- /** Upsert a line without any stock check. */
+ /** Upsert a line. A variant already here stays the one piece it is. */
upsert(item: CartItem) {
- const qty = Math.max(1, Math.floor(item.qty) || 1)
const i = this.find_index(item)
if (i === -1) {
- this.items.push({ ...item, qty })
+ this.items.push({ ...item, qty: 1 })
} else {
this.items[i] = {
...this.items[i],
product: item.product,
- qty,
+ qty: 1,
note: item.note ?? this.items[i].note,
}
}
@@ -167,10 +166,10 @@ export const useBuyLaterStore = defineStore('buyLater', {
this.writeLocal()
},
- updateQty(item: Pick, qty: number) {
+ updateQty(item: Pick, _qty: number) {
const i = this.find_index(item)
if (i === -1) return
- this.items[i].qty = Math.max(1, Math.floor(qty) || 1)
+ this.items[i].qty = 1
this.writeLocal()
},
diff --git a/apps/user-app-v2/src/stores/cartStore.ts b/apps/user-app-v2/src/stores/cartStore.ts
index de32a013..c37a38b2 100644
--- a/apps/user-app-v2/src/stores/cartStore.ts
+++ b/apps/user-app-v2/src/stores/cartStore.ts
@@ -33,10 +33,10 @@ function loadStored(): StoredCart {
const parsed = JSON.parse(raw)
// Legacy shape was a bare array.
if (Array.isArray(parsed)) {
- return { items: parsed, touchedAt: null }
+ return { items: oneEach(parsed), touchedAt: null }
}
return {
- items: Array.isArray(parsed?.items) ? parsed.items : [],
+ items: oneEach(Array.isArray(parsed?.items) ? parsed.items : []),
touchedAt: typeof parsed?.touchedAt === 'string' ? parsed.touchedAt : null,
}
} catch {
@@ -48,11 +48,16 @@ function persist(items: CartItem[], touchedAt: string | null) {
localStorage.setItem(STORAGE_KEY, JSON.stringify({ items, touchedAt }))
}
+/** A variant is one physical piece, so a line never carries a count above one. */
+function oneEach(items: CartItem[]): CartItem[] {
+ return items.map((item) => ({ ...item, qty: 1 }))
+}
+
function toServerItems(items: CartItem[]) {
return items.map((i) => ({
pid: i.pid,
vid: i.vid,
- qty: i.qty,
+ qty: 1,
note: i.note ?? null,
}))
}
@@ -172,7 +177,7 @@ export const useCartStore = defineStore('cart', {
next.push({
pid: line.pid,
vid: line.vid,
- qty: line.qty,
+ qty: 1,
note: line.note ?? null,
product,
})
@@ -207,35 +212,16 @@ export const useCartStore = defineStore('cart', {
if (!((target.qty ?? 0) > 0 || target.isPreOrder)) return false
const index = this.find_index(data)
- if (index === -1) this.items.push({ ...data, qty: this.capQty(data.qty, target) })
+ if (index === -1) this.items.push({ ...data, qty: 1 })
else {
+ // Already in the basket. Refresh the product blob and leave the line
+ // as the one piece it is — a second add must not become two.
this.items[index].product = data.product
- this.items[index].qty = this.capQty(data.qty, target)
+ this.items[index].qty = 1
}
this.writeLocal(true)
return true
},
-
- /**
- * Stock ceiling for a cart line. A pre-order variant is orderable beyond
- * what is on hand (that is the point of pre-ordering), so it is uncapped;
- * anything else stops at its on-hand quantity.
- */
- capQty(want: number, variant: { qty?: number; isPreOrder?: boolean }) {
- const n = Math.max(1, Math.floor(want) || 1)
- if (variant.isPreOrder) return n
- const max = variant.qty ?? 0
- return max > 0 ? Math.min(n, max) : n
- },
-
- /** The ceiling for an item already in the cart; null when uncapped. */
- maxQty(item: Pick) {
- const i = this.find_index(item)
- if (i === -1) return null
- const v = this.variant(this.items[i])
- if (!v || v.isPreOrder) return null
- return (v.qty ?? 0) > 0 ? (v.qty as number) : null
- },
remove(item: CartItem) {
const index = this.find_index(item)
if (index > -1) this.items.splice(index, 1)
@@ -246,13 +232,8 @@ export const useCartStore = defineStore('cart', {
updateFeild(value: unknown, index: number | null, item: Pick, field: keyof CartItem) {
if (!this.isInCart(item)) return false
const i = index ?? this.find_index(item)
- // A quantity change is clamped to what is actually in stock (unless the
- // variant is pre-orderable), so the ceiling holds no matter which screen
- // drives the stepper.
- if (field === 'qty') {
- const v = this.variant(this.items[i])
- value = v ? this.capQty(Number(value), v) : Math.max(1, Number(value) || 1)
- }
+ // A line is one piece. Notes still update; a quantity write cannot.
+ if (field === 'qty') value = 1
;(this.items[i] as any)[field] = value
this.writeLocal(true)
return true
diff --git a/apps/user-app-v2/src/views/CartView.vue b/apps/user-app-v2/src/views/CartView.vue
index 34a07bb7..73be3006 100644
--- a/apps/user-app-v2/src/views/CartView.vue
+++ b/apps/user-app-v2/src/views/CartView.vue
@@ -342,7 +342,7 @@ const submitOrder = async () => {
const variant = cart.variant(item)
return {
productVariantId: item.vid,
- quantity: item.qty,
+ quantity: 1,
// Sent for older API builds only: the server prices app orders itself
// (MON-08) and ignores this figure.
wagePercent: variant ? parseFloat(variant.defaultWagePercent) : 0,