File size: 846 Bytes
fb12607
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
export type PlanId = "hobby" | "creator" | "studio";

export function getPlanIdFromBillingSettings(billingSettings: unknown): PlanId {
  const rawPlan = (billingSettings as any)?.subscription?.planId;

  if (rawPlan === "creator" || rawPlan === "studio" || rawPlan === "hobby") {
    return rawPlan;
  }

  return "hobby";
}

export function getPlanBadgeConfig(planId: PlanId): { label: string; background: string; color: string } {
  if (planId === "creator") {
    return {
      label: "Creator",
      background: "rgba(108, 92, 231, 0.14)",
      color: "var(--color-primary)",
    };
  }

  if (planId === "studio") {
    return {
      label: "Studio",
      background: "rgba(245, 158, 11, 0.18)",
      color: "#b45309",
    };
  }

  return {
    label: "Hobby",
    background: "rgba(59, 130, 246, 0.12)",
    color: "#2563eb",
  };
}