Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

2.1 KB
Raw Blame
import { isNil } from '@activepieces/core-utils';
import { t } from 'i18next';
import { Check } from 'lucide-react';

import { Button } from '@/components/ui/button';
import { Dialog, DialogContent } from '@/components/ui/dialog';

import { billingDialogHooks } from '../hooks/billing-dialog-hooks';

import {
  planSelectorUtils,
  type PlanCatalogEntry,
} from './plan-selector-utils';

const HIGHLIGHT_COUNT = 3;

function resolveEntry(planId: string): PlanCatalogEntry | undefined {
  const key = planId.replace(/_annual$/, '');
  return planSelectorUtils.planCatalog().find((entry) => entry.key === key);
}

export function PlanSwitchSuccessDialog() {
  const { planId, closeDialog } =
    billingDialogHooks.usePlanSwitchSuccessDialogStore();
  const entry = isNil(planId) ? undefined : resolveEntry(planId);
  const features = entry?.features ?? [];

  return (
    <Dialog
      open={!isNil(entry)}
      onOpenChange={(open) => !open && closeDialog()}
    >
      <DialogContent showCloseButton={false} className="max-w-md">
        {!isNil(entry) && (
          <div className="flex flex-col items-center gap-5 py-4 text-center">
            <span className="flex size-14 items-center justify-center rounded-full bg-success-9">
              <Check className="size-7 text-on-success" strokeWidth={3} />
            </span>
            <div className="flex flex-col gap-2">
              <h2 className="text-xl font-semibold">
                {t("You're on the {plan} plan", { plan: entry.name })}
              </h2>
              <p className="text-sm text-gray-11">
                {t('You now have access to {benefits}.', {
                  benefits: new Intl.ListFormat(undefined, {
                    style: 'long',
                    type: 'conjunction',
                  }).format(
                    features
                      .slice(0, HIGHLIGHT_COUNT)
                      .map((feature) => feature.label),
                  ),
                })}
              </p>
            </div>
            <Button className="w-full" onClick={closeDialog}>
              {t('Got it')}
            </Button>
          </div>
        )}
      </DialogContent>
    </Dialog>
  );
}