create cart types from snippet

This commit is contained in:
nflnkr 2023-02-22 18:07:53 +03:00
parent 44d6972ffa
commit 2d2b16981f

@ -34,3 +34,124 @@ export interface Discount {
toTime: number;
toCapacity: number;
}
// New types from snippet
export namespace Cart {
type ServiceType =
| "templategen"
| "squiz"
| "dwarfener";
type PrivilegeType =
| "unlim"
| "gencount"
| "activequiz"
| "abcount"
| "extended";
export interface Privilege {
serviceKey: ServiceType;
name: PrivilegeType;
privilegeId: string;
description: string;
type: "day" | "count";
price: number;
}
export type Discount = {
_id: string;
name: string;
description: string;
/**
* Этап применения скидки
*/
layer: number;
} & ({
conditionType: "purchasesAmount";
condition: {
purchasesAmount: number;
};
/**
* Множитель, на который умножается сумма при применении скидки
*/
factor: number;
} | {
conditionType: "cartPurchasesAmount";
condition: {
cartPurchasesAmount: number;
};
/**
* Множитель, на который умножается сумма при применении скидки
*/
factor: number;
} | {
conditionType: "privilege";
condition: {
privilege: {
id: string;
/**
* Скидка применяется, если значение больше или равно этому значению
*/
value: number;
};
};
target: {
products: Array<{
productId: string;
/**
* Множитель, на который умножается сумма при применении скидки
*/
factor: number;
}>;
};
} | {
conditionType: "service";
condition: {
service: {
id: ServiceType;
/**
* Скидка применяется, если значение больше или равно этому значению
*/
value: number;
};
};
target: {
service: ServiceType;
/**
* Множитель, на который умножается сумма при применении скидки
*/
factor: number;
};
} | {
conditionType: "userType";
condition: {
userType: string;
};
target: {
IsAllProducts: boolean;
/**
* Множитель, на который умножается сумма при применении скидки
*/
factor: number;
};
overwhelm: boolean;
} | {
conditionType: "user";
condition: {
coupon: string;
user: string;
};
target: {
products: Array<{
productId: string;
/**
* Множитель, на который умножается сумма при применении скидки
*/
factor: number;
}>;
};
overwhelm: boolean;
});
export type DiscountConditionType = Discount["conditionType"];
}