@akinon/pz-otp 1.28.0-rc.1 → 1.29.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 +4 -2
- package/package.json +1 -1
- package/src/views/Otp.tsx +7 -4
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
package/src/views/Otp.tsx
CHANGED
|
@@ -22,9 +22,9 @@ enum ComponentWrapper {
|
|
|
22
22
|
Otp = 'otp'
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
type ComponentClassKey = typeof Component[keyof typeof Component];
|
|
25
|
+
type ComponentClassKey = (typeof Component)[keyof typeof Component];
|
|
26
26
|
type ComponentWrapperClassKey =
|
|
27
|
-
`${typeof ComponentWrapper[keyof typeof ComponentWrapper]}Wrapper`;
|
|
27
|
+
`${(typeof ComponentWrapper)[keyof typeof ComponentWrapper]}Wrapper`;
|
|
28
28
|
type ComponentClasses = ComponentClassKey | ComponentWrapperClassKey;
|
|
29
29
|
|
|
30
30
|
type OtpProps = {
|
|
@@ -42,6 +42,7 @@ type OtpProps = {
|
|
|
42
42
|
classes?: {
|
|
43
43
|
[c in ComponentClasses]?: string;
|
|
44
44
|
};
|
|
45
|
+
error?: string;
|
|
45
46
|
};
|
|
46
47
|
|
|
47
48
|
export const Otp = ({
|
|
@@ -50,7 +51,8 @@ export const Otp = ({
|
|
|
50
51
|
codeLength = 6,
|
|
51
52
|
timer = 60,
|
|
52
53
|
texts,
|
|
53
|
-
classes
|
|
54
|
+
classes,
|
|
55
|
+
error
|
|
54
56
|
}: OtpProps) => {
|
|
55
57
|
const [otp, setOtp] = useState('');
|
|
56
58
|
const [canResend, setCanResend] = useState(false);
|
|
@@ -70,7 +72,7 @@ export const Otp = ({
|
|
|
70
72
|
data.code = otp;
|
|
71
73
|
const res = await submitAction(data);
|
|
72
74
|
|
|
73
|
-
if (res
|
|
75
|
+
if (res?.status !== 200 || error) {
|
|
74
76
|
setHasError(true);
|
|
75
77
|
}
|
|
76
78
|
}
|
|
@@ -178,6 +180,7 @@ export const Otp = ({
|
|
|
178
180
|
renderInput={({ style, ...props }) => <input {...props} />}
|
|
179
181
|
skipDefaultStyles={true}
|
|
180
182
|
/>
|
|
183
|
+
{error && <p className="text-xs text-error mt-2">{error}</p>}
|
|
181
184
|
<Button
|
|
182
185
|
type="submit"
|
|
183
186
|
className={twMerge(
|