fix: update mass import handling to use selected profile indexes and add validation for empty selections

This commit is contained in:
Sam Chau
2025-01-09 17:04:14 +10:30
parent dd7f467691
commit c15502fa97

View File

@@ -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();