@akinon/projectzero 1.101.0-rc.73 → 1.101.0-rc.74

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/CHANGELOG.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # @akinon/projectzero
2
2
 
3
+ ## 1.101.0-rc.74
4
+
3
5
  ## 1.101.0-rc.73
4
6
 
5
7
  ### Minor Changes
@@ -1,5 +1,33 @@
1
1
  # projectzeronext
2
2
 
3
+ ## 1.101.0-rc.74
4
+
5
+ ### Minor Changes
6
+
7
+ - e9e902b: ZERO-3650: Add Loyalty
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [a2fbee6]
12
+ - @akinon/next@1.101.0-rc.74
13
+ - @akinon/pz-akifast@1.101.0-rc.74
14
+ - @akinon/pz-b2b@1.101.0-rc.74
15
+ - @akinon/pz-basket-gift-pack@1.101.0-rc.74
16
+ - @akinon/pz-bkm@1.101.0-rc.74
17
+ - @akinon/pz-checkout-gift-pack@1.101.0-rc.74
18
+ - @akinon/pz-click-collect@1.101.0-rc.74
19
+ - @akinon/pz-credit-payment@1.101.0-rc.74
20
+ - @akinon/pz-gpay@1.101.0-rc.74
21
+ - @akinon/pz-hepsipay@1.101.0-rc.74
22
+ - @akinon/pz-masterpass@1.101.0-rc.74
23
+ - @akinon/pz-one-click-checkout@1.101.0-rc.74
24
+ - @akinon/pz-otp@1.101.0-rc.74
25
+ - @akinon/pz-pay-on-delivery@1.101.0-rc.74
26
+ - @akinon/pz-saved-card@1.101.0-rc.74
27
+ - @akinon/pz-similar-products@1.101.0-rc.74
28
+ - @akinon/pz-tabby-extension@1.101.0-rc.74
29
+ - @akinon/pz-tamara-extension@1.101.0-rc.74
30
+
3
31
  ## 1.101.0-rc.73
4
32
 
5
33
  ### Minor Changes
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "projectzeronext",
3
- "version": "1.101.0-rc.73",
3
+ "version": "1.101.0-rc.74",
4
4
  "private": true,
5
5
  "license": "MIT",
6
6
  "scripts": {
@@ -24,22 +24,24 @@
24
24
  "test:middleware": "jest middleware-matcher.test.ts --bail"
25
25
  },
26
26
  "dependencies": {
27
- "@akinon/next": "1.101.0-rc.73",
28
- "@akinon/pz-akifast": "1.101.0-rc.73",
29
- "@akinon/pz-b2b": "1.101.0-rc.73",
30
- "@akinon/pz-basket-gift-pack": "1.101.0-rc.73",
31
- "@akinon/pz-bkm": "1.101.0-rc.73",
32
- "@akinon/pz-checkout-gift-pack": "1.101.0-rc.73",
33
- "@akinon/pz-click-collect": "1.101.0-rc.73",
34
- "@akinon/pz-credit-payment": "1.101.0-rc.73",
35
- "@akinon/pz-gpay": "1.101.0-rc.73",
36
- "@akinon/pz-masterpass": "1.101.0-rc.73",
37
- "@akinon/pz-one-click-checkout": "1.101.0-rc.73",
38
- "@akinon/pz-otp": "1.101.0-rc.73",
39
- "@akinon/pz-pay-on-delivery": "1.101.0-rc.73",
40
- "@akinon/pz-saved-card": "1.101.0-rc.73",
41
- "@akinon/pz-tabby-extension": "1.101.0-rc.73",
42
- "@akinon/pz-tamara-extension": "1.101.0-rc.73",
27
+ "@akinon/next": "1.101.0-rc.74",
28
+ "@akinon/pz-akifast": "1.101.0-rc.74",
29
+ "@akinon/pz-b2b": "1.101.0-rc.74",
30
+ "@akinon/pz-basket-gift-pack": "1.101.0-rc.74",
31
+ "@akinon/pz-bkm": "1.101.0-rc.74",
32
+ "@akinon/pz-checkout-gift-pack": "1.101.0-rc.74",
33
+ "@akinon/pz-click-collect": "1.101.0-rc.74",
34
+ "@akinon/pz-credit-payment": "1.101.0-rc.74",
35
+ "@akinon/pz-gpay": "1.101.0-rc.74",
36
+ "@akinon/pz-hepsipay": "1.101.0-rc.74",
37
+ "@akinon/pz-masterpass": "1.101.0-rc.74",
38
+ "@akinon/pz-one-click-checkout": "1.101.0-rc.74",
39
+ "@akinon/pz-otp": "1.101.0-rc.74",
40
+ "@akinon/pz-pay-on-delivery": "1.101.0-rc.74",
41
+ "@akinon/pz-saved-card": "1.101.0-rc.74",
42
+ "@akinon/pz-similar-products": "1.101.0-rc.74",
43
+ "@akinon/pz-tabby-extension": "1.101.0-rc.74",
44
+ "@akinon/pz-tamara-extension": "1.101.0-rc.74",
43
45
  "@hookform/resolvers": "2.9.0",
44
46
  "@next/third-parties": "14.1.0",
45
47
  "@react-google-maps/api": "2.17.1",
@@ -62,7 +64,7 @@
62
64
  "yup": "0.32.11"
63
65
  },
64
66
  "devDependencies": {
65
- "@akinon/eslint-plugin-projectzero": "1.101.0-rc.73",
67
+ "@akinon/eslint-plugin-projectzero": "1.101.0-rc.74",
66
68
  "@semantic-release/changelog": "6.0.2",
67
69
  "@semantic-release/exec": "6.0.3",
68
70
  "@semantic-release/git": "10.0.1",
@@ -37,6 +37,7 @@
37
37
  "subtotal": "Subtotal",
38
38
  "shipping": "Shipping",
39
39
  "discounts_total": "Discounts Total",
40
+ "loyalty_money_total": "Loyalty Money Total",
40
41
  "total": "Total",
41
42
  "delivery_info": "Delivery Info",
42
43
  "change": "change",
@@ -138,6 +139,11 @@
138
139
  "payments": "Payments",
139
140
  "per_month": "Per Month",
140
141
  "total": "Total"
142
+ },
143
+ "store_credit": {
144
+ "use_my_store_credits": "Use my pz-zero credits",
145
+ "available_balance": "Available Balance",
146
+ "insufficient_balance": "Your pz-zero credits are not sufficient to pay for the order, please select an additional payment method to cover the balance of <Amount/>"
141
147
  }
142
148
  },
143
149
  "agreement": {
@@ -37,6 +37,7 @@
37
37
  "subtotal": "Ara toplam",
38
38
  "shipping": "Kargo",
39
39
  "discounts_total": "İndirimler Toplamı",
40
+ "loyalty_money_total": "Sadakat Parası Toplamı",
40
41
  "total": "Toplam",
41
42
  "delivery_info": "Teslimat Bilgileri",
42
43
  "change": "değiştir",
@@ -138,6 +139,11 @@
138
139
  "payments": "Ödemeler",
139
140
  "per_month": "Her ay",
140
141
  "total": "Toplam"
142
+ },
143
+ "store_credit": {
144
+ "use_my_store_credits": "pz-zero kredilerimi kullan",
145
+ "available_balance": "Mevcut Bakiyem",
146
+ "insufficient_balance": "pz-zero kredileriniz siparişi ödemek için yeterli değil, lütfen <Amount/> tutarını karşılamak için ek bir ödeme yöntemi seçin."
141
147
  }
142
148
  },
143
149
  "agreement": {
@@ -56,7 +56,7 @@ export const Price = (props: NumericFormatProps & PriceProps) => {
56
56
 
57
57
  const currentCurrencyDecimalScale = Settings.localization.currencies.find(
58
58
  (currency) => currency.code === currencyCode_
59
- ).decimalScale;
59
+ )?.decimalScale;
60
60
 
61
61
  return (
62
62
  <NumericFormat
@@ -0,0 +1,121 @@
1
+ import clsx from 'clsx';
2
+ import {
3
+ useGetCheckoutLoyaltyBalanceQuery,
4
+ usePayWithLoyaltyBalanceMutation
5
+ } from '@akinon/next/data/client/checkout';
6
+ import { useAppSelector } from '@akinon/next/redux/hooks';
7
+ import { useMemo, useState } from 'react';
8
+ import { useLocalization } from '@akinon/next/hooks';
9
+ import { twMerge } from 'tailwind-merge';
10
+ import { Icon, Price } from '@theme/components';
11
+ import { Trans } from '@akinon/next/components';
12
+ import { LoaderSpinner } from '@theme/components';
13
+
14
+ export const StoreCredits = () => {
15
+ const { t } = useLocalization();
16
+
17
+ const [payWithLoyaltyBalance, { isLoading: isPayWithLoyaltyBalanceLoading }] =
18
+ usePayWithLoyaltyBalanceMutation();
19
+
20
+ const { loyaltyBalance, preOrder } = useAppSelector(
21
+ (state) => state.checkout
22
+ );
23
+
24
+ const { isLoading: isLoyaltyBalanceLoading } =
25
+ useGetCheckoutLoyaltyBalanceQuery(undefined, {
26
+ refetchOnMountOrArgChange: true,
27
+ skip: !preOrder?.payment_option
28
+ });
29
+
30
+ const isLoyaltyBalanceUsed = useMemo(() => {
31
+ return parseFloat(preOrder?.loyalty_money ?? '0') > 0;
32
+ }, [preOrder?.loyalty_money]);
33
+
34
+ const [isLoading, setIsLoading] = useState(false);
35
+
36
+ const handleClick = async () => {
37
+ if (isLoading) return;
38
+ setIsLoading(true);
39
+
40
+ try {
41
+ await payWithLoyaltyBalance(isLoyaltyBalanceUsed ? '0' : loyaltyBalance);
42
+ } finally {
43
+ setIsLoading(false);
44
+ }
45
+ };
46
+
47
+ if (preOrder?.is_guest) {
48
+ return null;
49
+ }
50
+
51
+ if (isLoyaltyBalanceLoading) {
52
+ return (
53
+ <div className="mb-3 px-4 py-3 xs:px-0">
54
+ <LoaderSpinner />
55
+ </div>
56
+ );
57
+ }
58
+
59
+ if (parseFloat(loyaltyBalance) <= 0) {
60
+ return null;
61
+ }
62
+ return (
63
+ <div
64
+ className={twMerge(
65
+ 'hidden flex-col w-full mb-4 border border-solid border-gray-400 px-0 md:p-4',
66
+ isPayWithLoyaltyBalanceLoading && 'pointer-events-none opacity-30',
67
+ parseFloat(loyaltyBalance) > 0 && 'block'
68
+ )}
69
+ >
70
+ <div className="flex w-full items-center">
71
+ <button onClick={handleClick}>
72
+ <span
73
+ className={clsx(
74
+ 'flex h-5 w-5 items-center justify-center rounded border border-solid border-primary',
75
+ isLoyaltyBalanceUsed ? 'bg-primary' : 'bg-white'
76
+ )}
77
+ >
78
+ <Icon
79
+ name={isLoyaltyBalanceUsed ? 'check' : ''}
80
+ size={10}
81
+ className={clsx({ 'text-white': isLoyaltyBalanceUsed })}
82
+ />
83
+ </span>
84
+ </button>
85
+
86
+ <div className="w-full pl-4">
87
+ <p className="cursor-pointer text-sm" onClick={handleClick}>
88
+ {t('checkout.payment.store_credit.use_my_store_credits')}
89
+ </p>
90
+ <p className="flex text-sm text-[#606060]">
91
+ {t('checkout.payment.store_credit.available_balance')}:
92
+ <Price
93
+ value={loyaltyBalance}
94
+ currencyCode={preOrder?.currency_type_label}
95
+ className="pe-1 font-bold"
96
+ />
97
+ </p>
98
+ </div>
99
+ </div>
100
+
101
+ {isLoyaltyBalanceUsed && parseFloat(preOrder?.unpaid_amount) > 0 && (
102
+ <p className="my-4 text-[15px] font-light italic text-[#707070] max-xs:text-xs">
103
+ <Trans
104
+ i18nKey="checkout.payment.store_credit.insufficient_balance"
105
+ components={{
106
+ Amount: (
107
+ <div className="inline-flex">
108
+ <Price
109
+ value={preOrder?.unpaid_amount}
110
+ currencyCode={preOrder?.currency_type_label}
111
+ className="text-primary"
112
+ />
113
+ </div>
114
+ )
115
+ }}
116
+ />
117
+ </p>
118
+ )}
119
+ </div>
120
+ );
121
+ };
@@ -8,6 +8,7 @@ import PluginModule, { Component } from '@akinon/next/components/plugin-module';
8
8
  import { twMerge } from 'tailwind-merge';
9
9
  import { Image } from '@akinon/next/components/image';
10
10
  import { Trans } from '@akinon/next/components/trans';
11
+ import { StoreCredits } from './steps/payment/options/store-credit';
11
12
 
12
13
  export const Summary = () => {
13
14
  const { t } = useLocalization();
@@ -38,6 +39,7 @@ export const Summary = () => {
38
39
  'flex flex-col w-full mb-4 border border-solid border-gray-400'
39
40
  }}
40
41
  />
42
+ <StoreCredits />
41
43
  <div className="flex flex-col w-full border border-solid border-gray-400">
42
44
  <div className="flex justify-between items-center flex-row border-b border-solid border-gray-400 px-4 py-2 sm:px-5 sm:py-4 sm:min-h-15">
43
45
  <span className="text-black-800 text-xl font-light sm:text-2xl">
@@ -118,6 +120,14 @@ export const Summary = () => {
118
120
  <Price value={preOrder?.shipping_amount} />
119
121
  </span>
120
122
  </div>
123
+ {parseFloat(preOrder?.loyalty_money) > 0 && (
124
+ <div className="flex items-center justify-between w-full text-xs text-black-800 py-1 px-4 sm:px-5">
125
+ <span>{t('checkout.summary.loyalty_money_total')}</span>
126
+ <span>
127
+ <Price value={preOrder?.loyalty_money} />
128
+ </span>
129
+ </div>
130
+ )}
121
131
  <div className="flex items-center justify-between w-full text-xs text-black-800 py-1 px-4 sm:px-5">
122
132
  <span>{t('checkout.summary.discounts_total')}</span>
123
133
  <span>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akinon/projectzero",
3
- "version": "1.101.0-rc.73",
3
+ "version": "1.101.0-rc.74",
4
4
  "private": false,
5
5
  "description": "CLI tool to manage your Project Zero Next project",
6
6
  "bin": {