Ship deploy build for multi-company order items.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Vendored
+12
-3
@@ -105,9 +105,16 @@ let CartsService = class CartsService {
|
||||
if (!item)
|
||||
throw new common_1.NotFoundException('آیتم سبد یافت نشد');
|
||||
await this.prisma.cartItem.delete({ where: { id: itemId } });
|
||||
const remaining = await this.prisma.cartItem.findMany({
|
||||
where: { cartId: cart.id },
|
||||
take: 1,
|
||||
});
|
||||
await this.prisma.cart.update({
|
||||
where: { id: cart.id },
|
||||
data: { updatedAt: new Date() },
|
||||
data: {
|
||||
companyId: remaining[0]?.companyId ?? null,
|
||||
updatedAt: new Date(),
|
||||
},
|
||||
});
|
||||
return this.getCart(userId);
|
||||
}
|
||||
@@ -151,12 +158,14 @@ let CartsService = class CartsService {
|
||||
return cart;
|
||||
}
|
||||
mapCart(cart) {
|
||||
const companyName = cart.items[0]?.companyName;
|
||||
const companyNames = [
|
||||
...new Set(cart.items.map((item) => item.companyName).filter(Boolean)),
|
||||
];
|
||||
return {
|
||||
id: cart.id,
|
||||
userId: cart.userId,
|
||||
companyId: cart.companyId ?? cart.items[0]?.companyId,
|
||||
companyName: companyName ?? '',
|
||||
companyName: companyNames.join('، '),
|
||||
notes: cart.notes ?? undefined,
|
||||
items: cart.items.map((item) => ({
|
||||
id: item.id,
|
||||
|
||||
Reference in New Issue
Block a user