feat: product design surveys, cart expiry/buy-later, and catalog polish

Add like/dislike surveys with majority alerts for manufacturing decisions, clearer accounting mapping copy, and related cart/catalog admin-app improvements.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
mahmood
2026-11-12 17:55:52 +03:30
co-authored by Cursor
parent 032fa800d9
commit 7dd74ff4f7
74 changed files with 6351 additions and 893 deletions
@@ -75,6 +75,13 @@ export class CatalogService {
}
/** One product for its own screen, instead of fetching the catalogue to find it. */
/** Counts one opening of a storefront product's detail screen. Unknown or hidden ids are ignored. */
async recordView(id: string) {
const exists = await this.prisma.product.count({ where: { id, isActive: true } });
if (!exists) return;
await this.prisma.productView.create({ data: { productId: id } });
}
async findProductById(id: string) {
const [product] = await this.buildProductList({ where: { ...this.storefrontWhere({}), id } });
if (!product) throw new NotFoundException('محصول یافت نشد');
@@ -90,7 +97,7 @@ export class CatalogService {
*/
async facets() {
const where = this.storefrontWhere({});
const [categories, brands, collections, gram] = await Promise.all([
const [categories, brands, collections, gram, tagged] = await Promise.all([
this.prisma.category.findMany({
where: { products: { some: where } },
select: { id: true, title: true },
@@ -111,12 +118,17 @@ export class CatalogService {
_min: { rashWeightGrams: true },
_max: { rashWeightGrams: true },
}),
this.prisma.product.findMany({
where: { ...where, NOT: { tags: { isEmpty: true } } },
select: { tags: true },
}),
]);
return {
categories,
brands,
collections,
tags: [...new Set(tagged.flatMap((p) => p.tags))].sort((a, b) => a.localeCompare(b, 'fa')),
// Strings, like every other weight this API returns (Decimal, not float).
gramRange: {
min: gram._min.rashWeightGrams?.toString() ?? '0',
@@ -155,6 +167,8 @@ export class CatalogService {
else if (brandIds.length > 1) where.brandId = { in: brandIds };
}
if (query.collectionId) where.collections = { some: { collectionId: query.collectionId } };
if (query.tag?.trim()) where.tags = { has: query.tag.trim() };
else if (query.tagged) where.NOT = { tags: { isEmpty: true } };
// A product is in range when at least ONE of its variants is, which is what
// the app's `limit_gram` filter meant (SearchView.vue:189-195).