@ikas/storefront 4.0.0-alpha.39 → 4.0.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +13 -13
- package/src/analytics/analytics.ts +1 -2
- package/src/analytics/googleUniversal.ts +2 -12
- package/src/analytics/head/index.tsx +2 -1
- package/src/analytics/ikas.ts +6 -24
- package/src/components/checkout/components/address-form/index.tsx +1 -1
- package/src/components/checkout/components/cart-summary/cart-item/index.tsx +9 -11
- package/src/components/checkout/components/cart-summary/cart-item/style.module.scss +10 -7
- package/src/components/checkout/components/cart-summary/index.tsx +17 -41
- package/src/components/checkout/components/customer-addresses/index.tsx +2 -6
- package/src/components/checkout/components/form-item/index.tsx +11 -9
- package/src/components/checkout/components/master-pass/credit-card-form/index.tsx +0 -2
- package/src/components/checkout/components/offer-product/index.tsx +19 -16
- package/src/components/checkout/components/offer-product/style.module.scss +3 -1
- package/src/components/checkout/components/phone-number-input/get-countries.ts +5 -37
- package/src/components/checkout/components/phone-number-input/index.tsx +10 -15
- package/src/components/checkout/components/phone-number-input/locale/en.ts +257 -0
- package/src/components/checkout/index.tsx +12 -14
- package/src/components/checkout/model.ts +61 -95
- package/src/components/checkout/modelMasterPass.ts +2 -2
- package/src/components/checkout/steps/step-payment/index.tsx +1 -6
- package/src/components/checkout/steps/step-payment/payment-gateways/index.tsx +3 -12
- package/src/components/checkout/steps/step-payment/payment-gateways/installments/index.tsx +3 -5
- package/src/components/checkout/steps/step-payment/style.module.scss +0 -5
- package/src/components/checkout/steps/step-shipping/index.tsx +4 -9
- package/src/components/checkout/steps/step-success/index.tsx +3 -4
- package/src/components/page/head.tsx +0 -12
- package/src/components/page/index.tsx +9 -10
- package/src/components/page-editor/ThemeComponentEditor.tsx +8 -15
- package/src/components/page-editor/model.ts +107 -44
- package/src/models/data/cart/campaign-offer/index.ts +2 -13
- package/src/models/data/cart/index.ts +1 -1
- package/src/models/data/category/path-item/index.ts +0 -4
- package/src/models/data/checkout/index.ts +3 -11
- package/src/models/data/checkout-settings/price/index.ts +0 -2
- package/src/models/data/merchant-settings/index.ts +0 -9
- package/src/models/data/order/index.ts +32 -51
- package/src/models/data/order/line-item/index.ts +13 -34
- package/src/models/data/order/line-item/variant/value/index.ts +1 -1
- package/src/models/data/order/transaction/index.ts +5 -2
- package/src/models/data/product/filter/index.ts +13 -4
- package/src/models/data/product/index.ts +3 -21
- package/src/models/data/product/option-set/index.ts +0 -4
- package/src/models/data/product/option-set/option/index.ts +10 -33
- package/src/models/data/product/variant/index.ts +1 -23
- package/src/models/data/product/variant/price/index.ts +9 -23
- package/src/models/data/product/variant-type/index.ts +0 -2
- package/src/models/data/raffle/index.ts +7 -9
- package/src/models/data/state/index.ts +2 -6
- package/src/models/data/storefront/index.ts +0 -2
- package/src/models/ui/product-list/index.ts +17 -26
- package/src/models/ui/raffle-list/index.ts +1 -1
- package/src/models/ui/validator/form/raffle-form.ts +3 -16
- package/src/models/ui/validator/rules/index.ts +13 -14
- package/src/page-data-init/index.ts +404 -159
- package/src/pages/checkout.tsx +1 -2
- package/src/pages/editor.tsx +2 -5
- package/src/store/cart/index.ts +2 -2
- package/src/store/customer/index.ts +17 -7
- package/src/store/raffle/index.ts +10 -7
- package/src/utils/constants.ts +1 -1
- package/src/utils/currency.ts +183 -9
package/src/pages/checkout.tsx
CHANGED
|
@@ -9,7 +9,7 @@ import IkasCheckoutPage, {
|
|
|
9
9
|
import { useRouter } from "next/router.js";
|
|
10
10
|
import { FullscreenLoading } from "../components/checkout/components/fullscreen-loading";
|
|
11
11
|
import { CheckoutStep } from "../components/checkout/model";
|
|
12
|
-
import { getCartById
|
|
12
|
+
import { getCartById } from "@ikas/storefront-api";
|
|
13
13
|
import { IkasStorefrontConfig } from "@ikas/storefront-config";
|
|
14
14
|
import { IkasBaseStore } from "..";
|
|
15
15
|
import { IkasCheckout, IkasCheckoutSettings } from "../models/data";
|
|
@@ -35,7 +35,6 @@ const CheckoutPage: React.FC<Props> = ({
|
|
|
35
35
|
const [checkout, setCheckout] = React.useState<IkasCheckout | undefined>();
|
|
36
36
|
|
|
37
37
|
IkasStorefrontConfig.init(configJson);
|
|
38
|
-
setAPIClientConfig();
|
|
39
38
|
|
|
40
39
|
React.useEffect(() => {
|
|
41
40
|
setCustomizationProps(customizationProps);
|
package/src/pages/editor.tsx
CHANGED
|
@@ -8,7 +8,7 @@ const IkasPageEditor = dynamic(
|
|
|
8
8
|
);
|
|
9
9
|
|
|
10
10
|
type Props = {
|
|
11
|
-
configJson
|
|
11
|
+
configJson: Record<string, any>;
|
|
12
12
|
components?: Record<string, any>;
|
|
13
13
|
};
|
|
14
14
|
|
|
@@ -19,12 +19,9 @@ export default class Page extends React.Component<Props> {
|
|
|
19
19
|
if (configJson) {
|
|
20
20
|
IkasStorefrontConfig.init({
|
|
21
21
|
...configJson,
|
|
22
|
+
currentPageComponents: components || {},
|
|
22
23
|
});
|
|
23
24
|
}
|
|
24
|
-
|
|
25
|
-
IkasStorefrontConfig.init({
|
|
26
|
-
currentPageComponents: components || {},
|
|
27
|
-
});
|
|
28
25
|
}
|
|
29
26
|
|
|
30
27
|
render() {
|
package/src/store/cart/index.ts
CHANGED
|
@@ -100,7 +100,7 @@ export class IkasCartStore {
|
|
|
100
100
|
|
|
101
101
|
product.productOptionSet?.initOptionValues();
|
|
102
102
|
|
|
103
|
-
return
|
|
103
|
+
return true;
|
|
104
104
|
} catch (err) {
|
|
105
105
|
console.log(err);
|
|
106
106
|
return false;
|
|
@@ -145,7 +145,7 @@ export class IkasCartStore {
|
|
|
145
145
|
Analytics.addToCart(item, quantity - oldQuantity, eventId, this.cart);
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
|
-
return
|
|
148
|
+
return true;
|
|
149
149
|
} catch (err) {
|
|
150
150
|
console.log(err);
|
|
151
151
|
return false;
|
|
@@ -24,7 +24,6 @@ import { IkasStorefrontConfig } from "@ikas/storefront-config";
|
|
|
24
24
|
import { SaveMyCustomerInput } from "@ikas/storefront-api";
|
|
25
25
|
import { populateRaffleProducts } from "@ikas/storefront-providers";
|
|
26
26
|
import { IkasBaseStore } from "../base";
|
|
27
|
-
import { IkasRaffle } from "@ikas/storefront-models";
|
|
28
27
|
|
|
29
28
|
const isServer = typeof localStorage === "undefined";
|
|
30
29
|
const LS_TOKEN_KEY = "customerToken";
|
|
@@ -294,7 +293,7 @@ export class IkasCustomerStore {
|
|
|
294
293
|
const favoriteProductsResponse =
|
|
295
294
|
await CustomerStoreAPI.listFavoriteProducts();
|
|
296
295
|
if (
|
|
297
|
-
|
|
296
|
+
favoriteProductsResponse.isSuccess ||
|
|
298
297
|
!favoriteProductsResponse.data?.length
|
|
299
298
|
)
|
|
300
299
|
return [];
|
|
@@ -404,11 +403,22 @@ export class IkasCustomerStore {
|
|
|
404
403
|
};
|
|
405
404
|
|
|
406
405
|
getRaffles = async () => {
|
|
407
|
-
const rafflesResponse = await RaffleStore.
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
406
|
+
const rafflesResponse = await RaffleStore.getRafflesByCustomerId({
|
|
407
|
+
winnerFilter: false,
|
|
408
|
+
});
|
|
409
|
+
const wonRafflesResponse = await RaffleStore.getRafflesByCustomerId({
|
|
410
|
+
winnerFilter: true,
|
|
411
|
+
});
|
|
412
|
+
|
|
413
|
+
const raffles = rafflesResponse.data;
|
|
414
|
+
const wonRaffles = wonRafflesResponse.data;
|
|
415
|
+
|
|
416
|
+
raffles?.forEach((raffle) => {
|
|
417
|
+
if (wonRaffles?.find((wonRaffle) => wonRaffle.id === raffle.id))
|
|
418
|
+
raffle.isCustomerWinner = true;
|
|
419
|
+
});
|
|
420
|
+
|
|
421
|
+
if (raffles) await populateRaffleProducts(raffles);
|
|
412
422
|
return raffles || [];
|
|
413
423
|
};
|
|
414
424
|
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { APIResponse } from "@ikas/fe-api-client";
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
getRafflesByCustomerId,
|
|
4
|
+
GetRafflesByCustomerIdQueryParams,
|
|
5
|
+
listRaffle,
|
|
5
6
|
listRaffleMetaData,
|
|
6
7
|
ListRaffleMetadataQueryParams,
|
|
7
|
-
|
|
8
|
+
ListRaffleQueryParams,
|
|
8
9
|
saveRaffleParticipant,
|
|
9
10
|
SaveRaffleParticipantQueryParams,
|
|
10
11
|
} from "@ikas/storefront-api";
|
|
@@ -15,8 +16,8 @@ import {
|
|
|
15
16
|
} from "../../models/data/raffle";
|
|
16
17
|
|
|
17
18
|
export default class RaffleStore {
|
|
18
|
-
static async
|
|
19
|
-
const response = await
|
|
19
|
+
static async listRaffle(params: ListRaffleQueryParams) {
|
|
20
|
+
const response = await listRaffle(params);
|
|
20
21
|
return new APIResponse({
|
|
21
22
|
...response.data,
|
|
22
23
|
data: response.data?.data?.map(
|
|
@@ -45,8 +46,10 @@ export default class RaffleStore {
|
|
|
45
46
|
);
|
|
46
47
|
}
|
|
47
48
|
|
|
48
|
-
static async
|
|
49
|
-
|
|
49
|
+
static async getRafflesByCustomerId(
|
|
50
|
+
params: GetRafflesByCustomerIdQueryParams
|
|
51
|
+
) {
|
|
52
|
+
const response = await getRafflesByCustomerId(params);
|
|
50
53
|
return new APIResponse(
|
|
51
54
|
response.data?.map((d) => new IkasRaffle(d as unknown as IkasRaffle)),
|
|
52
55
|
response.graphQLErrors
|
package/src/utils/constants.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const FREE_TEXT_CITY_COUNTRY_LIST = ["DE", "US"
|
|
1
|
+
export const FREE_TEXT_CITY_COUNTRY_LIST = ["DE", "US"];
|
|
2
2
|
export const DISTRICT_HIDDEN_COUNTRY_LIST = ["US"];
|
package/src/utils/currency.ts
CHANGED
|
@@ -13,19 +13,14 @@ const format = (p: number, n: number, x: number, s: string, c: string) => {
|
|
|
13
13
|
/**
|
|
14
14
|
*
|
|
15
15
|
* @param price Price to format
|
|
16
|
-
* @param currencyCode
|
|
17
|
-
* @param currencySymbol Symbol for the currency
|
|
16
|
+
* @param currencyCode Code for the currency, USD, EUR, TRY, etc..
|
|
18
17
|
*/
|
|
19
|
-
export const
|
|
20
|
-
price: number,
|
|
21
|
-
currencyCode: string,
|
|
22
|
-
currencySymbol: string | null
|
|
23
|
-
) => {
|
|
18
|
+
export const formatMoney = (price: number, currencyCode: string) => {
|
|
24
19
|
const formatSettings =
|
|
25
20
|
IkasStorefrontConfig.getMerchantSettings()?.currencyFormats?.find(
|
|
26
21
|
(s) => s.currencyCode === currencyCode
|
|
27
22
|
);
|
|
28
|
-
const symbol = formatSettings?.symbol ||
|
|
23
|
+
const symbol = formatSettings?.symbol || getCurrencySymbol(currencyCode);
|
|
29
24
|
const decimalSeparator = formatSettings?.decimalSeparator || ".";
|
|
30
25
|
const thousandSeparator = formatSettings?.thousandSeparator || ",";
|
|
31
26
|
const symbolPosition = formatSettings?.symbolPosition || "LEFT";
|
|
@@ -67,10 +62,189 @@ export const formatCurrency = (
|
|
|
67
62
|
IkasStorefrontConfig.getCurrentLocale(),
|
|
68
63
|
{
|
|
69
64
|
style: "currency",
|
|
70
|
-
currency:
|
|
65
|
+
currency: currencyCode || "TRY",
|
|
71
66
|
}
|
|
72
67
|
);
|
|
73
68
|
|
|
74
69
|
return formatter.format(price);
|
|
75
70
|
}
|
|
76
71
|
};
|
|
72
|
+
|
|
73
|
+
export function getCurrencySymbol(currencyCode: string) {
|
|
74
|
+
return CURRENCIES[currencyCode] || currencyCode;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const CURRENCIES: Record<string, string> = {
|
|
78
|
+
TRY: "₺",
|
|
79
|
+
USD: "$",
|
|
80
|
+
EUR: "€",
|
|
81
|
+
AZN: "₼",
|
|
82
|
+
AED: "د.إ.",
|
|
83
|
+
AFN: "؋",
|
|
84
|
+
ALL: "L",
|
|
85
|
+
AMD: "դր",
|
|
86
|
+
ANG: "ƒ",
|
|
87
|
+
AOA: "Kz",
|
|
88
|
+
ARS: "$",
|
|
89
|
+
AUD: "$",
|
|
90
|
+
AWG: "ƒ",
|
|
91
|
+
BAM: "КМ",
|
|
92
|
+
BBD: "$",
|
|
93
|
+
BDT: "৳",
|
|
94
|
+
BGN: "лв.",
|
|
95
|
+
BHD: "د.ب.",
|
|
96
|
+
BIF: "FBu",
|
|
97
|
+
BMD: "$",
|
|
98
|
+
BND: "$",
|
|
99
|
+
BOB: "Bs.",
|
|
100
|
+
BRL: "R$",
|
|
101
|
+
BSD: "$",
|
|
102
|
+
BTN: "Nu.",
|
|
103
|
+
BWP: "P",
|
|
104
|
+
BYN: "руб.",
|
|
105
|
+
BZD: "$",
|
|
106
|
+
CAD: "$",
|
|
107
|
+
CDF: "₣",
|
|
108
|
+
CHF: "₣",
|
|
109
|
+
CKD: "$",
|
|
110
|
+
CLP: "$",
|
|
111
|
+
CNY: "¥元",
|
|
112
|
+
COP: "$",
|
|
113
|
+
CRC: "₡",
|
|
114
|
+
CUC: "$",
|
|
115
|
+
CUP: "₱",
|
|
116
|
+
CVE: "$",
|
|
117
|
+
CZK: "Kč",
|
|
118
|
+
DJF: "ف.ج.",
|
|
119
|
+
DKK: "kr.",
|
|
120
|
+
DOP: "$",
|
|
121
|
+
DZD: "د.ج.",
|
|
122
|
+
EGP: "ج.م.",
|
|
123
|
+
EHP: "Ptas.",
|
|
124
|
+
ERN: "ناكفا",
|
|
125
|
+
ETB: "ብር",
|
|
126
|
+
FJD: "$",
|
|
127
|
+
FKP: "£",
|
|
128
|
+
FOK: "kr",
|
|
129
|
+
GBP: "£",
|
|
130
|
+
GEL: "₾",
|
|
131
|
+
GGP: "£",
|
|
132
|
+
GHS: "₵",
|
|
133
|
+
GIP: "£",
|
|
134
|
+
GMD: "D",
|
|
135
|
+
GNF: "FG",
|
|
136
|
+
GTQ: "$",
|
|
137
|
+
GYD: "$",
|
|
138
|
+
HKD: "$",
|
|
139
|
+
HNL: "L",
|
|
140
|
+
HRK: "kn",
|
|
141
|
+
HTG: "G",
|
|
142
|
+
HUF: "Ft",
|
|
143
|
+
IDR: "Rp",
|
|
144
|
+
ILS: "₪",
|
|
145
|
+
IMP: "£",
|
|
146
|
+
INR: "₹",
|
|
147
|
+
IQD: "د.ع.",
|
|
148
|
+
IRR: "﷼",
|
|
149
|
+
ISK: "kr",
|
|
150
|
+
JEP: "£",
|
|
151
|
+
JMD: "$",
|
|
152
|
+
JOD: "د.أ.",
|
|
153
|
+
JPY: "¥",
|
|
154
|
+
KES: "KSh",
|
|
155
|
+
KGS: "с",
|
|
156
|
+
KHR: "៛",
|
|
157
|
+
KID: "$",
|
|
158
|
+
KMF: "CF",
|
|
159
|
+
KPW: "₩",
|
|
160
|
+
KRW: "₩",
|
|
161
|
+
KWD: "د.ك.",
|
|
162
|
+
KYD: "$",
|
|
163
|
+
KZT: "₸",
|
|
164
|
+
LAK: "₭",
|
|
165
|
+
LBP: "ل.ل.",
|
|
166
|
+
LKR: "රු or ரூ",
|
|
167
|
+
LRD: "$",
|
|
168
|
+
LSL: "L",
|
|
169
|
+
LYD: "ل.د.",
|
|
170
|
+
MAD: "د.م.",
|
|
171
|
+
MDL: "L",
|
|
172
|
+
MGA: "Ar",
|
|
173
|
+
MKD: "ден",
|
|
174
|
+
MMK: "Ks",
|
|
175
|
+
MNT: "₮",
|
|
176
|
+
MOP: "MOP$",
|
|
177
|
+
MRU: "أ.م.",
|
|
178
|
+
MUR: "रु ",
|
|
179
|
+
MVR: ".ރ",
|
|
180
|
+
MWK: "MK",
|
|
181
|
+
MXN: "$",
|
|
182
|
+
MYR: "RM",
|
|
183
|
+
MZN: "MT",
|
|
184
|
+
NAD: "$",
|
|
185
|
+
NGN: "₦",
|
|
186
|
+
NIO: "C$",
|
|
187
|
+
NOK: "kr",
|
|
188
|
+
NPR: "रू",
|
|
189
|
+
NZD: "$",
|
|
190
|
+
OMR: "ر.ع.",
|
|
191
|
+
PAB: "B/.",
|
|
192
|
+
PEN: "S/.",
|
|
193
|
+
PGK: "K",
|
|
194
|
+
PHP: "₱",
|
|
195
|
+
PKR: "Rs",
|
|
196
|
+
PLN: "zł",
|
|
197
|
+
PND: "$",
|
|
198
|
+
PRB: "р.",
|
|
199
|
+
PYG: "₲",
|
|
200
|
+
QAR: "ر.ق.",
|
|
201
|
+
RON: "L",
|
|
202
|
+
RSD: "дин",
|
|
203
|
+
RUB: "₽",
|
|
204
|
+
RWF: "R₣",
|
|
205
|
+
SAR: "ر.س.",
|
|
206
|
+
SBD: "$",
|
|
207
|
+
SCR: "Rs",
|
|
208
|
+
SDG: "ج.س.",
|
|
209
|
+
SEK: "kr",
|
|
210
|
+
SGD: "$",
|
|
211
|
+
SHP: "£",
|
|
212
|
+
SLL: "Le",
|
|
213
|
+
SLS: "Sl",
|
|
214
|
+
SOS: "Ssh",
|
|
215
|
+
SRD: "$",
|
|
216
|
+
SSP: "SS£",
|
|
217
|
+
STN: "Db",
|
|
218
|
+
SVC: "₡",
|
|
219
|
+
SYP: "ل.س.",
|
|
220
|
+
SZL: "L",
|
|
221
|
+
THB: "฿",
|
|
222
|
+
TJS: "SM",
|
|
223
|
+
TMT: "T",
|
|
224
|
+
TND: "د.ت.",
|
|
225
|
+
TOP: "PT",
|
|
226
|
+
TTD: "$",
|
|
227
|
+
TVD: "$",
|
|
228
|
+
TWD: "圓",
|
|
229
|
+
TZS: "TSh",
|
|
230
|
+
UAH: "грн",
|
|
231
|
+
UGX: "Sh",
|
|
232
|
+
UYU: "$",
|
|
233
|
+
UZS: "сум",
|
|
234
|
+
VED: "Bs.",
|
|
235
|
+
VES: "Bs.F",
|
|
236
|
+
VND: "₫",
|
|
237
|
+
VUV: "VT",
|
|
238
|
+
WST: "ST",
|
|
239
|
+
XAF: "Fr.",
|
|
240
|
+
XCD: "$",
|
|
241
|
+
XOF: "₣",
|
|
242
|
+
XPF: "₣",
|
|
243
|
+
YER: "ر.ي.",
|
|
244
|
+
ZAR: "R",
|
|
245
|
+
ZMW: "ZK",
|
|
246
|
+
ZWB: "",
|
|
247
|
+
ZWL: "$",
|
|
248
|
+
Abkhazia: "",
|
|
249
|
+
Artsakh: "դր.",
|
|
250
|
+
};
|