"use client" import { useState } from "react"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "@/components/ui/table"; import { Button } from "@/components/ui/button"; import { EyeIcon, EyeOffIcon, PencilIcon } from "lucide-react"; import { revealCredential } from "@/modules/shared/actions/credentials"; import { getServiceById } from "@/modules/shared/data/services-data"; import { CredentialDialog } from "./credential-dialog"; import { DeleteCredentialDialog } from "./delete-credential-dialog"; import { ServiceLogo } from "./service-logo"; type Credential = { id: string; service: string; username: string; created_at: string; updated_at: string; }; function RevealButton({ credentialId }: { credentialId: string }) { const [password, setPassword] = useState(null); const [pending, setPending] = useState(false); async function handleToggle() { if (password !== null) { setPassword(null); return; } setPending(true); const result = await revealCredential(credentialId); setPending(false); if ("password" in result) { setPassword(result.password); } } return (
{password ?? "••••••••"}
); } export function CredentialsTable({ profileId, credentials, isAdmin, }: { profileId: string; credentials: Credential[]; isAdmin: boolean; }) { if (credentials.length === 0) { return (

Noch keine Passwörter hinterlegt.

); } return (
Dienst Benutzername Passwort {credentials.map((credential) => { const service = getServiceById(credential.service); return (
{service.label} {credential.username}
{credential.username}
} /> {isAdmin && ( )}
); })}
); }