@tellescope/react-components 1.231.0 → 1.232.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/lib/cjs/Forms/forms.js +1 -1
- package/lib/cjs/Forms/forms.js.map +1 -1
- package/lib/cjs/Forms/forms.v2.js +1 -1
- package/lib/cjs/Forms/forms.v2.js.map +1 -1
- package/lib/cjs/Forms/inputs.d.ts +2 -2
- package/lib/cjs/Forms/inputs.d.ts.map +1 -1
- package/lib/cjs/Forms/inputs.js +71 -18
- package/lib/cjs/Forms/inputs.js.map +1 -1
- package/lib/cjs/Forms/inputs.v2.d.ts +2 -4
- package/lib/cjs/Forms/inputs.v2.d.ts.map +1 -1
- package/lib/cjs/Forms/inputs.v2.js +9 -211
- package/lib/cjs/Forms/inputs.v2.js.map +1 -1
- package/lib/esm/Forms/forms.js +1 -1
- package/lib/esm/Forms/forms.js.map +1 -1
- package/lib/esm/Forms/forms.v2.js +1 -1
- package/lib/esm/Forms/forms.v2.js.map +1 -1
- package/lib/esm/Forms/inputs.d.ts +2 -2
- package/lib/esm/Forms/inputs.d.ts.map +1 -1
- package/lib/esm/Forms/inputs.js +72 -19
- package/lib/esm/Forms/inputs.js.map +1 -1
- package/lib/esm/Forms/inputs.v2.d.ts +2 -4
- package/lib/esm/Forms/inputs.v2.d.ts.map +1 -1
- package/lib/esm/Forms/inputs.v2.js +10 -212
- package/lib/esm/Forms/inputs.v2.js.map +1 -1
- package/lib/esm/controls.d.ts +2 -2
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +9 -9
- package/src/Forms/forms.tsx +1 -1
- package/src/Forms/forms.v2.tsx +1 -1
- package/src/Forms/inputs.tsx +73 -6
- package/src/Forms/inputs.v2.tsx +11 -340
|
@@ -45,9 +45,7 @@ export declare const FilesInput: ({ value, onChange, field, existingFileName, up
|
|
|
45
45
|
existingFileName?: string | undefined;
|
|
46
46
|
}) => JSX.Element;
|
|
47
47
|
export declare const MultipleChoiceInput: ({ field, form, value: _value, onChange }: FormInputProps<'multiple_choice'>) => JSX.Element;
|
|
48
|
-
export
|
|
49
|
-
setCustomerId: React.Dispatch<React.SetStateAction<string | undefined>>;
|
|
50
|
-
}) => JSX.Element;
|
|
48
|
+
export { StripeInput } from './inputs';
|
|
51
49
|
export declare const Progress: ({ numerator, denominator, style, color }: {
|
|
52
50
|
numerator: number;
|
|
53
51
|
denominator: number;
|
|
@@ -66,7 +64,7 @@ export declare const CanvasMedicationsInput: ({ field, value, onChange }: FormIn
|
|
|
66
64
|
export declare const MedicationsInput: ({ field, value, onChange, ...props }: FormInputProps<'Medications'>) => JSX.Element;
|
|
67
65
|
export declare const BelugaPatientPreferenceInput: ({ field, value: _value, onChange }: FormInputProps<'Beluga Patient Preference'>) => JSX.Element;
|
|
68
66
|
export declare const contact_is_valid: (e: Partial<Enduser>) => "Email is invalid" | "Phone is invalid" | "Date of birth should be MM-DD-YYYY" | undefined;
|
|
69
|
-
export declare const RelatedContactsInput: ({ field, value: _value, onChange, ...props }: FormInputProps<'Related Contacts'>) => JSX.Element;
|
|
67
|
+
export declare const RelatedContactsInput: ({ field, value: _value, onChange, error: parentError, ...props }: FormInputProps<'Related Contacts'>) => JSX.Element;
|
|
70
68
|
export declare const AppointmentBookingInput: ({ formResponseId, field, value, onChange, form, responses, goToPreviousField, isPreviousDisabled, enduserId, ...props }: FormInputProps<'Appointment Booking'>) => JSX.Element;
|
|
71
69
|
export declare const HeightInput: ({ field, value, onChange, ...props }: FormInputProps<'Height'>) => JSX.Element;
|
|
72
70
|
export declare const include_current_url_parameters_if_templated: (url: string) => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inputs.v2.d.ts","sourceRoot":"","sources":["../../../src/Forms/inputs.v2.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAwE,MAAM,OAAO,CAAA;AAE5F,OAAO,
|
|
1
|
+
{"version":3,"file":"inputs.v2.d.ts","sourceRoot":"","sources":["../../../src/Forms/input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,CAAA;AAED,eAAO,MAAM,4BAA4B,uCAAwC,eAAe,2BAA2B,CAAC,gBAoK3H,CAAA;AAED,eAAO,MAAM,gBAAgB,MAAO,QAAQ,OAAO,CAAC,+FAkBnD,CAAA;AAED,eAAO,MAAM,oBAAoB,qEAAsE,eAAe,kBAAkB,CAAC,gBAiLxI,CAAA;AAED,eAAO,MAAM,uBAAuB,4HAA6H,eAAe,qBAAqB,CAAC,gBAyOrM,CAAA;AAED,eAAO,MAAM,WAAW,yCAAoD,eAAe,QAAQ,CAAC,gBAenG,CAAA;AAED,eAAO,MAAM,2CAA2C,QAAS,MAAM,WAetE,CAAA;AAED,eAAO,MAAM,aAAa,uIAAkJ,eAAe,UAAU,CAAC,uBAkGrM,CAAA;AAED,eAAO,MAAM,gBAAgB,4FAA6F,eAAe,OAAO,CAAC,gBA+ChJ,CAAA;AAED,eAAO,MAAM,WAAW,iGAAkG,eAAe,OAAO,CAAC,gBA8ChJ,CAAA;AAMD,eAAO,MAAM,cAAc,iGAAkG,eAAe,WAAW,CAAC,gBAqHvJ,CAAA;AAGD,eAAO,MAAM,eAAe,iGAAkG,eAAe,YAAY,CAAC,gBAsDzJ,CAAA;AAED,eAAO,MAAM,aAAa,+BAAgC,eAAe,WAAW,CAAC,gBAEpF,CAAA;AAED,eAAO,MAAM,eAAe;mBACX,MAAM,QAAQ,CAAC,MAAM,cAAc,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;iBA6CxE,CAAA"}
|
|
@@ -72,10 +72,10 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
72
72
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
73
73
|
import React, { forwardRef, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
74
74
|
import axios from "axios";
|
|
75
|
-
import { Autocomplete, Box, Button, Checkbox, Chip, Divider, FormControl,
|
|
75
|
+
import { Autocomplete, Box, Button, Checkbox, Chip, Divider, FormControl, Grid, InputLabel, MenuItem, RadioGroup, Select, TextField, Typography } from "@mui/material";
|
|
76
76
|
import { useDropzone } from "react-dropzone";
|
|
77
77
|
import { CANVAS_TITLE, EMOTII_TITLE, INSURANCE_RELATIONSHIPS, INSURANCE_RELATIONSHIPS_CANVAS, PRIMARY_HEX, RELATIONSHIP_TYPES, TELLESCOPE_GENDERS } from "@tellescope/constants";
|
|
78
|
-
import { MM_DD_YYYY_to_YYYY_MM_DD, capture_is_supported, downloadFile, emit_gtm_event, first_letter_capitalized, form_response_value_to_string,
|
|
78
|
+
import { MM_DD_YYYY_to_YYYY_MM_DD, capture_is_supported, downloadFile, emit_gtm_event, first_letter_capitalized, form_response_value_to_string, getLocalTimezone, getPublicFileURL, mm_dd_yyyy, replace_enduser_template_values, truncate_string, update_local_storage, user_display_name } from "@tellescope/utilities";
|
|
79
79
|
import { TIMEZONES_USA } from "@tellescope/types-models";
|
|
80
80
|
import { VALID_STATES, emailValidator, phoneValidator } from "@tellescope/validation";
|
|
81
81
|
import Slider from '@mui/material/Slider';
|
|
@@ -89,8 +89,6 @@ import DragIndicatorIcon from '@mui/icons-material/DragIndicator';
|
|
|
89
89
|
import heic2any from "heic2any";
|
|
90
90
|
import AddPhotoAlternateIcon from '@mui/icons-material/AddPhotoAlternate';
|
|
91
91
|
import LanguageIcon from '@mui/icons-material/Language';
|
|
92
|
-
import { Elements, PaymentElement, useStripe, useElements, EmbeddedCheckout, EmbeddedCheckoutProvider } from '@stripe/react-stripe-js';
|
|
93
|
-
import { loadStripe } from '@stripe/stripe-js';
|
|
94
92
|
import { CheckCircleOutline, Delete, Edit, UploadFile } from "@mui/icons-material";
|
|
95
93
|
import { WYSIWYG } from "./wysiwyg";
|
|
96
94
|
export var LanguageSelect = function (_a) {
|
|
@@ -805,211 +803,11 @@ export var MultipleChoiceInput = function (_a) {
|
|
|
805
803
|
? __spreadArray(__spreadArray([], (value !== null && value !== void 0 ? value : []).filter(function (v) { return v !== otherString; }), true), [e.target.value], false) : value === null || value === void 0 ? void 0 : value.filter(function (v) { return v !== otherString; }))), field.id);
|
|
806
804
|
} }) }))] })));
|
|
807
805
|
};
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
var _f = useState(''), businessName = _f[0], setBusinessName = _f[1];
|
|
814
|
-
var _g = useState(false), isCheckout = _g[0], setIsCheckout = _g[1];
|
|
815
|
-
var _h = useState(), stripePromise = _h[0], setStripePromise = _h[1];
|
|
816
|
-
var _j = useState(''), answertext = _j[0], setAnswertext = _j[1];
|
|
817
|
-
var _k = useState(''), error = _k[0], setError = _k[1];
|
|
818
|
-
var _l = useState([]), selectedProducts = _l[0], setSelectedProducts = _l[1];
|
|
819
|
-
var _m = useState(false), showProductSelection = _m[0], setShowProductSelection = _m[1];
|
|
820
|
-
var _o = useState([]), availableProducts = _o[0], setAvailableProducts = _o[1];
|
|
821
|
-
var _p = useState(false), loadingProducts = _p[0], setLoadingProducts = _p[1];
|
|
822
|
-
var fetchRef = useRef(false);
|
|
823
|
-
useEffect(function () {
|
|
824
|
-
var _a, _b, _d;
|
|
825
|
-
if (fetchRef.current)
|
|
826
|
-
return;
|
|
827
|
-
if (value && ((_a = session.userInfo) === null || _a === void 0 ? void 0 : _a.stripeCustomerId)) {
|
|
828
|
-
return setCustomerId(function (c) { var _a; return c ? c : (_a = session.userInfo) === null || _a === void 0 ? void 0 : _a.stripeCustomerId; }); // already paid or saved card
|
|
829
|
-
}
|
|
830
|
-
// Check if product selection mode is enabled
|
|
831
|
-
if (((_b = field.options) === null || _b === void 0 ? void 0 : _b.stripeProductSelectionMode) && (((_d = field.options) === null || _d === void 0 ? void 0 : _d.productIds) || []).length > 1) {
|
|
832
|
-
setShowProductSelection(true);
|
|
833
|
-
setLoadingProducts(true);
|
|
834
|
-
// Fetch product data with real-time Stripe pricing via proxy_read
|
|
835
|
-
var productIds = (field.options.productIds || []).join(',');
|
|
836
|
-
session.api.integrations.proxy_read({
|
|
837
|
-
integration: 'Stripe',
|
|
838
|
-
type: 'product-prices',
|
|
839
|
-
id: productIds,
|
|
840
|
-
query: field.options.stripeKey
|
|
841
|
-
})
|
|
842
|
-
.then(function (_a) {
|
|
843
|
-
var data = _a.data;
|
|
844
|
-
setAvailableProducts(data.products || []);
|
|
845
|
-
setLoadingProducts(false);
|
|
846
|
-
})
|
|
847
|
-
.catch(function (e) {
|
|
848
|
-
var _a, _b;
|
|
849
|
-
console.error('Error loading product data:', e);
|
|
850
|
-
var errorMessage = ((_b = (_a = e === null || e === void 0 ? void 0 : e.message) === null || _a === void 0 ? void 0 : _a.includes) === null || _b === void 0 ? void 0 : _b.call(_a, 'Stripe pricing error:'))
|
|
851
|
-
? e.message.replace('Stripe pricing error: ', '')
|
|
852
|
-
: 'Failed to load product information from Stripe';
|
|
853
|
-
setError("Product configuration error: ".concat(errorMessage));
|
|
854
|
-
setLoadingProducts(false);
|
|
855
|
-
});
|
|
856
|
-
return;
|
|
857
|
-
}
|
|
858
|
-
fetchRef.current = true;
|
|
859
|
-
session.api.form_responses.stripe_details({ fieldId: field.id, enduserId: enduserId })
|
|
860
|
-
.then(function (_a) {
|
|
861
|
-
var clientSecret = _a.clientSecret, publishableKey = _a.publishableKey, stripeAccount = _a.stripeAccount, businessName = _a.businessName, customerId = _a.customerId, isCheckout = _a.isCheckout, answerText = _a.answerText;
|
|
862
|
-
setAnswertext(answerText || '');
|
|
863
|
-
setIsCheckout(!!isCheckout);
|
|
864
|
-
setClientSecret(clientSecret);
|
|
865
|
-
setStripePromise(loadStripe(publishableKey, { stripeAccount: stripeAccount }));
|
|
866
|
-
setBusinessName(businessName);
|
|
867
|
-
setCustomerId(customerId);
|
|
868
|
-
})
|
|
869
|
-
.catch(function (e) {
|
|
870
|
-
console.error(e);
|
|
871
|
-
if (typeof (e === null || e === void 0 ? void 0 : e.message) === 'string') {
|
|
872
|
-
setError(e.message);
|
|
873
|
-
}
|
|
874
|
-
});
|
|
875
|
-
}, [session, value, field.id, enduserId]);
|
|
876
|
-
var cost = (showProductSelection
|
|
877
|
-
? selectedProducts.reduce(function (total, productId) {
|
|
878
|
-
var _a;
|
|
879
|
-
var product = availableProducts.find(function (p) { return p._id === productId; });
|
|
880
|
-
if (product === null || product === void 0 ? void 0 : product.currentPrice) {
|
|
881
|
-
return total + (product.currentPrice.amount || 0);
|
|
882
|
-
}
|
|
883
|
-
return total + (((_a = product === null || product === void 0 ? void 0 : product.cost) === null || _a === void 0 ? void 0 : _a.amount) || 0);
|
|
884
|
-
}, 0)
|
|
885
|
-
: 0 // Will be calculated by existing Stripe flow when not in selection mode
|
|
886
|
-
);
|
|
887
|
-
// Handle product selection step
|
|
888
|
-
if (showProductSelection) {
|
|
889
|
-
if (error) {
|
|
890
|
-
return (_jsxs(Grid, __assign({ container: true, direction: "column", spacing: 2, alignItems: "center" }, { children: [_jsx(Grid, __assign({ item: true }, { children: _jsx(Typography, __assign({ color: "error", variant: "h6" }, { children: "Product Configuration Error" })) })), _jsx(Grid, __assign({ item: true }, { children: _jsx(Typography, __assign({ color: "error", sx: { textAlign: 'center' } }, { children: error })) }))] })));
|
|
891
|
-
}
|
|
892
|
-
if (loadingProducts) {
|
|
893
|
-
return (_jsxs(Grid, __assign({ container: true, direction: "column", spacing: 2, alignItems: "center" }, { children: [_jsx(Grid, __assign({ item: true }, { children: _jsx(LinearProgress, {}) })), _jsx(Grid, __assign({ item: true }, { children: _jsx(Typography, { children: "Loading product information..." }) }))] })));
|
|
894
|
-
}
|
|
895
|
-
var isSingleSelection_1 = ((_b = field.options) === null || _b === void 0 ? void 0 : _b.radio) === true;
|
|
896
|
-
var handleProductSelection_1 = function (productId) {
|
|
897
|
-
if (isSingleSelection_1) {
|
|
898
|
-
setSelectedProducts([productId]);
|
|
899
|
-
}
|
|
900
|
-
else {
|
|
901
|
-
setSelectedProducts(function (prev) {
|
|
902
|
-
return prev.includes(productId)
|
|
903
|
-
? prev.filter(function (id) { return id !== productId; })
|
|
904
|
-
: __spreadArray(__spreadArray([], prev, true), [productId], false);
|
|
905
|
-
});
|
|
906
|
-
}
|
|
907
|
-
};
|
|
908
|
-
var handleContinueToPayment = function () {
|
|
909
|
-
if (selectedProducts.length === 0)
|
|
910
|
-
return;
|
|
911
|
-
setShowProductSelection(false);
|
|
912
|
-
fetchRef.current = true;
|
|
913
|
-
// Now fetch Stripe details with selected products
|
|
914
|
-
session.api.form_responses.stripe_details(__assign({ fieldId: field.id, enduserId: enduserId }, (selectedProducts.length > 0 && { selectedProductIds: selectedProducts }) // Pass selected products to Stripe checkout
|
|
915
|
-
))
|
|
916
|
-
.then(function (_a) {
|
|
917
|
-
var clientSecret = _a.clientSecret, publishableKey = _a.publishableKey, stripeAccount = _a.stripeAccount, businessName = _a.businessName, customerId = _a.customerId, isCheckout = _a.isCheckout, answerText = _a.answerText;
|
|
918
|
-
setAnswertext(answerText || '');
|
|
919
|
-
setIsCheckout(!!isCheckout);
|
|
920
|
-
setClientSecret(clientSecret);
|
|
921
|
-
setStripePromise(loadStripe(publishableKey, { stripeAccount: stripeAccount }));
|
|
922
|
-
setBusinessName(businessName);
|
|
923
|
-
setCustomerId(customerId);
|
|
924
|
-
})
|
|
925
|
-
.catch(function (e) {
|
|
926
|
-
console.error(e);
|
|
927
|
-
if (typeof (e === null || e === void 0 ? void 0 : e.message) === 'string') {
|
|
928
|
-
setError(e.message);
|
|
929
|
-
}
|
|
930
|
-
});
|
|
931
|
-
};
|
|
932
|
-
return (_jsxs(Grid, __assign({ container: true, direction: "column", spacing: 2 }, { children: [_jsx(Grid, __assign({ item: true }, { children: _jsxs(Typography, __assign({ variant: "h6" }, { children: ["Select Product", isSingleSelection_1 ? '' : 's'] })) })), availableProducts.map(function (product) {
|
|
933
|
-
var _a, _b, _d;
|
|
934
|
-
// Use real-time Stripe pricing if available, fallback to Tellescope pricing
|
|
935
|
-
var price = product.currentPrice || product.cost;
|
|
936
|
-
var priceAmount = (price === null || price === void 0 ? void 0 : price.amount) || 0;
|
|
937
|
-
var priceCurrency = (price === null || price === void 0 ? void 0 : price.currency) || 'USD';
|
|
938
|
-
return (_jsx(Grid, __assign({ item: true }, { children: _jsx(FormControlLabel, { control: isSingleSelection_1 ? (_jsx(Radio, { checked: selectedProducts.includes(product._id), onChange: function () { return handleProductSelection_1(product._id); } })) : (_jsx(Checkbox, { checked: selectedProducts.includes(product._id), onChange: function () { return handleProductSelection_1(product._id); } })), label: _jsxs(Box, { children: [_jsx(Typography, __assign({ variant: "body1", fontWeight: "bold" }, { children: product.title })), product.description && (_jsx(Typography, __assign({ variant: "body2", color: "textSecondary" }, { children: product.description }))), _jsxs(Typography, __assign({ variant: "body2", color: "primary" }, { children: ["$", (priceAmount / 100).toFixed(2), " ", priceCurrency.toUpperCase(), ((_a = product.currentPrice) === null || _a === void 0 ? void 0 : _a.isSubscription) && (_jsx(Typography, __assign({ component: "span", variant: "caption", sx: { ml: 0.5 } }, { children: format_stripe_subscription_interval((_b = product.currentPrice) === null || _b === void 0 ? void 0 : _b.interval, (_d = product.currentPrice) === null || _d === void 0 ? void 0 : _d.interval_count) })))] }))] }) }) }), product._id));
|
|
939
|
-
}), _jsx(Grid, __assign({ item: true }, { children: _jsx(Button, __assign({ variant: "contained", onClick: handleContinueToPayment, disabled: selectedProducts.length === 0, sx: { mt: 2 } }, { children: "Continue to Payment" })) }))] })));
|
|
940
|
-
}
|
|
941
|
-
if (error) {
|
|
942
|
-
return (_jsx(Typography, __assign({ color: "error" }, { children: error })));
|
|
943
|
-
}
|
|
944
|
-
if (value) {
|
|
945
|
-
return (_jsxs(Grid, __assign({ container: true, alignItems: "center", wrap: "nowrap" }, { children: [_jsx(CheckCircleOutline, { color: "success" }), _jsx(Typography, __assign({ sx: { ml: 1, fontSize: 20 } }, { children: ((_d = field.options) === null || _d === void 0 ? void 0 : _d.chargeImmediately) ? 'Your purchase was successful' : "Your payment details have been saved!" }))] })));
|
|
946
|
-
}
|
|
947
|
-
if (!(clientSecret && stripePromise))
|
|
948
|
-
return _jsx(LinearProgress, {});
|
|
949
|
-
if (isCheckout && stripePromise)
|
|
950
|
-
return (_jsx(EmbeddedCheckoutProvider, __assign({ stripe: stripePromise, options: {
|
|
951
|
-
clientSecret: clientSecret,
|
|
952
|
-
onComplete: function () { return onChange(answertext || 'Completed checkout', field.id); },
|
|
953
|
-
} }, { children: _jsx(EmbeddedCheckout, {}) })));
|
|
954
|
-
return (_jsx(Elements, __assign({ stripe: stripePromise, options: {
|
|
955
|
-
clientSecret: clientSecret,
|
|
956
|
-
} }, { children: _jsx(StripeForm, { businessName: businessName, onSuccess: function () { return onChange(answertext || 'Saved card details', field.id); }, cost: cost, field: field }) })));
|
|
957
|
-
};
|
|
958
|
-
var StripeForm = function (_a) {
|
|
959
|
-
var _b, _d, _e;
|
|
960
|
-
var businessName = _a.businessName, onSuccess = _a.onSuccess, field = _a.field, cost = _a.cost;
|
|
961
|
-
var stripe = useStripe();
|
|
962
|
-
var elements = useElements();
|
|
963
|
-
var _f = useState(false), ready = _f[0], setReady = _f[1];
|
|
964
|
-
var _g = useState(''), errorMessage = _g[0], setErrorMessage = _g[1];
|
|
965
|
-
var handleSubmit = function (event) { return __awaiter(void 0, void 0, void 0, function () {
|
|
966
|
-
var error;
|
|
967
|
-
var _a, _b;
|
|
968
|
-
return __generator(this, function (_d) {
|
|
969
|
-
switch (_d.label) {
|
|
970
|
-
case 0:
|
|
971
|
-
// We don't want to let default form submission happen here,
|
|
972
|
-
// which would refresh the page.
|
|
973
|
-
event === null || event === void 0 ? void 0 : event.preventDefault();
|
|
974
|
-
if (!stripe || !elements) {
|
|
975
|
-
// Stripe.js hasn't yet loaded.
|
|
976
|
-
// Make sure to disable form submission until Stripe.js has loaded.
|
|
977
|
-
return [2 /*return*/, null];
|
|
978
|
-
}
|
|
979
|
-
return [4 /*yield*/, (((_a = field.options) === null || _a === void 0 ? void 0 : _a.chargeImmediately) ? stripe.confirmPayment : stripe.confirmSetup)({
|
|
980
|
-
//`Elements` instance that was used to create the Payment Element
|
|
981
|
-
elements: elements,
|
|
982
|
-
confirmParams: {
|
|
983
|
-
return_url: window.location.href,
|
|
984
|
-
},
|
|
985
|
-
redirect: 'if_required', // ensures the redirect url won't be used, unless the Bank redirect payment type is enabled (it's not, just card)
|
|
986
|
-
})];
|
|
987
|
-
case 1:
|
|
988
|
-
error = (_d.sent()).error;
|
|
989
|
-
if (error) {
|
|
990
|
-
// This point will only be reached if there is an immediate error when
|
|
991
|
-
// confirming the payment. Show error to your customer (for example, payment
|
|
992
|
-
// details incomplete)
|
|
993
|
-
setErrorMessage((_b = error === null || error === void 0 ? void 0 : error.message) !== null && _b !== void 0 ? _b : '');
|
|
994
|
-
}
|
|
995
|
-
else {
|
|
996
|
-
onSuccess();
|
|
997
|
-
// Your customer will be redirected to your `return_url`. For some payment
|
|
998
|
-
// methods like iDEAL, your customer will be redirected to an intermediate
|
|
999
|
-
// site first to authorize the payment, then redirected to the `return_url`.
|
|
1000
|
-
}
|
|
1001
|
-
return [2 /*return*/];
|
|
1002
|
-
}
|
|
1003
|
-
});
|
|
1004
|
-
}); };
|
|
1005
|
-
return (_jsxs("form", __assign({ onSubmit: handleSubmit }, { children: [_jsx(PaymentElement, { onReady: function () { return setReady(true); }, options: {
|
|
1006
|
-
business: { name: businessName },
|
|
1007
|
-
} }), _jsx(Button, __assign({ variant: "contained", color: "primary", type: "submit", sx: { mt: 1 }, disabled: !(stripe && ready) }, { children: ((_b = field.options) === null || _b === void 0 ? void 0 : _b.chargeImmediately) ? 'Make Payment' : 'Save Payment Details' })), cost > 0 &&
|
|
1008
|
-
_jsx(Typography, __assign({ sx: { mt: 0.5 } }, { children: ((_d = field.options) === null || _d === void 0 ? void 0 : _d.customPriceMessage)
|
|
1009
|
-
? field.options.customPriceMessage.replaceAll('{{PRICE}}', "$".concat((cost / 100).toFixed(2)))
|
|
1010
|
-
: "You will be charged $".concat((cost / 100).toFixed(2), " ").concat(((_e = field.options) === null || _e === void 0 ? void 0 : _e.chargeImmediately) ? '' : 'on form submission') })), errorMessage &&
|
|
1011
|
-
_jsx(Typography, __assign({ color: "error", sx: { mt: 0.5 } }, { children: errorMessage }))] })));
|
|
1012
|
-
};
|
|
806
|
+
// StripeInput is shared between v1 and v2 forms
|
|
807
|
+
// Both versions use the same implementation from inputs.tsx to ensure consistent behavior
|
|
808
|
+
// and avoid code duplication. Re-exporting here maintains the pattern where forms.v2.tsx
|
|
809
|
+
// only imports from inputs.v2.tsx
|
|
810
|
+
export { StripeInput } from './inputs';
|
|
1013
811
|
export var Progress = function (_a) {
|
|
1014
812
|
var numerator = _a.numerator, denominator = _a.denominator, style = _a.style, color = _a.color;
|
|
1015
813
|
return (_jsx(Box, __assign({ sx: __assign({ display: 'flex', alignItems: 'center' }, style) }, { children: _jsx(Box, __assign({ sx: { width: '100%' } }, { children: _jsx(LinearProgress, { variant: "determinate", value: (numerator / (denominator || 1)) * 100, sx: color ? {
|
|
@@ -1663,7 +1461,7 @@ export var contact_is_valid = function (e) {
|
|
|
1663
1461
|
};
|
|
1664
1462
|
export var RelatedContactsInput = function (_a) {
|
|
1665
1463
|
var _b, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _w, _x;
|
|
1666
|
-
var field = _a.field, _value = _a.value, onChange = _a.onChange, props = __rest(_a, ["field", "value", "onChange"]);
|
|
1464
|
+
var field = _a.field, _value = _a.value, onChange = _a.onChange, parentError = _a.error, props = __rest(_a, ["field", "value", "onChange", "error"]);
|
|
1667
1465
|
// safeguard against any rogue values like empty string
|
|
1668
1466
|
var value = Array.isArray(_value) ? _value : [];
|
|
1669
1467
|
var _y = useState(value.length === 1 ? 0 : -1), editing = _y[0], setEditing = _y[1];
|
|
@@ -1682,7 +1480,7 @@ export var RelatedContactsInput = function (_a) {
|
|
|
1682
1480
|
_jsx(Grid, __assign({ item: true, xs: 4 }, { children: _jsx(TextField, { label: "Last Name", size: "small", fullWidth: true, InputProps: defaultInputProps, value: lname, onChange: function (e) { return onChange(value.map(function (v, i) { return i === editing ? __assign(__assign({}, v), { lname: e.target.value }) : v; }), field.id); } }) })), _jsx(Grid, __assign({ item: true, xs: 4 }, { children: _jsx(StringSelector, { options: ((_j = (_h = field.options) === null || _h === void 0 ? void 0 : _h.relatedContactTypes) === null || _j === void 0 ? void 0 : _j.length) ? field.options.relatedContactTypes : RELATIONSHIP_TYPES, label: "Relationship", size: "small", disabled: ((_l = (_k = field === null || field === void 0 ? void 0 : field.options) === null || _k === void 0 ? void 0 : _k.relatedContactTypes) === null || _l === void 0 ? void 0 : _l.length) === 1, value: (_o = (_m = relationships === null || relationships === void 0 ? void 0 : relationships[0]) === null || _m === void 0 ? void 0 : _m.type) !== null && _o !== void 0 ? _o : '', onChange: function (type) { return onChange(value.map(function (v, i) { return i === editing ? __assign(__assign({}, v), { relationships: [{ type: type, id: '' /* to be filled on server-side */ }] }) : v; }), field.id); } }) }))] })) })), _jsx(Grid, __assign({ item: true }, { children: _jsxs(Grid, __assign({ container: true, alignItems: "center", wrap: "nowrap", spacing: 1 }, { children: [!((_q = (_p = field.options) === null || _p === void 0 ? void 0 : _p.hiddenDefaultFields) === null || _q === void 0 ? void 0 : _q.includes('Date of Birth')) &&
|
|
1683
1481
|
_jsx(Grid, __assign({ item: true, xs: 4 }, { children: _jsx(DateStringInput, { value: dateOfBirth, field: __assign(__assign({}, field), { isOptional: true }), size: "small", label: "Date of Birth (MM-DD-YYYY)", onChange: function (dateOfBirth) { return onChange(value.map(function (v, i) { return i === editing ? __assign(__assign({}, v), { dateOfBirth: dateOfBirth }) : v; }), field.id); } }) })), !((_s = (_r = field.options) === null || _r === void 0 ? void 0 : _r.hiddenDefaultFields) === null || _s === void 0 ? void 0 : _s.includes('Email')) &&
|
|
1684
1482
|
_jsx(Grid, __assign({ item: true, xs: 4 }, { children: _jsx(TextField, { label: "Email", size: "small", fullWidth: true, type: "email", InputProps: defaultInputProps, value: email, onChange: function (e) { return onChange(value.map(function (v, i) { return i === editing ? __assign(__assign({}, v), { email: e.target.value }) : v; }), field.id); } }) })), !((_u = (_t = field.options) === null || _t === void 0 ? void 0 : _t.hiddenDefaultFields) === null || _u === void 0 ? void 0 : _u.includes('Phone Number')) &&
|
|
1685
|
-
_jsx(Grid, __assign({ item: true, xs: 4 }, { children: _jsx(TextField, { label: "Phone Number", size: "small", fullWidth: true, InputProps: defaultInputProps, value: phone, onChange: function (e) { return onChange(value.map(function (v, i) { return i === editing ? __assign(__assign({}, v), { phone: e.target.value }) : v; }), field.id); } }) }))] })) })), (((_w = field.options) === null || _w === void 0 ? void 0 : _w.tableChoices) || []).length > 0 &&
|
|
1483
|
+
_jsx(Grid, __assign({ item: true, xs: 4 }, { children: _jsx(TextField, { label: "Phone Number", size: "small", fullWidth: true, InputProps: defaultInputProps, value: phone, onChange: function (e) { return onChange(value.map(function (v, i) { return i === editing ? __assign(__assign({}, v), { phone: e.target.value.trim() }) : v; }), field.id); } }) }))] })) })), (((_w = field.options) === null || _w === void 0 ? void 0 : _w.tableChoices) || []).length > 0 &&
|
|
1686
1484
|
_jsx(Grid, __assign({ item: true }, { children: _jsx(Grid, __assign({ container: true, spacing: 1 }, { children: (((_x = field.options) === null || _x === void 0 ? void 0 : _x.tableChoices) || []).map(function (_a, i) {
|
|
1687
1485
|
var info = _a.info, label = _a.label, type = _a.type;
|
|
1688
1486
|
return (_jsx(Grid, __assign({ item: true, xs: 6 }, { children: type === 'Text'
|
|
@@ -1702,7 +1500,7 @@ export var RelatedContactsInput = function (_a) {
|
|
|
1702
1500
|
return i === editing ? __assign(__assign({}, v), { fields: __assign(__assign({}, fields_1), (_a = {}, _a[label] = e.target.value, _a)) }) : v;
|
|
1703
1501
|
}), field.id); } }, { children: [_jsx(MenuItem, __assign({ value: "" }, { children: _jsx("em", { children: "None" }) })), info.choices.map(function (c) { return (_jsx(MenuItem, __assign({ value: c }, { children: c }), c)); })] }))] })))
|
|
1704
1502
|
: null }), i));
|
|
1705
|
-
}) })) })), _jsx(Grid, __assign({ item: true, sx: { my: 0.75 } }, { children: _jsx(Button, __assign({ variant: "outlined", onClick: function () { return setEditing(-1); }, size: "small" }, { children: "Save Contact" })) })), errorMessage &&
|
|
1503
|
+
}) })) })), _jsx(Grid, __assign({ item: true, sx: { my: 0.75 } }, { children: _jsx(Button, __assign({ variant: "outlined", onClick: function () { return setEditing(-1); }, size: "small", disabled: !!errorMessage || !!parentError }, { children: "Save Contact" })) })), errorMessage &&
|
|
1706
1504
|
_jsx(Grid, __assign({ item: true }, { children: _jsx(Typography, __assign({ color: "error" }, { children: errorMessage })) }))] })));
|
|
1707
1505
|
}
|
|
1708
1506
|
return (_jsxs(Grid, __assign({ container: true, direction: "column", spacing: 1 }, { children: [_jsx(Grid, __assign({ item: true }, { children: value.map(function (contact, i) { return (_jsx(Grid, __assign({ item: true }, { children: _jsxs(Grid, __assign({ container: true, alignItems: "center", justifyContent: "space-between", wrap: "nowrap", spacing: 1 }, { children: [_jsx(Grid, __assign({ item: true }, { children: _jsxs(Grid, __assign({ container: true, alignItems: "center" }, { children: [_jsx(IconButton, __assign({ onClick: function () { return setEditing(i); }, color: "primary", size: "small" }, { children: _jsx(Edit, {}) })), _jsx(Typography, __assign({ noWrap: true }, { children: user_display_name(contact) || "Unnamed Contact ".concat(i + 1) }))] })) })), _jsx(Grid, __assign({ item: true }, { children: _jsx(LabeledIconButton, { Icon: Delete, label: "Remove", onClick: function () { return onChange(value.filter(function (v, _i) { return i !== _i; }), field.id); } }) }))] })) }), i)); }) })), _jsx(Grid, __assign({ item: true }, { children: _jsx(Button, __assign({ variant: "contained", onClick: handleAddContact }, { children: "Add Contact" })) }))] })));
|