Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

1.2 KB
Raw Blame
import { BillingPortalRow } from "@/components/billing/billing-portal-row";
import { FoundingFreeRow } from "@/components/billing/founding-free-row";
import { SubscriptionPlanRow } from "@/components/billing/subscription-plan-row";
import { TrialStatusRow } from "@/components/billing/trial-status-row";
import { SettingsCard } from "@/components/settings/settings-card";
import type { GetBillingResponse } from "@/fetchers/billing/get-billing";

type CurrentPlanCardProps = {
  billing: GetBillingResponse;
  workspaceId: string | undefined;
  canManage: boolean;
  onChoosePlan: () => void;
};

export function CurrentPlanCard({
  billing,
  workspaceId,
  canManage,
  onChoosePlan,
}: CurrentPlanCardProps) {
  if (billing.foundingFree) {
    return (
      <SettingsCard>
        <FoundingFreeRow />
      </SettingsCard>
    );
  }

  if (billing.plan && billing.status) {
    return (
      <SettingsCard>
        <SubscriptionPlanRow billing={billing} />
        <BillingPortalRow
          workspaceId={workspaceId}
          hasCustomer={billing.hasCustomer}
          canManage={canManage}
        />
      </SettingsCard>
    );
  }

  return (
    <SettingsCard>
      <TrialStatusRow billing={billing} onChoosePlan={onChoosePlan} />
    </SettingsCard>
  );
}