import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger, } from "@/components/ui/dialog"; import { DropdownMenuItem } from "@/components/ui/dropdown-menu"; import { AlertBlock } from "@/components/shared/alert-block"; import { api } from "@/utils/api"; import { Code, Github, Globe, PuzzleIcon } from "lucide-react"; import Link from "next/link"; import { Input } from "@/components/ui/input"; import { useState } from "react"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger, } from "@/components/ui/alert-dialog"; import { toast } from "sonner"; interface Props { projectId: string; } export const AddTemplate = ({ projectId }: Props) => { const [query, setQuery] = useState(""); const { data } = api.compose.templates.useQuery(); const utils = api.useUtils(); const { mutateAsync, isLoading, error, isError } = api.compose.deployTemplate.useMutation(); const templates = data?.filter((t) => t.name.toLowerCase().includes(query.toLowerCase()), ); return ( e.preventDefault()} > Templates
Create Template Deploy a open source template to your project {isError && {error?.message}} setQuery(e.target.value)} value={query} />
{templates?.map((template, index) => (
{template.name} {template.version}
{template.links.website && ( )} {template.links.docs && ( )}
{template.tags.map((tag) => ( {tag} ))}
Are you absolutely sure? This will deploy {template.name} template to your project. Cancel { await mutateAsync({ projectId, id: template.id, }) .then(async () => { toast.success( `${template.name} template created succesfully`, ); utils.project.one.invalidate({ projectId, }); }) .catch(() => { toast.error( `Error to delete ${template.name} template`, ); }); }} > Confirm

{template.description}

))}
); };