Route shop browse through categories and catalogs, and align product detail with the mockup.

Customers can add items without a company-first path, and the detail page matches the card, badge, share, and footer layout.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-10 21:05:05 +03:30
co-authored by Cursor
parent c1acbebeb9
commit c81db8e620
21 changed files with 540 additions and 218 deletions
+12 -8
View File
@@ -231,14 +231,15 @@ export const useCartStore = defineStore('cart', () => {
catalogCode: string,
meterage: number,
): Promise<{ success: boolean; message?: string }> {
const company = catalogStore.getCompany(product.companyId)
if (!company) {
return { success: false, message: 'شرکت محصول یافت نشد.' }
if (!catalogStore.companies.length) {
await catalogStore.loadCompanies()
}
const cart = getOrCreateCart(company)
const companyMax = company.maxMeteragePerInvoice
const currentCompanyMeterage = companyMeterage(cart, company.id)
const company = catalogStore.getCompany(product.companyId)
const cart = activeCart.value ?? emptyCart()
const companyMax = company?.maxMeteragePerInvoice ?? DEFAULT_MAX_METERAGE
const currentCompanyMeterage = product.companyId
? companyMeterage(cart, product.companyId)
: 0
const existing = cart.items.find((i) => i.productId === product.id)
const previousMeterage = existing?.meterage ?? 0
@@ -254,6 +255,9 @@ export const useCartStore = defineStore('cart', () => {
}
if (useLocalCart()) {
if (!company) {
return { success: false, message: 'شرکت محصول یافت نشد.' }
}
return addItemLocal(product, catalogCode, meterage, company)
}
@@ -271,7 +275,7 @@ export const useCartStore = defineStore('cart', () => {
})
}
applyServerCart(serverCart)
selectedCompanyId.value = company.id
selectedCompanyId.value = company?.id || product.companyId || selectedCompanyId.value
return { success: true }
} catch (e) {
return {
+9 -1
View File
@@ -25,6 +25,7 @@ function mapProduct(p: {
companyId?: string
catalogId?: string
catalogCode?: string
catalogName?: string
color?: string
minMeterage?: number
orderMultiplier?: number
@@ -63,6 +64,7 @@ function mapProduct(p: {
companyId: p.companyId,
catalogId: p.catalogId,
catalogCode: p.catalogCode,
catalogName: p.catalogName,
color: p.color,
minMeterage: p.minMeterage ?? 30,
orderMultiplier: p.orderMultiplier ?? 10,
@@ -87,7 +89,12 @@ export const useCrmStore = defineStore('crm', () => {
return data
}
async function loadBrowseProducts(query?: { categoryId?: string; season?: string }) {
async function loadBrowseProducts(query?: {
categoryId?: string
season?: string
catalogId?: string
companyId?: string
}) {
const list = await fetchBrowseProducts(query)
browseProducts.value = list.map(mapProduct)
return browseProducts.value
@@ -101,6 +108,7 @@ export const useCrmStore = defineStore('crm', () => {
companyId?: string
catalogId?: string
catalogCode?: string
catalogName?: string
color?: string
minMeterage?: number
orderMultiplier?: number