@pollar/react 0.10.1-rc.2 → 0.10.1-rc.3
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/index.d.mts +11 -5
- package/dist/index.d.ts +11 -5
- package/dist/index.js +31 -44
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +31 -44
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1033,7 +1033,7 @@ var PollarModalFooter = () => {
|
|
|
1033
1033
|
/* @__PURE__ */ jsx("span", { className: "pollar-footer-name", children: "Pollar" }),
|
|
1034
1034
|
/* @__PURE__ */ jsxs("span", { className: "pollar-footer-version", children: [
|
|
1035
1035
|
"v",
|
|
1036
|
-
"0.10.1-rc.
|
|
1036
|
+
"0.10.1-rc.3"
|
|
1037
1037
|
] })
|
|
1038
1038
|
] })
|
|
1039
1039
|
] });
|
|
@@ -2504,8 +2504,8 @@ function RampWidgetTemplate({
|
|
|
2504
2504
|
amount,
|
|
2505
2505
|
currency,
|
|
2506
2506
|
country,
|
|
2507
|
-
|
|
2508
|
-
|
|
2507
|
+
requiredFields,
|
|
2508
|
+
fieldValues,
|
|
2509
2509
|
countries,
|
|
2510
2510
|
countriesLoading,
|
|
2511
2511
|
refreshing,
|
|
@@ -2521,8 +2521,7 @@ function RampWidgetTemplate({
|
|
|
2521
2521
|
errorMsg,
|
|
2522
2522
|
onDirectionChange,
|
|
2523
2523
|
onAmountChange,
|
|
2524
|
-
|
|
2525
|
-
onFullNameChange,
|
|
2524
|
+
onFieldChange,
|
|
2526
2525
|
onCountryChange,
|
|
2527
2526
|
onFindRoute,
|
|
2528
2527
|
onSelectQuote,
|
|
@@ -2673,33 +2672,19 @@ function RampWidgetTemplate({
|
|
|
2673
2672
|
/* @__PURE__ */ jsx("button", { type: "button", className: "pollar-btn-secondary", onClick: onClose, children: "Cancel" })
|
|
2674
2673
|
] }),
|
|
2675
2674
|
step === "contact" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2676
|
-
/* @__PURE__ */ jsxs("div", { className: "pollar-ramp-field", children: [
|
|
2677
|
-
/* @__PURE__ */ jsx("label", { className: "pollar-ramp-label", children:
|
|
2675
|
+
requiredFields.map((f) => /* @__PURE__ */ jsxs("div", { className: "pollar-ramp-field", children: [
|
|
2676
|
+
/* @__PURE__ */ jsx("label", { className: "pollar-ramp-label", children: f.label }),
|
|
2678
2677
|
/* @__PURE__ */ jsx(
|
|
2679
2678
|
"input",
|
|
2680
2679
|
{
|
|
2681
|
-
type:
|
|
2680
|
+
type: f.type,
|
|
2682
2681
|
className: "pollar-ramp-input",
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
onChange: (e) =>
|
|
2682
|
+
value: fieldValues[f.key] ?? "",
|
|
2683
|
+
autoComplete: f.type === "email" ? "email" : "off",
|
|
2684
|
+
onChange: (e) => onFieldChange(f.key, e.target.value)
|
|
2686
2685
|
}
|
|
2687
2686
|
)
|
|
2688
|
-
] }),
|
|
2689
|
-
/* @__PURE__ */ jsxs("div", { className: "pollar-ramp-field", children: [
|
|
2690
|
-
/* @__PURE__ */ jsx("label", { className: "pollar-ramp-label", children: "Email" }),
|
|
2691
|
-
/* @__PURE__ */ jsx(
|
|
2692
|
-
"input",
|
|
2693
|
-
{
|
|
2694
|
-
type: "email",
|
|
2695
|
-
className: "pollar-ramp-input",
|
|
2696
|
-
placeholder: "jane@example.com",
|
|
2697
|
-
value: email,
|
|
2698
|
-
autoComplete: "email",
|
|
2699
|
-
onChange: (e) => onEmailChange(e.target.value)
|
|
2700
|
-
}
|
|
2701
|
-
)
|
|
2702
|
-
] }),
|
|
2687
|
+
] }, f.key)),
|
|
2703
2688
|
/* @__PURE__ */ jsxs("div", { className: "pollar-modal-actions", children: [
|
|
2704
2689
|
/* @__PURE__ */ jsx("button", { type: "button", className: "pollar-btn-secondary", onClick: onRetry, children: "Back" }),
|
|
2705
2690
|
/* @__PURE__ */ jsx(
|
|
@@ -2707,7 +2692,7 @@ function RampWidgetTemplate({
|
|
|
2707
2692
|
{
|
|
2708
2693
|
type: "button",
|
|
2709
2694
|
className: "pollar-btn-primary",
|
|
2710
|
-
disabled:
|
|
2695
|
+
disabled: requiredFields.some((f) => !(fieldValues[f.key] ?? "").trim()) || isLoading,
|
|
2711
2696
|
onClick: onContactContinue,
|
|
2712
2697
|
children: isLoading ? "Starting\u2026" : "Continue"
|
|
2713
2698
|
}
|
|
@@ -2753,6 +2738,9 @@ function RampWidgetTemplate({
|
|
|
2753
2738
|
] });
|
|
2754
2739
|
}
|
|
2755
2740
|
var TERMINAL = ["completed", "failed"];
|
|
2741
|
+
function requiredFieldsOf(quote) {
|
|
2742
|
+
return quote.requiredFields ?? [];
|
|
2743
|
+
}
|
|
2756
2744
|
function RampWidget({ onClose }) {
|
|
2757
2745
|
const { getClient, signTx, wallet, styles } = usePollar();
|
|
2758
2746
|
const walletAddress = wallet?.address ?? "";
|
|
@@ -2763,8 +2751,8 @@ function RampWidget({ onClose }) {
|
|
|
2763
2751
|
const [amount, setAmount] = useState("");
|
|
2764
2752
|
const [currency, setCurrency] = useState("");
|
|
2765
2753
|
const [country, setCountry] = useState("");
|
|
2766
|
-
const [
|
|
2767
|
-
const
|
|
2754
|
+
const [fieldValues, setFieldValues] = useState({});
|
|
2755
|
+
const setFieldValue = (key, value) => setFieldValues((v) => ({ ...v, [key]: value }));
|
|
2768
2756
|
const [countries, setCountries] = useState([]);
|
|
2769
2757
|
const [countriesLoading, setCountriesLoading] = useState(true);
|
|
2770
2758
|
const [refreshing, setRefreshing] = useState(false);
|
|
@@ -2911,8 +2899,9 @@ function RampWidget({ onClose }) {
|
|
|
2911
2899
|
function handleSelectQuote(quote) {
|
|
2912
2900
|
setSelectedQuote(quote);
|
|
2913
2901
|
setErrorMsg(null);
|
|
2914
|
-
const
|
|
2915
|
-
|
|
2902
|
+
const fields = requiredFieldsOf(quote);
|
|
2903
|
+
const missing = fields.some((f) => !(fieldValues[f.key] ?? "").trim());
|
|
2904
|
+
if (fields.length > 0 && missing) {
|
|
2916
2905
|
setStep("contact");
|
|
2917
2906
|
return;
|
|
2918
2907
|
}
|
|
@@ -2925,15 +2914,14 @@ function RampWidget({ onClose }) {
|
|
|
2925
2914
|
setIsLoading(true);
|
|
2926
2915
|
setErrorMsg(null);
|
|
2927
2916
|
try {
|
|
2928
|
-
const base = {
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
};
|
|
2917
|
+
const base = { quoteId: quote.quoteId, amount: Number(amount), currency, country };
|
|
2918
|
+
if (walletAddress) base.walletAddress = walletAddress;
|
|
2919
|
+
for (const f of requiredFieldsOf(quote)) {
|
|
2920
|
+
const val = (fieldValues[f.key] ?? "").trim();
|
|
2921
|
+
if (!val) continue;
|
|
2922
|
+
if (f.bankType) base.bankDetails = { type: f.bankType, value: val };
|
|
2923
|
+
else base[f.key] = val;
|
|
2924
|
+
}
|
|
2937
2925
|
const result = direction === "onramp" ? await client.createOnRamp(base) : await client.createOffRamp(base);
|
|
2938
2926
|
await applyResult(result);
|
|
2939
2927
|
} catch (e) {
|
|
@@ -2978,8 +2966,8 @@ function RampWidget({ onClose }) {
|
|
|
2978
2966
|
amount,
|
|
2979
2967
|
currency,
|
|
2980
2968
|
country,
|
|
2981
|
-
|
|
2982
|
-
|
|
2969
|
+
requiredFields: selectedQuote ? requiredFieldsOf(selectedQuote) : [],
|
|
2970
|
+
fieldValues,
|
|
2983
2971
|
countries,
|
|
2984
2972
|
countriesLoading,
|
|
2985
2973
|
refreshing,
|
|
@@ -2995,8 +2983,7 @@ function RampWidget({ onClose }) {
|
|
|
2995
2983
|
errorMsg,
|
|
2996
2984
|
onDirectionChange: setDirection,
|
|
2997
2985
|
onAmountChange: setAmount,
|
|
2998
|
-
|
|
2999
|
-
onFullNameChange: setFullName,
|
|
2986
|
+
onFieldChange: setFieldValue,
|
|
3000
2987
|
onCountryChange: handleCountryChange,
|
|
3001
2988
|
onFindRoute: handleFindRoute,
|
|
3002
2989
|
onSelectQuote: handleSelectQuote,
|