diff --git a/apps/web/src/app/projects/page.tsx b/apps/web/src/app/projects/page.tsx index 677f109b..a86cf775 100644 --- a/apps/web/src/app/projects/page.tsx +++ b/apps/web/src/app/projects/page.tsx @@ -541,10 +541,25 @@ function ProjectItem({ const isSelected = selectedProjectIdSet.has(project.id); const selectedProjectCount = selectedProjectIds.length; const [isDropdownOpen, setIsDropdownOpen] = useState(false); + const [isRenameDialogOpen, setIsRenameDialogOpen] = useState(false); + const [isDeleteDialogOpen, setIsDeleteDialogOpen] = useState(false); + const [isInfoDialogOpen, setIsInfoDialogOpen] = useState(false); + const editor = useEditor(); const durationLabel = formatProjectDuration({ duration: project.duration }); const isMultiSelect = selectedProjectCount > 1; const isGridView = viewMode === "grid"; + const handleRename = () => setIsRenameDialogOpen(true); + const handleDuplicate = async () => { + await duplicateProjects({ editor, ids: [project.id] }); + }; + const handleDeleteClick = () => setIsDeleteDialogOpen(true); + const handleInfoClick = () => setIsInfoDialogOpen(true); + const handleDeleteConfirm = async () => { + await deleteProjects({ editor, ids: [project.id] }); + setIsDeleteDialogOpen(false); + }; + const handleCheckboxChange = ({ checked, shiftKey, @@ -649,120 +664,71 @@ function ProjectItem({ {listRowContent} - {!isMultiSelect && ( - - )} + {!isMultiSelect && ( + + )} ); - const cardContent = isGridView ? gridContent : listContent; - - if (!isGridView) { - return ( - - -
{listContent}
-
- -
- ); - } - - return ( - - -
- - {cardContent} - - - {isGridView && ( - <> - event.preventDefault()} - onClick={(event) => { - handleCheckboxChange({ - checked: !isSelected, - shiftKey: event.shiftKey, - }); - }} - onCheckedChange={() => { }} - className={`absolute z-10 size-5 top-3 left-3 ${isSelected || isDropdownOpen - ? "opacity-100" - : "opacity-0 group-hover:opacity-100" - }`} - /> - - {!isMultiSelect && ( - - )} - - )} -
-
- -
- ); -} - -function ProjectContextMenuContent({ project }: { project: TProjectMetadata }) { - const editor = useEditor(); - const [isRenameDialogOpen, setIsRenameDialogOpen] = useState(false); - const [isDeleteDialogOpen, setIsDeleteDialogOpen] = useState(false); - const [isInfoDialogOpen, setIsInfoDialogOpen] = useState(false); - - const handleRename = () => setIsRenameDialogOpen(true); - const handleDuplicate = async () => { - await duplicateProjects({ editor, ids: [project.id] }); - }; - const handleDeleteClick = () => setIsDeleteDialogOpen(true); - const handleInfoClick = () => setIsInfoDialogOpen(true); - - const handleDeleteConfirm = async () => { - await deleteProjects({ editor, ids: [project.id] }); - setIsDeleteDialogOpen(false); - }; - return ( <> - - } - onClick={handleRename} - > - Rename - - } - onClick={handleDuplicate} - > - Duplicate - - } - onClick={handleInfoClick} - > - Info - - - } - onClick={handleDeleteClick} - > - Delete - - + + +
+ {isGridView ? ( + <> + + {gridContent} + + + event.preventDefault()} + onClick={(event) => { + handleCheckboxChange({ + checked: !isSelected, + shiftKey: event.shiftKey, + }); + }} + onCheckedChange={() => {}} + className={`absolute z-10 size-5 top-3 left-3 ${ + isSelected || isDropdownOpen + ? "opacity-100" + : "opacity-0 group-hover:opacity-100" + }`} + /> + + {!isMultiSelect && ( + + )} + + ) : ( + listContent + )} +
+
+ +
void; + onDuplicateClick: () => void; + onDeleteClick: () => void; + onInfoClick: () => void; +}) { + return ( + + } + onClick={onRenameClick} + > + Rename + + } + onClick={onDuplicateClick} + > + Duplicate + + } + onClick={onInfoClick} + > + Info + + + } + onClick={onDeleteClick} + > + Delete + + + ); +} + function ProjectMenu({ isOpen, onOpenChange, - project, variant = "grid", + onRenameClick, + onDuplicateClick, + onDeleteClick, + onInfoClick, }: { isOpen: boolean; onOpenChange: (open: boolean) => void; - project: TProjectMetadata; variant?: "grid" | "list"; + onRenameClick: () => void; + onDuplicateClick: () => void; + onDeleteClick: () => void; + onInfoClick: () => void; }) { - const editor = useEditor(); - const [isRenameDialogOpen, setIsRenameDialogOpen] = useState(false); - const [isDeleteDialogOpen, setIsDeleteDialogOpen] = useState(false); - const [isInfoDialogOpen, setIsInfoDialogOpen] = useState(false); - const handleMenuClick = ({ event, }: { @@ -828,107 +838,77 @@ function ProjectMenu({ }; const handleRename = () => { - setIsRenameDialogOpen(true); + onRenameClick(); onOpenChange(false); }; - const handleDuplicate = async () => { - await duplicateProjects({ editor, ids: [project.id] }); + const handleDuplicate = () => { + onDuplicateClick(); onOpenChange(false); }; const handleDeleteClick = () => { - setIsDeleteDialogOpen(true); + onDeleteClick(); onOpenChange(false); }; - const handleDeleteConfirm = async () => { - await deleteProjects({ editor, ids: [project.id] }); - setIsDeleteDialogOpen(false); - }; - const handleInfoClick = () => { - setIsInfoDialogOpen(true); + onInfoClick(); onOpenChange(false); }; const isGrid = variant === "grid"; return ( - <> - - - - - - - - Rename - - - - Duplicate - - - - Info - - - - Delete - - - - - { - await renameProject({ editor, id: project.id, name: newName }); - setIsRenameDialogOpen(false); - }} - /> - - - - - + + + + + + + + Rename + + + + Duplicate + + + + Info + + + + Delete + + + ); }