This commit is contained in:
2025-11-15 11:35:46 +03:30
parent cfe4aeff7a
commit f0913840f2
4 changed files with 53 additions and 22 deletions
+6 -5
View File
@@ -29,17 +29,15 @@ export class FoodService {
noon: rest.noon ?? false,
dinner: rest.dinner ?? false,
// pickup/stock
isPickup: rest.isPickup ?? false,
stock: rest.stock ?? 0,
stockDefault: rest.stockDefault ?? 0,
isActive: rest.isActive ?? true,
inPlaceServe: rest.inPlaceServe ?? false,
pickupServe: rest.pickupServe ?? false,
rate: rest.rate ?? 0,
discount: rest.discount ?? 0,
// map single-title/content DTO to localized fields
titleFa: rest.title,
contentFa: rest.content,
title: rest.title,
content: rest.content,
// numeric/array fields
price: rest.price ?? 0,
points: rest.points ?? 0,
@@ -47,7 +45,10 @@ export class FoodService {
images: rest.images ?? undefined,
} as RequiredEntityData<Food>;
const food = this.foodRepository.create(data);
const food = this.foodRepository.create(data) as Food;
if (!food) {
throw new Error('Failed to create food entity');
}
// attach categories if provided
if (categoryIds && categoryIds.length) {