-
Notifications
You must be signed in to change notification settings - Fork 7
/
types.js
89 lines (81 loc) · 2.26 KB
/
types.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// @flow
import type { Offer as OfferType, Order, OrderItem, Product, Subscription, CatalogItem } from "@limio/types"
type Offer = CatalogItem<OfferType>
type CampaignInfo = {
name: string,
path: string,
attributes: { [string]: any }
}
type LandingInfo = {
inlineStyle: ?string,
customTranslations: { [string]: string },
favicon: ?string,
shop_title: ?string,
domain_url: ?string
}
type OfferGroup = {
id: string,
label: string
}
export type PageContext = {
endpoint?: string,
authProvider: ?string,
landing: LandingInfo,
campaign: CampaignInfo,
offers: Array<Offer>,§
groupValues: Array<OfferGroup>,
publicKey__limio: string,
tag__limio: string,
pageMasterLayout: string,
prevent_mixed_rates: boolean
}
type AddToBasket = (item: Offer, selectedProducts: ?(Product[]), quantity: ?number, redirectUrl: ?string) => void
type AddGiftToBasket = (offerItems: Offer[], giftCode: string, hasDeliver: boolean) => void
type RemoveFromBasket = (item: Offer) => void
type UpdateOrder = (order: Order) => void
type GoToCheckout = (basketId?: string) => Promise<void>
export type LimioContext = {
endpoint: ?string,
shop: {
location: {
pathname: string,
search: string
},
language: {
mode: string,
value: string
},
addToBasket: AddToBasket,
addGiftToBasket: AddGiftToBasket,
removeFromBasket: RemoveFromBasket,
updateOrder: UpdateOrder,
goToCheckout: GoToCheckout,
basketItems: OrderItem[],
basketOpen: boolean,
setBasketOpen: boolean => void,
formattedTotal: ?string,
campaign: CampaignInfo,
offers: Offer[],
tag: string,
customTranslations: { [string]: any },
updateCheckoutDisabled: boolean => {
type: "SET_CHECKOUT_DISABLED",
disabled: boolean
},
groupValues: Array<OfferGroup>
},
pageBuilder__limio?: boolean,
user: User,
key: {
limio: string
}
}
export type User = {
token: ?string,
loaded?: boolean,
attributes?: { [string]: any },
loginStatus?: "logged-out" | "logged-in",
subscriptions?: Subscription[],
refreshUser?: () => Promise<void>
}
s