@streamoid/settings 0.3.0 → 0.3.1

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 CHANGED
@@ -658,10 +658,11 @@ interface ConfirmDeleteModalProps {
658
658
  declare function ConfirmDeleteModal({ open, workspaceName, onClose, onConfirm, }: ConfirmDeleteModalProps): react_jsx_runtime.JSX.Element | null;
659
659
 
660
660
  interface BuyCreditsModalProps {
661
+ currencySymbol?: string;
661
662
  onClose: () => void;
662
663
  onBuy: (credits: number, price: number) => void;
663
664
  }
664
- declare function BuyCreditsModal({ onClose, onBuy }: BuyCreditsModalProps): react_jsx_runtime.JSX.Element;
665
+ declare function BuyCreditsModal({ currencySymbol, onClose, onBuy, }: BuyCreditsModalProps): react_jsx_runtime.JSX.Element;
665
666
 
666
667
  interface UserPermissions {
667
668
  artifax: boolean;
package/dist/index.d.ts CHANGED
@@ -658,10 +658,11 @@ interface ConfirmDeleteModalProps {
658
658
  declare function ConfirmDeleteModal({ open, workspaceName, onClose, onConfirm, }: ConfirmDeleteModalProps): react_jsx_runtime.JSX.Element | null;
659
659
 
660
660
  interface BuyCreditsModalProps {
661
+ currencySymbol?: string;
661
662
  onClose: () => void;
662
663
  onBuy: (credits: number, price: number) => void;
663
664
  }
664
- declare function BuyCreditsModal({ onClose, onBuy }: BuyCreditsModalProps): react_jsx_runtime.JSX.Element;
665
+ declare function BuyCreditsModal({ currencySymbol, onClose, onBuy, }: BuyCreditsModalProps): react_jsx_runtime.JSX.Element;
665
666
 
666
667
  interface UserPermissions {
667
668
  artifax: boolean;
package/dist/index.js CHANGED
@@ -3806,7 +3806,11 @@ var MIN_USD = 40;
3806
3806
  var MAX_USD = 1e4;
3807
3807
  var MIN_CREDITS = Math.round(MIN_USD / PRICE_PER_CREDIT);
3808
3808
  var MAX_CREDITS = Math.round(MAX_USD / PRICE_PER_CREDIT);
3809
- function BuyCreditsModal({ onClose, onBuy }) {
3809
+ function BuyCreditsModal({
3810
+ currencySymbol = "$",
3811
+ onClose,
3812
+ onBuy
3813
+ }) {
3810
3814
  const [credits, setCredits] = (0, import_react7.useState)(MIN_CREDITS);
3811
3815
  const [creditsInput, setCreditsInput] = (0, import_react7.useState)(String(MIN_CREDITS));
3812
3816
  const [priceInput, setPriceInput] = (0, import_react7.useState)(String(MIN_CREDITS * PRICE_PER_CREDIT));
@@ -4051,7 +4055,7 @@ function BuyCreditsModal({ onClose, onBuy }) {
4051
4055
  lineHeight: "var(--line-height-line-height-lg)",
4052
4056
  color: "var(--alias-text---icons-primary)"
4053
4057
  },
4054
- children: "$"
4058
+ children: currencySymbol
4055
4059
  }
4056
4060
  ),
4057
4061
  /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
@@ -4071,7 +4075,7 @@ function BuyCreditsModal({ onClose, onBuy }) {
4071
4075
  onKeyDown: (e) => {
4072
4076
  if (e.key === "Enter") e.currentTarget.blur();
4073
4077
  },
4074
- "aria-label": "Price in USD",
4078
+ "aria-label": "Price",
4075
4079
  style: {
4076
4080
  fontFamily: "var(--font-family-font-family-body)",
4077
4081
  fontSize: "var(--font-size-font-size-lg)",
@@ -4201,6 +4205,9 @@ function formatCurrency(cents, currency) {
4201
4205
  }
4202
4206
  return `$${(cents / 100).toFixed(2)}`;
4203
4207
  }
4208
+ function getCurrencySymbolByCountry(country) {
4209
+ return country?.trim().toUpperCase() === "IN" ? "\u20B9" : "$";
4210
+ }
4204
4211
  function formatCredits(n) {
4205
4212
  return n.toLocaleString("en-US");
4206
4213
  }
@@ -4763,10 +4770,14 @@ function PlansView({
4763
4770
  actionInFlight,
4764
4771
  onPlanAction,
4765
4772
  onCancelDowngrade,
4766
- workspace
4773
+ workspace,
4774
+ isProPlan
4767
4775
  }) {
4768
4776
  console.log("=============", products);
4769
4777
  const { toast } = useSettingsAdapters();
4778
+ const workspaceCurrencySymbol = getCurrencySymbolByCountry(
4779
+ workspace?.country
4780
+ );
4770
4781
  const allPlans = (0, import_react8.useMemo)(() => {
4771
4782
  if (products.length > 0) {
4772
4783
  return products.flatMap(
@@ -4775,7 +4786,7 @@ function PlansView({
4775
4786
  productId: product.id,
4776
4787
  priceId: price.id,
4777
4788
  planName: price.metadata.name,
4778
- price: price.unit_amount === 0 ? price.currency === "inr" ? "\u20B90" : "$0" : `${formatCurrency(price.unit_amount, price.currency ?? "usd")} / month`,
4789
+ price: price.unit_amount === 0 ? price.currency === "inr" ? "\u20B90" : `${workspaceCurrencySymbol}0` : `${formatCurrency(price.unit_amount, price.currency ?? "usd")} / month`,
4779
4790
  credits: `${Number(price.metadata.credits).toLocaleString()} credits`,
4780
4791
  amount: price.unit_amount,
4781
4792
  currency: price.currency?.toLowerCase(),
@@ -4935,7 +4946,7 @@ function PlansView({
4935
4946
  import_ui5.ScPlanCard,
4936
4947
  {
4937
4948
  planName: freePlan?.planName || "Free",
4938
- price: freePlan?.price || "$0",
4949
+ price: freePlan?.price || `${workspaceCurrencySymbol}0`,
4939
4950
  credits: freePlan?.credits || "3,000 credits",
4940
4951
  type: "free",
4941
4952
  features: getPlanFeatures(freePlan?.amount ?? 0),
@@ -5095,13 +5106,13 @@ function PlansView({
5095
5106
  UpdateSubscriptionModal,
5096
5107
  {
5097
5108
  open: showUpgradeConfirmModal,
5098
- currentPlanName: currentPlan?.planName || "Free",
5099
- currentPlanAmount: currentPlan ? currentPlan.amount === 0 ? "$0" : formatCurrency(currentPlan.amount, currentPlan.currency || "") : "$0",
5109
+ currentPlanName: isProPlan ? "Pro" : currentPlan?.planName || "Free",
5110
+ currentPlanAmount: currentPlan ? currentPlan.amount === 0 ? `${workspaceCurrencySymbol}0` : formatCurrency(currentPlan.amount, currentPlan.currency || "") : `${workspaceCurrencySymbol}0`,
5100
5111
  nextPlanName: selectedMiddlePlan?.planName || "Pro",
5101
- nextPlanAmount: selectedMiddlePlan ? selectedMiddlePlan.amount === 0 ? "$0" : formatCurrency(
5112
+ nextPlanAmount: selectedMiddlePlan ? selectedMiddlePlan.amount === 0 ? `${workspaceCurrencySymbol}0` : formatCurrency(
5102
5113
  selectedMiddlePlan.amount,
5103
5114
  selectedMiddlePlan.currency || ""
5104
- ) : "$0",
5115
+ ) : `${workspaceCurrencySymbol}0`,
5105
5116
  nextBillingDateLabel: formatNextBillingDateLabel(currentPlanEndDate),
5106
5117
  loading: isMiddleActionLoading,
5107
5118
  onClose: () => setShowUpgradeConfirmModal(false),
@@ -5164,9 +5175,11 @@ function BillingTabBar({
5164
5175
  }
5165
5176
  function InvoiceHistoryTable({
5166
5177
  invoices,
5167
- loading
5178
+ loading,
5179
+ workspaceCountry
5168
5180
  }) {
5169
5181
  const { api, toast } = useSettingsAdapters();
5182
+ const currencySymbol = getCurrencySymbolByCountry(workspaceCountry);
5170
5183
  const handleDownload = async (item) => {
5171
5184
  const orderId = item.transactionId;
5172
5185
  if (!orderId) {
@@ -5280,7 +5293,7 @@ function InvoiceHistoryTable({
5280
5293
  import_ui5.ScBillingHistoryTableList,
5281
5294
  {
5282
5295
  invoiceNumber: inv.transactionId ? `# ${inv.transactionId.slice(0, 16).toUpperCase()}` : "# INV-UNKNOWN",
5283
- amount: inv.amountPaid != null ? `$${inv.amountPaid.toFixed(2)}` : `$${(inv.amount / 100).toFixed(2)}`,
5296
+ amount: inv.amountPaid != null ? `${currencySymbol}${inv.amountPaid.toFixed(2)}` : `${currencySymbol}${(inv.amount / 100).toFixed(2)}`,
5284
5297
  date: formatDate(inv.createdAt),
5285
5298
  downloadLabel: "Download invoice",
5286
5299
  onClick: (e) => handleRowClick(e, inv)
@@ -5722,13 +5735,13 @@ function BillingContent({
5722
5735
  setShowInitialLoader(false);
5723
5736
  }, [showInitialLoader, initialFetchTriggered, loadingBilling]);
5724
5737
  console.log("subscription", subscription);
5725
- const isProPlan = products.find(
5738
+ const isProPlan = products.some(
5726
5739
  (product) => product.id == subscription?.stripeProductId && product.name == "Paid"
5727
5740
  );
5728
5741
  console.log("isProPlan", isProPlan);
5729
5742
  const planName = isProPlan ? "Pro" : subscription?.plan?.name?.trim() || (subscription?.plan?.amount ? subscription.plan.amount > 0 ? "Pro" : "Free" : "-");
5730
5743
  const isFreePlan = subscription?.plan?.amount == null || subscription.plan.amount === 0;
5731
- const planAmount = subscription?.plan?.amount != null ? `${subscription?.plan?.currency == "inr" ? "\u20B9" : "$"}${(subscription.plan.amount / 100).toFixed(2)} / ${subscription?.plan?.interval}` : "$0";
5744
+ const planAmount = subscription?.plan?.amount != null ? `${subscription?.plan?.currency == "inr" ? "\u20B9" : "$"}${(subscription.plan.amount / 100).toFixed(2)} / ${subscription?.plan?.interval}` : `${getCurrencySymbolByCountry(workspace.current?.country)}0`;
5732
5745
  const usedCredits = availableCredits != null && totalCredits != null ? Math.max(0, totalCredits - availableCredits) : null;
5733
5746
  const progressPct = usedCredits != null && totalCredits != null && totalCredits > 0 ? Math.min(100, Math.round(usedCredits / totalCredits * 100)) : 0;
5734
5747
  const remainingPct = 100 - progressPct;
@@ -5927,7 +5940,8 @@ function BillingContent({
5927
5940
  actionInFlight: planActionInFlight,
5928
5941
  onPlanAction: handlePlanAction,
5929
5942
  onCancelDowngrade: handleCancelDowngrade,
5930
- workspace: workspace.current
5943
+ workspace: workspace.current,
5944
+ isProPlan
5931
5945
  }
5932
5946
  );
5933
5947
  if (embedded) return plansView;
@@ -6018,7 +6032,14 @@ function BillingContent({
6018
6032
  }
6019
6033
  )
6020
6034
  ] }),
6021
- activeTab === "invoice" ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(InvoiceHistoryTable, { invoices, loading: loadingTable }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
6035
+ activeTab === "invoice" ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
6036
+ InvoiceHistoryTable,
6037
+ {
6038
+ invoices,
6039
+ loading: loadingTable,
6040
+ workspaceCountry: workspace.current?.country
6041
+ }
6042
+ ) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
6022
6043
  UsageLogsTable,
6023
6044
  {
6024
6045
  logs: usageLogs,
@@ -6037,6 +6058,7 @@ function BillingContent({
6037
6058
  showBuyCreditsModal && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
6038
6059
  BuyCreditsModal,
6039
6060
  {
6061
+ currencySymbol: getCurrencySymbolByCountry(workspace.current?.country),
6040
6062
  onClose: () => setShowBuyCreditsModal(false),
6041
6063
  onBuy: (credits, price) => {
6042
6064
  handleBuyCredits(credits, price);
package/dist/index.mjs CHANGED
@@ -3825,7 +3825,11 @@ var MIN_USD = 40;
3825
3825
  var MAX_USD = 1e4;
3826
3826
  var MIN_CREDITS = Math.round(MIN_USD / PRICE_PER_CREDIT);
3827
3827
  var MAX_CREDITS = Math.round(MAX_USD / PRICE_PER_CREDIT);
3828
- function BuyCreditsModal({ onClose, onBuy }) {
3828
+ function BuyCreditsModal({
3829
+ currencySymbol = "$",
3830
+ onClose,
3831
+ onBuy
3832
+ }) {
3829
3833
  const [credits, setCredits] = useState6(MIN_CREDITS);
3830
3834
  const [creditsInput, setCreditsInput] = useState6(String(MIN_CREDITS));
3831
3835
  const [priceInput, setPriceInput] = useState6(String(MIN_CREDITS * PRICE_PER_CREDIT));
@@ -4070,7 +4074,7 @@ function BuyCreditsModal({ onClose, onBuy }) {
4070
4074
  lineHeight: "var(--line-height-line-height-lg)",
4071
4075
  color: "var(--alias-text---icons-primary)"
4072
4076
  },
4073
- children: "$"
4077
+ children: currencySymbol
4074
4078
  }
4075
4079
  ),
4076
4080
  /* @__PURE__ */ jsx10(
@@ -4090,7 +4094,7 @@ function BuyCreditsModal({ onClose, onBuy }) {
4090
4094
  onKeyDown: (e) => {
4091
4095
  if (e.key === "Enter") e.currentTarget.blur();
4092
4096
  },
4093
- "aria-label": "Price in USD",
4097
+ "aria-label": "Price",
4094
4098
  style: {
4095
4099
  fontFamily: "var(--font-family-font-family-body)",
4096
4100
  fontSize: "var(--font-size-font-size-lg)",
@@ -4220,6 +4224,9 @@ function formatCurrency(cents, currency) {
4220
4224
  }
4221
4225
  return `$${(cents / 100).toFixed(2)}`;
4222
4226
  }
4227
+ function getCurrencySymbolByCountry(country) {
4228
+ return country?.trim().toUpperCase() === "IN" ? "\u20B9" : "$";
4229
+ }
4223
4230
  function formatCredits(n) {
4224
4231
  return n.toLocaleString("en-US");
4225
4232
  }
@@ -4782,10 +4789,14 @@ function PlansView({
4782
4789
  actionInFlight,
4783
4790
  onPlanAction,
4784
4791
  onCancelDowngrade,
4785
- workspace
4792
+ workspace,
4793
+ isProPlan
4786
4794
  }) {
4787
4795
  console.log("=============", products);
4788
4796
  const { toast } = useSettingsAdapters();
4797
+ const workspaceCurrencySymbol = getCurrencySymbolByCountry(
4798
+ workspace?.country
4799
+ );
4789
4800
  const allPlans = useMemo2(() => {
4790
4801
  if (products.length > 0) {
4791
4802
  return products.flatMap(
@@ -4794,7 +4805,7 @@ function PlansView({
4794
4805
  productId: product.id,
4795
4806
  priceId: price.id,
4796
4807
  planName: price.metadata.name,
4797
- price: price.unit_amount === 0 ? price.currency === "inr" ? "\u20B90" : "$0" : `${formatCurrency(price.unit_amount, price.currency ?? "usd")} / month`,
4808
+ price: price.unit_amount === 0 ? price.currency === "inr" ? "\u20B90" : `${workspaceCurrencySymbol}0` : `${formatCurrency(price.unit_amount, price.currency ?? "usd")} / month`,
4798
4809
  credits: `${Number(price.metadata.credits).toLocaleString()} credits`,
4799
4810
  amount: price.unit_amount,
4800
4811
  currency: price.currency?.toLowerCase(),
@@ -4954,7 +4965,7 @@ function PlansView({
4954
4965
  ScPlanCard,
4955
4966
  {
4956
4967
  planName: freePlan?.planName || "Free",
4957
- price: freePlan?.price || "$0",
4968
+ price: freePlan?.price || `${workspaceCurrencySymbol}0`,
4958
4969
  credits: freePlan?.credits || "3,000 credits",
4959
4970
  type: "free",
4960
4971
  features: getPlanFeatures(freePlan?.amount ?? 0),
@@ -5114,13 +5125,13 @@ function PlansView({
5114
5125
  UpdateSubscriptionModal,
5115
5126
  {
5116
5127
  open: showUpgradeConfirmModal,
5117
- currentPlanName: currentPlan?.planName || "Free",
5118
- currentPlanAmount: currentPlan ? currentPlan.amount === 0 ? "$0" : formatCurrency(currentPlan.amount, currentPlan.currency || "") : "$0",
5128
+ currentPlanName: isProPlan ? "Pro" : currentPlan?.planName || "Free",
5129
+ currentPlanAmount: currentPlan ? currentPlan.amount === 0 ? `${workspaceCurrencySymbol}0` : formatCurrency(currentPlan.amount, currentPlan.currency || "") : `${workspaceCurrencySymbol}0`,
5119
5130
  nextPlanName: selectedMiddlePlan?.planName || "Pro",
5120
- nextPlanAmount: selectedMiddlePlan ? selectedMiddlePlan.amount === 0 ? "$0" : formatCurrency(
5131
+ nextPlanAmount: selectedMiddlePlan ? selectedMiddlePlan.amount === 0 ? `${workspaceCurrencySymbol}0` : formatCurrency(
5121
5132
  selectedMiddlePlan.amount,
5122
5133
  selectedMiddlePlan.currency || ""
5123
- ) : "$0",
5134
+ ) : `${workspaceCurrencySymbol}0`,
5124
5135
  nextBillingDateLabel: formatNextBillingDateLabel(currentPlanEndDate),
5125
5136
  loading: isMiddleActionLoading,
5126
5137
  onClose: () => setShowUpgradeConfirmModal(false),
@@ -5183,9 +5194,11 @@ function BillingTabBar({
5183
5194
  }
5184
5195
  function InvoiceHistoryTable({
5185
5196
  invoices,
5186
- loading
5197
+ loading,
5198
+ workspaceCountry
5187
5199
  }) {
5188
5200
  const { api, toast } = useSettingsAdapters();
5201
+ const currencySymbol = getCurrencySymbolByCountry(workspaceCountry);
5189
5202
  const handleDownload = async (item) => {
5190
5203
  const orderId = item.transactionId;
5191
5204
  if (!orderId) {
@@ -5299,7 +5312,7 @@ function InvoiceHistoryTable({
5299
5312
  ScBillingHistoryTableList,
5300
5313
  {
5301
5314
  invoiceNumber: inv.transactionId ? `# ${inv.transactionId.slice(0, 16).toUpperCase()}` : "# INV-UNKNOWN",
5302
- amount: inv.amountPaid != null ? `$${inv.amountPaid.toFixed(2)}` : `$${(inv.amount / 100).toFixed(2)}`,
5315
+ amount: inv.amountPaid != null ? `${currencySymbol}${inv.amountPaid.toFixed(2)}` : `${currencySymbol}${(inv.amount / 100).toFixed(2)}`,
5303
5316
  date: formatDate(inv.createdAt),
5304
5317
  downloadLabel: "Download invoice",
5305
5318
  onClick: (e) => handleRowClick(e, inv)
@@ -5741,13 +5754,13 @@ function BillingContent({
5741
5754
  setShowInitialLoader(false);
5742
5755
  }, [showInitialLoader, initialFetchTriggered, loadingBilling]);
5743
5756
  console.log("subscription", subscription);
5744
- const isProPlan = products.find(
5757
+ const isProPlan = products.some(
5745
5758
  (product) => product.id == subscription?.stripeProductId && product.name == "Paid"
5746
5759
  );
5747
5760
  console.log("isProPlan", isProPlan);
5748
5761
  const planName = isProPlan ? "Pro" : subscription?.plan?.name?.trim() || (subscription?.plan?.amount ? subscription.plan.amount > 0 ? "Pro" : "Free" : "-");
5749
5762
  const isFreePlan = subscription?.plan?.amount == null || subscription.plan.amount === 0;
5750
- const planAmount = subscription?.plan?.amount != null ? `${subscription?.plan?.currency == "inr" ? "\u20B9" : "$"}${(subscription.plan.amount / 100).toFixed(2)} / ${subscription?.plan?.interval}` : "$0";
5763
+ const planAmount = subscription?.plan?.amount != null ? `${subscription?.plan?.currency == "inr" ? "\u20B9" : "$"}${(subscription.plan.amount / 100).toFixed(2)} / ${subscription?.plan?.interval}` : `${getCurrencySymbolByCountry(workspace.current?.country)}0`;
5751
5764
  const usedCredits = availableCredits != null && totalCredits != null ? Math.max(0, totalCredits - availableCredits) : null;
5752
5765
  const progressPct = usedCredits != null && totalCredits != null && totalCredits > 0 ? Math.min(100, Math.round(usedCredits / totalCredits * 100)) : 0;
5753
5766
  const remainingPct = 100 - progressPct;
@@ -5946,7 +5959,8 @@ function BillingContent({
5946
5959
  actionInFlight: planActionInFlight,
5947
5960
  onPlanAction: handlePlanAction,
5948
5961
  onCancelDowngrade: handleCancelDowngrade,
5949
- workspace: workspace.current
5962
+ workspace: workspace.current,
5963
+ isProPlan
5950
5964
  }
5951
5965
  );
5952
5966
  if (embedded) return plansView;
@@ -6037,7 +6051,14 @@ function BillingContent({
6037
6051
  }
6038
6052
  )
6039
6053
  ] }),
6040
- activeTab === "invoice" ? /* @__PURE__ */ jsx11(InvoiceHistoryTable, { invoices, loading: loadingTable }) : /* @__PURE__ */ jsx11(
6054
+ activeTab === "invoice" ? /* @__PURE__ */ jsx11(
6055
+ InvoiceHistoryTable,
6056
+ {
6057
+ invoices,
6058
+ loading: loadingTable,
6059
+ workspaceCountry: workspace.current?.country
6060
+ }
6061
+ ) : /* @__PURE__ */ jsx11(
6041
6062
  UsageLogsTable,
6042
6063
  {
6043
6064
  logs: usageLogs,
@@ -6056,6 +6077,7 @@ function BillingContent({
6056
6077
  showBuyCreditsModal && /* @__PURE__ */ jsx11(
6057
6078
  BuyCreditsModal,
6058
6079
  {
6080
+ currencySymbol: getCurrencySymbolByCountry(workspace.current?.country),
6059
6081
  onClose: () => setShowBuyCreditsModal(false),
6060
6082
  onBuy: (credits, price) => {
6061
6083
  handleBuyCredits(credits, price);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamoid/settings",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",