Skip to content

Commit

Permalink
feat: add meta fields to cart items
Browse files Browse the repository at this point in the history
  • Loading branch information
Huy-DNA committed Dec 29, 2023
1 parent 580653c commit 4abd916
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/dtos/out/getCart.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ export const GetCartResultDto = Type.Object({
name: Type.String(),
price: Type.Number(),
discount: Type.Optional(Type.Number()),
image: Type.Optional(Type.String())
image: Type.Optional(Type.String()),
isDiscontinued: Type.Boolean(),
isUserUploaded: Type.Boolean()
})
)
});
Expand Down
7 changes: 5 additions & 2 deletions src/handlers/cart.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ const get: Handler<GetCartResultDto> = async (req, res) => {
price: true,
DefaultModel: {
select: {
imageUrl: true
imageUrl: true,
isDiscontinued: true
}
},
ModelPromotion: {
Expand All @@ -42,7 +43,9 @@ const get: Handler<GetCartResultDto> = async (req, res) => {
id: item.model.id,
name: item.model.name,
price: item.model.price,
quantity: item.quantity
quantity: item.quantity,
isDiscontinued: item.model.DefaultModel?.isDiscontinued || false,
isUserUploaded: item.model.DefaultModel !== undefined
}))
};
} catch (e) {
Expand Down

0 comments on commit 4abd916

Please sign in to comment.