@infosoftas/s4-orders-js-sdk 0.1.19 → 0.1.21-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/README.md +471 -426
- package/build/postcss-scope-tailwind.cjs +66 -0
- package/components.json +21 -0
- package/package.json +59 -43
- package/src/App.css +409 -0
- package/src/App.tsx +639 -569
- package/src/api/OrdersApi.ts +2 -2
- package/src/components/Alert/Alert.tsx +23 -22
- package/src/components/Button/Button.tsx +18 -22
- package/src/components/EHFForm/EHFForm.tsx +253 -235
- package/src/components/FormFields/AddressField.tsx +55 -62
- package/src/components/FormFields/EmailField.tsx +53 -58
- package/src/components/FormFields/InputField.tsx +52 -53
- package/src/components/FormFields/NameField.tsx +52 -53
- package/src/components/FormFields/PhoneField.tsx +53 -58
- package/src/components/FormFields/TermsCheckbox.tsx +70 -58
- package/src/components/FormFields/ToggleFiled.tsx +52 -63
- package/src/components/FormFields/fieldValidators.ts +71 -0
- package/src/components/OIOForm/OIOForm.tsx +132 -71
- package/src/components/OrderDenialModal/OrderDenialModal.tsx +102 -89
- package/src/components/OrderForm/ContactDetailsSection.tsx +71 -0
- package/src/components/OrderForm/OrderForm.tsx +177 -224
- package/src/components/OrderForm/PaymentMethodContent.tsx +62 -0
- package/src/components/OrderForm/PaymentMethodSection.tsx +79 -0
- package/src/components/OrderForm/SubmitConfirmationDialog.tsx +55 -0
- package/src/components/OrderForm/orderFormState.ts +171 -0
- package/src/components/OrderForm/useSlotElement.tsx +89 -0
- package/src/components/ui/alert-dialog.tsx +185 -0
- package/src/components/ui/alert.tsx +75 -0
- package/src/components/ui/button.tsx +55 -0
- package/src/components/ui/card.tsx +99 -0
- package/src/components/ui/checkbox.tsx +28 -0
- package/src/components/ui/field.tsx +238 -0
- package/src/components/ui/input.tsx +19 -0
- package/src/components/ui/label.tsx +19 -0
- package/src/components/ui/radio-group.tsx +37 -0
- package/src/components/ui/separator.tsx +24 -0
- package/src/components/ui/skeleton.tsx +13 -0
- package/src/components/ui/spinner.tsx +10 -0
- package/src/components/ui/switch.tsx +29 -0
- package/src/components/ui/textarea.tsx +17 -0
- package/src/constants/index.ts +0 -2
- package/src/custom.d.ts +4 -4
- package/src/enums/general.ts +1 -0
- package/src/hooks/useMessageEvent.tsx +54 -3
- package/src/hooks/useOrderForm.tsx +9 -2
- package/src/index.tsx +2 -0
- package/src/lib/utils.ts +1 -0
- package/src/types/general.ts +136 -111
- package/src/types/order.ts +8 -0
- package/src/utils/order.helper.ts +14 -3
- package/tsconfig.json +37 -38
- package/src/App.scss +0 -23
- package/src/assets/styles/forms.scss +0 -164
- package/src/assets/styles/general.scss +0 -46
- package/src/assets/styles/variables.scss +0 -29
- package/src/components/Alert/alert.scss +0 -21
- package/src/components/Button/button.scss +0 -48
- package/src/components/Loader/Loader.tsx +0 -22
- package/src/components/Loader/loader.scss +0 -37
- package/src/components/OrderDenialModal/orderDenialModal.scss +0 -42
- package/src/components/OrderForm/orderForm.scss +0 -10
|
@@ -1,62 +1,55 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
2
|
-
import { useFormContext } from 'react-hook-form';
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
{
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
{
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
<div className="text-error caption">{errors[name].message}</div>
|
|
57
|
-
)}
|
|
58
|
-
</div>
|
|
59
|
-
);
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
export default AddressField;
|
|
1
|
+
import { FC, useId } from 'react';
|
|
2
|
+
import { useFormContext } from 'react-hook-form';
|
|
3
|
+
|
|
4
|
+
import { Field, FieldError, FieldLabel } from '../ui/field';
|
|
5
|
+
import { Textarea } from '../ui/textarea';
|
|
6
|
+
|
|
7
|
+
type Props = {
|
|
8
|
+
name: string;
|
|
9
|
+
required: boolean;
|
|
10
|
+
readOnly: boolean;
|
|
11
|
+
label?: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const AddressField: FC<Props> = ({
|
|
15
|
+
name = 'address',
|
|
16
|
+
required = false,
|
|
17
|
+
readOnly = false,
|
|
18
|
+
label = 'Address',
|
|
19
|
+
}) => {
|
|
20
|
+
const { register, getFieldState, formState } = useFormContext();
|
|
21
|
+
const { error } = getFieldState(name, formState);
|
|
22
|
+
const id = useId();
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<Field data-invalid={!!error} data-testid={`sdk-${name}-field-id`}>
|
|
26
|
+
<FieldLabel htmlFor={id}>
|
|
27
|
+
<span>
|
|
28
|
+
{label}
|
|
29
|
+
{required && (
|
|
30
|
+
<span aria-hidden="true" className="text-destructive">
|
|
31
|
+
{' '}
|
|
32
|
+
*
|
|
33
|
+
</span>
|
|
34
|
+
)}
|
|
35
|
+
</span>
|
|
36
|
+
</FieldLabel>
|
|
37
|
+
<Textarea
|
|
38
|
+
id={id}
|
|
39
|
+
autoComplete="street-address"
|
|
40
|
+
readOnly={readOnly}
|
|
41
|
+
className="read-only:cursor-not-allowed read-only:bg-input/50"
|
|
42
|
+
aria-invalid={!!error}
|
|
43
|
+
aria-required={required}
|
|
44
|
+
required={required}
|
|
45
|
+
{...register(name, {
|
|
46
|
+
setValueAs: (value) =>
|
|
47
|
+
typeof value === 'string' ? value.trim() : value,
|
|
48
|
+
})}
|
|
49
|
+
/>
|
|
50
|
+
<FieldError errors={[error]} />
|
|
51
|
+
</Field>
|
|
52
|
+
);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export default AddressField;
|
|
@@ -1,58 +1,53 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
2
|
-
import { useFormContext } from 'react-hook-form';
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
type="email"
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
/>
|
|
48
|
-
<
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
</div>
|
|
55
|
-
);
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
export default EmailField;
|
|
1
|
+
import { FC, useId } from 'react';
|
|
2
|
+
import { useFormContext } from 'react-hook-form';
|
|
3
|
+
|
|
4
|
+
import { Field, FieldError, FieldLabel } from '../ui/field';
|
|
5
|
+
import { Input } from '../ui/input';
|
|
6
|
+
|
|
7
|
+
type Props = {
|
|
8
|
+
name: string;
|
|
9
|
+
required: boolean;
|
|
10
|
+
readOnly: boolean;
|
|
11
|
+
label?: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const EmailField: FC<Props> = ({
|
|
15
|
+
name = 'email',
|
|
16
|
+
required = false,
|
|
17
|
+
readOnly = false,
|
|
18
|
+
label = 'Email',
|
|
19
|
+
}) => {
|
|
20
|
+
const { register, getFieldState, formState } = useFormContext();
|
|
21
|
+
const { error } = getFieldState(name, formState);
|
|
22
|
+
const id = useId();
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<Field data-invalid={!!error} data-testid={`sdk-${name}-field-id`}>
|
|
26
|
+
<FieldLabel htmlFor={id}>
|
|
27
|
+
<span>
|
|
28
|
+
{label}
|
|
29
|
+
{required && (
|
|
30
|
+
<span aria-hidden="true" className="text-destructive">
|
|
31
|
+
{' '}
|
|
32
|
+
*
|
|
33
|
+
</span>
|
|
34
|
+
)}
|
|
35
|
+
</span>
|
|
36
|
+
</FieldLabel>
|
|
37
|
+
<Input
|
|
38
|
+
id={id}
|
|
39
|
+
type="email"
|
|
40
|
+
autoComplete="email"
|
|
41
|
+
readOnly={readOnly}
|
|
42
|
+
className="read-only:cursor-not-allowed read-only:bg-input/50"
|
|
43
|
+
aria-invalid={!!error}
|
|
44
|
+
aria-required={required}
|
|
45
|
+
required={required}
|
|
46
|
+
{...register(name)}
|
|
47
|
+
/>
|
|
48
|
+
<FieldError errors={[error]} />
|
|
49
|
+
</Field>
|
|
50
|
+
);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export default EmailField;
|
|
@@ -1,53 +1,52 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
2
|
-
import { useFormContext } from 'react-hook-form';
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
type Props = {
|
|
8
|
-
name: string;
|
|
9
|
-
required: boolean;
|
|
10
|
-
readOnly: boolean;
|
|
11
|
-
label?: string;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
name,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
{
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
{
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
export default NameField;
|
|
1
|
+
import { FC, useId } from 'react';
|
|
2
|
+
import { useFormContext } from 'react-hook-form';
|
|
3
|
+
|
|
4
|
+
import { Field, FieldError, FieldLabel } from '../ui/field';
|
|
5
|
+
import { Input } from '../ui/input';
|
|
6
|
+
|
|
7
|
+
type Props = {
|
|
8
|
+
name: string;
|
|
9
|
+
required: boolean;
|
|
10
|
+
readOnly: boolean;
|
|
11
|
+
label?: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const InputField: FC<Props> = ({
|
|
15
|
+
name,
|
|
16
|
+
required = false,
|
|
17
|
+
readOnly = false,
|
|
18
|
+
label = '',
|
|
19
|
+
}) => {
|
|
20
|
+
const { register, getFieldState, formState } = useFormContext();
|
|
21
|
+
const { error } = getFieldState(name, formState);
|
|
22
|
+
const id = useId();
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<Field data-invalid={!!error} data-testid={`sdk-${name}-field-id`}>
|
|
26
|
+
<FieldLabel htmlFor={id}>
|
|
27
|
+
<span>
|
|
28
|
+
{label}
|
|
29
|
+
{required && (
|
|
30
|
+
<span aria-hidden="true" className="text-destructive">
|
|
31
|
+
{' '}
|
|
32
|
+
*
|
|
33
|
+
</span>
|
|
34
|
+
)}
|
|
35
|
+
</span>
|
|
36
|
+
</FieldLabel>
|
|
37
|
+
<Input
|
|
38
|
+
id={id}
|
|
39
|
+
autoComplete={name}
|
|
40
|
+
readOnly={readOnly}
|
|
41
|
+
className="read-only:cursor-not-allowed read-only:bg-input/50"
|
|
42
|
+
aria-invalid={!!error}
|
|
43
|
+
aria-required={required}
|
|
44
|
+
required={required}
|
|
45
|
+
{...register(name)}
|
|
46
|
+
/>
|
|
47
|
+
<FieldError errors={[error]} />
|
|
48
|
+
</Field>
|
|
49
|
+
);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export default InputField;
|
|
@@ -1,53 +1,52 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
2
|
-
import { useFormContext } from 'react-hook-form';
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
type Props = {
|
|
8
|
-
name: string;
|
|
9
|
-
required: boolean;
|
|
10
|
-
readOnly: boolean;
|
|
11
|
-
label?: string;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
{
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
{
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
export default NameField;
|
|
1
|
+
import { FC, useId } from 'react';
|
|
2
|
+
import { useFormContext } from 'react-hook-form';
|
|
3
|
+
|
|
4
|
+
import { Field, FieldError, FieldLabel } from '../ui/field';
|
|
5
|
+
import { Input } from '../ui/input';
|
|
6
|
+
|
|
7
|
+
type Props = {
|
|
8
|
+
name: string;
|
|
9
|
+
required: boolean;
|
|
10
|
+
readOnly: boolean;
|
|
11
|
+
label?: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const NameField: FC<Props> = ({
|
|
15
|
+
name = 'name',
|
|
16
|
+
required = false,
|
|
17
|
+
readOnly = false,
|
|
18
|
+
label = 'Name',
|
|
19
|
+
}) => {
|
|
20
|
+
const { register, getFieldState, formState } = useFormContext();
|
|
21
|
+
const { error } = getFieldState(name, formState);
|
|
22
|
+
const id = useId();
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<Field data-invalid={!!error} data-testid={`sdk-${name}-field-id`}>
|
|
26
|
+
<FieldLabel htmlFor={id}>
|
|
27
|
+
<span>
|
|
28
|
+
{label}
|
|
29
|
+
{required && (
|
|
30
|
+
<span aria-hidden="true" className="text-destructive">
|
|
31
|
+
{' '}
|
|
32
|
+
*
|
|
33
|
+
</span>
|
|
34
|
+
)}
|
|
35
|
+
</span>
|
|
36
|
+
</FieldLabel>
|
|
37
|
+
<Input
|
|
38
|
+
id={id}
|
|
39
|
+
autoComplete="name"
|
|
40
|
+
readOnly={readOnly}
|
|
41
|
+
className="read-only:cursor-not-allowed read-only:bg-input/50"
|
|
42
|
+
aria-invalid={!!error}
|
|
43
|
+
aria-required={required}
|
|
44
|
+
required={required}
|
|
45
|
+
{...register(name)}
|
|
46
|
+
/>
|
|
47
|
+
<FieldError errors={[error]} />
|
|
48
|
+
</Field>
|
|
49
|
+
);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export default NameField;
|
|
@@ -1,58 +1,53 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
2
|
-
import { useFormContext } from 'react-hook-form';
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
type="tel"
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
/>
|
|
48
|
-
<
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
</div>
|
|
55
|
-
);
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
export default PhoneFiled;
|
|
1
|
+
import { FC, useId } from 'react';
|
|
2
|
+
import { useFormContext } from 'react-hook-form';
|
|
3
|
+
|
|
4
|
+
import { Field, FieldError, FieldLabel } from '../ui/field';
|
|
5
|
+
import { Input } from '../ui/input';
|
|
6
|
+
|
|
7
|
+
type Props = {
|
|
8
|
+
name: string;
|
|
9
|
+
required: boolean;
|
|
10
|
+
readOnly: boolean;
|
|
11
|
+
label?: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const PhoneField: FC<Props> = ({
|
|
15
|
+
name = 'phoneNumber',
|
|
16
|
+
required = false,
|
|
17
|
+
readOnly = false,
|
|
18
|
+
label = 'Phone number',
|
|
19
|
+
}) => {
|
|
20
|
+
const { register, getFieldState, formState } = useFormContext();
|
|
21
|
+
const { error } = getFieldState(name, formState);
|
|
22
|
+
const id = useId();
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<Field data-invalid={!!error} data-testid={`sdk-${name}-field-id`}>
|
|
26
|
+
<FieldLabel htmlFor={id}>
|
|
27
|
+
<span>
|
|
28
|
+
{label}
|
|
29
|
+
{required && (
|
|
30
|
+
<span aria-hidden="true" className="text-destructive">
|
|
31
|
+
{' '}
|
|
32
|
+
*
|
|
33
|
+
</span>
|
|
34
|
+
)}
|
|
35
|
+
</span>
|
|
36
|
+
</FieldLabel>
|
|
37
|
+
<Input
|
|
38
|
+
id={id}
|
|
39
|
+
type="tel"
|
|
40
|
+
autoComplete="tel"
|
|
41
|
+
readOnly={readOnly}
|
|
42
|
+
className="read-only:cursor-not-allowed read-only:bg-input/50"
|
|
43
|
+
aria-invalid={!!error}
|
|
44
|
+
aria-required={required}
|
|
45
|
+
required={required}
|
|
46
|
+
{...register(name)}
|
|
47
|
+
/>
|
|
48
|
+
<FieldError errors={[error]} />
|
|
49
|
+
</Field>
|
|
50
|
+
);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export default PhoneField;
|