All files / web/src/routes/_main ai-providers.$id.edit.lazy.tsx

42.85% Statements 15/35
33.33% Branches 1/3
100% Functions 1/1
42.85% Lines 15/35

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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 37 38 39 40 41 42 43 44 45 46 47 48    1x 1x 1x 1x   1x 1x 1x   1x 1x 1x   1x   1x                           1x                           1x 1x  
'use client';
 
import { createLazyFileRoute } from '@tanstack/react-router';
import { APIKeyForm } from '@web/components/ai-providers';
import { Skeleton } from '@web/components/ui/skeleton';
import { useAIProviders } from '@web/providers/ai-providers';
 
export const Route = createLazyFileRoute('/_main/ai-providers/$id/edit')({
  component: EditAPIKeyPage,
});
 
function EditAPIKeyPage() {
  const { id } = Route.useParams();
  const { getAPIKeyById, isLoading } = useAIProviders();
 
  const apiKey = getAPIKeyById(id);
 
  if (isLoading) {
    return (
      <div className="p-6 space-y-6">
        <div className="space-y-2">
          <Skeleton className="h-8 w-48" />
          <Skeleton className="h-4 w-96" />
        </div>
        <div className="space-y-4">
          <Skeleton className="h-64 w-full" />
        </div>
      </div>
    );
  }
 
  if (!apiKey) {
    return (
      <div className="flex flex-1 items-center justify-center">
        <div className="text-center">
          <h2 className="text-2xl font-semibold mb-2">API Key Not Found</h2>
          <p className="text-muted-foreground">
            The API key you&apos;re looking for doesn&apos;t exist or has been
            deleted.
          </p>
        </div>
      </div>
    );
  }
 
  return <APIKeyForm apiKey={apiKey} mode="edit" />;
}