Skip to content

Commit

Permalink
address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
olivermrbl committed Jan 16, 2024
1 parent 011aa91 commit 2f51e82
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ describe("Cart Module Service", () => {
expect(updatedItem.title).toBe("test2")
})

it.only("should update line items in carts succesfully with multi-selector approach", async () => {
it("should update line items in carts succesfully with multi-selector approach", async () => {
const [createdCart] = await service.create([
{
currency_code: "eur",
Expand Down
5 changes: 3 additions & 2 deletions packages/cart/src/models/line-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type OptionalLineItemProps =
| "is_tax_inclusive"
| "compare_at_unit_price"
| "requires_shipping"
| "cart"
| DAL.EntityDateColumns

@Entity({ tableName: "cart_line_item" })
Expand All @@ -32,14 +33,14 @@ export default class LineItem {
id: string

@Property({ columnType: "text" })
cart_id!: string
cart_id: string

@ManyToOne(() => Cart, {
onDelete: "cascade",
index: "IDX_line_item_cart_id",
nullable: true,
})
cart?: Cart
cart?: Cart | null

@Property({ columnType: "text" })
title: string
Expand Down
6 changes: 2 additions & 4 deletions packages/cart/src/services/cart-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,11 +345,10 @@ export default class CartModuleService implements ICartModuleService {
| string
| CartTypes.UpdateLineItemWithSelectorDTO[]
| Partial<CartTypes.CartLineItemDTO>,
// @MedusaContext()
dataOrSharedContext?:
dataOrSharedContext:
| CartTypes.UpdateLineItemDTO
| Partial<CartTypes.UpdateLineItemDTO>
| Context,
| Context = {},
@MedusaContext()
sharedContext: Context = {}
): Promise<CartTypes.CartLineItemDTO[] | CartTypes.CartLineItemDTO> {
Expand Down Expand Up @@ -410,7 +409,6 @@ export default class CartModuleService implements ICartModuleService {
updates: CartTypes.UpdateLineItemWithSelectorDTO[],
@MedusaContext() sharedContext: Context = {}
): Promise<LineItem[]> {
console.log("Context in method: ", sharedContext)
let toUpdate: UpdateLineItemDTO[] = []
for (const { selector, data } of updates) {
const items = await this.listLineItems({ ...selector }, {}, sharedContext)
Expand Down
4 changes: 3 additions & 1 deletion packages/cart/src/types/line-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ export interface CreateLineItemDTO extends PartialUpsertLineItemDTO {
cart_id: string
}

export interface UpdateLineItemDTO extends PartialUpsertLineItemDTO {
export interface UpdateLineItemDTO
extends PartialUpsertLineItemDTO,
Partial<CreateLineItemDTO> {
id: string
}
2 changes: 1 addition & 1 deletion packages/types/src/cart/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ export interface CartLineItemDTO {
*
* @expandable
*/
cart?: CartDTO
cart: CartDTO
/**
* The ID of the associated cart.
*/
Expand Down

0 comments on commit 2f51e82

Please sign in to comment.