From 6c5c22945506f032e47a693cea464b0171b22b0f Mon Sep 17 00:00:00 2001 From: nflnkr <105123049+nflnkr@users.noreply.github.com> Date: Sat, 25 Feb 2023 15:28:50 +0300 Subject: [PATCH] fix types --- src/model/cart.ts | 19 +------------------ src/model/tariff.ts | 24 ++++++++++++++++++++---- src/stores/mocks/exampleCartValues.ts | 3 ++- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/model/cart.ts b/src/model/cart.ts index eb67ccf..2b65311 100644 --- a/src/model/cart.ts +++ b/src/model/cart.ts @@ -49,23 +49,6 @@ export interface Discount { // New types from snippet export namespace Cart { - - export type PrivilegeType = - | "unlim" - | "gencount" - | "activequiz" - | "abcount" - | "extended"; - - export interface Privilege { - serviceKey: Tariffs.ServiceType; - name: PrivilegeType; - privilegeId: string; - description: string; - type: "day" | "count"; - price: number; - } - interface DiscountBase { _id: string; name: string; @@ -193,7 +176,7 @@ export namespace Cart { endless: boolean; from: string; dueTo: string; - privileges: Privilege[]; + privileges: Tariffs.Privilege[]; } export interface CartItem { diff --git a/src/model/tariff.ts b/src/model/tariff.ts index 1f3574b..d151d58 100644 --- a/src/model/tariff.ts +++ b/src/model/tariff.ts @@ -38,11 +38,27 @@ export interface ArrayProps { tariffs?: Array; } + +export const SERVICE_LIST = ["templategen", "squiz", "dwarfener"] as const; + export namespace Tariffs { - export type ServiceType = - | "templategen" - | "squiz" - | "dwarfener"; + export type ServiceType = typeof SERVICE_LIST[number]; + + export type PrivilegeType = + | "unlim" + | "gencount" + | "activequiz" + | "abcount" + | "extended"; + + export interface Privilege { + serviceKey: Tariffs.ServiceType; + name: PrivilegeType; + privilegeId: string; + description: string; + type: "day" | "count"; + price: number; + } export interface Tariff { id: string; diff --git a/src/stores/mocks/exampleCartValues.ts b/src/stores/mocks/exampleCartValues.ts index 13df6eb..cd56a49 100644 --- a/src/stores/mocks/exampleCartValues.ts +++ b/src/stores/mocks/exampleCartValues.ts @@ -1,8 +1,9 @@ import { Cart } from "../../model/cart"; +import { Tariffs } from "../../model/tariff"; type ExampleCartValues = { - privileges: Cart.Privilege[]; + privileges: Tariffs.Privilege[]; discounts: Cart.AnyDiscount[]; testCases: any; };