Clear only the submitted company from multi-company carts and label all companies.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -198,12 +198,14 @@ export class CartsService {
|
||||
companyName: string;
|
||||
}>;
|
||||
}) {
|
||||
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,
|
||||
|
||||
@@ -254,7 +254,14 @@ export class OrdersService {
|
||||
const cart = await tx.cart.findFirst({ where: { userId } });
|
||||
if (cart) {
|
||||
await tx.cartItem.deleteMany({
|
||||
where: { cartId: cart.id, companyId: company.id },
|
||||
where: { cartId: cart.id, companyId: orderCompany.id },
|
||||
});
|
||||
const remaining = await tx.cartItem.findFirst({
|
||||
where: { cartId: cart.id },
|
||||
});
|
||||
await tx.cart.update({
|
||||
where: { id: cart.id },
|
||||
data: { companyId: remaining?.companyId ?? null },
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user