Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
olivermrbl committed Jan 16, 2024
1 parent 7410b59 commit 9ce8990
Showing 1 changed file with 7 additions and 18 deletions.
25 changes: 7 additions & 18 deletions packages/cart/src/services/cart-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,23 +272,19 @@ export default class CartModuleService implements ICartModuleService {
| string
| CartTypes.CreateLineItemForCartDTO[]
| CartTypes.CreateLineItemForCartDTO,
@MedusaContext()
dataOrSharedContext:
| CartTypes.CreateLineItemDTO[]
| CartTypes.CreateLineItemDTO
| Context = {},
data: CartTypes.CreateLineItemDTO[] | CartTypes.CreateLineItemDTO,
@MedusaContext() sharedContext: Context = {}
): Promise<CartTypes.CartLineItemDTO[] | CartTypes.CartLineItemDTO> {
let items: LineItem[] = []
if (isString(cartIdOrData)) {
items = await this.addLineItems_(
cartIdOrData,
dataOrSharedContext as CartTypes.CreateLineItemDTO[],
data as CartTypes.CreateLineItemDTO[],
sharedContext
)
} else {
const data = Array.isArray(cartIdOrData) ? cartIdOrData : [cartIdOrData]
items = await this.addLineItemsBulk_(data, dataOrSharedContext as Context)
items = await this.addLineItemsBulk_(data, sharedContext)
}

return await this.baseRepository_.serialize<CartTypes.CartLineItemDTO[]>(
Expand Down Expand Up @@ -346,18 +342,14 @@ export default class CartModuleService implements ICartModuleService {
| string
| CartTypes.UpdateLineItemWithSelectorDTO[]
| Partial<CartTypes.CartLineItemDTO>,
@MedusaContext()
dataOrSharedContext:
| CartTypes.UpdateLineItemDTO
| Partial<CartTypes.UpdateLineItemDTO>
| Context = {},
data?: CartTypes.UpdateLineItemDTO | Partial<CartTypes.UpdateLineItemDTO>,
@MedusaContext() sharedContext: Context = {}
): Promise<CartTypes.CartLineItemDTO[] | CartTypes.CartLineItemDTO> {
let items: LineItem[] = []
if (isString(lineItemIdOrDataOrSelector)) {
const item = await this.updateLineItem_(
lineItemIdOrDataOrSelector,
dataOrSharedContext as Partial<CartTypes.UpdateLineItemDTO>,
data as Partial<CartTypes.UpdateLineItemDTO>,
sharedContext
)

Expand All @@ -374,14 +366,11 @@ export default class CartModuleService implements ICartModuleService {
: [
{
selector: lineItemIdOrDataOrSelector,
data: dataOrSharedContext,
data: data,
} as CartTypes.UpdateLineItemWithSelectorDTO,
]

items = await this.updateLineItemsWithSelector_(
toUpdate,
dataOrSharedContext as Context
)
items = await this.updateLineItemsWithSelector_(toUpdate, sharedContext)

return await this.baseRepository_.serialize<CartTypes.CartLineItemDTO[]>(
items,
Expand Down

0 comments on commit 9ce8990

Please sign in to comment.