"use client"; import { Calendar, MoreHorizontal, Search, Settings, Share2, Trash2, UserCheck, Users, } from "lucide-react"; import { useTranslations } from "next-intl"; import { useState } from "react"; import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, } from "@/components/ui/alert-dialog"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; import { Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle, } from "@/components/ui/sheet"; import type { SearchSpace } from "../../types/layout.types"; function formatDate(dateString: string): string { return new Date(dateString).toLocaleDateString("en-US", { year: "numeric", month: "short", day: "numeric", }); } interface AllSearchSpacesSheetProps { open: boolean; onOpenChange: (open: boolean) => void; searchSpaces: SearchSpace[]; onSearchSpaceSelect: (id: number) => void; onCreateNew?: () => void; onSettings?: (id: number) => void; onDelete?: (id: number) => void; } export function AllSearchSpacesSheet({ open, onOpenChange, searchSpaces, onSearchSpaceSelect, onCreateNew, onSettings, onDelete, }: AllSearchSpacesSheetProps) { const t = useTranslations("searchSpace"); const tCommon = useTranslations("common"); const [spaceToDelete, setSpaceToDelete] = useState(null); const handleSelect = (id: number) => { onSearchSpaceSelect(id); onOpenChange(false); }; const handleSettings = (e: React.MouseEvent, space: SearchSpace) => { e.stopPropagation(); onOpenChange(false); onSettings?.(space.id); }; const handleDeleteClick = (e: React.MouseEvent, space: SearchSpace) => { e.stopPropagation(); setSpaceToDelete(space); }; const confirmDelete = () => { if (spaceToDelete) { onDelete?.(spaceToDelete.id); setSpaceToDelete(null); } }; return ( <>
{t("all_search_spaces")} {t("search_spaces_count", { count: searchSpaces.length })}
{searchSpaces.length === 0 ? (

{t("no_search_spaces")}

{t("create_first_search_space")}

{onCreateNew && ( )}
) : ( searchSpaces.map((space) => ( handleSettings(e, space)}> {tCommon("settings")} handleDeleteClick(e, space)} className="text-destructive focus:text-destructive" > {tCommon("delete")} )}
{space.isOwner ? ( ) : ( )} {t("members_count", { count: space.memberCount })} {space.createdAt && ( {formatDate(space.createdAt)} )}
)) )} {searchSpaces.length > 0 && onCreateNew && (
)}
!open && setSpaceToDelete(null)}> {t("delete_title")} {t("delete_confirm", { name: spaceToDelete?.name ?? "" })} {tCommon("cancel")} {tCommon("delete")} ); }