@open-tender/utils 0.1.66 → 0.1.68
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/dist/cjs/hooks/useResetPasswordForm.d.ts +5 -11
- package/dist/cjs/hooks/useResetPasswordForm.js +16 -7
- package/dist/cjs/utils/cart.js +1 -0
- package/dist/esm/hooks/useResetPasswordForm.d.ts +5 -11
- package/dist/esm/hooks/useResetPasswordForm.js +16 -7
- package/dist/esm/utils/cart.js +1 -0
- package/package.json +1 -1
|
@@ -1,18 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { RequestStatus, ResetPasswordData } from '@open-tender/types';
|
|
3
|
-
export
|
|
4
|
-
label: string;
|
|
5
|
-
name: string;
|
|
6
|
-
type: string;
|
|
7
|
-
required?: boolean;
|
|
8
|
-
}
|
|
9
|
-
export declare const useResetPasswordForm: (loading: RequestStatus, error: any, reset: (newPassword: string, callback: () => void) => void, resetForm: () => void, resetToken: () => void) => {
|
|
2
|
+
import { FormFields, RequestError, RequestStatus, ResetPasswordData } from '@open-tender/types';
|
|
3
|
+
export declare const useResetPasswordForm: (loading: RequestStatus, error: RequestError, reset: (newPassword: string, resetToken: string) => void, resetToken: string) => {
|
|
10
4
|
submitRef: import("react").MutableRefObject<HTMLButtonElement | null>;
|
|
11
5
|
inputRef: import("react").MutableRefObject<HTMLInputElement | null>;
|
|
12
|
-
fields:
|
|
6
|
+
fields: FormFields;
|
|
13
7
|
data: Partial<ResetPasswordData>;
|
|
14
8
|
errors: {};
|
|
15
9
|
submitting: boolean;
|
|
16
|
-
handleChange: (name: string, value: string) => void;
|
|
17
|
-
handleSubmit: (evt?:
|
|
10
|
+
handleChange: (name: string, value: string | number | boolean) => void;
|
|
11
|
+
handleSubmit: (evt?: React.FormEvent<HTMLFormElement>) => void;
|
|
18
12
|
};
|
|
@@ -2,32 +2,41 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useResetPasswordForm = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
|
-
const
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
|
+
const useResetPasswordForm = (loading, error, reset, resetToken) => {
|
|
6
7
|
const submitRef = (0, react_1.useRef)(null);
|
|
7
8
|
const inputRef = (0, react_1.useRef)(null);
|
|
8
9
|
const [data, setData] = (0, react_1.useState)({});
|
|
9
10
|
const [errors, setErrors] = (0, react_1.useState)({});
|
|
10
11
|
const [submitting, setSubmitting] = (0, react_1.useState)(false);
|
|
11
12
|
const fields = [
|
|
12
|
-
{
|
|
13
|
-
|
|
13
|
+
{
|
|
14
|
+
label: 'New Password',
|
|
15
|
+
name: 'new_password',
|
|
16
|
+
type: 'password',
|
|
17
|
+
required: true
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
label: 'Confirm Password',
|
|
21
|
+
name: 'confirm',
|
|
22
|
+
type: 'password',
|
|
23
|
+
required: true
|
|
24
|
+
}
|
|
14
25
|
];
|
|
15
26
|
(0, react_1.useEffect)(() => {
|
|
16
27
|
setData({});
|
|
17
28
|
setErrors({});
|
|
18
|
-
resetForm();
|
|
19
29
|
return () => {
|
|
20
30
|
setData({});
|
|
21
31
|
setErrors({});
|
|
22
|
-
resetForm();
|
|
23
32
|
};
|
|
24
|
-
}, [
|
|
33
|
+
}, []);
|
|
25
34
|
(0, react_1.useEffect)(() => {
|
|
26
35
|
var _a, _b;
|
|
27
36
|
if (loading === 'idle') {
|
|
28
37
|
setSubmitting(false);
|
|
29
38
|
if (error) {
|
|
30
|
-
setErrors(error);
|
|
39
|
+
setErrors((0, utils_1.makeFormErrors)(error));
|
|
31
40
|
((_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus) && ((_b = inputRef.current) === null || _b === void 0 ? void 0 : _b.focus());
|
|
32
41
|
}
|
|
33
42
|
}
|
package/dist/cjs/utils/cart.js
CHANGED
|
@@ -440,6 +440,7 @@ const makeDisplayItem = (item, isOption = false) => {
|
|
|
440
440
|
name: item.name,
|
|
441
441
|
nutritionalInfo: item.nutritional_info,
|
|
442
442
|
quantity: item.quantity,
|
|
443
|
+
points: null,
|
|
443
444
|
price: item.price,
|
|
444
445
|
shortDescription: item.short_description,
|
|
445
446
|
tags: item.tags,
|
|
@@ -1,18 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { RequestStatus, ResetPasswordData } from '@open-tender/types';
|
|
3
|
-
export
|
|
4
|
-
label: string;
|
|
5
|
-
name: string;
|
|
6
|
-
type: string;
|
|
7
|
-
required?: boolean;
|
|
8
|
-
}
|
|
9
|
-
export declare const useResetPasswordForm: (loading: RequestStatus, error: any, reset: (newPassword: string, callback: () => void) => void, resetForm: () => void, resetToken: () => void) => {
|
|
2
|
+
import { FormFields, RequestError, RequestStatus, ResetPasswordData } from '@open-tender/types';
|
|
3
|
+
export declare const useResetPasswordForm: (loading: RequestStatus, error: RequestError, reset: (newPassword: string, resetToken: string) => void, resetToken: string) => {
|
|
10
4
|
submitRef: import("react").MutableRefObject<HTMLButtonElement | null>;
|
|
11
5
|
inputRef: import("react").MutableRefObject<HTMLInputElement | null>;
|
|
12
|
-
fields:
|
|
6
|
+
fields: FormFields;
|
|
13
7
|
data: Partial<ResetPasswordData>;
|
|
14
8
|
errors: {};
|
|
15
9
|
submitting: boolean;
|
|
16
|
-
handleChange: (name: string, value: string) => void;
|
|
17
|
-
handleSubmit: (evt?:
|
|
10
|
+
handleChange: (name: string, value: string | number | boolean) => void;
|
|
11
|
+
handleSubmit: (evt?: React.FormEvent<HTMLFormElement>) => void;
|
|
18
12
|
};
|
|
@@ -1,30 +1,39 @@
|
|
|
1
1
|
import { useState, useEffect, useRef } from 'react';
|
|
2
|
-
|
|
2
|
+
import { makeFormErrors } from '../utils';
|
|
3
|
+
export const useResetPasswordForm = (loading, error, reset, resetToken) => {
|
|
3
4
|
const submitRef = useRef(null);
|
|
4
5
|
const inputRef = useRef(null);
|
|
5
6
|
const [data, setData] = useState({});
|
|
6
7
|
const [errors, setErrors] = useState({});
|
|
7
8
|
const [submitting, setSubmitting] = useState(false);
|
|
8
9
|
const fields = [
|
|
9
|
-
{
|
|
10
|
-
|
|
10
|
+
{
|
|
11
|
+
label: 'New Password',
|
|
12
|
+
name: 'new_password',
|
|
13
|
+
type: 'password',
|
|
14
|
+
required: true
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
label: 'Confirm Password',
|
|
18
|
+
name: 'confirm',
|
|
19
|
+
type: 'password',
|
|
20
|
+
required: true
|
|
21
|
+
}
|
|
11
22
|
];
|
|
12
23
|
useEffect(() => {
|
|
13
24
|
setData({});
|
|
14
25
|
setErrors({});
|
|
15
|
-
resetForm();
|
|
16
26
|
return () => {
|
|
17
27
|
setData({});
|
|
18
28
|
setErrors({});
|
|
19
|
-
resetForm();
|
|
20
29
|
};
|
|
21
|
-
}, [
|
|
30
|
+
}, []);
|
|
22
31
|
useEffect(() => {
|
|
23
32
|
var _a, _b;
|
|
24
33
|
if (loading === 'idle') {
|
|
25
34
|
setSubmitting(false);
|
|
26
35
|
if (error) {
|
|
27
|
-
setErrors(error);
|
|
36
|
+
setErrors(makeFormErrors(error));
|
|
28
37
|
((_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus) && ((_b = inputRef.current) === null || _b === void 0 ? void 0 : _b.focus());
|
|
29
38
|
}
|
|
30
39
|
}
|
package/dist/esm/utils/cart.js
CHANGED
|
@@ -419,6 +419,7 @@ export const makeDisplayItem = (item, isOption = false) => {
|
|
|
419
419
|
name: item.name,
|
|
420
420
|
nutritionalInfo: item.nutritional_info,
|
|
421
421
|
quantity: item.quantity,
|
|
422
|
+
points: null,
|
|
422
423
|
price: item.price,
|
|
423
424
|
shortDescription: item.short_description,
|
|
424
425
|
tags: item.tags,
|
package/package.json
CHANGED