120 lines
3.2 KiB
TypeScript
120 lines
3.2 KiB
TypeScript
import {
|
|
IGraphQLCart,
|
|
IGraphQLCountry,
|
|
IGraphQLCoupon,
|
|
IGraphQLCurrency,
|
|
IGraphQLGtmActions,
|
|
IGraphQLGtmData,
|
|
IGraphQLJsShopContext,
|
|
IGraphQLLanguage,
|
|
IGraphQLPrice,
|
|
IGraphQLProduct,
|
|
IGraphQLProductFavorite,
|
|
IGraphQLProductPublic,
|
|
IGraphQLPublicPhoto,
|
|
IGraphQLRedirectLocation,
|
|
IGraphQLSeller,
|
|
IGraphQLShippingInfo,
|
|
IGraphQLStore,
|
|
IGraphQLTotalPrice,
|
|
IGraphQLUser,
|
|
} from '@assets/interfaces/gqlApi/graphql';
|
|
import { IJsShopConfig } from '@assets/js-shop/Interfaces';
|
|
|
|
export type WithOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
export type OptionalExcept<T, K extends keyof T> = Pick<T, K> & Partial<Omit<T, K>>;
|
|
|
|
export interface IData {
|
|
cart: ICart;
|
|
productFavorites: IProductFavorites[];
|
|
me?: IUser;
|
|
contexts: IShopContexts;
|
|
gtmData: IGtmData;
|
|
alsoBought?: string;
|
|
redirectLocation?: Partial<IGraphQLRedirectLocation>;
|
|
seller?: ISeller;
|
|
}
|
|
|
|
export interface ICart {
|
|
url: string;
|
|
items: ICartItem[];
|
|
totalPrice: ITotalPrice;
|
|
savings: ITotalPrice;
|
|
charges: ITotalPrice;
|
|
freeDeliveryFrom?: number;
|
|
shippingInfo?: IShippingInfo;
|
|
activeCoupons: ICoupon[];
|
|
bonusPoints: number;
|
|
lastUpdated?: string;
|
|
availability: number;
|
|
}
|
|
|
|
export interface ICartItem {
|
|
id: number;
|
|
productId: number;
|
|
variationId?: number;
|
|
name: string;
|
|
pieces: number;
|
|
step: number;
|
|
price: IPrice;
|
|
discount: number;
|
|
priceOriginal: IPrice;
|
|
product: IProduct;
|
|
note?: string | object;
|
|
printNote: string;
|
|
gtmActions: IGraphQLGtmActions;
|
|
}
|
|
|
|
export interface IShopContexts {
|
|
currency: ICurrency;
|
|
language: ILanguage;
|
|
country?: Partial<IGraphQLCountry>;
|
|
jsShop: Partial<IJsShopConfig>;
|
|
}
|
|
|
|
export interface IProductFavorites extends Pick<IGraphQLProductFavorite, 'productId'> {}
|
|
|
|
export interface IShippingInfo
|
|
extends Pick<
|
|
IGraphQLShippingInfo,
|
|
'minDeliveryDate' | 'minDeliveryDateInPerson' | 'minDeliveryDateDelivery' | 'isFreeShipping'
|
|
> {}
|
|
|
|
export interface ICoupon extends OptionalExcept<IGraphQLCoupon, 'code'> {}
|
|
|
|
export interface ITotalPrice extends Pick<IGraphQLTotalPrice, 'withVat' | 'withoutVat'> {
|
|
currency: ICurrency;
|
|
}
|
|
|
|
export interface IPrice extends Pick<IGraphQLPrice, 'withVat' | 'withoutVat' | 'vatValue' | 'vat'> {
|
|
currency: ICurrency;
|
|
}
|
|
|
|
export interface IProduct
|
|
extends Pick<
|
|
IGraphQLProduct,
|
|
'id' | 'url' | 'inStore' | 'inStoreSuppliers' | 'title' | 'variationTitle' | 'deliveryTime'
|
|
> {
|
|
photo?: IPhoto;
|
|
}
|
|
|
|
export interface IPhoto extends IGraphQLPublicPhoto {}
|
|
|
|
export interface ICurrency
|
|
extends OptionalExcept<IGraphQLCurrency, 'code' | 'name' | 'symbol' | 'rate'> {}
|
|
|
|
export interface ILanguage extends OptionalExcept<IGraphQLLanguage, 'code'> {}
|
|
|
|
export interface IUser
|
|
extends OptionalExcept<IGraphQLUser, 'id' | 'email' | 'name' | 'surname' | 'isB2B' | 'userIconLabel'> {}
|
|
|
|
export interface IInStoreSeller
|
|
extends Pick<IGraphQLProductPublic, 'inStoreSeller' | 'inStoreSellerOther'> {}
|
|
|
|
export interface IGtmData extends Pick<IGraphQLGtmData, 'user' | 'dataPrinterData'> {
|
|
}
|
|
|
|
export interface ISeller extends Pick<IGraphQLSeller, 'id' | 'city' | 'name'> {
|
|
store?: Pick<IGraphQLStore, 'id'>;
|
|
}
|