diff --git a/src/pages/LEVANTE/RegisterUsers.vue b/src/pages/LEVANTE/RegisterUsers.vue
index 0673b06c9..fd884cbf7 100644
--- a/src/pages/LEVANTE/RegisterUsers.vue
+++ b/src/pages/LEVANTE/RegisterUsers.vue
@@ -47,11 +47,7 @@
-
+
Object.values(obj)
.map((value) => {
- if (value === null || value === undefined) return ''; // Handle null/undefined values
- return `"${value.toString().replace(/"/g, '""')}"`; // Handle values containing commas or quotes
+ if (value === null || value === undefined) return '';
+ return `"${value.toString().replace(/"/g, '""')}"`;
})
.join(','),
)
@@ -346,21 +344,31 @@ function convertUsersToCSV() {
const csvString = csvHeader + csvRows;
// Create Blob from CSV String
- const blob = new Blob([csvString], { type: 'text/csv;charset=utf-8;' });
+ csvBlob.value = new Blob([csvString], { type: 'text/csv;charset=utf-8;' });
+
+ // Create URL from Blob
+ csvURL.value = URL.createObjectURL(csvBlob.value);
- // Create Download Link
- const link = document.createElement('a');
- const url = URL.createObjectURL(blob);
- link.setAttribute('href', url);
- link.setAttribute('download', filename);
- document.body.appendChild(link); // Required for Firefox
+ // Initiate download
+ downloadCSV();
+}
+
+function downloadCSV() {
+ const filename = 'registered-users.csv';
- // Trigger the Download
- link.click();
+ if (csvURL.value) {
+ // Create Download Link
+ const link = document.createElement('a');
+ link.setAttribute('href', csvURL.value);
+ link.setAttribute('download', filename);
+ document.body.appendChild(link); // Required for Firefox
- // Cleanup
- document.body.removeChild(link);
- URL.revokeObjectURL(url);
+ // Trigger the Download
+ link.click();
+
+ // Cleanup
+ document.body.removeChild(link);
+ }
}
function addErrorUser(user, error) {