Favorites Drag and Drop Implementation (#8979)
Adds drag and drop functionality for favorites management, allowing users to: - Move favorites between folders - Move favorites from folders to orphan section - Move orphan favorites into folders Known Issues: Drop detection at folder boundaries requires spacing workaround
This commit is contained in:
@ -0,0 +1,29 @@
|
||||
import { FAVORITE_DROPPABLE_IDS } from '@/favorites/constants/FavoriteDroppableIds';
|
||||
|
||||
export const validateAndExtractFolderId = (
|
||||
droppableId: string,
|
||||
): string | null => {
|
||||
if (droppableId === FAVORITE_DROPPABLE_IDS.ORPHAN_FAVORITES) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (droppableId.startsWith(FAVORITE_DROPPABLE_IDS.FOLDER_HEADER_PREFIX)) {
|
||||
const folderId = droppableId.replace(
|
||||
FAVORITE_DROPPABLE_IDS.FOLDER_HEADER_PREFIX,
|
||||
'',
|
||||
);
|
||||
if (!folderId) throw new Error(`Invalid folder header ID: ${droppableId}`);
|
||||
return folderId;
|
||||
}
|
||||
|
||||
if (droppableId.startsWith(FAVORITE_DROPPABLE_IDS.FOLDER_PREFIX)) {
|
||||
const folderId = droppableId.replace(
|
||||
FAVORITE_DROPPABLE_IDS.FOLDER_PREFIX,
|
||||
'',
|
||||
);
|
||||
if (!folderId) throw new Error(`Invalid folder ID: ${droppableId}`);
|
||||
return folderId;
|
||||
}
|
||||
|
||||
throw new Error(`Invalid droppable ID format: ${droppableId}`);
|
||||
};
|
||||
Reference in New Issue
Block a user