@akinon/pz-otp 1.23.0-rc.5 → 1.23.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-otp
2
2
 
3
- ## 1.23.0-rc.5
4
-
5
- ## 1.23.0-rc.4
6
-
7
- ## 1.23.0-rc.3
8
-
9
- ## 1.23.0-rc.2
10
-
11
- ## 1.23.0-rc.1
12
-
13
- ## 1.23.0-rc.0
14
-
15
- ### Minor Changes
16
-
17
- - 0181251: ZERO-2440: move otp popup state to redux
3
+ ## 1.23.0
18
4
 
19
5
  ## 1.22.0
20
6
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akinon/pz-otp",
3
- "version": "1.23.0-rc.5",
3
+ "version": "1.23.0",
4
4
  "license": "MIT",
5
5
  "main": "src/index.tsx",
6
6
  "peerDependencies": {
package/src/index.tsx CHANGED
@@ -1,4 +1 @@
1
- import otpReducer from './redux/reducer';
2
-
3
1
  export * from './views/Otp';
4
- export { otpReducer };
package/src/views/Otp.tsx CHANGED
@@ -1,10 +1,9 @@
1
1
  import { FormEvent, ReactNode, useEffect, useState } from 'react';
2
+ import { useRouter } from '@akinon/next/hooks';
2
3
  import { Button } from '@akinon/next/components/button';
3
4
  import OtpInput from 'react-otp-input';
4
5
  import { SubmitHandler } from 'react-hook-form';
5
6
  import { twMerge } from 'tailwind-merge';
6
- import { useAppDispatch } from '@akinon/next/redux/hooks';
7
- import { hidePopup } from '../redux/reducer';
8
7
 
9
8
  enum Component {
10
9
  Title = 'title',
@@ -22,14 +21,15 @@ enum ComponentWrapper {
22
21
  Otp = 'otp'
23
22
  }
24
23
 
25
- type ComponentClassKey = typeof Component[keyof typeof Component];
24
+ type ComponentClassKey = (typeof Component)[keyof typeof Component];
26
25
  type ComponentWrapperClassKey =
27
- `${typeof ComponentWrapper[keyof typeof ComponentWrapper]}Wrapper`;
26
+ `${(typeof ComponentWrapper)[keyof typeof ComponentWrapper]}Wrapper`;
28
27
  type ComponentClasses = ComponentClassKey | ComponentWrapperClassKey;
29
28
 
30
29
  type OtpProps = {
31
30
  codeLength?: number;
32
31
  timer?: number;
32
+ setShowPopup: any;
33
33
  submitAction: SubmitHandler<{
34
34
  [key: string]: any;
35
35
  }>;
@@ -49,14 +49,16 @@ export const Otp = ({
49
49
  data,
50
50
  codeLength = 6,
51
51
  timer = 60,
52
+ setShowPopup,
52
53
  texts,
53
54
  classes
54
55
  }: OtpProps) => {
56
+ const router = useRouter();
57
+
55
58
  const [otp, setOtp] = useState('');
56
59
  const [canResend, setCanResend] = useState(false);
57
60
  const [time, setTime] = useState(timer);
58
61
  const [hasError, setHasError] = useState(false);
59
- const dispatch = useAppDispatch();
60
62
 
61
63
  const resetTimer = () => {
62
64
  setTime(timer);
@@ -77,7 +79,9 @@ export const Otp = ({
77
79
  };
78
80
 
79
81
  const closeHandler = () => {
80
- dispatch(hidePopup());
82
+ if (setShowPopup) {
83
+ setShowPopup(false);
84
+ }
81
85
  };
82
86
 
83
87
  const resendHandler = async () => {
@@ -101,9 +105,9 @@ export const Otp = ({
101
105
  }, 1000);
102
106
 
103
107
  return () => clearInterval(timerId);
108
+ } else {
109
+ onTimerEnd();
104
110
  }
105
-
106
- onTimerEnd();
107
111
  }, [time, onTimerEnd]);
108
112
 
109
113
  useEffect(() => {
@@ -113,7 +117,7 @@ export const Otp = ({
113
117
  return () => {
114
118
  document.body.style.overflow = 'auto';
115
119
  };
116
- }, []);
120
+ });
117
121
 
118
122
  return (
119
123
  <div className="fixed left-0 top-0 z-50 flex h-screen w-screen items-end md:items-center md:justify-center md:bg-black/10">
@@ -1,26 +0,0 @@
1
- import { createSlice } from '@reduxjs/toolkit';
2
-
3
- export interface OtpState {
4
- isPopupVisible: boolean;
5
- }
6
-
7
- const initialState: OtpState = {
8
- isPopupVisible: false
9
- };
10
-
11
- const otpSlice = createSlice({
12
- name: 'otp',
13
- initialState,
14
- reducers: {
15
- showPopup(state) {
16
- state.isPopupVisible = true;
17
- },
18
- hidePopup(state) {
19
- state.isPopupVisible = false;
20
- }
21
- }
22
- });
23
-
24
- export const { showPopup, hidePopup } = otpSlice.actions;
25
-
26
- export default otpSlice.reducer;