@infosoftas/s4-orders-js-sdk 0.1.20 → 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 -444
- package/build/postcss-scope-tailwind.cjs +66 -0
- package/components.json +21 -0
- package/package.json +59 -50
- package/src/App.css +409 -0
- package/src/App.tsx +639 -594
- 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 +130 -69
- package/src/components/OrderDenialModal/OrderDenialModal.tsx +102 -89
- package/src/components/OrderForm/ContactDetailsSection.tsx +71 -0
- package/src/components/OrderForm/OrderForm.tsx +173 -232
- 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/index.tsx +2 -0
- package/src/lib/utils.ts +1 -0
- package/src/types/general.ts +136 -122
- 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,89 +1,102 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
2
|
-
|
|
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
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
<
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
|
|
3
|
+
import { OrderDenialFallbackOfferType } from '../../types/general';
|
|
4
|
+
import {
|
|
5
|
+
AlertDialog,
|
|
6
|
+
AlertDialogAction,
|
|
7
|
+
AlertDialogCancel,
|
|
8
|
+
AlertDialogContent,
|
|
9
|
+
AlertDialogDescription,
|
|
10
|
+
AlertDialogFooter,
|
|
11
|
+
AlertDialogHeader,
|
|
12
|
+
AlertDialogTitle,
|
|
13
|
+
} from '../ui/alert-dialog';
|
|
14
|
+
|
|
15
|
+
type Props = {
|
|
16
|
+
isOpen: boolean;
|
|
17
|
+
message?: string;
|
|
18
|
+
offer?: OrderDenialFallbackOfferType;
|
|
19
|
+
canContinue?: boolean;
|
|
20
|
+
closeButtonText?: string;
|
|
21
|
+
continueButtonText?: string;
|
|
22
|
+
onContinue: () => void;
|
|
23
|
+
onClose: () => void;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const splitMessage = (message = '') => {
|
|
27
|
+
const [title = '', ...rest] = message
|
|
28
|
+
.replace(/\\n/g, '\n')
|
|
29
|
+
.split(/\n\s*\n/)
|
|
30
|
+
.map((part) => part.trim())
|
|
31
|
+
.filter(Boolean);
|
|
32
|
+
|
|
33
|
+
return { title, description: rest.join('\n\n') };
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const OrderDenialModal: FC<Props> = ({
|
|
37
|
+
isOpen,
|
|
38
|
+
message,
|
|
39
|
+
offer,
|
|
40
|
+
canContinue = true,
|
|
41
|
+
closeButtonText = 'Close',
|
|
42
|
+
continueButtonText = 'Continue',
|
|
43
|
+
onContinue,
|
|
44
|
+
onClose,
|
|
45
|
+
}) => {
|
|
46
|
+
const { title, description } = splitMessage(message);
|
|
47
|
+
const showOffer = !!offer?.title && !!offer?.templatePackageId;
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<AlertDialog
|
|
51
|
+
open={isOpen}
|
|
52
|
+
onOpenChange={(open) => {
|
|
53
|
+
if (!open) onClose();
|
|
54
|
+
}}
|
|
55
|
+
>
|
|
56
|
+
<AlertDialogContent data-testid="sdk-order-denial-modal">
|
|
57
|
+
<AlertDialogHeader>
|
|
58
|
+
<AlertDialogTitle className="whitespace-pre-line">
|
|
59
|
+
{title}
|
|
60
|
+
</AlertDialogTitle>
|
|
61
|
+
{description && (
|
|
62
|
+
<AlertDialogDescription className="whitespace-pre-line">
|
|
63
|
+
{description}
|
|
64
|
+
</AlertDialogDescription>
|
|
65
|
+
)}
|
|
66
|
+
</AlertDialogHeader>
|
|
67
|
+
|
|
68
|
+
{showOffer && (
|
|
69
|
+
<div
|
|
70
|
+
className="flex flex-col gap-1 rounded-2xl bg-muted p-4 text-sm"
|
|
71
|
+
data-testid="sdk-order-denial-offer"
|
|
72
|
+
>
|
|
73
|
+
<p className="font-medium">{offer?.title}</p>
|
|
74
|
+
{offer?.description && (
|
|
75
|
+
<p className="text-muted-foreground">
|
|
76
|
+
{offer.description}
|
|
77
|
+
</p>
|
|
78
|
+
)}
|
|
79
|
+
{offer?.price && (
|
|
80
|
+
<p className="mt-1 font-semibold tabular-nums">
|
|
81
|
+
{offer.price}
|
|
82
|
+
</p>
|
|
83
|
+
)}
|
|
84
|
+
</div>
|
|
85
|
+
)}
|
|
86
|
+
|
|
87
|
+
<AlertDialogFooter>
|
|
88
|
+
<AlertDialogCancel variant="ghost">
|
|
89
|
+
{closeButtonText}
|
|
90
|
+
</AlertDialogCancel>
|
|
91
|
+
{canContinue && (
|
|
92
|
+
<AlertDialogAction onClick={onContinue}>
|
|
93
|
+
{continueButtonText}
|
|
94
|
+
</AlertDialogAction>
|
|
95
|
+
)}
|
|
96
|
+
</AlertDialogFooter>
|
|
97
|
+
</AlertDialogContent>
|
|
98
|
+
</AlertDialog>
|
|
99
|
+
);
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
export default OrderDenialModal;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
|
|
3
|
+
import formFieldsMapper from '../FormFields/FormFieldsMapper';
|
|
4
|
+
import ToggleField from '../FormFields/ToggleFiled';
|
|
5
|
+
import { OrderFormFieldType } from '../../types/general';
|
|
6
|
+
import { FieldGroup, FieldLegend, FieldSet } from '../ui/field';
|
|
7
|
+
|
|
8
|
+
type FieldListProps = {
|
|
9
|
+
fields: OrderFormFieldType[];
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const FieldList: FC<FieldListProps> = ({ fields }) => (
|
|
13
|
+
<>
|
|
14
|
+
{fields.map((field) => {
|
|
15
|
+
const Component = formFieldsMapper[field.name];
|
|
16
|
+
|
|
17
|
+
return Component ? (
|
|
18
|
+
<Component
|
|
19
|
+
key={field.name}
|
|
20
|
+
name={field.name}
|
|
21
|
+
label={field.label}
|
|
22
|
+
required={field.required || false}
|
|
23
|
+
readOnly={field.readOnly || false}
|
|
24
|
+
/>
|
|
25
|
+
) : null;
|
|
26
|
+
})}
|
|
27
|
+
</>
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
type Props = {
|
|
31
|
+
label?: string;
|
|
32
|
+
orderFields: OrderFormFieldType[];
|
|
33
|
+
invoiceOrderFields: OrderFormFieldType[];
|
|
34
|
+
showOrderFields: boolean;
|
|
35
|
+
showInvoiceToggle: boolean;
|
|
36
|
+
showInvoiceFields: boolean;
|
|
37
|
+
invoiceToggleLabel?: string;
|
|
38
|
+
onInvoiceToggle?: (value: boolean) => void;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const ContactDetailsSection: FC<Props> = ({
|
|
42
|
+
label,
|
|
43
|
+
orderFields,
|
|
44
|
+
invoiceOrderFields,
|
|
45
|
+
showOrderFields,
|
|
46
|
+
showInvoiceToggle,
|
|
47
|
+
showInvoiceFields,
|
|
48
|
+
invoiceToggleLabel,
|
|
49
|
+
onInvoiceToggle,
|
|
50
|
+
}) => (
|
|
51
|
+
<div className="sdk-order-details-section">
|
|
52
|
+
<FieldSet>
|
|
53
|
+
{label && <FieldLegend variant="label">{label}</FieldLegend>}
|
|
54
|
+
<FieldGroup>
|
|
55
|
+
{showOrderFields && <FieldList fields={orderFields} />}
|
|
56
|
+
{showInvoiceToggle && (
|
|
57
|
+
<ToggleField
|
|
58
|
+
name="invoiceAddressSelection"
|
|
59
|
+
label={invoiceToggleLabel ?? 'Invoice Address'}
|
|
60
|
+
toggleCallback={onInvoiceToggle}
|
|
61
|
+
/>
|
|
62
|
+
)}
|
|
63
|
+
{showInvoiceFields && (
|
|
64
|
+
<FieldList fields={invoiceOrderFields} />
|
|
65
|
+
)}
|
|
66
|
+
</FieldGroup>
|
|
67
|
+
</FieldSet>
|
|
68
|
+
</div>
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
export default ContactDetailsSection;
|