diff --git a/src/app/dashboard/[teamIdOrSlug]/sandboxes/(tabs)/@list/page.tsx b/src/app/dashboard/[teamIdOrSlug]/sandboxes/(tabs)/@list/page.tsx index 5b8217ec7..1c1a0703f 100644 --- a/src/app/dashboard/[teamIdOrSlug]/sandboxes/(tabs)/@list/page.tsx +++ b/src/app/dashboard/[teamIdOrSlug]/sandboxes/(tabs)/@list/page.tsx @@ -8,7 +8,7 @@ export default async function ListPage({ }: PageProps<'/dashboard/[teamIdOrSlug]/sandboxes'>) { const { teamIdOrSlug } = await params - await prefetch( + prefetch( trpc.sandboxes.getSandboxes.queryOptions({ teamIdOrSlug, }) diff --git a/src/app/dashboard/[teamIdOrSlug]/templates/loading.tsx b/src/app/dashboard/[teamIdOrSlug]/templates/loading.tsx deleted file mode 100644 index 249f11404..000000000 --- a/src/app/dashboard/[teamIdOrSlug]/templates/loading.tsx +++ /dev/null @@ -1 +0,0 @@ -export { default } from '@/features/dashboard/loading-layout' diff --git a/src/app/dashboard/[teamIdOrSlug]/templates/page.tsx b/src/app/dashboard/[teamIdOrSlug]/templates/page.tsx index edeca56ff..ea21637fc 100644 --- a/src/app/dashboard/[teamIdOrSlug]/templates/page.tsx +++ b/src/app/dashboard/[teamIdOrSlug]/templates/page.tsx @@ -1,39 +1,25 @@ +import LoadingLayout from '@/features/dashboard/loading-layout' import TemplatesTable from '@/features/dashboard/templates/table' -import { - getDefaultTemplates, - getTeamTemplates, -} from '@/server/templates/get-team-templates' -import ErrorBoundary from '@/ui/error' +import { HydrateClient, prefetch, trpc } from '@/trpc/server' +import { Suspense } from 'react' export default async function Page({ params, }: PageProps<'/dashboard/[teamIdOrSlug]/templates'>) { const { teamIdOrSlug } = await params - const res = await getTeamTemplates({ - teamIdOrSlug, - }) + prefetch( + trpc.templates.getTemplates.queryOptions({ + teamIdOrSlug, + }) + ) + prefetch(trpc.templates.getDefaultTemplatesCached.queryOptions()) - const defaultRes = await getDefaultTemplates() - - if (!res?.data?.templates || res?.serverError) { - return ( - - ) - } - - const templates = [ - ...res.data.templates, - ...(defaultRes?.data?.templates ? defaultRes.data.templates : []), - ] - - return + return ( + + }> + + + + ) } diff --git a/src/features/dashboard/templates/table-cells.tsx b/src/features/dashboard/templates/table-cells.tsx index a655e2d16..31b3e0532 100644 --- a/src/features/dashboard/templates/table-cells.tsx +++ b/src/features/dashboard/templates/table-cells.tsx @@ -7,10 +7,7 @@ import { } from '@/lib/hooks/use-toast' import { cn } from '@/lib/utils' import { isVersionCompatible } from '@/lib/utils/version' -import { - deleteTemplateAction, - updateTemplateAction, -} from '@/server/templates/templates-actions' +import { useTRPC } from '@/trpc/client' import { DefaultTemplate, Template } from '@/types/api.types' import { AlertDialog } from '@/ui/alert-dialog' import { E2BBadge } from '@/ui/brand' @@ -26,9 +23,10 @@ import { DropdownMenuTrigger, } from '@/ui/primitives/dropdown-menu' import { Loader } from '@/ui/primitives/loader_d' +import { useMutation, useQueryClient } from '@tanstack/react-query' import { CellContext } from '@tanstack/react-table' import { Lock, LockOpen, MoreVertical } from 'lucide-react' -import { useAction } from 'next-safe-action/hooks' +import { useParams } from 'next/navigation' import { useMemo, useState } from 'react' import ResourceUsage from '../common/resource-usage' import { useDashboard } from '../context' @@ -49,60 +47,144 @@ export function ActionsCell({ }: CellContext