@streamoid/settings 0.3.1 → 0.3.2
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 +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +49 -23
- package/dist/index.mjs +49 -23
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -659,10 +659,11 @@ declare function ConfirmDeleteModal({ open, workspaceName, onClose, onConfirm, }
|
|
|
659
659
|
|
|
660
660
|
interface BuyCreditsModalProps {
|
|
661
661
|
currencySymbol?: string;
|
|
662
|
+
country?: string;
|
|
662
663
|
onClose: () => void;
|
|
663
664
|
onBuy: (credits: number, price: number) => void;
|
|
664
665
|
}
|
|
665
|
-
declare function BuyCreditsModal({ currencySymbol, onClose, onBuy, }: BuyCreditsModalProps): react_jsx_runtime.JSX.Element;
|
|
666
|
+
declare function BuyCreditsModal({ currencySymbol, country, onClose, onBuy, }: BuyCreditsModalProps): react_jsx_runtime.JSX.Element;
|
|
666
667
|
|
|
667
668
|
interface UserPermissions {
|
|
668
669
|
artifax: boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -659,10 +659,11 @@ declare function ConfirmDeleteModal({ open, workspaceName, onClose, onConfirm, }
|
|
|
659
659
|
|
|
660
660
|
interface BuyCreditsModalProps {
|
|
661
661
|
currencySymbol?: string;
|
|
662
|
+
country?: string;
|
|
662
663
|
onClose: () => void;
|
|
663
664
|
onBuy: (credits: number, price: number) => void;
|
|
664
665
|
}
|
|
665
|
-
declare function BuyCreditsModal({ currencySymbol, onClose, onBuy, }: BuyCreditsModalProps): react_jsx_runtime.JSX.Element;
|
|
666
|
+
declare function BuyCreditsModal({ currencySymbol, country, onClose, onBuy, }: BuyCreditsModalProps): react_jsx_runtime.JSX.Element;
|
|
666
667
|
|
|
667
668
|
interface UserPermissions {
|
|
668
669
|
artifax: boolean;
|
package/dist/index.js
CHANGED
|
@@ -3801,41 +3801,63 @@ var import_react7 = require("react");
|
|
|
3801
3801
|
var import_icons4 = require("@streamoid/icons");
|
|
3802
3802
|
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
3803
3803
|
var STEP = 500;
|
|
3804
|
-
var
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3804
|
+
var USD_TOPUP_CONFIG = {
|
|
3805
|
+
currencyCode: "usd",
|
|
3806
|
+
pricePerCredit: 0.08,
|
|
3807
|
+
minAmount: 40,
|
|
3808
|
+
maxAmount: 1e4
|
|
3809
|
+
};
|
|
3810
|
+
var INR_TOPUP_CONFIG = {
|
|
3811
|
+
currencyCode: "inr",
|
|
3812
|
+
pricePerCredit: 5,
|
|
3813
|
+
minAmount: 2500,
|
|
3814
|
+
maxAmount: 1e5
|
|
3815
|
+
};
|
|
3809
3816
|
function BuyCreditsModal({
|
|
3810
3817
|
currencySymbol = "$",
|
|
3818
|
+
country,
|
|
3811
3819
|
onClose,
|
|
3812
3820
|
onBuy
|
|
3813
3821
|
}) {
|
|
3814
|
-
const
|
|
3815
|
-
const
|
|
3816
|
-
const
|
|
3822
|
+
const normalizedCountry = country?.trim().toUpperCase();
|
|
3823
|
+
const topupConfig = normalizedCountry === "IN" ? INR_TOPUP_CONFIG : USD_TOPUP_CONFIG;
|
|
3824
|
+
const minCredits = Math.round(
|
|
3825
|
+
topupConfig.minAmount / topupConfig.pricePerCredit
|
|
3826
|
+
);
|
|
3827
|
+
const maxCredits = Math.round(
|
|
3828
|
+
topupConfig.maxAmount / topupConfig.pricePerCredit
|
|
3829
|
+
);
|
|
3830
|
+
const [credits, setCredits] = (0, import_react7.useState)(minCredits);
|
|
3831
|
+
const [creditsInput, setCreditsInput] = (0, import_react7.useState)(String(minCredits));
|
|
3832
|
+
const [priceInput, setPriceInput] = (0, import_react7.useState)(
|
|
3833
|
+
String(minCredits * topupConfig.pricePerCredit)
|
|
3834
|
+
);
|
|
3817
3835
|
const [activeField, setActiveField] = (0, import_react7.useState)("credits");
|
|
3818
3836
|
const parsedCredits = creditsInput.length ? Number(creditsInput) : credits;
|
|
3819
3837
|
const previewCredits = Number.isFinite(parsedCredits) ? parsedCredits : credits;
|
|
3820
3838
|
const pricedCredits = previewCredits > 0 ? previewCredits : 0;
|
|
3821
|
-
const price = Number(
|
|
3822
|
-
|
|
3823
|
-
|
|
3839
|
+
const price = Number(
|
|
3840
|
+
(pricedCredits * topupConfig.pricePerCredit).toFixed(2)
|
|
3841
|
+
);
|
|
3842
|
+
const isBelowMin = price < topupConfig.minAmount;
|
|
3843
|
+
const isAboveMax = price > topupConfig.maxAmount;
|
|
3824
3844
|
const isError = isBelowMin || isAboveMax;
|
|
3825
3845
|
const isInvalid = isError;
|
|
3826
3846
|
const syncFromCredits = (value) => {
|
|
3827
3847
|
setCredits(value);
|
|
3828
3848
|
setCreditsInput(String(value));
|
|
3829
|
-
setPriceInput(
|
|
3849
|
+
setPriceInput(
|
|
3850
|
+
String(Number((value * topupConfig.pricePerCredit).toFixed(2)))
|
|
3851
|
+
);
|
|
3830
3852
|
};
|
|
3831
|
-
const syncFromPrice = (
|
|
3832
|
-
const derived = Math.round(
|
|
3853
|
+
const syncFromPrice = (amount) => {
|
|
3854
|
+
const derived = Math.round(amount / topupConfig.pricePerCredit);
|
|
3833
3855
|
setCredits(derived);
|
|
3834
3856
|
setCreditsInput(String(derived));
|
|
3835
|
-
setPriceInput(String(
|
|
3857
|
+
setPriceInput(String(amount));
|
|
3836
3858
|
};
|
|
3837
|
-
const handleDecrement = () => syncFromCredits(Math.max(
|
|
3838
|
-
const handleIncrement = () => syncFromCredits(Math.min(
|
|
3859
|
+
const handleDecrement = () => syncFromCredits(Math.max(minCredits, credits - STEP));
|
|
3860
|
+
const handleIncrement = () => syncFromCredits(Math.min(maxCredits, credits + STEP));
|
|
3839
3861
|
const handleCreditsChange = (value) => {
|
|
3840
3862
|
const raw = value.replace(/[^\d]/g, "");
|
|
3841
3863
|
setCreditsInput(raw);
|
|
@@ -3844,7 +3866,9 @@ function BuyCreditsModal({
|
|
|
3844
3866
|
const next = Number(raw);
|
|
3845
3867
|
if (!Number.isNaN(next)) {
|
|
3846
3868
|
setCredits(next);
|
|
3847
|
-
setPriceInput(
|
|
3869
|
+
setPriceInput(
|
|
3870
|
+
String(Number((next * topupConfig.pricePerCredit).toFixed(2)))
|
|
3871
|
+
);
|
|
3848
3872
|
}
|
|
3849
3873
|
};
|
|
3850
3874
|
const handleCreditsBlur = () => {
|
|
@@ -3862,7 +3886,7 @@ function BuyCreditsModal({
|
|
|
3862
3886
|
if (!raw.length) return;
|
|
3863
3887
|
const next = Number(raw);
|
|
3864
3888
|
if (!Number.isNaN(next) && next >= 0) {
|
|
3865
|
-
const derived = Math.round(next /
|
|
3889
|
+
const derived = Math.round(next / topupConfig.pricePerCredit);
|
|
3866
3890
|
setCredits(derived);
|
|
3867
3891
|
setCreditsInput(String(derived));
|
|
3868
3892
|
}
|
|
@@ -3966,7 +3990,7 @@ function BuyCreditsModal({
|
|
|
3966
3990
|
style: {
|
|
3967
3991
|
width: 24,
|
|
3968
3992
|
height: 24,
|
|
3969
|
-
opacity: credits <=
|
|
3993
|
+
opacity: credits <= minCredits ? 0.3 : 1,
|
|
3970
3994
|
transition: "opacity 0.15s ease"
|
|
3971
3995
|
},
|
|
3972
3996
|
onClick: handleDecrement,
|
|
@@ -4024,7 +4048,7 @@ function BuyCreditsModal({
|
|
|
4024
4048
|
style: {
|
|
4025
4049
|
width: 24,
|
|
4026
4050
|
height: 24,
|
|
4027
|
-
opacity: credits >=
|
|
4051
|
+
opacity: credits >= maxCredits ? 0.3 : 1,
|
|
4028
4052
|
transition: "opacity 0.15s ease"
|
|
4029
4053
|
},
|
|
4030
4054
|
onClick: handleIncrement,
|
|
@@ -4111,7 +4135,7 @@ function BuyCreditsModal({
|
|
|
4111
4135
|
lineHeight: "var(--line-height-line-height-sm)",
|
|
4112
4136
|
color: "var(--alias-text---icons-error)"
|
|
4113
4137
|
},
|
|
4114
|
-
children: isBelowMin ? `Min. ${
|
|
4138
|
+
children: isBelowMin ? `Min. ${minCredits.toLocaleString()} credits` : `Max. ${maxCredits.toLocaleString()} credits`
|
|
4115
4139
|
}
|
|
4116
4140
|
) })
|
|
4117
4141
|
}
|
|
@@ -5838,12 +5862,13 @@ function BillingContent({
|
|
|
5838
5862
|
}
|
|
5839
5863
|
);
|
|
5840
5864
|
try {
|
|
5865
|
+
const topupCurrency = workspace.current?.country?.trim().toUpperCase() === "IN" ? "inr" : "usd";
|
|
5841
5866
|
const res = await api.buyCredits({
|
|
5842
5867
|
serviceName: DEFAULT_TOPUP_SERVICE,
|
|
5843
5868
|
credits,
|
|
5844
5869
|
unitAmount: price,
|
|
5845
5870
|
itemCount: 1,
|
|
5846
|
-
currency:
|
|
5871
|
+
currency: topupCurrency,
|
|
5847
5872
|
successUrl: resolveReturnUrl("success"),
|
|
5848
5873
|
cancelUrl: resolveReturnUrl("cancel"),
|
|
5849
5874
|
metadata: { source: "self-serve" }
|
|
@@ -6058,6 +6083,7 @@ function BillingContent({
|
|
|
6058
6083
|
showBuyCreditsModal && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
6059
6084
|
BuyCreditsModal,
|
|
6060
6085
|
{
|
|
6086
|
+
country: workspace.current?.country,
|
|
6061
6087
|
currencySymbol: getCurrencySymbolByCountry(workspace.current?.country),
|
|
6062
6088
|
onClose: () => setShowBuyCreditsModal(false),
|
|
6063
6089
|
onBuy: (credits, price) => {
|
package/dist/index.mjs
CHANGED
|
@@ -3820,41 +3820,63 @@ import { useState as useState6 } from "react";
|
|
|
3820
3820
|
import { SiconClose as SiconClose3, SiconPlus, SiconMinus } from "@streamoid/icons";
|
|
3821
3821
|
import { jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
3822
3822
|
var STEP = 500;
|
|
3823
|
-
var
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3823
|
+
var USD_TOPUP_CONFIG = {
|
|
3824
|
+
currencyCode: "usd",
|
|
3825
|
+
pricePerCredit: 0.08,
|
|
3826
|
+
minAmount: 40,
|
|
3827
|
+
maxAmount: 1e4
|
|
3828
|
+
};
|
|
3829
|
+
var INR_TOPUP_CONFIG = {
|
|
3830
|
+
currencyCode: "inr",
|
|
3831
|
+
pricePerCredit: 5,
|
|
3832
|
+
minAmount: 2500,
|
|
3833
|
+
maxAmount: 1e5
|
|
3834
|
+
};
|
|
3828
3835
|
function BuyCreditsModal({
|
|
3829
3836
|
currencySymbol = "$",
|
|
3837
|
+
country,
|
|
3830
3838
|
onClose,
|
|
3831
3839
|
onBuy
|
|
3832
3840
|
}) {
|
|
3833
|
-
const
|
|
3834
|
-
const
|
|
3835
|
-
const
|
|
3841
|
+
const normalizedCountry = country?.trim().toUpperCase();
|
|
3842
|
+
const topupConfig = normalizedCountry === "IN" ? INR_TOPUP_CONFIG : USD_TOPUP_CONFIG;
|
|
3843
|
+
const minCredits = Math.round(
|
|
3844
|
+
topupConfig.minAmount / topupConfig.pricePerCredit
|
|
3845
|
+
);
|
|
3846
|
+
const maxCredits = Math.round(
|
|
3847
|
+
topupConfig.maxAmount / topupConfig.pricePerCredit
|
|
3848
|
+
);
|
|
3849
|
+
const [credits, setCredits] = useState6(minCredits);
|
|
3850
|
+
const [creditsInput, setCreditsInput] = useState6(String(minCredits));
|
|
3851
|
+
const [priceInput, setPriceInput] = useState6(
|
|
3852
|
+
String(minCredits * topupConfig.pricePerCredit)
|
|
3853
|
+
);
|
|
3836
3854
|
const [activeField, setActiveField] = useState6("credits");
|
|
3837
3855
|
const parsedCredits = creditsInput.length ? Number(creditsInput) : credits;
|
|
3838
3856
|
const previewCredits = Number.isFinite(parsedCredits) ? parsedCredits : credits;
|
|
3839
3857
|
const pricedCredits = previewCredits > 0 ? previewCredits : 0;
|
|
3840
|
-
const price = Number(
|
|
3841
|
-
|
|
3842
|
-
|
|
3858
|
+
const price = Number(
|
|
3859
|
+
(pricedCredits * topupConfig.pricePerCredit).toFixed(2)
|
|
3860
|
+
);
|
|
3861
|
+
const isBelowMin = price < topupConfig.minAmount;
|
|
3862
|
+
const isAboveMax = price > topupConfig.maxAmount;
|
|
3843
3863
|
const isError = isBelowMin || isAboveMax;
|
|
3844
3864
|
const isInvalid = isError;
|
|
3845
3865
|
const syncFromCredits = (value) => {
|
|
3846
3866
|
setCredits(value);
|
|
3847
3867
|
setCreditsInput(String(value));
|
|
3848
|
-
setPriceInput(
|
|
3868
|
+
setPriceInput(
|
|
3869
|
+
String(Number((value * topupConfig.pricePerCredit).toFixed(2)))
|
|
3870
|
+
);
|
|
3849
3871
|
};
|
|
3850
|
-
const syncFromPrice = (
|
|
3851
|
-
const derived = Math.round(
|
|
3872
|
+
const syncFromPrice = (amount) => {
|
|
3873
|
+
const derived = Math.round(amount / topupConfig.pricePerCredit);
|
|
3852
3874
|
setCredits(derived);
|
|
3853
3875
|
setCreditsInput(String(derived));
|
|
3854
|
-
setPriceInput(String(
|
|
3876
|
+
setPriceInput(String(amount));
|
|
3855
3877
|
};
|
|
3856
|
-
const handleDecrement = () => syncFromCredits(Math.max(
|
|
3857
|
-
const handleIncrement = () => syncFromCredits(Math.min(
|
|
3878
|
+
const handleDecrement = () => syncFromCredits(Math.max(minCredits, credits - STEP));
|
|
3879
|
+
const handleIncrement = () => syncFromCredits(Math.min(maxCredits, credits + STEP));
|
|
3858
3880
|
const handleCreditsChange = (value) => {
|
|
3859
3881
|
const raw = value.replace(/[^\d]/g, "");
|
|
3860
3882
|
setCreditsInput(raw);
|
|
@@ -3863,7 +3885,9 @@ function BuyCreditsModal({
|
|
|
3863
3885
|
const next = Number(raw);
|
|
3864
3886
|
if (!Number.isNaN(next)) {
|
|
3865
3887
|
setCredits(next);
|
|
3866
|
-
setPriceInput(
|
|
3888
|
+
setPriceInput(
|
|
3889
|
+
String(Number((next * topupConfig.pricePerCredit).toFixed(2)))
|
|
3890
|
+
);
|
|
3867
3891
|
}
|
|
3868
3892
|
};
|
|
3869
3893
|
const handleCreditsBlur = () => {
|
|
@@ -3881,7 +3905,7 @@ function BuyCreditsModal({
|
|
|
3881
3905
|
if (!raw.length) return;
|
|
3882
3906
|
const next = Number(raw);
|
|
3883
3907
|
if (!Number.isNaN(next) && next >= 0) {
|
|
3884
|
-
const derived = Math.round(next /
|
|
3908
|
+
const derived = Math.round(next / topupConfig.pricePerCredit);
|
|
3885
3909
|
setCredits(derived);
|
|
3886
3910
|
setCreditsInput(String(derived));
|
|
3887
3911
|
}
|
|
@@ -3985,7 +4009,7 @@ function BuyCreditsModal({
|
|
|
3985
4009
|
style: {
|
|
3986
4010
|
width: 24,
|
|
3987
4011
|
height: 24,
|
|
3988
|
-
opacity: credits <=
|
|
4012
|
+
opacity: credits <= minCredits ? 0.3 : 1,
|
|
3989
4013
|
transition: "opacity 0.15s ease"
|
|
3990
4014
|
},
|
|
3991
4015
|
onClick: handleDecrement,
|
|
@@ -4043,7 +4067,7 @@ function BuyCreditsModal({
|
|
|
4043
4067
|
style: {
|
|
4044
4068
|
width: 24,
|
|
4045
4069
|
height: 24,
|
|
4046
|
-
opacity: credits >=
|
|
4070
|
+
opacity: credits >= maxCredits ? 0.3 : 1,
|
|
4047
4071
|
transition: "opacity 0.15s ease"
|
|
4048
4072
|
},
|
|
4049
4073
|
onClick: handleIncrement,
|
|
@@ -4130,7 +4154,7 @@ function BuyCreditsModal({
|
|
|
4130
4154
|
lineHeight: "var(--line-height-line-height-sm)",
|
|
4131
4155
|
color: "var(--alias-text---icons-error)"
|
|
4132
4156
|
},
|
|
4133
|
-
children: isBelowMin ? `Min. ${
|
|
4157
|
+
children: isBelowMin ? `Min. ${minCredits.toLocaleString()} credits` : `Max. ${maxCredits.toLocaleString()} credits`
|
|
4134
4158
|
}
|
|
4135
4159
|
) })
|
|
4136
4160
|
}
|
|
@@ -5857,12 +5881,13 @@ function BillingContent({
|
|
|
5857
5881
|
}
|
|
5858
5882
|
);
|
|
5859
5883
|
try {
|
|
5884
|
+
const topupCurrency = workspace.current?.country?.trim().toUpperCase() === "IN" ? "inr" : "usd";
|
|
5860
5885
|
const res = await api.buyCredits({
|
|
5861
5886
|
serviceName: DEFAULT_TOPUP_SERVICE,
|
|
5862
5887
|
credits,
|
|
5863
5888
|
unitAmount: price,
|
|
5864
5889
|
itemCount: 1,
|
|
5865
|
-
currency:
|
|
5890
|
+
currency: topupCurrency,
|
|
5866
5891
|
successUrl: resolveReturnUrl("success"),
|
|
5867
5892
|
cancelUrl: resolveReturnUrl("cancel"),
|
|
5868
5893
|
metadata: { source: "self-serve" }
|
|
@@ -6077,6 +6102,7 @@ function BillingContent({
|
|
|
6077
6102
|
showBuyCreditsModal && /* @__PURE__ */ jsx11(
|
|
6078
6103
|
BuyCreditsModal,
|
|
6079
6104
|
{
|
|
6105
|
+
country: workspace.current?.country,
|
|
6080
6106
|
currencySymbol: getCurrencySymbolByCountry(workspace.current?.country),
|
|
6081
6107
|
onClose: () => setShowBuyCreditsModal(false),
|
|
6082
6108
|
onBuy: (credits, price) => {
|