diff --git a/frontend/src/components/newUID.js b/frontend/src/components/newUID.js
new file mode 100644
index 00000000..1cdebcdb
--- /dev/null
+++ b/frontend/src/components/newUID.js
@@ -0,0 +1,13 @@
+import React from "react";
+
+export default function generateUID() {
+ const charset =
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
+ const uidLength = 28;
+ let uid = "";
+ for (let i = 0; i < uidLength; i += 1) {
+ const randomIndex = Math.floor(Math.random() * charset.length);
+ uid += charset.charAt(randomIndex);
+ }
+ return uid;
+}
diff --git a/frontend/src/containers/pages/ScenarioSelectionPage.js b/frontend/src/containers/pages/ScenarioSelectionPage.js
index 5f576092..849c6ba4 100644
--- a/frontend/src/containers/pages/ScenarioSelectionPage.js
+++ b/frontend/src/containers/pages/ScenarioSelectionPage.js
@@ -1,4 +1,4 @@
-import React, { useContext, useEffect } from "react";
+import React, { useContext, useEffect, useState } from "react";
import { useHistory } from "react-router-dom";
import SideBar from "../../components/SideBar";
import ListContainer from "../../components/ListContainer";
diff --git a/frontend/src/containers/pages/SceneSelectionPage.js b/frontend/src/containers/pages/SceneSelectionPage.js
index dc974469..b6fc196b 100644
--- a/frontend/src/containers/pages/SceneSelectionPage.js
+++ b/frontend/src/containers/pages/SceneSelectionPage.js
@@ -20,6 +20,7 @@ import AuthoringToolContextProvider from "../../context/AuthoringToolContextProv
import AuthenticationContext from "../../context/AuthenticationContext";
import HelpButton from "../../components/HelpButton";
import AccessLevel from "../../enums/route.access.level";
+import generateUID from "../../components/newUID";
/**
* Page that shows the scenes belonging to a scenario.
@@ -43,8 +44,25 @@ export function SceneSelectionPage({ data = null }) {
Papa.parse(selectedFile, {
header: true,
skipEmptyLines: true,
- complete(results) {
- console.log(results.data);
+ complete: async (results) => {
+ const usersData = results.data;
+ usersData.forEach(async (userData) => {
+ const { name, email } = userData;
+ const uid = generateUID(); // Implement your UID generation logic
+ const pictureURL = "null"; // Set the picture URL if available
+ const newUser = await usePost(
+ `/api/user/`,
+ {
+ name,
+ uid,
+ email,
+ pictureURL,
+ },
+ getUserIdToken
+ );
+ console.log(`User ${name} uploaded to MongoDB.`);
+ });
+ console.log("CSV data uploaded to MongoDB.");
},
});
};
@@ -202,14 +220,18 @@ export function SceneSelectionPage({ data = null }) {
>
Share
-
+ {VpsUser.role === AccessLevel.USER ? (
+
+ ) : (
+ ""
+ )}