remove package functionality

This commit is contained in:
nflnkr 2023-02-25 16:59:16 +03:00
parent 40a61e888e
commit 80c03bdcd9
3 changed files with 3 additions and 40 deletions

@ -180,7 +180,7 @@ export namespace Cart {
} }
export interface CartItem { export interface CartItem {
item: Tariffs.Tariff | Tariffs.Package; item: Tariffs.Tariff;
/** /**
* Посчитанная цена пункта корзины * Посчитанная цена пункта корзины
*/ */
@ -196,12 +196,12 @@ export namespace Cart {
*/ */
envolvedDiscounts: string[]; envolvedDiscounts: string[];
totalPrice: number; totalPrice: number;
item: Tariffs.Tariff | Tariffs.Package; item: Tariffs.Tariff;
} }
export interface CartTotal { export interface CartTotal {
items: CartItemTotal[]; items: CartItemTotal[];
totalPrice: number; totalPrice: number;
priceByService: { [Key in Tariffs.ServiceType]: number;} priceByService: { [Key in Tariffs.ServiceType]: number; };
} }
} }

@ -77,11 +77,4 @@ export namespace Tariffs {
*/ */
customPrice?: number; customPrice?: number;
} }
export interface Package {
id: string;
name: string;
services: ServiceType[];
tariffs: Tariff[];
}
} }

@ -61,12 +61,6 @@ export function calcCartData(
totalPrice: cartItem.price, totalPrice: cartItem.price,
}; };
if (isPackage(cartItem.item)) {
// TODO implement for package
throw new Error("unimplemented");
}
const tariff = cartItem.item; const tariff = cartItem.item;
const maxPrivilegeDiscount = findMaxApplicablePrivilegeDiscount(discounts, tariff); const maxPrivilegeDiscount = findMaxApplicablePrivilegeDiscount(discounts, tariff);
@ -177,12 +171,6 @@ function calcCartItemWithPromocode(
totalPrice: 0, totalPrice: 0,
}; };
if (isPackage(cartItem.item)) {
// TODO implement for package
throw new Error("unimplemented");
}
const tariff = cartItem.item; const tariff = cartItem.item;
discount.target.products.forEach(product => { discount.target.products.forEach(product => {
@ -195,22 +183,4 @@ function calcCartItemWithPromocode(
priceByService[tariff.privilege.serviceKey] = cartItemTotal.totalPrice; priceByService[tariff.privilege.serviceKey] = cartItemTotal.totalPrice;
return cartItemTotal; return cartItemTotal;
}
export function packTariffs(tariffs: Tariffs.Tariff[], id: string, name: string): Tariffs.Package {
const services: Tariffs.ServiceType[] = [];
tariffs.forEach(tariff => {
if (!services.includes(tariff.privilege.serviceKey)) services.push(tariff.privilege.serviceKey);
});
return {
id,
name,
services,
tariffs,
};
}
export function isPackage(item: Tariffs.Tariff | Tariffs.Package): item is Tariffs.Package {
return "tariffs" in item;
} }