'use client';
import { Check, FolderInput, Plus } from 'lucide-react';
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuLabel,
DropdownMenuSeparator,
DropdownMenuTrigger,
} from '@/components/ui/dropdown-menu';
import { useI18n } from '@/lib/hooks/use-i18n';
import type { FolderRecord } from '@/lib/utils/database';
/**
* Move-course-to-folder menu. Rendered as the 📂 button on a course tile
* (the caller positions it via the ClassroomCard overlay). Lists "Ungrouped"
* plus every folder (the current one gets a ✓), and a "New folder" entry that
* asks the caller to open a folder dialog (a Radix DropdownMenu is modal, so an
* inline cannot keep focus there — the dialog is the focus surface).
*/
export function MoveToFolderMenu({
folders,
currentFolderId,
onMove,
onCreateAndMove,
}: {
folders: FolderRecord[];
currentFolderId: string | undefined;
onMove: (folderId: string | undefined) => void;
/** Request to create a new folder and move this course into it. */
onCreateAndMove: () => void;
}) {
const { t } = useI18n();
return (
e.stopPropagation()}
onPointerDown={(e) => e.stopPropagation()}
>
{t('classroom.moveToFolderLabel')}
{/* Ungrouped */}
onMove(undefined)}
className="flex items-center justify-between"
>
{t('classroom.ungrouped')}
{currentFolderId === undefined && }
{/* All folders */}
{folders.map((f) => (
onMove(f.id)}
className="flex items-center justify-between"
>
{f.name}
{currentFolderId === f.id && }
))}
{/* New folder — opens the folder dialog (focus-safe). */}
{t('classroom.newFolderInline')}
);
}