From c15502fa9721a7e16b3d50ddfe7367a78f310d3a Mon Sep 17 00:00:00 2001 From: Sam Chau Date: Thu, 9 Jan 2025 17:04:14 +1030 Subject: [PATCH] fix: update mass import handling to use selected profile indexes and add validation for empty selections --- frontend/src/components/profile/ProfilePage.jsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/profile/ProfilePage.jsx b/frontend/src/components/profile/ProfilePage.jsx index 48695d0..f782820 100644 --- a/frontend/src/components/profile/ProfilePage.jsx +++ b/frontend/src/components/profile/ProfilePage.jsx @@ -214,13 +214,19 @@ function ProfilePage() { const handleMassImport = async arr => { try { - const selectedProfiles = Array.from(selectedItems).map(identifier => - profiles.find(p => p.content.name === identifier) - ); + // Get array of indexes from selectedItems + const selectedProfilesList = Array.from(selectedItems) + .map(index => profiles[index]) + .filter(profile => profile); // Filter out any undefined entries + + if (selectedProfilesList.length === 0) { + Alert.error('No valid profiles selected for import'); + return; + } await importProfiles( arr, - selectedProfiles.map(p => p.file_name) + selectedProfilesList.map(p => p.file_name) ); Alert.success('Profiles imported successfully'); toggleSelectionMode();