"use client"; import { useState } from "react"; import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query"; import Link from "next/link"; import { api, Key } from "@/lib/api"; import { Badge, Button, Card, CardHeader, CardTitle } from "@/components/ui"; import { Table, Thead, Tbody, Tr, Th, Td } from "@/components/ui"; function UploadKeyModal({ onClose }: { onClose: () => void }) { const queryClient = useQueryClient(); const [label, setLabel] = useState(""); const [publicKey, setPublicKey] = useState(""); const { mutate: upload, isPending, error } = useMutation({ mutationFn: () => api.uploadKey(label.trim(), publicKey.trim()), onSuccess: () => { queryClient.invalidateQueries({ queryKey: ["keys"] }); onClose(); }, }); return (
{keys?.length ?? 0} key{keys?.length !== 1 ? "s" : ""} managed
| Label | Fingerprint | Source | Assignments | Created | |
|---|---|---|---|---|---|
| {key.label} | {key.fingerprint} |
|
{key.assigned_count ?? 0} server{(key.assigned_count ?? 0) !== 1 ? "s" : ""} | {new Date(key.created_at).toLocaleDateString()} |
No SSH keys yet.