import { Copy, Folder } from "lucide-react"; import { useState } from "react"; import { useFetcher } from "react-router"; import { createVolume, deleteVolume, listVolumes } from "~/api-client"; import { CreateVolumeDialog } from "~/components/create-volume-dialog"; import { Button } from "~/components/ui/button"; import { Input } from "~/components/ui/input"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "~/components/ui/select"; import { Table, TableBody, TableCaption, TableCell, TableHead, TableHeader, TableRow } from "~/components/ui/table"; import { cn } from "~/lib/utils"; import type { Route } from "./+types/home"; import { parseError } from "~/lib/errors"; import { toast } from "sonner"; export function meta(_: Route.MetaArgs) { return [ { title: "Ironmount" }, { name: "description", content: "Create, manage, monitor, and automate your Docker volumes with ease.", }, ]; } export async function clientAction({ request }: Route.ClientActionArgs) { const formData = await request.formData(); const { _action, ...rest } = Object.fromEntries(formData.entries()); if (_action === "delete") { const { error } = await deleteVolume({ path: { name: rest.name as string } }); if (error) { toast.error("Failed to delete volume", { description: parseError(error)?.message, }); } else { toast.success("Volume deleted successfully"); } return { error: parseError(error), _action: "delete" as const }; } if (_action === "create") { const { error } = await createVolume({ body: { name: rest.name as string, config: { backend: "directory" } } }); if (error) { toast.error("Failed to create volume", { description: parseError(error)?.message, }); } else { toast.success("Volume created successfully"); } return { error: parseError(error), _action: "create" as const }; } } export async function clientLoader(_: Route.ClientLoaderArgs) { const volumes = await listVolumes(); return volumes.data; } export default function Home({ loaderData, actionData }: Route.ComponentProps) { const [open, setOpen] = useState(false); const createFetcher = useFetcher>(); const deleteFetcher = useFetcher>(); createFetcher.data; deleteFetcher.data; const isDeleting = deleteFetcher.state === "submitting"; const isCreating = createFetcher.state === "submitting"; console.log(createFetcher); const handleDeleteConfirm = (name: string) => { deleteFetcher.submit({ _action: "delete", name }, { method: "DELETE" }); }; return (

Ironmount

Create, manage, monitor, and automate your Docker volumes with ease.

createFetcher.submit({ _action: "create", ...values }, { method: "POST" })} />
A list of your managed Docker volumes. Name Backend Mountpoint Status Actions {loaderData?.volumes.map((volume) => ( {volume.name} Dir {volume.path} ))}
); }