fix(admin-panel): fix blog bugs and add ingredients editor, draft autosave, and category seeding
Deploy Canina / deploy (push) Successful in 2m20s
E2E Playwright Tests / Run Full E2E & Security Suites (push) Failing after 6s

This commit is contained in:
parsa committed 2026-09-24 03:06:17 +03:30
1 parent ebc61d5be2
commit 913e6acd3d
11 files changed
+375 -20

No files matched your search

+32 -2
View File
@@ -445,7 +445,7 @@ export class AdminService {
skip,
take: limit,
orderBy: { [sortField]: sortDirection },
include: { category: true, symptoms: true },
include: { category: true, symptoms: true, ingredientList: true },
}),
this.prisma.product.count({ where }),
]);
@@ -516,6 +516,7 @@ export class AdminService {
scientificTagline: data.scientificTagline || '',
description: data.description || '',
shortDescription: data.shortDescription || '',
ingredients: data.ingredients || null,
categoryId: data.categoryId || '',
categorySlug: data.categorySlug || 'general',
buyPrice: data.buyPrice !== undefined ? data.buyPrice : 0,
@@ -587,6 +588,18 @@ export class AdminService {
});
}
if (data.ingredientList && Array.isArray(data.ingredientList)) {
const uniqueIngs = Array.from(new Set(data.ingredientList.map((i: string) => i.trim()).filter(Boolean)));
if (uniqueIngs.length > 0) {
await this.prisma.productIngredient.createMany({
data: uniqueIngs.map((ingredient: string) => ({
productId: product.id,
ingredient,
})),
});
}
}
await this.revalidationService.revalidateProduct(
product.slug,
product.artNo,
@@ -658,6 +671,7 @@ export class AdminService {
scientificTagline: data.scientificTagline,
description: data.description,
shortDescription: data.shortDescription,
ingredients: data.ingredients !== undefined ? data.ingredients : undefined,
categoryId: data.categoryId,
categorySlug: data.categorySlug,
buyPrice: data.buyPrice !== undefined ? data.buyPrice : undefined,
@@ -742,11 +756,27 @@ export class AdminService {
}
}
if (data.ingredientList !== undefined && Array.isArray(data.ingredientList)) {
await this.prisma.productIngredient.deleteMany({ where: { productId: id } });
if (data.ingredientList.length > 0) {
const uniqueIngs = Array.from(new Set(data.ingredientList.map((i: string) => i.trim()).filter(Boolean)));
await this.prisma.productIngredient.createMany({
data: uniqueIngs.map((ingredient: string) => ({
productId: id,
ingredient,
})),
});
}
}
await this.revalidationService.revalidateProduct(
product.slug,
product.artNo,
);
return product;
return this.prisma.product.findUnique({
where: { id },
include: { category: true, symptoms: true, ingredientList: true },
});
}
async deleteProduct(id: string) {