@ikas/storefront 4.0.0-alpha.29 → 4.0.0-alpha.30

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikas/storefront",
3
- "version": "4.0.0-alpha.29",
3
+ "version": "4.0.0-alpha.30",
4
4
  "description": "Storefront functionality for ikas storefront themes.",
5
5
  "author": "Umut Ozan Yıldırım",
6
6
  "license": "ISC",
@@ -24,11 +24,11 @@
24
24
  "libphonenumber-js": "^1.10.6"
25
25
  },
26
26
  "devDependencies": {
27
- "@ikas/storefront-api": "^4.0.0-alpha.29",
28
- "@ikas/storefront-config": "^4.0.0-alpha.29",
29
- "@ikas/storefront-model-functions": "^4.0.0-alpha.29",
30
- "@ikas/storefront-models": "^4.0.0-alpha.29",
31
- "@ikas/storefront-providers": "^4.0.0-alpha.29",
27
+ "@ikas/storefront-api": "^4.0.0-alpha.30",
28
+ "@ikas/storefront-config": "^4.0.0-alpha.30",
29
+ "@ikas/storefront-model-functions": "^4.0.0-alpha.30",
30
+ "@ikas/storefront-models": "^4.0.0-alpha.30",
31
+ "@ikas/storefront-providers": "^4.0.0-alpha.30",
32
32
  "@rollup/plugin-commonjs": "^22.0.0",
33
33
  "@rollup/plugin-json": "^4.1.0",
34
34
  "@rollup/plugin-node-resolve": "^13.3.0",
@@ -52,11 +52,11 @@
52
52
  "html-react-parser": "^1.4.0"
53
53
  },
54
54
  "peerDependencies": {
55
- "@ikas/storefront-api": "^4.0.0-alpha.29",
56
- "@ikas/storefront-config": "^4.0.0-alpha.29",
57
- "@ikas/storefront-model-functions": "^4.0.0-alpha.29",
58
- "@ikas/storefront-models": "^4.0.0-alpha.29",
59
- "@ikas/storefront-providers": "^4.0.0-alpha.29",
55
+ "@ikas/storefront-api": "^4.0.0-alpha.30",
56
+ "@ikas/storefront-config": "^4.0.0-alpha.30",
57
+ "@ikas/storefront-model-functions": "^4.0.0-alpha.30",
58
+ "@ikas/storefront-models": "^4.0.0-alpha.30",
59
+ "@ikas/storefront-providers": "^4.0.0-alpha.30",
60
60
  "mobx": "^6.1.3",
61
61
  "mobx-react-lite": "^3.1.5",
62
62
  "next": "12.2.0",
@@ -4,7 +4,11 @@ import {
4
4
  IkasOrderLineItem,
5
5
  IkasProductOptionType,
6
6
  } from "../../../../../models";
7
- import { formatDate, formatMoney, useTranslation } from "../../../../../utils";
7
+ import {
8
+ formatDate,
9
+ formatCurrency,
10
+ useTranslation,
11
+ } from "../../../../../utils";
8
12
  import CheckoutViewModel from "../../../../../components/checkout/model";
9
13
  import { Modal } from "../../modal";
10
14
 
@@ -159,19 +163,17 @@ export const CartItem: React.FC<Props> = observer(
159
163
  {!!cartItem.overridenPriceWithQuantity && (
160
164
  <span className={styles.GrayPrice}>
161
165
  {!!adjustmentTotal
162
- ? formatMoney(cartItem.finalPriceWithQuantity, currencyCode)
163
- : formatMoney(
164
- cartItem.overridenPriceWithQuantity,
165
- currencyCode
166
- )}
166
+ ? cartItem.formattedFinalPriceWithQuantity
167
+ : cartItem.formattedOverridenPriceWithQuantity}
167
168
  </span>
168
169
  )}
169
170
  {!!adjustmentTotal
170
- ? formatMoney(
171
+ ? formatCurrency(
171
172
  cartItem.finalPriceWithQuantity - adjustmentTotal,
172
- currencyCode
173
+ currencyCode,
174
+ cartItem.currencySymbol
173
175
  )
174
- : formatMoney(cartItem.finalPriceWithQuantity, currencyCode)}
176
+ : cartItem.formattedFinalPriceWithQuantity}
175
177
  </div>
176
178
  </div>
177
179
  </div>
@@ -5,7 +5,7 @@ import _sortBy from "lodash/sortBy";
5
5
  import InputWithButton from "../input-with-button";
6
6
  import NotificationBox from "../notification-box";
7
7
  import CheckoutViewModel, { CheckoutStep } from "../../model";
8
- import { formatMoney, useTranslation } from "../../../../utils";
8
+ import { formatCurrency, useTranslation } from "../../../../utils";
9
9
  import { CartItem } from "./cart-item";
10
10
  import { FormItem } from "../form-item";
11
11
  import { FormItemType } from "../form-item/model";
@@ -95,9 +95,13 @@ export const CartSummary: React.FC<Props> = observer(({ vm, allowExpand }) => {
95
95
  <div className={styles.Left}>{t("checkout-page:summary")}</div>
96
96
  <div className={styles.Price}>
97
97
  <span className={styles.PriceText}>
98
- {`${formatMoney(vm.finalPrice || 0, checkout.currencyCode)} (${
99
- checkout.items.length
100
- } ${t("checkout-page:cartItemProduct")})`}
98
+ {`${formatCurrency(
99
+ vm.finalPrice || 0,
100
+ checkout.currencyCode,
101
+ checkout.currencySymbol
102
+ )} (${checkout.items.length} ${t(
103
+ "checkout-page:cartItemProduct"
104
+ )})`}
101
105
  </span>
102
106
  <span className={arrowDownClasses}>
103
107
  <SVGArrowDown />
@@ -132,7 +136,7 @@ export const CartSummary: React.FC<Props> = observer(({ vm, allowExpand }) => {
132
136
  )}
133
137
  <InfoRow
134
138
  label={t("checkout-page:subtotal")}
135
- value={formatMoney(checkout.totalPrice, checkout.currencyCode)}
139
+ value={checkout.formattedTotalPrice}
136
140
  tooltipText={t("checkout-page:subtotalTooltip")}
137
141
  />
138
142
  {!!checkout.shippingLines?.length && (
@@ -140,10 +144,7 @@ export const CartSummary: React.FC<Props> = observer(({ vm, allowExpand }) => {
140
144
  label={t("checkout-page:cartShippingTitle")}
141
145
  value={
142
146
  checkout.shippingTotal
143
- ? formatMoney(
144
- checkout.shippingTotal,
145
- checkout.currencyCode
146
- )
147
+ ? checkout.formattedShippingTotal
147
148
  : t("checkout-page:free")
148
149
  }
149
150
  />
@@ -151,15 +152,16 @@ export const CartSummary: React.FC<Props> = observer(({ vm, allowExpand }) => {
151
152
  {!!checkout.totalTax && !!vm.customizationProps?.showTax && (
152
153
  <InfoRow
153
154
  label={t("checkout-page:cartTaxTitle")}
154
- value={formatMoney(checkout.totalTax, checkout.currencyCode)}
155
+ value={checkout.formattedTotalTax}
155
156
  />
156
157
  )}
157
158
  {!!vm.installmentExtraPrice && (
158
159
  <InfoRow
159
160
  label={t("checkout-page:cartInterest")}
160
- value={formatMoney(
161
+ value={formatCurrency(
161
162
  vm.installmentExtraPrice,
162
- checkout.currencyCode
163
+ checkout.currencyCode,
164
+ checkout.currencySymbol
163
165
  )}
164
166
  />
165
167
  )}
@@ -193,7 +195,11 @@ export const CartSummary: React.FC<Props> = observer(({ vm, allowExpand }) => {
193
195
  <div className={styles.Title}>{t("checkout-page:total")}</div>
194
196
  </div>
195
197
  <div className={styles.TotalPrice}>
196
- {formatMoney(vm.finalPrice || 0, checkout.currencyCode)}
198
+ {formatCurrency(
199
+ vm.finalPrice || 0,
200
+ checkout.currencyCode,
201
+ checkout.currencySymbol
202
+ )}
197
203
  </div>
198
204
  </div>
199
205
 
@@ -273,7 +279,11 @@ const Adjustments: React.FC<CommonProps> = observer(({ vm }) => {
273
279
  <div className={styles.Value}>
274
280
  <span>{adjustment.type === "DECREMENT" ? "- " : ""}</span>{" "}
275
281
  <span>
276
- {formatMoney(adjustment.amount, vm.checkout.currencyCode)}
282
+ {formatCurrency(
283
+ adjustment.amount,
284
+ vm.checkout.currencyCode,
285
+ vm.checkout.currencySymbol
286
+ )}
277
287
  </span>
278
288
  </div>
279
289
  </div>
@@ -304,7 +314,11 @@ const CalculatedAdditionalPrices: React.FC<CommonProps> = observer(({ vm }) => {
304
314
  <div className={styles.Value}>
305
315
  <span>{adjustment.type === "DECREMENT" ? "- " : ""}</span>{" "}
306
316
  <span>
307
- {formatMoney(adjustment.amount, vm.checkout!.currencyCode)}
317
+ {formatCurrency(
318
+ adjustment.amount,
319
+ vm.checkout!.currencyCode,
320
+ vm.checkout!.currencySymbol
321
+ )}
308
322
  </span>
309
323
  </div>
310
324
  </div>
@@ -318,7 +332,13 @@ const CalculatedAdditionalPrices: React.FC<CommonProps> = observer(({ vm }) => {
318
332
  </div>
319
333
  </div>
320
334
  <div className={styles.Value}>
321
- <span>{formatMoney(gpl.price, vm.checkout.currencyCode)}</span>
335
+ <span>
336
+ {formatCurrency(
337
+ gpl.price,
338
+ vm.checkout.currencyCode,
339
+ vm.checkout!.currencySymbol
340
+ )}
341
+ </span>
322
342
  </div>
323
343
  </div>
324
344
  ))}
@@ -410,7 +430,11 @@ const Coupon: React.FC<CouponProps> = observer(
410
430
  <div className={styles.Value}>
411
431
  <span>{adjustment?.type === "DECREMENT" ? "- " : ""}</span>{" "}
412
432
  <span>
413
- {formatMoney(adjustment?.amount || 0, vm.checkout.currencyCode)}
433
+ {formatCurrency(
434
+ adjustment?.amount || 0,
435
+ vm.checkout.currencyCode,
436
+ vm.checkout.currencySymbol
437
+ )}
414
438
  </span>
415
439
  </div>
416
440
  )}
@@ -8,7 +8,7 @@ import SVGCross from "../svg/cross";
8
8
  import styles from "./style.module.scss";
9
9
  import { useTranslation } from "../../../../utils/i18n";
10
10
  import { IkasProductVariant } from "../../../../models";
11
- import { formatMoney } from "../../../../utils/currency";
11
+ import { formatCurrency } from "../../../../utils/currency";
12
12
 
13
13
  type Props = {
14
14
  vm: CheckoutViewModel;
@@ -95,12 +95,13 @@ const OfferProduct: React.FC<Props> = ({ vm, campaignOffer }) => {
95
95
  <span className={styles.Discount}>
96
96
  {selectedVariant.price.formattedFinalPrice}
97
97
  </span>{" "}
98
- {formatMoney(
98
+ {formatCurrency(
99
99
  selectedVariant.price.finalPrice -
100
100
  (selectedVariant.price.finalPrice *
101
101
  (campaignOffer.offer.discountAmount || 100)) /
102
102
  100,
103
- vm.checkout!.currencyCode
103
+ vm.checkout!.currencyCode,
104
+ vm.checkout!.currencySymbol
104
105
  )}
105
106
  </div>
106
107
  <div className={styles.Actions}>
@@ -7,7 +7,7 @@ import ReactTooltip from "react-tooltip";
7
7
  import CheckoutViewModel, { CheckoutStep } from "./model";
8
8
  import { IkasCheckoutSettings } from "../../models/data/checkout-settings";
9
9
  import { IkasCheckout } from "../../models/data/checkout";
10
- import { formatMoney, useTranslation } from "../../utils";
10
+ import { formatCurrency, useTranslation } from "../../utils";
11
11
 
12
12
  import CheckoutStepInfo from "./steps/step-info";
13
13
  import { CheckoutStepShipping } from "./steps/step-shipping";
@@ -443,9 +443,10 @@ const StepSummaryShipping: React.FC<CommonProps> = observer(({ vm }) => {
443
443
  {" / " +
444
444
  (vm.checkout.shippingLines[0].price === 0
445
445
  ? t("checkout-page:free")
446
- : formatMoney(
446
+ : formatCurrency(
447
447
  vm.checkout.shippingLines[0].price,
448
- vm.checkout!.currencyCode
448
+ vm.checkout!.currencyCode,
449
+ vm.checkout.currencySymbol
449
450
  ))}
450
451
  </span>
451
452
  </React.Fragment>
@@ -12,7 +12,7 @@ import { CreditCardForm } from "../../../components/credit-card-form";
12
12
  import { Installments } from "./installments";
13
13
  import SelectBox from "../../../components/select-box";
14
14
  import styles from "./style.module.scss";
15
- import { formatMoney, useTranslation } from "../../../../../utils";
15
+ import { formatCurrency, useTranslation } from "../../../../../utils";
16
16
  import SVGExternal from "../../../components/svg/external";
17
17
  import SVGMasterCard from "../../../components/master-pass/payment-gateway/svg/master-card";
18
18
  import { IkasPaymentGatewayAdditionalPrice } from "../../../../../models/data/payment-gateway/additional-price";
@@ -50,7 +50,11 @@ export const PaymentGateways: React.FC<Props> = observer(({ vm }) => {
50
50
 
51
51
  return `${
52
52
  ap.amountType === IkasPaymentGatewayTransactionFeeType.AMOUNT
53
- ? formatMoney(ap.amount, vm.checkout.currencyCode)
53
+ ? formatCurrency(
54
+ ap.amount,
55
+ vm.checkout.currencyCode,
56
+ vm.checkout.currencySymbol
57
+ )
54
58
  : " %" + ap.amount
55
59
  }${
56
60
  ap.type === IkasPaymentGatewayAdditionalPriceType.DECREMENT
@@ -2,7 +2,7 @@ import * as React from "react";
2
2
  import { observer } from "mobx-react-lite";
3
3
  import CheckoutViewModel from "../../../../model";
4
4
 
5
- import { formatMoney, useTranslation } from "../../../../../../utils";
5
+ import { formatCurrency, useTranslation } from "../../../../../../utils";
6
6
  import styles from "./style.module.scss";
7
7
  import { Toggle } from "../../../../../../components/checkout/components/toggle";
8
8
 
@@ -33,17 +33,19 @@ export const Installments: React.FC<Props> = observer(({ vm }) => {
33
33
  </div>
34
34
  {ip.installmentCount !== 1 && (
35
35
  <div className={styles.InstallmentPrice}>
36
- {formatMoney(
36
+ {formatCurrency(
37
37
  ip.installmentPrice!,
38
38
  vm.checkout!.currencyCode,
39
+ vm.checkout!.currencySymbol
39
40
  )}
40
41
  </div>
41
42
  )}
42
43
  </div>
43
44
  <div className={styles.Price}>
44
- {formatMoney(
45
+ {formatCurrency(
45
46
  ip.totalPrice!,
46
47
  vm.checkout!.currencyCode,
48
+ vm.checkout!.currencySymbol
47
49
  )}
48
50
  </div>
49
51
  </div>
@@ -1,7 +1,7 @@
1
1
  import * as React from "react";
2
2
  import { observer } from "mobx-react-lite";
3
3
  import CheckoutViewModel from "../../model";
4
- import { formatMoney, useTranslation } from "../../../../utils";
4
+ import { formatCurrency, useTranslation } from "../../../../utils";
5
5
 
6
6
  import styles from "./style.module.scss";
7
7
  import { Button } from "../../components/button";
@@ -59,7 +59,11 @@ const ShippingMethods: React.FC<CommonProps> = observer(({ vm }) => {
59
59
  <div className={styles.ShippingPrice}>
60
60
  {asm.price === 0
61
61
  ? t("checkout-page:free")
62
- : formatMoney(asm.price, vm.checkout.currencyCode)}
62
+ : formatCurrency(
63
+ asm.price,
64
+ vm.checkout.currencyCode,
65
+ vm.checkout.currencySymbol
66
+ )}
63
67
  </div>
64
68
  }
65
69
  onClick={() => vm.onShippingMethodChange(asm)}
@@ -95,9 +99,10 @@ const GiftPackage: React.FC<CommonProps> = observer(({ vm }) => {
95
99
  const checkboxLabel =
96
100
  t("checkout-page:giftPackageCta") +
97
101
  (giftPackagePrice && giftPackagePrice.price
98
- ? ` (+ ${formatMoney(
102
+ ? ` (+ ${formatCurrency(
99
103
  giftPackagePrice!.price,
100
- giftPackagePrice!.currencyCode
104
+ giftPackagePrice!.currencyCode,
105
+ giftPackagePrice!.currencySymbol
101
106
  )})`
102
107
  : "");
103
108
 
@@ -11,7 +11,7 @@ import SVGAmex from "../../components/credit-card-form/svg/amex";
11
11
  import SVGMasterCard from "../../components/credit-card-form/svg/master-card";
12
12
  import SVGTroy from "../../components/credit-card-form/svg/troy";
13
13
  import SVGVisa from "../../components/credit-card-form/svg/visa";
14
- import { formatMoney, useTranslation } from "../../../../utils";
14
+ import { formatCurrency, useTranslation } from "../../../../utils";
15
15
  import { IkasOrderPackageStatus } from "../../../../models";
16
16
  import {
17
17
  IkasPaymentGatewayType,
@@ -125,9 +125,10 @@ export const StepSuccess: React.FC<Props> = observer(({ vm }) => {
125
125
  null && (
126
126
  <div className={styles.InfoText}>{`${
127
127
  paymentMethodDetail.installment.installmentCount
128
- } x ${formatMoney(
128
+ } x ${formatCurrency(
129
129
  paymentMethodDetail.installment.installmentPrice,
130
- vm.checkout.currencyCode
130
+ vm.checkout.currencyCode,
131
+ vm.checkout.currencySymbol
131
132
  )}`}</div>
132
133
  )}
133
134
  </React.Fragment>
@@ -461,8 +461,7 @@ export default class IkasPageEditorViewModel {
461
461
  const pageDataProvider = new IkasPageDataProvider(
462
462
  theme,
463
463
  pageParams,
464
- pageType,
465
- true
464
+ pageType
466
465
  );
467
466
 
468
467
  if (pageParams.blogId || pageParams.blogCategoryId) {
@@ -2,7 +2,7 @@ import { IkasCart } from "../cart";
2
2
  import { IkasCheckout as ICheckout } from "@ikas/storefront-models";
3
3
  import { IkasCheckoutFunctions } from "@ikas/storefront-model-functions";
4
4
  import { IkasPaymentGateway } from "../payment-gateway";
5
- import { formatMoney } from "../../../utils/currency";
5
+ import { formatCurrency } from "../../../utils/currency";
6
6
  import { computed, makeObservable, observable } from "mobx";
7
7
  import { formatDate } from "../../../utils/helper";
8
8
 
@@ -44,7 +44,11 @@ export class IkasCheckout extends IkasCart implements ICheckout {
44
44
  }
45
45
 
46
46
  get $formattedTotalFinalPrice() {
47
- return formatMoney(this.$totalFinalPrice, this.currencySymbol);
47
+ return formatCurrency(
48
+ this.$totalFinalPrice,
49
+ this.currencyCode,
50
+ this.currencySymbol
51
+ );
48
52
  }
49
53
 
50
54
  get dateStr() {
@@ -3,10 +3,12 @@ import { makeAutoObservable } from "mobx";
3
3
 
4
4
  export class IkasCheckoutSettingsPrice implements ICheckoutSettingsPrice {
5
5
  currencyCode: string;
6
+ currencySymbol: string | null;
6
7
  price: number;
7
8
 
8
9
  constructor(data: ICheckoutSettingsPrice) {
9
10
  this.currencyCode = data.currencyCode;
11
+ this.currencySymbol = data.currencySymbol || null;
10
12
  this.price = data.price;
11
13
 
12
14
  makeAutoObservable(this);
@@ -20,7 +20,7 @@ import {
20
20
  import { IkasOrder as IOrder } from "@ikas/storefront-models";
21
21
  import { computed, makeObservable, observable } from "mobx";
22
22
  import { IkasOrderFunctions } from "@ikas/storefront-model-functions";
23
- import { formatMoney, getCurrencySymbol } from "../../../utils/currency";
23
+ import { formatCurrency } from "../../../utils/currency";
24
24
 
25
25
  type IOrderConstructorData = {
26
26
  refundSettings?: IkasOrderRefundSettings | null;
@@ -31,6 +31,7 @@ export class IkasOrder extends IkasBaseModel implements IOrder {
31
31
  cancelReason: IkasOrderCancelReason | null = null;
32
32
  cancelledAt: number | null = null;
33
33
  currencyCode: string;
34
+ currencySymbol: string | null = null;
34
35
  customer: IkasOrderCustomer | null = null;
35
36
  customerId: string | null = null;
36
37
  giftPackageLines: IkasOrderGiftPackageLine[] | null = null;
@@ -66,6 +67,7 @@ export class IkasOrder extends IkasBaseModel implements IOrder {
66
67
  this.cancelReason = data.cancelReason || null;
67
68
  this.cancelledAt = data.cancelledAt || null;
68
69
  this.currencyCode = data.currencyCode;
70
+ this.currencySymbol = data.currencySymbol || null;
69
71
  this.customer = data.customer ? new IkasOrderCustomer(data.customer) : null;
70
72
  this.customerId = data.customerId || null;
71
73
  this.giftPackageLines =
@@ -104,6 +106,7 @@ export class IkasOrder extends IkasBaseModel implements IOrder {
104
106
  cancelReason: observable,
105
107
  cancelledAt: observable,
106
108
  currencyCode: observable,
109
+ currencySymbol: observable,
107
110
  customer: observable,
108
111
  customerId: observable,
109
112
  giftPackageLines: observable,
@@ -130,7 +133,6 @@ export class IkasOrder extends IkasBaseModel implements IOrder {
130
133
 
131
134
  items: computed,
132
135
  itemCount: computed,
133
- currencySymbol: computed,
134
136
  refundableItems: computed,
135
137
  unfullfilledItems: computed,
136
138
  refundedItems: computed,
@@ -157,10 +159,6 @@ export class IkasOrder extends IkasBaseModel implements IOrder {
157
159
  return this.items?.length || 0;
158
160
  }
159
161
 
160
- get currencySymbol() {
161
- return getCurrencySymbol(this.currencyCode);
162
- }
163
-
164
162
  get refundableItems() {
165
163
  if (!this.refundSettings) return [];
166
164
  return IkasOrderFunctions.getRefundableItems(this, this.refundSettings).map(
@@ -185,7 +183,11 @@ export class IkasOrder extends IkasBaseModel implements IOrder {
185
183
  }
186
184
 
187
185
  get formattedTotalTax() {
188
- return formatMoney(this.totalTax, this.currencySymbol);
186
+ return formatCurrency(
187
+ this.totalTax,
188
+ this.currencyCode,
189
+ this.currencySymbol || ""
190
+ );
189
191
  }
190
192
 
191
193
  get shippingTotal() {
@@ -193,15 +195,27 @@ export class IkasOrder extends IkasBaseModel implements IOrder {
193
195
  }
194
196
 
195
197
  get formattedShippingTotal() {
196
- return formatMoney(this.shippingTotal, this.currencySymbol);
198
+ return formatCurrency(
199
+ this.shippingTotal,
200
+ this.currencyCode,
201
+ this.currencySymbol || ""
202
+ );
197
203
  }
198
204
 
199
205
  get formattedTotalFinalPrice() {
200
- return formatMoney(this.totalFinalPrice, this.currencySymbol);
206
+ return formatCurrency(
207
+ this.totalFinalPrice,
208
+ this.currencyCode,
209
+ this.currencySymbol || ""
210
+ );
201
211
  }
202
212
 
203
213
  get formattedTotalPrice() {
204
- return formatMoney(this.totalPrice, this.currencySymbol);
214
+ return formatCurrency(
215
+ this.totalPrice,
216
+ this.currencyCode,
217
+ this.currencySymbol || ""
218
+ );
205
219
  }
206
220
 
207
221
  get hasCustomer() {
@@ -8,7 +8,7 @@ import { IkasOrderLineItemOption } from "./option";
8
8
  import { IkasBaseModel } from "../../base";
9
9
  import { computed, makeObservable, observable } from "mobx";
10
10
  import { IkasOrderLineItemFunctions } from "@ikas/storefront-model-functions";
11
- import { formatMoney, getCurrencySymbol } from "../../../../utils/currency";
11
+ import { formatCurrency } from "../../../../utils/currency";
12
12
 
13
13
  type IOrderLineItemConstructorParams = {
14
14
  refundQuantity?: number;
@@ -16,6 +16,7 @@ type IOrderLineItemConstructorParams = {
16
16
 
17
17
  export class IkasOrderLineItem extends IkasBaseModel implements IOrderLineItem {
18
18
  currencyCode: string | null = null;
19
+ currencySymbol: string | null;
19
20
  discount: IkasOrderLineDiscount | null = null;
20
21
  discountPrice: number | null = null;
21
22
  finalPrice: number | null = null;
@@ -37,6 +38,7 @@ export class IkasOrderLineItem extends IkasBaseModel implements IOrderLineItem {
37
38
  super(data);
38
39
 
39
40
  this.currencyCode = data.currencyCode || null;
41
+ this.currencySymbol = data.currencySymbol || null;
40
42
  this.discount = data.discount
41
43
  ? new IkasOrderLineDiscount(data.discount)
42
44
  : null;
@@ -55,6 +57,7 @@ export class IkasOrderLineItem extends IkasBaseModel implements IOrderLineItem {
55
57
 
56
58
  makeObservable(this, {
57
59
  currencyCode: observable,
60
+ currencySymbol: observable,
58
61
  discount: observable,
59
62
  discountPrice: observable,
60
63
  finalPrice: observable,
@@ -69,7 +72,6 @@ export class IkasOrderLineItem extends IkasBaseModel implements IOrderLineItem {
69
72
  variant: observable,
70
73
  orderedAt: observable,
71
74
 
72
- currencySymbol: computed,
73
75
  priceWithQuantity: computed,
74
76
  formattedPriceWithQuantity: computed,
75
77
  overridenPriceWithQuantity: computed,
@@ -84,16 +86,16 @@ export class IkasOrderLineItem extends IkasBaseModel implements IOrderLineItem {
84
86
  });
85
87
  }
86
88
 
87
- get currencySymbol() {
88
- return getCurrencySymbol(this.currencyCode || "");
89
- }
90
-
91
89
  get priceWithQuantity() {
92
90
  return IkasOrderLineItemFunctions.getPriceWithQuantity(this);
93
91
  }
94
92
 
95
93
  get formattedPriceWithQuantity() {
96
- return formatMoney(this.priceWithQuantity, this.currencySymbol);
94
+ return formatCurrency(
95
+ this.priceWithQuantity,
96
+ this.currencyCode || "",
97
+ this.currencySymbol || ""
98
+ );
97
99
  }
98
100
 
99
101
  get overridenPriceWithQuantity() {
@@ -101,18 +103,27 @@ export class IkasOrderLineItem extends IkasBaseModel implements IOrderLineItem {
101
103
  }
102
104
 
103
105
  get formattedOverridenPriceWithQuantity() {
104
- return formatMoney(
106
+ return formatCurrency(
105
107
  this.overridenPriceWithQuantity || 0,
106
- this.currencySymbol
108
+ this.currencyCode || "",
109
+ this.currencySymbol || ""
107
110
  );
108
111
  }
109
112
 
110
113
  get formattedFinalPrice() {
111
- return formatMoney(this.finalPrice || 0, this.currencySymbol);
114
+ return formatCurrency(
115
+ this.finalPrice || 0,
116
+ this.currencyCode || "",
117
+ this.currencySymbol || ""
118
+ );
112
119
  }
113
120
 
114
121
  get formattedDiscountPrice() {
115
- return formatMoney(this.discountPrice || 0, this.currencySymbol);
122
+ return formatCurrency(
123
+ this.discountPrice || 0,
124
+ this.currencyCode || "",
125
+ this.currencySymbol || ""
126
+ );
116
127
  }
117
128
 
118
129
  get finalPriceWithQuantity() {
@@ -120,7 +131,11 @@ export class IkasOrderLineItem extends IkasBaseModel implements IOrderLineItem {
120
131
  }
121
132
 
122
133
  get formattedFinalPriceWithQuantity() {
123
- return formatMoney(this.finalPriceWithQuantity || 0, this.currencySymbol);
134
+ return formatCurrency(
135
+ this.finalPriceWithQuantity || 0,
136
+ this.currencyCode || "",
137
+ this.currencySymbol || ""
138
+ );
124
139
  }
125
140
 
126
141
  get tax() {
@@ -128,7 +143,11 @@ export class IkasOrderLineItem extends IkasBaseModel implements IOrderLineItem {
128
143
  }
129
144
 
130
145
  get formattedTax() {
131
- return formatMoney(this.tax, this.currencySymbol);
146
+ return formatCurrency(
147
+ this.tax,
148
+ this.currencyCode || "",
149
+ this.currencySymbol || ""
150
+ );
132
151
  }
133
152
 
134
153
  get refundQuantity() {
@@ -5,7 +5,6 @@ import {
5
5
  IkasOrderTransaction as IOrderTransaction,
6
6
  } from "@ikas/storefront-models";
7
7
  import { makeAutoObservable } from "mobx";
8
- import { getCurrencySymbol } from "../../../../utils/currency";
9
8
  import { IkasTransactionError } from "./error";
10
9
  import { IkasTransactionPaymentMethodDetail } from "./payment-method-detail";
11
10
 
@@ -14,6 +13,7 @@ export class IkasOrderTransaction implements IOrderTransaction {
14
13
  checkoutId: string | null;
15
14
  createdAt: number | null;
16
15
  currencyCode: string | null;
16
+ currencySymbol: string | null;
17
17
  customerId: string | null;
18
18
  error: IkasTransactionError | null;
19
19
  id: string | null;
@@ -33,6 +33,7 @@ export class IkasOrderTransaction implements IOrderTransaction {
33
33
  this.checkoutId = data.checkoutId || null;
34
34
  this.createdAt = data.createdAt || null;
35
35
  this.currencyCode = data.currencyCode || null;
36
+ this.currencySymbol = data.currencySymbol || null;
36
37
  this.customerId = data.customerId || null;
37
38
  this.error = data.error ? new IkasTransactionError(data.error) : null;
38
39
  this.id = data.id;
@@ -49,10 +50,6 @@ export class IkasOrderTransaction implements IOrderTransaction {
49
50
 
50
51
  makeAutoObservable(this);
51
52
  }
52
-
53
- get currencySymbol() {
54
- return getCurrencySymbol(this.currencyCode || "");
55
- }
56
53
  }
57
54
 
58
55
  export { IkasTransactionStatus, IkasTransactionType };
@@ -1,11 +1,12 @@
1
1
  import { IkasProductPriceFunctions } from "@ikas/storefront-model-functions";
2
2
  import { IkasProductPrice as IProductPrice } from "@ikas/storefront-models";
3
3
  import { makeAutoObservable } from "mobx";
4
- import { getCurrencySymbol, formatMoney } from "../../../../../utils/currency";
4
+ import { formatCurrency } from "../../../../../utils/currency";
5
5
 
6
6
  export class IkasProductPrice implements IProductPrice {
7
7
  buyPrice: number | null = null;
8
8
  currency: string | null = null;
9
+ currencySymbol: string | null = null;
9
10
  discountPrice: number | null = null;
10
11
  priceListId: string | null = null;
11
12
  sellPrice: number;
@@ -13,6 +14,7 @@ export class IkasProductPrice implements IProductPrice {
13
14
  constructor(data?: IProductPrice) {
14
15
  this.buyPrice = data?.buyPrice ?? null;
15
16
  this.currency = data?.currency ?? null;
17
+ this.currencySymbol = data?.currencySymbol ?? "";
16
18
  this.discountPrice = data?.discountPrice ?? null;
17
19
  this.priceListId = data?.priceListId ?? null;
18
20
  this.sellPrice = data?.sellPrice ?? 0;
@@ -20,28 +22,40 @@ export class IkasProductPrice implements IProductPrice {
20
22
  makeAutoObservable(this);
21
23
  }
22
24
 
23
- get currencySymbol() {
24
- return getCurrencySymbol(this.currency || "");
25
- }
26
-
27
25
  get finalPrice() {
28
26
  return IkasProductPriceFunctions.getFinalPrice(this);
29
27
  }
30
28
 
31
29
  get formattedFinalPrice() {
32
- return formatMoney(this.finalPrice, this.currencySymbol);
30
+ return formatCurrency(
31
+ this.finalPrice,
32
+ this.currency || "",
33
+ this.currencySymbol || ""
34
+ );
33
35
  }
34
36
 
35
37
  get formattedBuyPrice() {
36
- return formatMoney(this.buyPrice || 0, this.currencySymbol);
38
+ return formatCurrency(
39
+ this.buyPrice || 0,
40
+ this.currency || "",
41
+ this.currencySymbol || ""
42
+ );
37
43
  }
38
44
 
39
45
  get formattedDiscountPrice() {
40
- return formatMoney(this.discountPrice || 0, this.currencySymbol);
46
+ return formatCurrency(
47
+ this.discountPrice || 0,
48
+ this.currency || "",
49
+ this.currencySymbol || ""
50
+ );
41
51
  }
42
52
 
43
53
  get formattedSellPrice() {
44
- return formatMoney(this.sellPrice || 0, this.currencySymbol);
54
+ return formatCurrency(
55
+ this.sellPrice || 0,
56
+ this.currency || "",
57
+ this.currencySymbol || ""
58
+ );
45
59
  }
46
60
 
47
61
  get hasDiscount() {
@@ -8,6 +8,7 @@ import {
8
8
  IkasRaffleAppliedProduct as IRaffleAppliedProduct,
9
9
  IkasRaffleVerificationType,
10
10
  IkasRaffleMetadataTargetType,
11
+ IkasRaffleParticipantStatus,
11
12
  } from "@ikas/storefront-models";
12
13
  import { IkasRaffleFunctions } from "@ikas/storefront-model-functions";
13
14
 
@@ -33,13 +34,12 @@ export class IkasRaffle implements IRaffle {
33
34
  dateRange: IkasRaffleDateRangeField | null;
34
35
  metadata: IkasRaffleMetaData | null;
35
36
  name: string;
36
- participantCount?: number | null;
37
37
  requiredCustomerAccount: boolean;
38
38
  status: boolean;
39
39
  variants: IkasRaffleAppliedProduct[] | null;
40
- products: IkasProduct[];
41
40
  verificationType: IkasRaffleVerificationType;
42
- isCustomerWinner: boolean | null;
41
+
42
+ products: IkasProduct[];
43
43
 
44
44
  constructor(data: Partial<IkasRaffle> = {}) {
45
45
  this.id = data.id || Date.now() + "";
@@ -47,12 +47,10 @@ export class IkasRaffle implements IRaffle {
47
47
  this.updatedAt = data.updatedAt || Date.now();
48
48
  this.deleted = data.deleted || null;
49
49
  this.name = data.name || "";
50
- this.participantCount = data.participantCount || 0;
51
50
  this.requiredCustomerAccount = data.requiredCustomerAccount || false;
52
51
  this.status = data.status || false;
53
52
  this.verificationType =
54
53
  data.verificationType || IkasRaffleVerificationType.EMAIL;
55
- this.isCustomerWinner = data.isCustomerWinner || null;
56
54
 
57
55
  this.dateRange = data.dateRange
58
56
  ? new IkasRaffleDateRangeField(data.dateRange)
@@ -113,8 +111,10 @@ export class IkasRaffleParticipant implements IRaffleParticipant {
113
111
  email: string;
114
112
  applicationDate: number;
115
113
  phone: string | null = null;
116
- isWinner: boolean | null = null;
114
+ isDeliveredCargo: boolean | null;
117
115
 
116
+ raffle: IkasRaffle;
117
+ status: IkasRaffleParticipantStatus | null;
118
118
  extraData: Record<string, any> | null = null;
119
119
  appliedProduct: IkasRaffleAppliedProduct;
120
120
 
@@ -131,8 +131,10 @@ export class IkasRaffleParticipant implements IRaffleParticipant {
131
131
  this.email = data.email || "";
132
132
  this.applicationDate = data.applicationDate || 0;
133
133
  this.phone = data.phone || null;
134
- this.isWinner = data.isWinner || null;
134
+ this.isDeliveredCargo = data.isDeliveredCargo || false;
135
135
 
136
+ this.raffle = new IkasRaffle(data.raffle);
137
+ this.status = data.status || null;
136
138
  this.extraData = data.extraData || {};
137
139
  this.appliedProduct = new IkasRaffleAppliedProduct(
138
140
  data.appliedProduct || {}
@@ -75,7 +75,7 @@ export class IkasRaffleList {
75
75
  }
76
76
 
77
77
  private async getRaffleList(page: number, limit: number) {
78
- const response = await RaffleStore.listRaffle({
78
+ const response = await RaffleStore.listStorefrontRaffle({
79
79
  start: this._start ? { eq: this._start } : undefined,
80
80
  end: this._end ? { eq: this._end } : undefined,
81
81
  includeDeleted: this._includeDeleted || false,
@@ -24,6 +24,7 @@ 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";
27
28
 
28
29
  const isServer = typeof localStorage === "undefined";
29
30
  const LS_TOKEN_KEY = "customerToken";
@@ -403,22 +404,11 @@ export class IkasCustomerStore {
403
404
  };
404
405
 
405
406
  getRaffles = async () => {
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);
407
+ const rafflesResponse = await RaffleStore.listRaffleParticipants();
408
+ let raffles: IkasRaffle[] = [];
409
+ if (!rafflesResponse.data?.length) return raffles;
410
+ raffles = rafflesResponse.data;
411
+ if (raffles.length) await populateRaffleProducts(raffles);
422
412
  return raffles || [];
423
413
  };
424
414
 
@@ -1,11 +1,10 @@
1
1
  import { APIResponse } from "@ikas/fe-api-client";
2
2
  import {
3
- getRafflesByCustomerId,
4
- GetRafflesByCustomerIdQueryParams,
5
- listRaffle,
3
+ listRaffleParticipants,
4
+ listStorefrontRaffle,
6
5
  listRaffleMetaData,
7
6
  ListRaffleMetadataQueryParams,
8
- ListRaffleQueryParams,
7
+ ListStorefrontRaffleParams,
9
8
  saveRaffleParticipant,
10
9
  SaveRaffleParticipantQueryParams,
11
10
  } from "@ikas/storefront-api";
@@ -16,8 +15,8 @@ import {
16
15
  } from "../../models/data/raffle";
17
16
 
18
17
  export default class RaffleStore {
19
- static async listRaffle(params: ListRaffleQueryParams) {
20
- const response = await listRaffle(params);
18
+ static async listStorefrontRaffle(params: ListStorefrontRaffleParams) {
19
+ const response = await listStorefrontRaffle(params);
21
20
  return new APIResponse({
22
21
  ...response.data,
23
22
  data: response.data?.data?.map(
@@ -46,10 +45,8 @@ export default class RaffleStore {
46
45
  );
47
46
  }
48
47
 
49
- static async getRafflesByCustomerId(
50
- params: GetRafflesByCustomerIdQueryParams
51
- ) {
52
- const response = await getRafflesByCustomerId(params);
48
+ static async listRaffleParticipants() {
49
+ const response = await listRaffleParticipants();
53
50
  return new APIResponse(
54
51
  response.data?.map((d) => new IkasRaffle(d as unknown as IkasRaffle)),
55
52
  response.graphQLErrors
@@ -13,14 +13,19 @@ 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 Code for the currency, USD, EUR, TRY, etc..
16
+ * @param currencyCode Currency code
17
+ * @param currencySymbol Symbol for the currency
17
18
  */
18
- export const formatMoney = (price: number, currencyCode: string) => {
19
+ export const formatCurrency = (
20
+ price: number,
21
+ currencyCode: string,
22
+ currencySymbol: string | null
23
+ ) => {
19
24
  const formatSettings =
20
25
  IkasStorefrontConfig.getMerchantSettings()?.currencyFormats?.find(
21
26
  (s) => s.currencyCode === currencyCode
22
27
  );
23
- const symbol = formatSettings?.symbol || getCurrencySymbol(currencyCode);
28
+ const symbol = formatSettings?.symbol || currencySymbol || "";
24
29
  const decimalSeparator = formatSettings?.decimalSeparator || ".";
25
30
  const thousandSeparator = formatSettings?.thousandSeparator || ",";
26
31
  const symbolPosition = formatSettings?.symbolPosition || "LEFT";
@@ -62,189 +67,10 @@ export const formatMoney = (price: number, currencyCode: string) => {
62
67
  IkasStorefrontConfig.getCurrentLocale(),
63
68
  {
64
69
  style: "currency",
65
- currency: currencyCode || "TRY",
70
+ currency: currencySymbol || "TRY",
66
71
  }
67
72
  );
68
73
 
69
74
  return formatter.format(price);
70
75
  }
71
76
  };
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
- };