@akinon/pz-masterpass 1.50.0 → 1.52.0

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,13 @@
1
1
  # @akinon/pz-masterpass
2
2
 
3
+ ## 1.52.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 50b9069: ZERO-2767: update plugin readme files
8
+
9
+ ## 1.51.0
10
+
3
11
  ## 1.50.0
4
12
 
5
13
  ## 1.49.0
package/README.md CHANGED
@@ -1,4 +1,14 @@
1
- # pz-masterpass
1
+ # @akinon/pz-masterpass
2
+
3
+ ### Install the npm package
4
+
5
+ ```bash
6
+ # For latest version
7
+ yarn add @akinon/pz-masterpass
8
+
9
+ # Preferred installation method
10
+ npx @akinon/projectzero@latest --plugins
11
+ ```
2
12
 
3
13
  ## Available Props
4
14
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akinon/pz-masterpass",
3
- "version": "1.50.0",
3
+ "version": "1.52.0",
4
4
  "license": "MIT",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.d.ts",
@@ -41,16 +41,15 @@ export const MasterpassCardRegistration = ({
41
41
  translations?: typeof defaultTranslations;
42
42
  }) => {
43
43
  const { preOrder } = useAppSelector((state: RootState) => state.checkout);
44
- const { msisdn, token, language, otp, isDirectPurchase } = useAppSelector(
45
- (state) => state.masterpass
46
- );
44
+ const { msisdn, token, language, otp, isDirectPurchase, accountStatus } =
45
+ useAppSelector((state) => state.masterpass);
47
46
 
48
47
  const [isInfoModalOpen, setIsInfoModalOpen] = useState(false);
49
48
  const [isAgreementChecked, setIsAgreementChecked] = useState(false);
50
49
  const [accountAliasName, setAccountAliasName] = useState('');
51
50
  const [formError, setFormError] = useState<string | null>(null);
52
51
  const [isBusy, setIsBusy] = useState(false);
53
- const { refreshCards } = useCards();
52
+ const { refreshCards, cards } = useCards();
54
53
 
55
54
  const dispatch = useAppDispatch();
56
55
 
@@ -153,6 +152,14 @@ export const MasterpassCardRegistration = ({
153
152
  }
154
153
  }, [otp.response]);
155
154
 
155
+ useEffect(() => {
156
+ if (cards && cards.length !== 0) {
157
+ dispatch(setAccountStatus(MasterpassStatus.ListCards));
158
+ } else {
159
+ dispatch(setAccountStatus(MasterpassStatus.NoAccount));
160
+ }
161
+ }, [cards]);
162
+
156
163
  if (
157
164
  preOrder.payment_option?.payment_type !== 'masterpass' ||
158
165
  !isDirectPurchase ||
@@ -251,18 +258,22 @@ export const MasterpassCardRegistration = ({
251
258
  </div>
252
259
  </div>
253
260
 
254
- <a
255
- href="#"
256
- className="block text-xs underline mt-5"
257
- onClick={(e) => {
258
- e.preventDefault();
259
- dispatch(setIsDirectPurchase(false));
260
- dispatch(setInstallmentOptions([]));
261
- }}
262
- >
263
- {translations?.pay_with_my_masterpass_card ??
264
- defaultTranslations.pay_with_my_masterpass_card}
265
- </a>
261
+ {accountStatus !== MasterpassStatus.NoAccount &&
262
+ cards &&
263
+ cards.length !== 0 && (
264
+ <a
265
+ href="#"
266
+ className="block text-xs underline mt-5"
267
+ onClick={(e) => {
268
+ e.preventDefault();
269
+ dispatch(setIsDirectPurchase(false));
270
+ dispatch(setInstallmentOptions([]));
271
+ }}
272
+ >
273
+ {translations?.pay_with_my_masterpass_card ??
274
+ defaultTranslations.pay_with_my_masterpass_card}
275
+ </a>
276
+ )}
266
277
  </div>
267
278
  );
268
279
  };