@akinon/pz-masterpass 1.104.0-rc.83 → 1.104.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,20 +1,6 @@
1
1
  # @akinon/pz-masterpass
2
2
 
3
- ## 1.104.0-rc.83
4
-
5
- ### Minor Changes
6
-
7
- - d8be48fb: ZERO-3422: Update fetch method to use dynamic request method in wallet complete redirection middleware
8
- - 16aff543: ZERO-3431: Add test script for redirect utility in package.json
9
- - 64699d3ff: ZERO-2761: Fix invalid import for plugin module
10
- - e974d8e8: ZERO-3406: Fix rc build
11
- - 7eb51ca9: ZERO-3424 :Update package versions
12
- - 7727ae55: ZERO-3073: Refactor basket page to use server-side data fetching and simplify component structure
13
- - 8b1d24eb: ZERO-3422: Update fetch method to use dynamic request method in wallet complete redirection middleware
14
- - 33377cfd: ZERO-3267: Refactor import statement for ROUTES in error-page component
15
- - 08c3caec: ZERO-3607 :Enhance the DeleteButton component with additional features and improve the OTP modal functionality by adding minutes and seconds
16
- - 33d4d0c: ZERO-3615: remove custom not found
17
- - e9af4e24: ZERO-3607 :Enhance the DeleteButton component with additional features and improve the OTP modal functionality by adding minutes and seconds
3
+ ## 1.104.0
18
4
 
19
5
  ## 1.103.0
20
6
 
@@ -55,8 +41,6 @@
55
41
 
56
42
  ## 1.91.0
57
43
 
58
- > > > > > > > origin/ZERO-3418
59
-
60
44
  ## 1.90.0
61
45
 
62
46
  ## 1.89.0
package/README.md CHANGED
@@ -188,73 +188,77 @@ npx @akinon/projectzero@latest --plugins
188
188
  resendSms,
189
189
  resendSmsFetching,
190
190
  targetDate,
191
- otpRef,
192
- minutes,
193
- seconds,
194
- control,
195
- formError
191
+ otpRef
196
192
  }) => {
197
193
  const [code, setCode] = useState('');
194
+ const [remainingSeconds, setRemainingSeconds] = useState(
195
+ Math.ceil((targetDate - Date.now()) / 1000)
196
+ );
197
+ useEffect(() => {
198
+ if (!targetDate) return;
199
+ const interval = setInterval(() => {
200
+ const secondsLeft = Math.ceil((targetDate - Date.now()) / 1000);
201
+ setRemainingSeconds(secondsLeft);
202
+ if (secondsLeft <= 0) {
203
+ clearInterval(interval);
204
+ }
205
+ }, 1000);
206
+ return () => clearInterval(interval);
207
+ }, [targetDate]);
198
208
  return (
199
209
  <Modal
200
- portalId="otp-masterpass"
201
210
  open={open}
202
211
  setOpen={setOpen}
203
- className="w-[330px] bottom-auto top-1/4 mx-auto px-0 pb-0 md:pb-0 md:rounded-none md:pt-0 md:px-0 md:bottom-auto"
204
- iconSize={20}
212
+ className="w-full sm:w-[28rem]"
213
+ portalId="otp-masterpass"
205
214
  >
206
- <div className="py-4 px-14 pt-12 pb-9 flex flex-col justify-center items-center">
207
- <div className="text-lg leading-5 font-semibold text-secondary text-center pb-7">
208
- Telefon doğrulama kodunu gir
209
- </div>
215
+ <div className="px-6 py-4">
216
+ <h2 className="text-center text-xl text-primary-600 font-semibold">
217
+ Verification Required
218
+ </h2>
210
219
  <form
211
220
  onSubmit={(e) => {
212
221
  e.preventDefault();
213
222
  onSubmit({ otp_code: code });
214
223
  }}
224
+ className="flex flex-col items-center mt-4"
215
225
  >
216
- <div className="mt-2 flex flex-col items-center justify-between">
217
- <div>
218
- <label className="text-xs leading-[14px] font-normal text-secondary">
219
- SMS kodu
220
- </label>
221
- <Input
222
- id="otp_code"
223
- autoComplete="off"
224
- minLength={6}
225
- maxLength={6}
226
- max="999999"
227
- min="000000"
228
- control={control}
229
- className="h-9 rounded-full border-gray-620 mt-2"
230
- onChange={(e) =>
231
- setCode((e.target as HTMLInputElement).value)
232
- }
233
- />
234
- </div>
235
- <Button className="w-full capitalize bg-secondary rounded-full text-base h-auto py-1.5 mt-2 border-none">
236
- Doğrula
237
- </Button>
238
- {formError && (
239
- <p className="mt-2 text-error text-xs text-center">
240
- {formError}
241
- </p>
242
- )}
243
- </div>
226
+ <label
227
+ htmlFor="otp_code"
228
+ className="text-sm mb-1 text-gray-700"
229
+ >
230
+ SMS Code
231
+ </label>
232
+ <input
233
+ id="otp_code"
234
+ maxLength={6}
235
+ value={code}
236
+ onChange={(e) => setCode(e.target.value)}
237
+ placeholder="••••••"
238
+ className="border p-2 rounded w-full max-w-[200px] text-center tracking-widest"
239
+ />
240
+ <Button
241
+ type="submit"
242
+ className="mt-4 px-4 py-2 bg-blue-600 text-black rounded"
243
+ >
244
+ Verify
245
+ </Button>
246
+ {error && <p className="mt-2 text-xs text-red-500">{error}</p>}
244
247
  </form>
245
- {minutes + seconds > 0 ? (
246
- <div className="flex mt-2 flex justify-center">
247
- {`0${minutes}`} :{' '}
248
- {`${seconds < 10 ? '0' : ''}${seconds}`}
249
- </div>
250
- ) : (
248
+ <div className="mt-2 flex justify-center text-sm text-gray-600">
249
+ {remainingSeconds > 0
250
+ ? `Time remaining: ${remainingSeconds} seconds`
251
+ : 'Time is up'}
252
+ </div>
253
+ <div className="mt-2 flex justify-center">
251
254
  <Button
252
- onClick={() => resendSms()}
253
- className="w-full capitalize bg-secondary rounded-full text-base h-auto py-1.5 mt-2 border-none text-white"
255
+ onClick={resendSms}
256
+ disabled={loading}
257
+ className="mt-4 text-sm underline text-secondary-500"
254
258
  >
255
- {!resendSmsFetching ? 'resend code' : <LoaderSpinner />}
259
+ {resendSmsFetching ? 'Code sent' : 'Resend SMS code'}
256
260
  </Button>
257
- )}
261
+ </div>
258
262
  </div>
259
263
  </Modal>
260
264
  );
@@ -433,11 +437,7 @@ npx @akinon/projectzero@latest --plugins
433
437
  <p className="text-xs text-gray-500">{card.Value1}</p>
434
438
  </div>
435
439
  </div>
436
- <DeleteButton
437
- cardAliasName={card.Name}
438
- content={<Icon name="close" size={12} />}
439
- className="mb-8"
440
- />
440
+ <DeleteButton cardAliasName={card.Name} />
441
441
  </div>
442
442
  </li>
443
443
  ),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akinon/pz-masterpass",
3
- "version": "1.104.0-rc.83",
3
+ "version": "1.104.0",
4
4
  "license": "MIT",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.d.ts",
@@ -3,20 +3,14 @@
3
3
  import { useAppDispatch, useAppSelector } from '@akinon/next/redux/hooks';
4
4
  import { Icon } from 'components';
5
5
  import { useCallback, useEffect, useMemo, useState } from 'react';
6
- import { twMerge } from 'tailwind-merge';
7
6
  import {
8
7
  setDeletionCardAliasName,
9
8
  setDeletionModalVisible
10
9
  } from '../redux/reducer';
10
+ import { CheckMasterpassResponse } from '../types';
11
11
  import { formCreator } from '../utils';
12
12
  import { useCards } from './use-cards';
13
13
 
14
- export type DeleteButtonProps = {
15
- cardAliasName: string;
16
- content?: JSX.Element;
17
- className?: string;
18
- };
19
-
20
14
  export const useDeleteCard = () => {
21
15
  const { msisdn, token, language, deletion } = useAppSelector(
22
16
  (state: any) => state.masterpass
@@ -73,27 +67,22 @@ export const useDeleteCard = () => {
73
67
 
74
68
  const DeleteButton = useMemo(
75
69
  () =>
76
- ({ cardAliasName, content, className }: DeleteButtonProps) => {
70
+ ({ cardAliasName }: { cardAliasName: string }) => {
77
71
  return (
78
72
  <span
79
- className={twMerge('cursor-pointer p-1', className)}
73
+ className="cursor-pointer p-1"
80
74
  onClick={(event: React.MouseEvent<HTMLElement>) => {
81
75
  event.stopPropagation();
82
76
  dispatch(setDeletionModalVisible(true));
83
77
  dispatch(setDeletionCardAliasName(cardAliasName));
84
78
  }}
85
79
  >
86
- {content ?? <Icon name="close" size={12} />}
80
+ <Icon name="close" size={12} />
87
81
  </span>
88
82
  );
89
83
  },
90
84
  []
91
85
  );
92
86
 
93
- return {
94
- DeleteButton,
95
- deleteCard,
96
- isLoading,
97
- error
98
- };
87
+ return { DeleteButton, deleteCard, isLoading, error };
99
88
  };
@@ -54,12 +54,7 @@ interface RendererProps {
54
54
  card: any;
55
55
  selectedCard: any;
56
56
  onSelect: (card: any) => Promise<void>;
57
- DeleteButton?: React.FC<{
58
- cardAliasName: string;
59
- onDelete: () => void;
60
- className?: string;
61
- content?: JSX.Element;
62
- }>;
57
+ DeleteButton?: React.FC<{ cardAliasName: string; onDelete: () => void }>;
63
58
  }) => JSX.Element;
64
59
  Loader?: () => JSX.Element;
65
60
  ErrorFallback?: (params: {
@@ -251,14 +246,12 @@ export const MasterpassCardList = ({
251
246
  className="mr-2"
252
247
  onChange={(e) => e.preventDefault()}
253
248
  />
254
-
255
249
  <label
256
250
  htmlFor={card.UniqueId}
257
251
  className="flex flex-col w-full cursor-pointer md:flex-row md:items-center md:justify-between"
258
252
  >
259
253
  <p className="w-full lg:w-1/3">{card.Name}</p>
260
254
  <p className="w-full text-[10px] lg:w-1/3">{card.Value1}</p>
261
-
262
255
  <Image
263
256
  className="w-8 h-6 object-contain flex items-center justify-center mr-4"
264
257
  width={50}
@@ -267,7 +260,6 @@ export const MasterpassCardList = ({
267
260
  alt={card.Name}
268
261
  />
269
262
  </label>
270
-
271
263
  <DeleteButton cardAliasName={card.Name} />
272
264
  </div>
273
265
  {cvcField}
@@ -12,7 +12,6 @@ import { OtpForm, OtpFormProps, defaultTranslations } from './otp-form';
12
12
  import { useAppDispatch, useAppSelector } from '@akinon/next/redux/hooks';
13
13
  import { setOtpModalVisible, setOtpResponse } from '../../redux/reducer';
14
14
  import { Image } from '@akinon/next/components/image';
15
- import { useCountdown } from '../../hooks/use-countdown';
16
15
 
17
16
  export interface MasterpassOtpModalProps {
18
17
  translations?: {
@@ -29,8 +28,6 @@ export interface MasterpassOtpModalProps {
29
28
  resendSmsFetching: boolean;
30
29
  targetDate: number;
31
30
  otpRef: string | null;
32
- minutes?: number;
33
- seconds?: number;
34
31
  }) => JSX.Element;
35
32
  };
36
33
  }
@@ -129,8 +126,6 @@ export const MasterpassOtpModal = ({
129
126
  }, [isModalOpen]);
130
127
 
131
128
  if (renderer.Content) {
132
- const [minutes, seconds] = useCountdown(new Date(otpTime));
133
-
134
129
  return (
135
130
  <renderer.Content
136
131
  open={isModalOpen}
@@ -142,8 +137,6 @@ export const MasterpassOtpModal = ({
142
137
  resendSmsFetching={isBusy}
143
138
  targetDate={otpTime}
144
139
  otpRef={otpRef}
145
- minutes={minutes}
146
- seconds={seconds}
147
140
  />
148
141
  );
149
142
  }