'use client'; import { useState } from 'react'; import { useRouter } from 'next/navigation'; import type { FileAsset } from '@/lib/types'; export function FileList({ files, canDelete, }: { files: FileAsset[]; canDelete: boolean; }) { const router = useRouter(); const [lightbox, setLightbox] = useState(null); async function onDelete(fileId: number) { const res = await fetch(`/api/files/${fileId}`, { method: 'DELETE' }); if (res.ok) router.refresh(); } if (files.length === 0) { return (

ファイルはありません。

); } return ( <> {lightbox && (
setLightbox(null)} data-testid="lightbox" > {lightbox.originalName}
)} ); }