Skip to content

The open alternative to Salesforce, designed for AI.

884 B
Raw Blame
import { useParams } from 'react-router-dom';
import { isDefined } from 'twenty-shared/utils';

import { SettingsBillingLimitEditForm } from '@/settings/billing/components/SettingsBillingLimitEditForm';
import { useUsageQuotasWithConsumption } from '@/settings/billing/hooks/useUsageQuotasWithConsumption';
import { NotFound } from '~/pages/not-found/NotFound';

export const SettingsBillingLimitEdit = () => {
  const { usageLimitId = '' } = useParams();
  const { usageQuotasWithConsumption, loading } =
    useUsageQuotasWithConsumption();

  if (loading) {
    return null;
  }

  const quota = usageQuotasWithConsumption.find(
    (candidate) => candidate.id === usageLimitId,
  );

  if (!isDefined(quota)) {
    return <NotFound />;
  }

  return (
    <SettingsBillingLimitEditForm
      key={usageLimitId}
      usageLimitId={usageLimitId}
      quota={quota}
    />
  );
};