@umituz/web-dashboard 3.1.10 → 3.2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/web-dashboard",
3
- "version": "3.1.10",
3
+ "version": "3.2.0",
4
4
  "description": "Dashboard Layout System - Comprehensive analytics, calendar, customizable layouts, and config-based architecture",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -63,7 +63,8 @@
63
63
  "react-dom": "^18.0.0 || ^19.0.0",
64
64
  "react-router-dom": "^6.0.0 || ^7.0.0",
65
65
  "firebase": "^10.0.0 || ^11.0.0 || ^12.0.0",
66
- "@umituz/web-firebase": "^3.0.0"
66
+ "@umituz/web-firebase": "^3.0.0",
67
+ "@umituz/web-polar-payment": "^1.0.20"
67
68
  },
68
69
  "dependencies": {
69
70
  "class-variance-authority": "^0.7.1",
@@ -0,0 +1,49 @@
1
+ /**
2
+ * BillingPage Component
3
+ *
4
+ * Complete billing page for displaying subscription, invoices, and plan management
5
+ * Data fetching should be handled by passing billing summary
6
+ *
7
+ * @example
8
+ * ```tsx
9
+ * <BillingPage
10
+ * billing={billingData}
11
+ * loading={false}
12
+ * activeTab="overview"
13
+ * onTabChange={(tab) => setActiveTab(tab)}
14
+ * />
15
+ * ```
16
+ */
17
+
18
+ import { BillingLayout, BillingPortal } from ".";
19
+ import type { BillingPortalProps } from "../types/billing";
20
+
21
+ export interface BillingPageProps extends Omit<BillingPortalProps, "showTabs"> {
22
+ /** Billing configuration */
23
+ config?: {
24
+ brandName?: string;
25
+ supportEmail?: string;
26
+ };
27
+ }
28
+
29
+ /**
30
+ * BillingPage Component
31
+ *
32
+ * Ready-to-use billing page component
33
+ * Combine BillingLayout with BillingPortal
34
+ */
35
+ export const BillingPage = ({ config, ...portalProps }: BillingPageProps) => {
36
+ const billingConfig = {
37
+ brandName: config?.brandName || "Growth Factory",
38
+ supportEmail: config?.supportEmail,
39
+ plans: [],
40
+ };
41
+
42
+ return (
43
+ <BillingLayout config={billingConfig}>
44
+ <BillingPortal showTabs={true} {...portalProps} />
45
+ </BillingLayout>
46
+ );
47
+ };
48
+
49
+ export default BillingPage;
@@ -10,3 +10,4 @@ export { InvoiceCard } from "./InvoiceCard";
10
10
  export { UsageCard } from "./UsageCard";
11
11
  export { BillingPortal } from "./BillingPortal";
12
12
  export { BillingLayout } from "./BillingLayout";
13
+ export { BillingPage } from "./BillingPage";
@@ -23,9 +23,9 @@ export type SubscriptionStatus = typeof SUBSCRIPTION_STATUS[keyof typeof SUBSCRI
23
23
  export type InvoiceStatus = typeof INVOICE_STATUS[keyof typeof INVOICE_STATUS];
24
24
 
25
25
  /**
26
- * Plan type
26
+ * Plan type - dynamic string from product provider
27
27
  */
28
- export type PlanType = "free" | "basic" | "pro" | "enterprise" | "custom";
28
+ export type PlanType = string;
29
29
 
30
30
  /**
31
31
  * Currency
@@ -38,8 +38,8 @@ export type Currency = typeof CURRENCY[keyof typeof CURRENCY];
38
38
  export interface PlanTier {
39
39
  /** Plan ID */
40
40
  id: string;
41
- /** Plan type */
42
- type: PlanType;
41
+ /** Plan type - optional, from product metadata */
42
+ type?: PlanType;
43
43
  /** Plan name */
44
44
  name: string;
45
45
  /** Plan description */
@@ -27,3 +27,5 @@ export {
27
27
  isPopularPlan,
28
28
  getTrialDaysText,
29
29
  } from "./billing";
30
+
31
+ export { transformPolarProductToPlan, transformPolarProducts } from "./polar";
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Polar.sh Integration Helpers
3
+ *
4
+ * Utility functions to transform Polar.sh data to billing types
5
+ *
6
+ * Note: These utilities require @umituz/web-polar-payment to be installed
7
+ */
8
+
9
+ import type { PlanTier } from "../types/billing";
10
+
11
+ // Polar types - will be resolved if package is installed
12
+ type PolarProduct = {
13
+ id: string;
14
+ name: string;
15
+ description: string | null;
16
+ is_archived: boolean;
17
+ prices: PolarPrice[];
18
+ benefits: Array<{ description: string | null }>;
19
+ };
20
+
21
+ type PolarPrice = {
22
+ amount?: number;
23
+ currency: string;
24
+ recurring_interval?: string;
25
+ is_archived: boolean;
26
+ };
27
+
28
+ /**
29
+ * Transform Polar product to billing plan format
30
+ */
31
+ export function transformPolarProductToPlan(
32
+ product: PolarProduct,
33
+ price: PolarPrice
34
+ ): PlanTier {
35
+ const amount = price.amount || 0;
36
+ const monthlyAmount = price.recurring_interval === "month" ? amount : amount / 12;
37
+
38
+ return {
39
+ id: product.id,
40
+ name: product.name,
41
+ description: product.description || "",
42
+ monthlyPrice: Math.round(monthlyAmount),
43
+ yearlyPrice: Math.round(amount),
44
+ currency: price.currency.toUpperCase() as PlanTier["currency"],
45
+ features: product.benefits
46
+ .map((b: { description: string | null }) => b.description || "")
47
+ .filter(Boolean),
48
+ };
49
+ }
50
+
51
+ /**
52
+ * Transform multiple Polar products to billing plans
53
+ */
54
+ export function transformPolarProducts(products: PolarProduct[]): PlanTier[] {
55
+ return products
56
+ .filter((product) => !product.is_archived)
57
+ .flatMap((product) => {
58
+ const activePrices = product.prices.filter((p: PolarPrice) => !p.is_archived);
59
+ return activePrices.map((price: PolarPrice) =>
60
+ transformPolarProductToPlan(product, price)
61
+ );
62
+ });
63
+ }