Skip to content

Commit

Permalink
update cart return info (#76)
Browse files Browse the repository at this point in the history
Co-authored-by: NHT <[email protected]>
  • Loading branch information
nfesta2023 and hoangtuan910 authored Mar 14, 2024
1 parent e3011b1 commit 54f18dc
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 194 deletions.
2 changes: 2 additions & 0 deletions src/feature/cart/cart.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@ export class CartService {
item_img: additionalInfoForSku.sku_img,
customer_id: item.customer_id,
sku_id: item.sku_id,
menu_item_id: additionalInfoForSku.menu_item_id,
quantity_available: additionalInfoForSku.quantity_available,
price: additionalInfoForSku.sku_price,
price_after_discount: additionalInfoForSku.sku_price_after_discount,
unit: additionalInfoForSku.sku_unit,
Expand Down
41 changes: 2 additions & 39 deletions src/feature/cart/dto/add-to-cart-response.dto.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,3 @@
import { GeneralResponse } from 'src/dto/general-response.dto';
import { TextByLang } from 'src/type';
import { GetCartDetailResponse } from './get-cart-detail-response.dto';

export class AddToCartResponse extends GeneralResponse {
data: AddToCartResponseData;
}

interface AddToCartResponseData {
customer_id: number;
restaurant_id: number;
restaurant_name: TextByLang[];
restaurant_logo_img: string;
cart_info: FullCartItem[];
}

interface FullCartItem {
item_id: number;
item_name: TextByLang[];
item_img: string;
customer_id: number;
sku_id: number;
price: number;
price_after_discount: number;
unit: string;
qty_ordered: number;
advanced_taste_customization: string;
basic_taste_customization: string;
portion_customization: string;
advanced_taste_customization_obj: string;
basic_taste_customization_obj: string;
notes: string;
restaurant_id: number;
packaging_info: CartPackagingInfo;
}

interface CartPackagingInfo {
packaging_id: number;
name: TextByLang[];
price: number;
}
export class AddToCartResponse extends GetCartDetailResponse {}
40 changes: 2 additions & 38 deletions src/feature/cart/dto/delete-cart-item-response.dto.ts
Original file line number Diff line number Diff line change
@@ -1,39 +1,3 @@
import { GeneralResponse } from 'src/dto/general-response.dto';
import { TextByLang } from 'src/type';
import { GetCartDetailResponse } from './get-cart-detail-response.dto';

export class DeleteCartItemResponse extends GeneralResponse {
data: Data;
}
interface Data {
customer_id: number;
restaurant_id: number;
restaurant_name: TextByLang[];
restaurant_logo_img: string;
cart_info: FullCartItem[];
}

interface FullCartItem {
item_id: number;
item_name: TextByLang[];
item_img: string;
customer_id: number;
sku_id: number;
price: number;
price_after_discount: number;
unit: string;
qty_ordered: number;
advanced_taste_customization: string;
basic_taste_customization: string;
portion_customization: string;
advanced_taste_customization_obj: string;
basic_taste_customization_obj: string;
notes: string;
restaurant_id: number;
packaging_info: CartPackagingInfo;
}

interface CartPackagingInfo {
packaging_id: number;
name: TextByLang[];
price: number;
}
export class DeleteCartItemResponse extends GetCartDetailResponse {}
2 changes: 2 additions & 0 deletions src/feature/cart/dto/get-cart-detail-response.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ interface FullCartItem {
item_img: string;
customer_id: number;
sku_id: number;
menu_item_id: number;
quantity_available: number;
price: number;
price_after_discount: number;
unit: string;
Expand Down
41 changes: 2 additions & 39 deletions src/feature/cart/dto/quick-add-to-cart-response.dto.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,3 @@
import { GeneralResponse } from 'src/dto/general-response.dto';
import { TextByLang } from 'src/type';
import { GetCartDetailResponse } from './get-cart-detail-response.dto';

export class QuickAddToCartResponse extends GeneralResponse {
data: QuickAddToCartResponseData;
}

interface QuickAddToCartResponseData {
customer_id: number;
restaurant_id: number;
restaurant_name: TextByLang[];
restaurant_logo_img: string;
cart_info: FullCartItem[];
}

interface FullCartItem {
item_id: number;
item_name: TextByLang[];
item_img: string;
customer_id: number;
sku_id: number;
price: number;
price_after_discount: number;
unit: string;
qty_ordered: number;
advanced_taste_customization: string;
basic_taste_customization: string;
portion_customization: string;
advanced_taste_customization_obj: string;
basic_taste_customization_obj: string;
notes: string;
restaurant_id: number;
packaging_info: CartPackagingInfo;
}

interface CartPackagingInfo {
packaging_id: number;
name: TextByLang[];
price: number;
}
export class QuickAddToCartResponse extends GetCartDetailResponse {}
41 changes: 2 additions & 39 deletions src/feature/cart/dto/update-cart-advanced-response.dto.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,3 @@
import { GeneralResponse } from 'src/dto/general-response.dto';
import { TextByLang } from 'src/type';
import { GetCartDetailResponse } from './get-cart-detail-response.dto';

export class UpdateCartAdvancedResponse extends GeneralResponse {
data: CartDetail;
}

interface CartDetail {
customer_id: number;
restaurant_id: number;
restaurant_name: TextByLang[];
restaurant_logo_img: string;
cart_info: FullCartItem[];
}

interface FullCartItem {
item_id: number;
item_name: TextByLang[];
item_img: string;
customer_id: number;
sku_id: number;
price: number;
price_after_discount: number;
unit: string;
qty_ordered: number;
advanced_taste_customization: string;
basic_taste_customization: string;
portion_customization: string;
advanced_taste_customization_obj: string;
basic_taste_customization_obj: string;
notes: string;
restaurant_id: number;
packaging_info: CartPackagingInfo;
}

interface CartPackagingInfo {
packaging_id: number;
name: TextByLang[];
price: number;
}
export class UpdateCartAdvancedResponse extends GetCartDetailResponse {}
41 changes: 2 additions & 39 deletions src/feature/cart/dto/update-cart-basic-response.dto.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,3 @@
import { GeneralResponse } from 'src/dto/general-response.dto';
import { TextByLang } from 'src/type';
import { GetCartDetailResponse } from './get-cart-detail-response.dto';

export class UpdateCartBasicResponse extends GeneralResponse {
data: CartDetail;
}

interface CartDetail {
customer_id: number;
restaurant_id: number;
restaurant_name: TextByLang[];
restaurant_logo_img: string;
cart_info: FullCartItem[];
}

interface FullCartItem {
item_id: number;
item_name: TextByLang[];
item_img: string;
customer_id: number;
sku_id: number;
price: number;
price_after_discount: number;
unit: string;
qty_ordered: number;
advanced_taste_customization: string;
basic_taste_customization: string;
portion_customization: string;
advanced_taste_customization_obj: string;
basic_taste_customization_obj: string;
notes: string;
restaurant_id: number;
packaging_info: CartPackagingInfo;
}

interface CartPackagingInfo {
packaging_id: number;
name: TextByLang[];
price: number;
}
export class UpdateCartBasicResponse extends GetCartDetailResponse {}
2 changes: 2 additions & 0 deletions src/feature/common/common.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,8 @@ export class CommonService {
sku_price: item.price,
sku_price_after_discount: await this.getAvailableDiscountPrice(item),
sku_unit: priceUnit?.price_unit || null,
menu_item_id: item.menu_item_id,
quantity_available: item.menu_item.quantity_available,
};
data.push(additionalInfoForSKU);
}
Expand Down
4 changes: 4 additions & 0 deletions src/type/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ export interface FullCartItem {
item_img: string;
customer_id: number;
sku_id: number;
menu_item_id: number;
quantity_available: number;
price: number;
price_after_discount: number;
unit: string;
Expand Down Expand Up @@ -175,6 +177,8 @@ export interface AdditionalInfoForSKU {
sku_price: number;
sku_price_after_discount: number;
sku_unit: string;
menu_item_id: number;
quantity_available: number;
}
export interface PriceUnitByMenuItem {
menu_item_id: number;
Expand Down

0 comments on commit 54f18dc

Please sign in to comment.