diff --git a/client/Activity_card_code/activitity_card.css b/client/Activity_card_code/activitity_card.css index 486cc91f104fa385640e5534524e003e08e14076..81d1c4fa770951ccc0202d23a9a55f89d34534af 100644 --- a/client/Activity_card_code/activitity_card.css +++ b/client/Activity_card_code/activitity_card.css @@ -1,5 +1,5 @@ .activityCardFont{ - font-family: 'Gill Sans MT'; + font-family: "Roboto", sans-serif; } .activityCard{ height: 170px; @@ -11,7 +11,7 @@ width: 100%; height: 100%; /*background: linear-gradient(to right, #efcdea 0%, #f3daef 11%, #edddeb 22%, #ffffff 35%);*/ - background: linear-gradient(to right, #efcdea 12%, #f3daef 25%, #edddeb 50%, #ffffff 75%); + background: linear-gradient(to right, #efcdea 0%, #edddeb 0%, #ffffff 30%, #ffffff 10%); text-align: left; display: flex; flex-direction: row; @@ -35,11 +35,12 @@ text-align: left; margin-left: 15%; -.activityCardMore { + +/* .activityCardMore { flex: 1; padding: 10px; box-sizing: border-box; -} +}*/ } #activityCardDepHeader{ diff --git a/client/Database/database.js b/client/Database/database.js index 45d24cfbd76c285e4c96a8d9b199de62cc6c8108..ac3c1a1ba8b414622e719d703d60cdbc81b69168 100644 --- a/client/Database/database.js +++ b/client/Database/database.js @@ -10,23 +10,32 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge import { initializeApp } from "firebase/app"; import { getFirestore, collection, doc, setDoc, updateDoc, arrayUnion, getDocs, getDoc, where, query, deleteDoc, orderBy, } from "firebase/firestore"; import { getAuth } from "firebase/auth"; -// const firebaseConfig = { -// apiKey: "AIzaSyDqkaVZMr11J4mfnR0auqoQilZyPfyD-x4", -// authDomain: "c3solutions-dc109.firebaseapp.com", -// projectId: "c3solutions-dc109", -// storageBucket: "c3solutions-dc109.appspot.com", -// messagingSenderId: "902143402555", -// appId: "1:902143402555:web:29213e81de0a0cba38b21e", -// }; const firebaseConfig = { - apiKey: "AIzaSyBIsZq_yOsJljp1woIxndJO1GkW6soh-g4", - authDomain: "company3-456bb.firebaseapp.com", - projectId: "company3-456bb", - storageBucket: "company3-456bb.appspot.com", - messagingSenderId: "310033686522", - appId: "1:310033686522:web:63198bb0db679c98ee4e43", - measurementId: "G-PFLDQY00DB" + apiKey: "AIzaSyDqkaVZMr11J4mfnR0auqoQilZyPfyD-x4", + authDomain: "c3solutions-dc109.firebaseapp.com", + projectId: "c3solutions-dc109", + storageBucket: "c3solutions-dc109.appspot.com", + messagingSenderId: "902143402555", + appId: "1:902143402555:web:29213e81de0a0cba38b21e", }; +/*const firebaseConfig = { + apiKey: "AIzaSyBIsZq_yOsJljp1woIxndJO1GkW6soh-g4", + authDomain: "company3-456bb.firebaseapp.com", + projectId: "company3-456bb", + storageBucket: "company3-456bb.appspot.com", + messagingSenderId: "310033686522", + appId: "1:310033686522:web:63198bb0db679c98ee4e43", + measurementId: "G-PFLDQY00DB" +};*/ +// const firebaseConfig = { +// apiKey: "AIzaSyBIsZq_yOsJljp1woIxndJO1GkW6soh-g4", +// authDomain: "company3-456bb.firebaseapp.com", +// projectId: "company3-456bb", +// storageBucket: "company3-456bb.appspot.com", +// messagingSenderId: "310033686522", +// appId: "1:310033686522:web:63198bb0db679c98ee4e43", +// measurementId: "G-PFLDQY00DB" +// }; const app = initializeApp(firebaseConfig); export const auth = getAuth(); export const db = getFirestore(app); @@ -37,7 +46,7 @@ const taskCollection = collection(db, "task"); const hospitalCollection = collection(db, "hospital"); const suggestionCollection = collection(db, "suggestion"); const knowledgeDocumentCollection = collection(db, "knowledgeDocument"); -const userImprovementWorkCollections = collection(db, "userImprovementWork"); +const userImprovementWorkCollection = collection(db, "userImprovementWork"); const userTaskCollection = collection(db, "userTask"); ////////////////////////////////////////Setters/////////////////////////////////////////////////////////////////// // Function to create user a new user in database @@ -71,13 +80,9 @@ function createUser(hsaId, unitId, firstName, lastName, email, manager, uid) { } }); } -//Adds a new improvementWork to the database -// takes in Id, name, currentStage in PDSA, content, unitId refers to as string and if completed as boolean -// throws error if transaction failed function createImprovementWork(id, name, currentStage, content, // Är detta description bör detta förtydligas. unitId, purpose, //Bör tas bort motsvaras av p2- mål med projektet patientRiskLevel, area, -// patientRiskLevel: "Green" | "Blue" | "Orange" | "Red" //Questions in planning stage p1, p2, p3, p4, p5, p6, p7, //Questions in Doing (G) stage @@ -89,11 +94,9 @@ a1, a2, a3, a4) { return __awaiter(this, void 0, void 0, function* () { //ID has to be a string try { - const improvementWorkRef = doc(improvementWorkCollection, id); - yield setDoc(improvementWorkRef, { - id: improvementWorkRef.id, - currentStage: currentStage, + const improvementWorkData = { name: name, + currentStage: currentStage, content: content, purpose: purpose, dateStarted: new Date(), @@ -101,7 +104,7 @@ a1, a2, a3, a4) { completed: false, ongoing: false, tasks: [], - // TODO Replace with userImprovementWork collection + // TODO Remove members array members: [], patientRiskLevel: patientRiskLevel, area: area, @@ -124,7 +127,15 @@ a1, a2, a3, a4) { a2: a2, a3: a3, a4: a4, - }); + }; + if (id) { + const improvementWorkRef = doc(improvementWorkCollection, id); + yield setDoc(improvementWorkRef, Object.assign({ id: improvementWorkRef.id }, improvementWorkData)); + } + else { + const improvementWorkRef = doc(improvementWorkCollection); + yield setDoc(improvementWorkRef, improvementWorkData); + } } catch (error) { console.log("Error creating improvementWork: ", error); @@ -132,37 +143,6 @@ a1, a2, a3, a4) { } }); } -// Replace with userTask collection (OLD) -//adds a member to task -// takes in ID, the added members hsaId, task id as string and if person is responsible as boolean -// throws error if transaction failed -// async function addMemberToTask( -// userHsaId: string, -// taskId: string, -// isResponsibleFor: boolean -// ): Promise<void> { -// try { -// // Atomically add a member to task. -// const taskRef = doc(taskCollection, taskId); -// await updateDoc(taskRef, { -// members: arrayUnion({ -// userHsaId: userHsaId, -// isResponsibleFor: isResponsibleFor, -// }), -// }); -// // Atomically add a task to user. -// const userRef = doc(userCollection, userHsaId); -// await updateDoc(userRef, { -// tasks: arrayUnion({ -// taskId: taskId, -// isResponsibleFor: isResponsibleFor, -// }), -// }); -// } catch (error) { -// console.log("Error adding member: ", error); -// throw error; -// } -// } function addMemberToTask(userHsaId, taskId, isResponsibleFor) { return __awaiter(this, void 0, void 0, function* () { try { @@ -183,7 +163,7 @@ function addMemberToTask(userHsaId, taskId, isResponsibleFor) { function addMemberToImprovementWork(userHsaId, improvementWorkId, isOwner, isResponsibleFor) { return __awaiter(this, void 0, void 0, function* () { try { - const relationRef = doc(userImprovementWorkCollections); + const relationRef = doc(userImprovementWorkCollection); yield setDoc(relationRef, { id: relationRef.id, userHsaId: userHsaId, @@ -198,66 +178,26 @@ function addMemberToImprovementWork(userHsaId, improvementWorkId, isOwner, isRes } }); } -// TODO Replace with userImprovementWork collection (OLD) -// add a member to a improvementWork -// takes in id, users HSAid, improvementWorks id as string and if is owner, is responsible as boolean -// throws error if transaction failed -// async function addMemberToImprovementWork( -// userHsaId: string, -// improvementWorkId: string, -// isOwner: boolean, -// isResponsibleFor: boolean -// ): Promise<void> { -// try { -// const improvementWorkRef = doc( -// improvementWorkCollection, -// improvementWorkId -// ); -// // return; -// // Atomically update the members array in the improvementWork document -// await updateDoc(improvementWorkRef, { -// members: arrayUnion({ -// userHsaId: userHsaId, -// isOwner: isOwner, -// isResponsibleFor: isResponsibleFor, -// }), -// }); -// const userRef = doc(userCollection, userHsaId); -// // Atomically add improvementWork to user -// await updateDoc(userRef, { -// improvementWorks: arrayUnion({ -// improvementWorkId: improvementWorkId, -// isOwner: isOwner, -// isResponsibleFor: isResponsibleFor, -// }), -// }); -// } catch (error) { -// console.log("Error adding member: ", error); -// throw error; -// } -// } -//create task to improvementWork -// takes in improvementWorkId, name, deadline date, start date, stage in PDSA and content as string -// throws error if transaction failed function createTaskOnImprovementWork(taskId, improvementWorkId, name, deadlineDate, startDate, stage, content) { return __awaiter(this, void 0, void 0, function* () { try { - const ref = doc(taskCollection, taskId); - yield setDoc(ref, { - id: ref.id, - improvementWorkId: improvementWorkId, - name: name, - deadlineDate: deadlineDate, - startDate: startDate, - stage: stage, - content: content, - members: [], - }); - const improvementWorkRef = doc(improvementWorkCollection, improvementWorkId); - // Atomically add task to the tasks array field. - yield updateDoc(improvementWorkRef, { - tasks: arrayUnion(taskId), - }); + const taskData = { + improvementWorkId, + name, + deadlineDate, + startDate, + stage, + content, + members: [], // Initialize with an empty array + }; + if (taskId) { + const taskRef = doc(taskCollection, taskId); + yield setDoc(taskRef, Object.assign({ id: taskRef.id }, taskData)); + } + else { + const taskRef = doc(taskCollection); + yield setDoc(taskRef, taskData); + } } catch (error) { console.log("Error creating task: ", error); @@ -305,19 +245,22 @@ function addDocumentToImprovementWork(documentUrl, name, improvementWorkId) { } }); } -//create a hospital -// takes in ID, name as string -// throws error if transaction failed function createHospital(hospitalId, // should be auto? name) { return __awaiter(this, void 0, void 0, function* () { try { - const ref = doc(hospitalCollection, hospitalId); - yield setDoc(ref, { - id: ref.id, - name: name, - units: [], - }); + const hospitalData = { + name, + units: [] + }; + if (hospitalId) { + const hospitalRef = doc(hospitalCollection, hospitalId); + yield setDoc(hospitalRef, Object.assign({ id: hospitalRef.id }, hospitalData)); + } + else { + const hospitalRef = doc(hospitalCollection); + yield setDoc(hospitalRef, hospitalData); + } } catch (error) { console.log("Error creating hospital: ", error); @@ -325,25 +268,23 @@ name) { } }); } -//create a unit -// takes in id, hospitals id and name as string -// throws error if transaction failed function createUnit(unitId, //should be auto? hospitalId, name) { return __awaiter(this, void 0, void 0, function* () { try { - const unitRef = doc(unitCollection, unitId); - yield setDoc(unitRef, { - id: unitRef.id, - hospitalId: hospitalId, - name: name, - members: [], - }); - // Atomically add unit to hospital. - const hospitalRef = doc(hospitalCollection, hospitalId); - yield updateDoc(hospitalRef, { - units: arrayUnion(unitRef.id), - }); + const unitData = { + hospitalId, + name, + members: [] + }; + if (unitId) { + const unitRef = doc(unitCollection, unitId); + yield setDoc(unitRef, Object.assign({ id: unitRef.id }, unitData)); + } + else { + const unitRef = doc(unitCollection); + yield setDoc(unitRef, unitData); + } } catch (error) { console.log("Error creating unit: ", error); @@ -351,34 +292,35 @@ hospitalId, name) { } }); } -//creates a suggestion -// takes in ID, the creators hsaId, name, content and the responding unitId as string -// throws error if transaction failed function createSuggestion(id, creatorHsaId, name, area, content, purpose, measure, ideas, //need: boolean, unitId, departmentId, isPublic) { return __awaiter(this, void 0, void 0, function* () { try { - const suggestionRef = doc(suggestionCollection, id); - yield setDoc(suggestionRef, { - id: suggestionRef.id, - creatorHsaId: creatorHsaId, - name: name, - area: area, - content: content, - purpose: purpose, - measure: measure, - ideas: ideas, - //need: need, - unitId: unitId, - departmentId: departmentId, + const suggestionData = { + creatorHsaId, + name, + area, + content, + purpose, + measure, + ideas, + //need, + unitId, + departmentId, public: isPublic, upvotes: [], comments: [], - dateCreated: new Date(), - }); - const commentCollection = yield collection(suggestionRef, "comment"); - yield doc(commentCollection); + dateCreated: new Date() + }; + if (id) { + const suggestionRef = doc(suggestionCollection, id); + yield setDoc(suggestionRef, Object.assign({ id: suggestionRef.id }, suggestionData)); + } + else { + const suggestionRef = doc(suggestionCollection); + yield setDoc(suggestionRef, suggestionData); + } } catch (error) { console.log("Error creating suggestion: ", error); @@ -505,7 +447,7 @@ function getObjectById(collectionPath, documentId) { const docRef = doc(db, collectionPath, documentId); const docSnapshot = yield getDoc(docRef); if (docSnapshot.exists()) { - return docSnapshot.data(); + return Object.assign({ id: docSnapshot.id }, docSnapshot.data()); } else { console.warn(`No such document! ${collectionPath}/${documentId}`); @@ -688,6 +630,50 @@ function getImprovementWorks({ id, nolanStage, unitId, completed, ongoing, patie } }); } +function getImprovementWorkOwner(improvementWorkId) { + return __awaiter(this, void 0, void 0, function* () { + try { + let constraints = []; + constraints.push(where("improvementWorkId", "==", improvementWorkId)); + constraints.push(where("isOwner", "==", true)); + const q = query(userImprovementWorkCollection, ...constraints); + const querySnapshot = yield getDocs(q); + if (querySnapshot.empty) { + console.log("Improvement work ", improvementWorkId, " has no owner"); + return null; + } + else { + const owner = querySnapshot.docs[0].data().userHsaId; + return owner; + } + } + catch (error) { + console.log(error); + } + }); +} +function getImprovementWorkResponsible(improvementWorkId) { + return __awaiter(this, void 0, void 0, function* () { + try { + let constraints = []; + constraints.push(where("improvementWorkId", "==", improvementWorkId)); + constraints.push(where("isResponsibleFor", "==", true)); + const q = query(userImprovementWorkCollection, ...constraints); + const querySnapshot = yield getDocs(q); + if (querySnapshot.empty) { + console.log("Improvement work ", improvementWorkId, " has no responsible"); + return null; + } + else { + const responsible = querySnapshot.docs[0].data().userHsaId; + return responsible; + } + } + catch (error) { + console.log(error); + } + }); +} // TODO getUsersForTask! /** * Asynchronously retrieves user documents from the database based on various filter criteria. @@ -752,7 +738,7 @@ uid, }) { function getTasks({ // userHsaId, // isResponsibleFor, -improvementWorkId, ascendingDates = false, // Descending dates by default +improvementWorkId, stage, ascendingDates = false, // Descending dates by default }) { return __awaiter(this, void 0, void 0, function* () { try { @@ -767,6 +753,9 @@ improvementWorkId, ascendingDates = false, // Descending dates by default // }) // ); // } + if (stage) { + constraints.push(where("stage", "==", stage)); + } if (improvementWorkId != undefined) { constraints.push(where("improvementWorkId", "==", improvementWorkId)); constraints.push(orderBy("startDate", ascendingDates ? "asc" : "desc")); @@ -834,7 +823,7 @@ function getImprovementWorksForUser(userHsaId) { try { console.log("Getting improvementworks for user: ", userHsaId); // Query the userImprovementWork collection for relations involving this user - const q = query(userImprovementWorkCollections, where('userHsaId', '==', userHsaId)); + const q = query(userImprovementWorkCollection, where('userHsaId', '==', userHsaId)); const querySnapshot = yield getDocs(q); // Fetch each related improvementWork document const improvementWorks = []; @@ -856,7 +845,7 @@ function getUsersForImprovementWork(improvementWorkId) { try { console.log("Getting users for improvementwork: ", improvementWorkId); // Query the userImprovementWork collection for relations involving this improvementWork - const q = query(userImprovementWorkCollections, where('improvementWorkId', '==', improvementWorkId)); + const q = query(userImprovementWorkCollection, where('improvementWorkId', '==', improvementWorkId)); const querySnapshot = yield getDocs(q); // Fetch each related user document const users = []; @@ -874,7 +863,7 @@ function getUsersForImprovementWork(improvementWorkId) { }); } // export getters to be able to use in other files -export { getObject, getObjectById, getSuggestions, getImprovementWorks, getUsers, getTasks, getUnits, getComments, getHospitals, getImprovementWorksForUser, getUsersForImprovementWork, }; +export { getObject, getObjectById, getSuggestions, getImprovementWorks, getUsers, getTasks, getUnits, getComments, getHospitals, getImprovementWorksForUser, getUsersForImprovementWork, getImprovementWorkOwner, getImprovementWorkResponsible, }; ////////////////////////////////////DELETING///////////////////////////////////////////// // delete an instance of a type function deleteInstance(docType, docId) { diff --git a/client/Database/database.ts b/client/Database/database.ts index d2e299e6ea31662cc09e315d20ae6e875c1b4d1c..927b451c482ce923c4fd7f2e78805b83c83facf4 100644 --- a/client/Database/database.ts +++ b/client/Database/database.ts @@ -39,6 +39,16 @@ import { getAuth, createUserWithEmailAndPassword } from "firebase/auth"; measurementId: "G-PFLDQY00DB" };*/ +// const firebaseConfig = { +// apiKey: "AIzaSyBIsZq_yOsJljp1woIxndJO1GkW6soh-g4", +// authDomain: "company3-456bb.firebaseapp.com", +// projectId: "company3-456bb", +// storageBucket: "company3-456bb.appspot.com", +// messagingSenderId: "310033686522", +// appId: "1:310033686522:web:63198bb0db679c98ee4e43", +// measurementId: "G-PFLDQY00DB" +// }; + const app = initializeApp(firebaseConfig); export const auth = getAuth(); export const db = getFirestore(app); @@ -49,7 +59,7 @@ const taskCollection = collection(db, "task"); const hospitalCollection = collection(db, "hospital"); const suggestionCollection = collection(db, "suggestion"); const knowledgeDocumentCollection = collection(db, "knowledgeDocument"); -const userImprovementWorkCollections = collection(db, "userImprovementWork"); +const userImprovementWorkCollection = collection(db, "userImprovementWork"); const userTaskCollection = collection(db, "userTask"); interface improvementWorkType { @@ -270,7 +280,7 @@ async function addMemberToImprovementWork( isResponsibleFor: boolean ): Promise<void> { try { - const relationRef = doc(userImprovementWorkCollections); + const relationRef = doc(userImprovementWorkCollection); await setDoc(relationRef, { id: relationRef.id, @@ -909,6 +919,48 @@ async function getImprovementWorks({ } } +async function getImprovementWorkOwner(improvementWorkId: string) { + try { + let constraints : any[] = []; + constraints.push(where("improvementWorkId", "==", improvementWorkId)); + constraints.push(where("isOwner", "==", true)); + + const q = query(userImprovementWorkCollection, ...constraints); + const querySnapshot = await getDocs(q); + + if (querySnapshot.empty) { + console.log("Improvement work ", improvementWorkId, " has no owner"); + return null; + } else { + const owner = querySnapshot.docs[0].data().userHsaId; + return owner; + } + } catch (error) { + console.log(error); + } +} + +async function getImprovementWorkResponsible(improvementWorkId: string) { + try { + let constraints : any[] = []; + constraints.push(where("improvementWorkId", "==", improvementWorkId)); + constraints.push(where("isResponsibleFor", "==", true)); + + const q = query(userImprovementWorkCollection, ...constraints); + const querySnapshot = await getDocs(q); + + if (querySnapshot.empty) { + console.log("Improvement work ", improvementWorkId, " has no responsible"); + return null; + } else { + const responsible = querySnapshot.docs[0].data().userHsaId; + return responsible; + } + } catch (error) { + console.log(error); + } +} + // TODO getUsersForTask! /** @@ -1100,7 +1152,7 @@ async function getImprovementWorksForUser(userHsaId: string): Promise<DocumentDa try { console.log("Getting improvementworks for user: ", userHsaId); // Query the userImprovementWork collection for relations involving this user - const q = query(userImprovementWorkCollections, where('userHsaId', '==', userHsaId)); + const q = query(userImprovementWorkCollection, where('userHsaId', '==', userHsaId)); const querySnapshot = await getDocs(q); // Fetch each related improvementWork document @@ -1121,7 +1173,7 @@ async function getUsersForImprovementWork(improvementWorkId: string): Promise<Do try { console.log("Getting users for improvementwork: ", improvementWorkId); // Query the userImprovementWork collection for relations involving this improvementWork - const q = query(userImprovementWorkCollections, where('improvementWorkId', '==', improvementWorkId)); + const q = query(userImprovementWorkCollection, where('improvementWorkId', '==', improvementWorkId)); const querySnapshot = await getDocs(q); // Fetch each related user document @@ -1153,6 +1205,8 @@ export { getHospitals, getImprovementWorksForUser, getUsersForImprovementWork, + getImprovementWorkOwner, + getImprovementWorkResponsible, }; ////////////////////////////////////DELETING///////////////////////////////////////////// diff --git a/client/Database/initDatabase_test.js b/client/Database/initDatabase_test.js index b8f64c221bbbb79fef4ea2bb5b30fd41a4806510..f7c3728b517993a64f9cbde66be4345ca27081c5 100644 --- a/client/Database/initDatabase_test.js +++ b/client/Database/initDatabase_test.js @@ -416,7 +416,44 @@ function testFinalizeImprovementWork() { } }); } +function testImprovementWorksForUser(userHsaId) { + return __awaiter(this, void 0, void 0, function* () { + try { + let improvementWorks = yield getImprovementWorksForUser(userHsaId); + if (improvementWorks.length == 0) { + console.log("No such improvement works found"); + } + improvementWorks.forEach((improvementWork, key) => { + console.log("Improvement work number " + key + ": "); + console.log(improvementWork); + }); + } + catch (error) { + console.log(error); + } + }); +} +function testUsersForImprovementWork(improvementWorkId) { + return __awaiter(this, void 0, void 0, function* () { + try { + let users = yield getUsersForImprovementWork(improvementWorkId); + if (users.length == 0) { + console.log("No such users found"); + } + users.forEach((user, key) => { + console.log("User with id " + user.id + ": "); + console.log(user); + }); + } + catch (error) { + console.log(error); + } + }); +} +// testImprovementWorksForUser("micbro012"); +// testUsersForImprovementWork("proj_002"); // resetData(); +// deleteData(); // addData(); //testFinalizeImprovementWork(); //startOrPauseImprovementWork("micbro012", "proj_004") @@ -427,4 +464,4 @@ function testFinalizeImprovementWork() { testTasks(); // testUsers(); // testUnits(); -testComments(); +// testComments(); diff --git a/client/KnowledgeBank/completedProjects.js b/client/KnowledgeBank/completedProjects.js index f534620f22c7dee30dbc5cd2245403530cf15b80..70f1c109dbd4f16e69569f9a6ac385794a185946 100644 --- a/client/KnowledgeBank/completedProjects.js +++ b/client/KnowledgeBank/completedProjects.js @@ -7,82 +7,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; -import { getImprovementWorks } from "../Database/database.js"; -/* -//SAMPLES, TO BE REPLACED BY DB -const sampleUnits: Unit[] = [ - { - ID: "1", - hospital_ID: "1", - name: "Akuten" - }, - - { - ID: "2", - hospital_ID: "1", - name: "BB" - }, - { - ID: "3", - hospital_ID: "1", - name: "Onkolog" - }, - - -]; - -const unitNameLookup: Record<string, string> = {}; -sampleUnits.forEach((unit) => { - unitNameLookup[unit.ID] = unit.name; -}); -*/ -/* -const sampleProjects: Project[] = [ - { - id: "1", - name: "Birthing of a Child", - current_stage: "In Progress", - content: "This is project 1.", - unitId: "2", - dateStarted: new Date("2023-01-15"), - }, - { - id: "2", - name: "How to save a life", - current_stage: "Completed", - content: "This is project 2.", - unitId: "1", - dateStarted: new Date("2023-02-20"), - }, - { - id: "3", - name: "BB tutorial", - current_stage: "Completed", - content: "This is project 3.", - unitId: "2", - dateStarted: new Date("2023-06-05"), - }, - { - id: "4", - name: "Cancerbehandling 101", - current_stage: "Completed", - content: "This is project 4.", - unitId: "3", - dateStarted: new Date("2023-10-24"), - }, -]; - - - -sampleProjects.sort((a,b) => b.dateStarted.getTime() - a.dateStarted.getTime()); //SORTING THE PROJECTS FROM NEWEST TO OLDEST -*/ +import { getImprovementWorks, getUnits, getObjectById } from "../Database/database.js"; function getCompletedProjects() { return __awaiter(this, void 0, void 0, function* () { let CompletedProjects = yield getImprovementWorks({ completed: true }); + //CompletedProjects.sort((a,b) => b.dateStarted.getTime() - a.dateStarted.getTime()); return CompletedProjects; }); } -//let completedImprovmentWorks = await getImprovementWorks({}); //TO MAKE DATE APPEAR NICELY function formatDate(timeStamp) { const date = timeStamp.toDate(); @@ -96,16 +28,22 @@ function formatDate(timeStamp) { } //TO CREATE GRID HTML ELEMENT OF PROJECTS function createGridRow(project) { - const row = document.createElement("div"); - row.className = "grid-row"; - const unitName = project.unitId || 'Unknown Unit'; - row.innerHTML = ` + return __awaiter(this, void 0, void 0, function* () { + let unit = yield getObjectById("unit", project.unitId); + const row = document.createElement("div"); + row.className = "grid-row"; + let unitName = "Unspecified Unit"; + if (unit) { + unitName = unit.name; + } + row.innerHTML = ` <div class="column">${project.name}</div> <div class="column">${unitName}</div> <div class="column">${formatDate(project.dateStarted)}</div> <div class="column">Link-placeholder</div> `; - return row; + return row; + }); } //TO ADD GRID ELEMENTS TO GRID-CONTAINER function addGridRows() { @@ -113,73 +51,56 @@ function addGridRows() { const gridContainer = document.getElementById("grid-container"); let projects = yield getCompletedProjects(); console.log(projects); - projects.forEach((project) => { + projects.forEach((project) => __awaiter(this, void 0, void 0, function* () { const row = createGridRow(project); if (gridContainer != null) { - gridContainer.appendChild(row); + gridContainer.appendChild(yield row); } - }); - /* - projects.forEach((project) => { - const row = createGridRow(project); - if(gridContainer != null) { - gridContainer.appendChild(row); - } - }); - */ + })); }); } -const departmentDropdown = document.getElementById("departmentDropdown"); //INSTANCING THE FILTER HTLM ELEMENTS -const dateDropdown = document.getElementById("dateDropdown"); -const searchInput = document.getElementById("searchInput"); -let selectedDepartment = "all"; -let selectedDateFilter = "newest"; -let searchQuery; -//TO MAKE DEPARTMENTDROPDOWN CONTAIN ALL THE UNITS FROM DB -/* -async function fillDropdown() { -sampleUnits.forEach((unit) => { - const option = document.createElement("option"); - option.value = unit.ID; - option.textContent = unit.name; - //departmentDropdown.appendChild(option); -}); +function fillDropdown() { + return __awaiter(this, void 0, void 0, function* () { + const departmentDropdown = document.getElementById("departmentDropdown"); + let units = yield getUnits({}); + console.log(units); + units.forEach(unit => { + const option = document.createElement("option"); + option.value = unit.Id; + option.textContent = unit.name; + departmentDropdown.appendChild(option); + }); + }); } -*/ -/* //FILTERING BY DEPARTMENT AND DATE -function filterProjects(selectedDepartment: string, selectedDateFilter: string, searchQuery: String) { - - if(selectedDateFilter == "oldest") { //FILTER BY DATE - sampleProjects.sort((a,b) => a.dateStarted.getTime() - b.dateStarted.getTime()); - } - else { - sampleProjects.sort((a,b) => b.dateStarted.getTime() - a.dateStarted.getTime()); - } - - let filteredProjects = sampleProjects; //FILTER BY DEPARTMENT - if (selectedDepartment !== "all") { - filteredProjects = filteredProjects.filter((project) => project.unitId === selectedDepartment); - } - - if(searchQuery) { //SEARCH - filteredProjects = filteredProjects.filter((project) => - project.name.toLowerCase().indexOf(searchQuery.toLowerCase()) !== -1 - ); - } - - if(gridContainer != null) { //PRINTING TO THE GRID - gridContainer.innerHTML = ''; //CLEAR THE GRID - filteredProjects.forEach((project) => { - const row = createGridRow(project); - if (gridContainer) { - gridContainer.appendChild(row); +function filterProjects(selectedDepartment, selectedDateFilter, searchQuery) { + return __awaiter(this, void 0, void 0, function* () { + let projects = yield getCompletedProjects(); + if (selectedDateFilter == "oldest") { //FILTER BY DATE + projects.sort((a, b) => a.dateStarted.getTime() - b.dateStarted.getTime()); + } + else { + projects.sort((a, b) => b.dateStarted.getTime() - a.dateStarted.getTime()); + } + let filteredProjects = projects; //FILTER BY DEPARTMENT + if (selectedDepartment !== "all") { + filteredProjects = filteredProjects.filter((project) => project.unitId === selectedDepartment); + } + if (searchQuery) { //SEARCH + filteredProjects = filteredProjects.filter((project) => project.name.toLowerCase().indexOf(searchQuery.toLowerCase()) !== -1); + } + const gridContainer = document.getElementById("grid-container"); + if (gridContainer != null) { //PRINTING TO THE GRID + gridContainer.innerHTML = ''; //CLEAR THE GRID + filteredProjects.forEach((project) => __awaiter(this, void 0, void 0, function* () { + const row = createGridRow(project); + if (gridContainer) { + gridContainer.appendChild(yield row); + } + })); } }); } - -} -*/ //EVENT-LISTENERERS /* departmentDropdown.addEventListener("change", () => { @@ -187,7 +108,7 @@ departmentDropdown.addEventListener("change", () => { filterProjects(selectedDepartment, selectedDateFilter, searchQuery); }); - +/* dateDropdown.addEventListener("change", () => { selectedDateFilter = dateDropdown.value; filterProjects(selectedDepartment,selectedDateFilter, searchQuery); @@ -215,8 +136,14 @@ export function loadPage() { // Insert the specific element into the target element container.insertBefore(specificElement, container.firstChild); } - //fillDropdown(); + const dateDropdown = document.getElementById("dateDropdown"); + const searchInput = document.getElementById("searchInput"); + let selectedDepartment = "all"; + let selectedDateFilter = "newest"; + let searchQuery; + fillDropdown(); addGridRows(); + console.log(getCompletedProjects()); }) .catch(error => { console.error('Failed to load the external HTML file:', error); diff --git a/client/KnowledgeBank/knowledgeBank.css b/client/KnowledgeBank/knowledgeBank.css index abfc2c60225585ac95abd7d4c698e8977c4c08f3..50d30f1d9047b416c259461b9b7d526dc6232a56 100644 --- a/client/KnowledgeBank/knowledgeBank.css +++ b/client/KnowledgeBank/knowledgeBank.css @@ -1,88 +1,107 @@ - .container { display: flex; justify-content: center; /* Horizontally center */ - } -.maincontainer p { - flex: 1; - width: 80%; - height: 20%; - margin-right: 5%; - margin-left: 5%; - padding-top: 2%; - font-size: 18px; - font-family: 'Roboto', sans-serif; +.maincontent-header{ + background-color: #f0f0f0; + border: 1px solid #ccc; + border-radius: 8px; } - .top-buttons{ -padding-bottom: 40px; -display: flex; -justify-content: left; -padding-top: 20px; -padding-left: 150px; } .bottom-buttons{ - display: flex; - justify-content: left; - padding-left: 150px; } +.button-kunskapsbanken { + position: relative; + font-size: 1.7vw !important; + font-family: 'Roboto', sans-serif; + font-weight: bold; + text-align: center; + text-shadow: rgba(0, 0, 0, 0.25) 0 3px 8px; + border-radius: 8px; + border-style: none; + height: 13rem; + width: 22rem; + transition: ease .5s; + user-select: none; + overflow: hidden; +} + +.button-kunskapsbanken::before { + content: ""; + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + background: rgba(0, 0, 0, 0.3); + box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5); + border-radius: 8px; + opacity: 0; + transition: opacity 0.3s ease; +} -.button-kunskapsbanken{ - border-radius: 8px; - border-style: none; - box-sizing: border-box; - cursor: pointer; - /* flex-shrink: 0;*/ - font-family: 'Roboto',sans-serif; - font-size: 25px; - font-weight: bold; - height: 13rem; - width: 22rem; - /*padding: 0 1.6rem;*/ - text-align: center; - text-shadow: rgba(0, 0, 0, 0.25) 0 3px 8px; - transition: all .5s; - user-select: none; - -webkit-user-select: none; - touch-action: manipulation; - margin-right: 30px; +/* Add shadow only on small screens */ +@media screen and (max-width: 980px) { + .button-kunskapsbanken:hover::before { + opacity: 1; } - .button-kunskapsbanken:hover{ - height: 15rem; - width: 25rem; + .button-kunskapsbanken{ + margin: 5px; + } + } + +/* Add resizing effect on large screens */ +@media screen and (min-width: 981px) { + .button-kunskapsbanken:hover { + transform: scale(1.1); + } + + .button-kunskapsbanken:hover::before { + opacity: 0.7; + } +} + + #buttons-kunskapsbanken-button1{ background-image: linear-gradient(#c29ffa, #dfcdfa); color:white; } + #buttons-kunskapsbanken-button1:hover{ background-color:#d6a5db; - } + } + #buttons-kunskapsbanken-button2{ background-image: linear-gradient(#6610f2, #9e64fa); color: white; } + #buttons-kunskapsbanken-button2:hover{ background-color:#aa5ac0; } + #buttons-kunskapsbanken-button3{ background-image: linear-gradient(#3d0a91, #653ea4); color:white; } + #buttons-kunskapsbanken-button3:hover{ background-color:#6456c1; ; - } + } + #buttons-kunskapsbanken-button4{ background-image: linear-gradient(#290661, #4b2686); color:white; } + #buttons-kunskapsbanken-button4:hover{ background-color:#5013ca; } diff --git a/client/KnowledgeBank/knowledgeBank.html b/client/KnowledgeBank/knowledgeBank.html index 7421a2d10e3832fde8c1d49da0ce23248b26f006..e73445c5c65cfacb925cbc727bbf1e70c5cae245 100644 --- a/client/KnowledgeBank/knowledgeBank.html +++ b/client/KnowledgeBank/knowledgeBank.html @@ -8,99 +8,66 @@ <link rel="stylesheet" href="knowledgeBank.css"> <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400&display=swap" rel="stylesheet"> <meta charset="UTF-8"> <!-- Does so that å,ä,ö works --> + <link + href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" + rel="stylesheet" + integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" + crossorigin="anonymous" + /> <!-- Bootstrap --> <title>Page with a Navbar and Sidebar</title> </head> <body> - <div class="navbar"> - <img src="images/companyLogo.png" alt="companyLogo"> - <h1><a>Kunskapsbanken</a></h1> - <div class="myProfileTopRight"> - <p><a class ="profileName" href="https://sv.wikipedia.org/wiki/Bill_Gates">Bill fkn Gates</a></p> - <img src="images/testPerson.jpg" class ="profilePicture" alt="testPerson"> + + <div class="main-container"> + + <div class="maincontent-header d-flex m-3 p-3"> + <p> + Välkommen till kunskapsbanken! Här finner du ingående information om hur Nolans förbättringsmodell egentligen går till och andra generella förbättringsmetoder. <br> Du hittar också kontaktinformation till relevanta förbättringsoranisationer samt ett urval av lyckade, avslutade förbättringsarbeten som kan ge inspiration. + </p> </div> - </div> - <div class="container"> - <div class="sidebar"> - - <div class="sidebarTopElements"> - <div class ="sidebarElement"> - <img src="images/lightBulb.png" alt="lightBulb"> - <p><a href="../client/index.html">Förslag</a></p> - </div> - <div class ="sidebarElement"> - <img src="images/lightBulb.png" alt="lightBulb"> - <p><a href="../client/currentProjects.html">Aktiva arbeten</a></p> - </div> - - <div class ="sidebarElement"> - <img src="images/lightBulb.png" alt="lightBulb"> - <p><a href="../client/knowledgeBank.html">Kunskapsbanken</a> </p> + + <div id="kunskapButtonContainer" class="d-flex flex-column justify-content-evenly" style="width: 100%;"> + <div class="top-buttons d-flex p-3 m-2 justify-content-evenly"> + <button + id="buttons-kunskapsbanken-button1" + class="button-kunskapsbanken" role="button" + >Nolans<br>Förbättringsmodell</button> + + <button onclick="redirectToPage('GeneralImprovementsMethods.html')" + id="buttons-kunskapsbanken-button2" + class="button-kunskapsbanken" role="button" + >Generella<br>förbättringsmetoder</button> </div> - - </div> - <div class="sidebarMiddleElements"> - <div class ="sidebarElement"> - <img src="images/lightBulb.png" alt="lightBulb"> - <p><a href="../client/myProfile.html">Min profil</a></p> - </div> - - <div class ="sidebarElement"> - <img src="images/lightBulb.png" alt="lightBulb"> - <p><a href="../client/settings.html">Inställningar</a> </p> - </div> - - </div> + <div class="bottom-buttons d-flex m-2 p-3 justify-content-evenly"> + <button onclick="redirectToPage('completedProjects.html')" id="buttons-kunskapsbanken-button3" + class="button-kunskapsbanken" role="button" + >Inspiration:<br>avslutade förbättringarbeten</button> - <div class="sidebarBottomElements"> - <div class ="sidebarElement"> - <img src="images/lightBulb.png" alt="lightBulb"> - <p><a href="../client/faq.html">FAQ & Support</a></p> + <button onclick="redirectToPage('ContactOrganizations.html')" + id="buttons-kunskapsbanken-button4" + class="button-kunskapsbanken" role="button" + >Konktakinformation<br>förbättringsorganisationer</button> </div> - </div> - </div> - - <div class="main-container"> - - <div class="maincontent-header"><p>Välkommen till kunskapsbanken! Här finner du ingående information om hur Nolans förbättringsmodell egentligen går till och andra generella förbättringsmetoder. Du hittar också kontaktinformation till relevanta förbättringsoranisationer samt ett urval av lyckade, avslutade förbättringsarbeten som kan ge inspiration. - </p></div> - - <div class=top-buttons> - <button - id="buttons-kunskapsbanken-button1" - class="button-kunskapsbanken" role="button" - >Nolans Förbättringsmodell</button> - - <button onclick="redirectToPage('GeneralImprovementsMethods.html')" - id="buttons-kunskapsbanken-button2" - class="button-kunskapsbanken" role="button" - >Generella förbättringsmetoder</button> - </div> - - <div class=bottom-buttons> - <button onclick="redirectToPage('completedProjects.html')" id="buttons-kunskapsbanken-button3" - class="button-kunskapsbanken" role="button" - >Inspriation: avslutade förbättringarbeten</button> - - <button onclick="redirectToPage('ContactOrganizations.html')" - id="buttons-kunskapsbanken-button4" - class="button-kunskapsbanken" role="button" - >Konktakinformation förbättringsorganisationer</button> - </div> <script type = "module" src="../SidebarAndHeader/pageHandler.js"></script> </div> </div> - <script> - function redirectToPage(page) { - window.location.href = page; - } - </script> - - - - <script type = "module" src="SidebarAndHeader/pageHandler.js"></script> + + <!-- Bootstrap script --> + <script + src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" + integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" + crossorigin="anonymous" + ></script> + <script> + function redirectToPage(page) { + window.location.href = page; + } + </script> + + <script type = "module" src="SidebarAndHeader/pageHandler.js"></script> </body> </html> diff --git a/client/Make_Suggestion_Code/makeSuggestion.css b/client/Make_Suggestion_Code/makeSuggestion.css index a56bfacec6c41dc877d7f04384f459bda08314f2..f7a81cfbe4d785209f599788cb9987d453dc6116 100644 --- a/client/Make_Suggestion_Code/makeSuggestion.css +++ b/client/Make_Suggestion_Code/makeSuggestion.css @@ -1,29 +1,31 @@ -/* .filterFont { + /* + .filterFont { font-family: "Roboto", sans-serif; margin-left: 5%; -} */ + } +*/ .makeSuggestionFilterButtons { margin-left: 5%; margin-bottom: 1%; + margin-top: 1%; + } .filterButtons { - background-image: linear-gradient( - to right, - rgb(201, 164, 213), - rgb(162, 88, 202) - ); + background-image: linear-gradient(to right, #845380, #303866); + border: none; padding: 8px; color: #fffafa; font-weight: 1700; border-radius: 8px; - margin-right: 3%; - width: 12%; + margin-right: 2%; + width: 13%; font-family: "Roboto", sans-serif; font-weight: 400; font-size: medium; - text-align: center; + text-align: left; + text-overflow: ellipsis; } #middleFilterButtonLabel { @@ -56,7 +58,7 @@ width: 78%; margin-top: 1%; margin-left: 5%; - border: 1px solid rgb(246, 144, 255); + border: none; border-radius: 5px; align-items: right; } @@ -79,11 +81,8 @@ } #suggestionButton { - background-image: linear-gradient( - to right, - rgb(201, 164, 213), - rgb(162, 88, 202) - ); + background-image: linear-gradient(to right, #845380, #303866); + border: none; padding: 6px; color: #fffafa; font-weight: 1700; diff --git a/client/Make_Suggestion_Code/makeSuggestion.html b/client/Make_Suggestion_Code/makeSuggestion.html index 920490bf45839cd9a48a731c48c1f09106c215ee..3a1720f21ef2d648b685f364a7c4f8c76219ccf2 100644 --- a/client/Make_Suggestion_Code/makeSuggestion.html +++ b/client/Make_Suggestion_Code/makeSuggestion.html @@ -22,15 +22,13 @@ <div id="suggestionPage"> <div class="filter-section"> - <!-- <p class="filterFont" id="filter-font"> - Fyll i vårdinstans och avdelning som förslaget gäller - </p> --> + <div class="makeSuggestionFilterButtons"> <select name="department" id="selectHospital" class="filterButtons" - > + > <option class ="ideaCardFont" value="" disabled selected>Välj arbetsplats</option> <!-- Options will be added dynamically here --> </select> @@ -41,6 +39,7 @@ <select name="section" id="selectDepartment" class="filterButtons"> <!-- Options will be added dynamically here --> + <option class ="ideaCardFont" value="" disabled selected>Välj avdelning</option> </select> <!-- <select class="filter" id="departmentDropdown"> <option value="all">Avdelningar</option> --> diff --git a/client/Make_Suggestion_Code/makeSuggestion.js b/client/Make_Suggestion_Code/makeSuggestion.js index fef9e5d8d0539810c5b0e22b1987b2bbf0a73d17..ed7dbd23c1e76a6d75f43c4ae1930f4b1a977e39 100644 --- a/client/Make_Suggestion_Code/makeSuggestion.js +++ b/client/Make_Suggestion_Code/makeSuggestion.js @@ -8,7 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; -import { createSuggestion, getObject, getHospitals, getUnits } from "../Database/database.js"; +import { createSuggestion, getObject, getHospitals, getUnits, getUsers } from "../Database/database.js"; function loadFilter() { return __awaiter(this, void 0, void 0, function* () { const selectHospitalHTML = $('#selectHospital'); // loads the select type from html @@ -45,57 +45,73 @@ function populateOptions(object, selectElement) { } // Define the submitHandler function export function submitHandler() { - const selectDepartment = document.getElementById("selectHospital"); - const selectUnit = document.getElementById("selectDepartment"); - //populateOptions("hospital", selectDepartment); - //populateOptions("unit", selectUnit); - // JavaScript to get the inputted text when the form is submitted - const inputBoxFormNameInput = document.getElementById("inputBoxFormNameInput"); - const inputBoxFormName = document.getElementById("inputBoxFormName"); - const inputBoxFormAreaInput = document.getElementById("inputBoxFormAreaInput"); - const inputBoxFormArea = document.getElementById("inputBoxFormArea"); - const inputBoxFormContentInput = document.getElementById("inputBoxFormContentInput"); - const inputBoxFormContent = document.getElementById("inputBoxFormContent"); - const inputBoxFormPurposeInput = document.getElementById("inputBoxFormPurposeInput"); - const inputBoxFormPurpose = document.getElementById("inputBoxFormPurpose"); - const inputBoxFormMeasureInput = document.getElementById("inputBoxFormMeasureInput"); - const inputBoxFormMeasure = document.getElementById("inputBoxFormMeasure"); - const inputBoxFormIdeasInput = document.getElementById("inputBoxFormIdeasInput"); - const inputBoxFormIdeas = document.getElementById("inputBoxFormIdeas"); - const submitButton = document.getElementById("suggestionButton"); - inputBoxFormName.addEventListener("submit", (e) => { - e.preventDefault(); - }); - inputBoxFormArea.addEventListener("submit", (e) => { - e.preventDefault(); - }); - inputBoxFormContent.addEventListener("submit", (e) => { - e.preventDefault(); - }); - inputBoxFormPurpose.addEventListener("submit", (e) => { - e.preventDefault(); - }); - inputBoxFormMeasure.addEventListener("submit", (e) => { - e.preventDefault(); - }); - inputBoxFormIdeas.addEventListener("submit", (e) => { - e.preventDefault(); + return __awaiter(this, void 0, void 0, function* () { + const selectDepartment = document.getElementById("selectHospital"); + const selectUnit = document.getElementById("selectDepartment"); + //populateOptions("hospital", selectDepartment); + //populateOptions("unit", selectUnit); + // JavaScript to get the inputted text when the form is submitted + const inputBoxFormNameInput = document.getElementById("inputBoxFormNameInput"); + const inputBoxFormName = document.getElementById("inputBoxFormName"); + const inputBoxFormAreaInput = document.getElementById("inputBoxFormAreaInput"); + const inputBoxFormArea = document.getElementById("inputBoxFormArea"); + const inputBoxFormContentInput = document.getElementById("inputBoxFormContentInput"); + const inputBoxFormContent = document.getElementById("inputBoxFormContent"); + const inputBoxFormPurposeInput = document.getElementById("inputBoxFormPurposeInput"); + const inputBoxFormPurpose = document.getElementById("inputBoxFormPurpose"); + const inputBoxFormMeasureInput = document.getElementById("inputBoxFormMeasureInput"); + const inputBoxFormMeasure = document.getElementById("inputBoxFormMeasure"); + const inputBoxFormIdeasInput = document.getElementById("inputBoxFormIdeasInput"); + const inputBoxFormIdeas = document.getElementById("inputBoxFormIdeas"); + const submitButton = document.getElementById("suggestionButton"); + inputBoxFormName.addEventListener("submit", (e) => { + e.preventDefault(); + }); + inputBoxFormArea.addEventListener("submit", (e) => { + e.preventDefault(); + }); + inputBoxFormContent.addEventListener("submit", (e) => { + e.preventDefault(); + }); + inputBoxFormPurpose.addEventListener("submit", (e) => { + e.preventDefault(); + }); + inputBoxFormMeasure.addEventListener("submit", (e) => { + e.preventDefault(); + }); + inputBoxFormIdeas.addEventListener("submit", (e) => { + e.preventDefault(); + }); + // Get values from each form and do something with them + var nameInput = inputBoxFormNameInput.value; + var areaInput = inputBoxFormAreaInput.value; + var contentInput = inputBoxFormContentInput.value; + var purposeInput = inputBoxFormPurposeInput.value; + var measureInput = inputBoxFormMeasureInput.value; + var ideasInput = inputBoxFormIdeasInput.value; + var tmp = localStorage.getItem('user'); + if (!tmp) { + console.log("there is not an user in localStorage"); + return; + } + var uid = JSON.parse(tmp)[0].uid; + var user = yield getUsers({ uid: uid }); + console.log(user); + console.log(user[0].uid); + console.log(user[0].id); + console.log(user[0].creatorHsaId); + try { + if (user[0].id) { + createSuggestion(null, user[0].id, //The unique identifyer for the user, not the idea + nameInput, areaInput, contentInput, purposeInput, measureInput, ideasInput, selectUnit.value, selectDepartment.value, true); + } + // Call the createSuggestion function with the obtained values + alert("created successfully"); + } + catch (_a) { + alert("Error creating"); + } }); - // Get values from each form and do something with them - var nameInput = inputBoxFormNameInput.value; - var areaInput = inputBoxFormAreaInput.value; - var contentInput = inputBoxFormContentInput.value; - var purposeInput = inputBoxFormPurposeInput.value; - var measureInput = inputBoxFormMeasureInput.value; - var ideasInput = inputBoxFormIdeasInput.value; - try { - // Call the createSuggestion function with the obtained values - createSuggestion("<Header>", "<Department>", nameInput, areaInput, contentInput, purposeInput, measureInput, ideasInput, selectUnit.value, selectDepartment.value, true); - alert("created successfully"); - } - catch (_a) { - alert("Error creating"); - } } export function loadPage() { const container = document.querySelector('#container-fluid'); diff --git a/client/Make_Suggestion_Code/makeSuggestion.ts b/client/Make_Suggestion_Code/makeSuggestion.ts index cc0aeae4c9008e2d396ac5dc805d97db049db92a..aa2a54d986819ee30475efa3e63bfd74b06e676e 100644 --- a/client/Make_Suggestion_Code/makeSuggestion.ts +++ b/client/Make_Suggestion_Code/makeSuggestion.ts @@ -135,13 +135,14 @@ export async function submitHandler() { var user = await getUsers({uid : uid}); console.log(user); console.log(user[0].uid); + console.log(user[0].id); console.log(user[0].creatorHsaId); try { - if (user[0].uid) { + if (user[0].id) { createSuggestion( - user[0].uid, - "<Department>", + null, + user[0].id, //The unique identifyer for the user, not the idea nameInput, areaInput, contentInput, diff --git a/client/SidebarAndHeader/pageHandler.js b/client/SidebarAndHeader/pageHandler.js index b4282902fe9e44fbf1276f960c5aab0ee53cf6cd..ba21e584ba705a461192f62de32cdaee18d366b6 100644 --- a/client/SidebarAndHeader/pageHandler.js +++ b/client/SidebarAndHeader/pageHandler.js @@ -150,7 +150,7 @@ function loadIdeaBank() { const target = event.target; //adds an event listener for the initiate page if (target && target.className === "initiateProjectButton") { - const cardId = "suggestion" + target.id.replace("initiateProjectFromCard", ""); + const cardId = target.id.replace("initiateProjectFromCard", ""); loadInitiatePage(cardId); } }); diff --git a/client/SidebarAndHeader/pageHandler.ts b/client/SidebarAndHeader/pageHandler.ts index 607abd730221f5bdac46968f097a5d54b674b9a3..44de7ee75fade481dc0ead206c3fa299e1d2a7fe 100644 --- a/client/SidebarAndHeader/pageHandler.ts +++ b/client/SidebarAndHeader/pageHandler.ts @@ -166,7 +166,7 @@ function loadIdeaBank() { const target = event.target as HTMLElement; //adds an event listener for the initiate page if (target && target.className === "initiateProjectButton") { - const cardId = "suggestion" + target.id.replace("initiateProjectFromCard", ""); + const cardId = target.id.replace("initiateProjectFromCard", ""); loadInitiatePage(cardId); } }); diff --git a/client/currentProjects/currentProjects.css b/client/currentProjects/currentProjects.css index 803a1202507379c3fe3facecf26ff019ac27a322..08136ba9efdfc71f516fb3020f3c22359f548984 100644 --- a/client/currentProjects/currentProjects.css +++ b/client/currentProjects/currentProjects.css @@ -208,6 +208,14 @@ a { .container-fluid{ padding-left: 0%; } +.statusText { + font-weight: bold; + text-align: center; + font-family: 'Gill Sans MT'; + font-size: 24px; + color: rgb(111, 111, 111); + margin-left: 15%; +} .projectButton { background: linear-gradient(to right,rgba(220, 144, 215, 0.3), rgba(234, 103, 225, 0)); border: none; diff --git a/client/currentProjects/currentProjects.js b/client/currentProjects/currentProjects.js index 0b1474da2750d9324c7eff4f84c882eb9a47bef8..047b1a0d44a847a0cbefad7d04e48536ba2e5a59 100644 --- a/client/currentProjects/currentProjects.js +++ b/client/currentProjects/currentProjects.js @@ -9,16 +9,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }); }; import { getImprovementWorks, getObjectById } from "../Database/database.js"; -import { loadProjectPageP } from "../SidebarAndHeader/pageHandler.js"; +import { loadProjectPageP, loadProjectPageA, loadProjectPageG, loadProjectPageS } from "../SidebarAndHeader/pageHandler.js"; let projectCards = {}; class projectCard { - constructor(id, name, department, title, description, projectId) { + constructor(id, name, department, title, description, projectId, currentStage) { this.name = name; this.department = department; this.title = title; this.description = description; this.id = id; this.projectId = projectId; + this.stage = currentStage; } showMoreInfo(blockId, thisTextId) { const blockElement = document.getElementById(blockId); @@ -45,7 +46,7 @@ class projectCard { } generateHTML() { return `<div class="totalExpandedOngoingWorkCard"> - <div class="flex-container ongoingCard" id="${this.projectId}"> + <div style="cursor: pointer;" class="flex-container ongoingCard" id="${this.projectId}"> <div class="ongoingCardImageContainer toSinglePage"> <div class = "flex-box ongoingCardImage toSinglePage" id="pinkFaded"></div> </div> @@ -57,10 +58,12 @@ class projectCard { <button data-project-id="${this.id}" class="projectButton" role="button">Gå till projektsidan</button> - + <div class="statusText"> + Status: ${this.stage} + </div> <div class="container ongoingSeeCardDetails toSinglePage"> <div class="ongoingSeeCardDetailsInner"> - <p id="ongoingSeeDetailsButton${this.id}" class = "moreInfoClass">> Mer information</p> + <p id="ongoingSeeDetailsButton${this.projectId}" class = "moreInfoClass">> Mer information</p> </div> </div> </div> @@ -109,7 +112,7 @@ function getProjects(selectElement, listenersLoaded) { let name = "Projektledare"; //Waiting for backend fix let description = project.content; let i = id; - let card = new projectCard(i, name, department.name, title, description, project.id); + let card = new projectCard(i, name, department.name, title, description, project.id, project.currentStage); projectCards[i] = card; let cardHTML = card.generateHTML(); addEventListener(listenersLoaded, project.id, card); @@ -140,8 +143,23 @@ function addEventListener(listenersLoaded, projectId, card) { card.closeMoreInfo(`expandedOngoingWorkCard` + projectId, `ongoingSeeDetailsButton` + projectId); } } - else { - loadProjectPageP(projectId); + else if (element.classList.contains('projectButton')) { + const currentStage = card.stage; + if (currentStage === 'Agera') { + loadProjectPageA(projectId); + } + else if (currentStage === 'Studera') { + loadProjectPageS(projectId); + } + else if (currentStage === 'Göra') { + loadProjectPageG(projectId); + } + else if (currentStage === 'Planera') { + loadProjectPageP(projectId); + } + else if (currentStage === 'Avslutat') { + loadProjectPageP(projectId); + } } }); } diff --git a/client/currentProjects/currentProjects.ts b/client/currentProjects/currentProjects.ts index 38bda39102ba48f415d05a176d93837d7bf2ace1..725d4b89f8664ce99b475df70a73af6b0e6e4b12 100644 --- a/client/currentProjects/currentProjects.ts +++ b/client/currentProjects/currentProjects.ts @@ -1,6 +1,6 @@ "use strict"; import { getImprovementWorks, getObject, getObjectById } from "../Database/database.js"; -import { loadProjectPageP, loadProjectPageA } from "../SidebarAndHeader/pageHandler.js"; +import { loadProjectPageP, loadProjectPageA, loadProjectPageG, loadProjectPageS } from "../SidebarAndHeader/pageHandler.js"; import * as projectPage from "../projectPage/projectPage.js"; @@ -13,16 +13,19 @@ class projectCard { private description: string; private id: number; private projectId: string; + public stage: any; - constructor(id: number, name: string, department: string, title: string, description: string, projectId: string) { + constructor(id: number, name: string, department: string, title: string, description: string, projectId: string, currentStage : string) { this.name = name; this.department = department; this.title = title; this.description = description; this.id = id; this.projectId = projectId; + this.stage = currentStage; } + showMoreInfo(blockId: string, thisTextId: string): void { const blockElement = document.getElementById(blockId); if (blockElement) { @@ -45,7 +48,7 @@ class projectCard { textElement.innerText = '> Mer information'; } } - + loadInitiatePage() { alert('The initiate project page should now be loaded'); } @@ -64,9 +67,11 @@ class projectCard { <p class="toSinglePage" id="ongoingCardIdeaTitle">${this.title}</p> </div> - <!--<button data-project-id="${this.id}" class="projectButton" role="button">Gå till projektsidan</button>--> - + <button data-project-id="${this.id}" class="projectButton" role="button">Gå till projektsidan</button> + <div class="statusText"> + Status: ${this.stage} + </div> <div class="container ongoingSeeCardDetails toSinglePage"> <div class="ongoingSeeCardDetailsInner"> <p id="ongoingSeeDetailsButton${this.projectId}" class = "moreInfoClass">> Mer information</p> @@ -122,7 +127,7 @@ async function getProjects (selectElement : Element, listenersLoaded:boolean) { let name = "Projektledare"; //Waiting for backend fix let description = project.content; let i = id; - let card = new projectCard(i, name, department.name, title, description, project.id); + let card = new projectCard(i, name, department.name, title, description, project.id, project.currentStage); projectCards[i] = card; let cardHTML = card.generateHTML(); addEventListener(listenersLoaded, project.id, card); @@ -149,9 +154,20 @@ function addEventListener(listenersLoaded:boolean, projectId:string, card:projec } else { card.closeMoreInfo(`expandedOngoingWorkCard`+projectId, `ongoingSeeDetailsButton`+projectId); } - } else { - loadProjectPageP(projectId); - } - }); + } else if (element.classList.contains('projectButton')){ + const currentStage = card.stage; + if (currentStage === 'Agera') { + loadProjectPageA(projectId); + } else if (currentStage === 'Studera') { + loadProjectPageS(projectId); + } else if (currentStage === 'Göra') { + loadProjectPageG(projectId); + } else if(currentStage === 'Planera') { + loadProjectPageP(projectId); + } else if(currentStage === 'Avslutat') { + loadProjectPageP(projectId); + } + } } +)} } \ No newline at end of file diff --git a/client/dist/completedProjects.bundle.js b/client/dist/completedProjects.bundle.js index bc91064658db56a7e2b38ce1918c6253421054b1..24f9c06a1d5f9b2739cb7ad0b68f17d44d25b97f 100644 --- a/client/dist/completedProjects.bundle.js +++ b/client/dist/completedProjects.bundle.js @@ -96,7 +96,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \*************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addDocumentToImprovementWork: () => (/* binding */ addDocumentToImprovementWork),\n/* harmony export */ addMemberToImprovementWork: () => (/* binding */ addMemberToImprovementWork),\n/* harmony export */ addMemberToTask: () => (/* binding */ addMemberToTask),\n/* harmony export */ addNoteToUser: () => (/* binding */ addNoteToUser),\n/* harmony export */ auth: () => (/* binding */ auth),\n/* harmony export */ changePatientRiskLevel: () => (/* binding */ changePatientRiskLevel),\n/* harmony export */ createComment: () => (/* binding */ createComment),\n/* harmony export */ createHospital: () => (/* binding */ createHospital),\n/* harmony export */ createImprovementWork: () => (/* binding */ createImprovementWork),\n/* harmony export */ createSuggestion: () => (/* binding */ createSuggestion),\n/* harmony export */ createTaskOnImprovementWork: () => (/* binding */ createTaskOnImprovementWork),\n/* harmony export */ createUnit: () => (/* binding */ createUnit),\n/* harmony export */ createUser: () => (/* binding */ createUser),\n/* harmony export */ createdDocumentInKnowledgeBank: () => (/* binding */ createdDocumentInKnowledgeBank),\n/* harmony export */ db: () => (/* binding */ db),\n/* harmony export */ deleteAllDocumentsInCollection: () => (/* binding */ deleteAllDocumentsInCollection),\n/* harmony export */ deleteInstance: () => (/* binding */ deleteInstance),\n/* harmony export */ finalizeImprovementWork: () => (/* binding */ finalizeImprovementWork),\n/* harmony export */ getComments: () => (/* binding */ getComments),\n/* harmony export */ getHospitals: () => (/* binding */ getHospitals),\n/* harmony export */ getImprovementWorks: () => (/* binding */ getImprovementWorks),\n/* harmony export */ getObject: () => (/* binding */ getObject),\n/* harmony export */ getObjectById: () => (/* binding */ getObjectById),\n/* harmony export */ getSuggestions: () => (/* binding */ getSuggestions),\n/* harmony export */ getTasks: () => (/* binding */ getTasks),\n/* harmony export */ getUnits: () => (/* binding */ getUnits),\n/* harmony export */ getUsers: () => (/* binding */ getUsers),\n/* harmony export */ startOrPauseImprovementWork: () => (/* binding */ startOrPauseImprovementWork),\n/* harmony export */ updateInstance: () => (/* binding */ updateInstance),\n/* harmony export */ upvoteComment: () => (/* binding */ upvoteComment),\n/* harmony export */ upvoteSuggestion: () => (/* binding */ upvoteSuggestion)\n/* harmony export */ });\n/* harmony import */ var firebase_app__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! firebase/app */ \"./node_modules/firebase/app/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_firestore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! firebase/firestore */ \"./node_modules/firebase/firestore/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_auth__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! firebase/auth */ \"./node_modules/firebase/auth/dist/esm/index.esm.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nvar firebaseConfig = {\n apiKey: \"AIzaSyDqkaVZMr11J4mfnR0auqoQilZyPfyD-x4\",\n authDomain: \"c3solutions-dc109.firebaseapp.com\",\n projectId: \"c3solutions-dc109\",\n storageBucket: \"c3solutions-dc109.appspot.com\",\n messagingSenderId: \"902143402555\",\n appId: \"1:902143402555:web:29213e81de0a0cba38b21e\"\n};\nvar app = (0,firebase_app__WEBPACK_IMPORTED_MODULE_0__.initializeApp)(firebaseConfig);\nvar auth = (0,firebase_auth__WEBPACK_IMPORTED_MODULE_2__.getAuth)();\nvar db = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getFirestore)(app);\nvar userCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\nvar unitCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\nvar improvementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\nvar taskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\nvar hospitalCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\nvar suggestionCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\nvar knowledgeDocumentCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"knowledgeDocument\");\n////////////////////////////////////////Setters///////////////////////////////////////////////////////////////////\n// Function to create user a new user in database\n// takes in userId, unitId, firstname, lastname, email and password as string\n// throws error if transaction failed\nfunction createUser(hsaId, unitId, firstName, lastName, email, manager, uid) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var userRef, unitRef;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, hsaId);\n _context.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(userRef, {\n id: userRef.id,\n uid: uid,\n unitId: unitId,\n firstName: firstName,\n lastName: lastName,\n email: email,\n improvementWorks: [],\n tasks: [],\n manager: manager\n });\n case 4:\n // Atomically add user to unit.\n unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection, unitId);\n _context.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(unitRef, {\n members: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userRef.id)\n });\n case 7:\n _context.next = 12;\n break;\n case 9:\n _context.prev = 9;\n _context.t0 = _context[\"catch\"](0);\n console.log(_context.t0);\n case 12:\n case \"end\":\n return _context.stop();\n }\n }, _callee, null, [[0, 9]]);\n }));\n}\n//Adds a new improvementWork to the database\n// takes in Id, name, currentStage in PDSA, content, unitId refers to as string and if completed as boolean\n// throws error if transaction failed\nfunction createImprovementWork(id, name, currentStage, content,\n// Är detta description bör detta förtydligas. \nunitId, purpose,\n//Bör tas bort motsvaras av p2- mål med projektet\npatientRiskLevel, area,\n// patientRiskLevel: \"Green\" | \"Blue\" | \"Orange\" | \"Red\"\n//Questions in planning stage\np1, p2, p3, p4, p5, p6, p7,\n//Questions in Doing (G) stage\ng1, g2, g3, g4, g5,\n//Questions in stydy stage\ns1, s2, s3,\n//Questions in acting stage\na1, a2, a3, a4) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var improvementWorkRef;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.prev = 0;\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, id);\n _context2.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(improvementWorkRef, {\n id: improvementWorkRef.id,\n currentStage: currentStage,\n name: name,\n content: content,\n purpose: purpose,\n dateStarted: new Date(),\n unitId: unitId,\n completed: false,\n ongoing: false,\n tasks: [],\n members: [],\n patientRiskLevel: patientRiskLevel,\n area: area,\n p1: p1,\n p2: p2,\n p3: p3,\n p4: p4,\n p5: p5,\n p6: p6,\n p7: p7,\n g1: g1,\n g2: g2,\n g3: g3,\n g4: g4,\n g5: g5,\n s1: s1,\n s2: s2,\n s3: s3,\n a1: a1,\n a2: a2,\n a3: a3,\n a4: a4\n });\n case 4:\n _context2.next = 10;\n break;\n case 6:\n _context2.prev = 6;\n _context2.t0 = _context2[\"catch\"](0);\n console.log(\"Error creating improvementWork: \", _context2.t0);\n throw _context2.t0;\n case 10:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, null, [[0, 6]]);\n }));\n}\n//create task to improvementWork\n// takes in improvementWorkId, name, deadline date, start date, stage in PDSA and content as string\n// throws error if transaction failed\nfunction createTaskOnImprovementWork(taskId, improvementWorkId, name, deadlineDate, startDate, stage, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var ref, improvementWorkRef;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.prev = 0;\n ref = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection, taskId);\n _context3.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(ref, {\n id: ref.id,\n improvementWorkId: improvementWorkId,\n name: name,\n deadlineDate: deadlineDate,\n startDate: startDate,\n stage: stage,\n content: content,\n members: []\n });\n case 4:\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, improvementWorkId); // Atomically add task to the tasks array field.\n _context3.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(improvementWorkRef, {\n tasks: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(taskId)\n });\n case 7:\n _context3.next = 13;\n break;\n case 9:\n _context3.prev = 9;\n _context3.t0 = _context3[\"catch\"](0);\n console.log(\"Error creating task: \", _context3.t0);\n throw _context3.t0;\n case 13:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, null, [[0, 9]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction createdDocumentInKnowledgeBank(documentUrl, name) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n _context4.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(knowledgeDocumentCollection);\n _context4.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n name: name\n });\n case 4:\n _context4.next = 10;\n break;\n case 6:\n _context4.prev = 6;\n _context4.t0 = _context4[\"catch\"](0);\n console.log(\"Error adding document: \", _context4.t0);\n throw _context4.t0;\n case 10:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4, null, [[0, 6]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction addDocumentToImprovementWork(documentUrl, name, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var improvementWorkRef, docRef;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n _context5.prev = 0;\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, improvementWorkId);\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkRef, \"documents\");\n _context5.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n timestamp: new Date(),\n name: name\n });\n case 5:\n _context5.next = 11;\n break;\n case 7:\n _context5.prev = 7;\n _context5.t0 = _context5[\"catch\"](0);\n console.log(\"Error adding document: \", _context5.t0);\n throw _context5.t0;\n case 11:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5, null, [[0, 7]]);\n }));\n}\n//add a member to a improvementWork\n// takes in id, users HSAid, improvementWorks id as string and if is owner, is responsible as boolean\n// throws error if transaction failed\nfunction addMemberToImprovementWork(userHsaId, improvementWorkId, isOwner, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var improvementWorkRef, userRef;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n _context6.prev = 0;\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, improvementWorkId); // return;\n // Atomically update the members array in the improvementWork document\n _context6.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(improvementWorkRef, {\n members: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)({\n userHsaId: userHsaId,\n isOwner: isOwner,\n isResponsibleFor: isResponsibleFor\n })\n });\n case 4:\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, userHsaId); // Atomically add improvementWork to user\n _context6.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(userRef, {\n improvementWorks: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)({\n improvementWorkId: improvementWorkId,\n isOwner: isOwner,\n isResponsibleFor: isResponsibleFor\n })\n });\n case 7:\n _context6.next = 13;\n break;\n case 9:\n _context6.prev = 9;\n _context6.t0 = _context6[\"catch\"](0);\n console.log(\"Error adding member: \", _context6.t0);\n throw _context6.t0;\n case 13:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6, null, [[0, 9]]);\n }));\n}\n//create a hospital\n// takes in ID, name as string\n// throws error if transaction failed\nfunction createHospital(hospitalId,\n// should be auto?\nname) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var ref;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.prev = 0;\n ref = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection, hospitalId);\n _context7.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(ref, {\n id: ref.id,\n name: name,\n units: []\n });\n case 4:\n _context7.next = 10;\n break;\n case 6:\n _context7.prev = 6;\n _context7.t0 = _context7[\"catch\"](0);\n console.log(\"Error creating hospital: \", _context7.t0);\n throw _context7.t0;\n case 10:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7, null, [[0, 6]]);\n }));\n}\n//create a unit\n// takes in id, hospitals id and name as string\n// throws error if transaction failed\nfunction createUnit(unitId,\n//should be auto?\nhospitalId, name) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var unitRef, hospitalRef;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n _context8.prev = 0;\n unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection, unitId);\n _context8.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(unitRef, {\n id: unitRef.id,\n hospitalId: hospitalId,\n name: name,\n members: []\n });\n case 4:\n // Atomically add unit to hospital.\n hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection, hospitalId);\n _context8.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(hospitalRef, {\n units: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(unitRef.id)\n });\n case 7:\n _context8.next = 13;\n break;\n case 9:\n _context8.prev = 9;\n _context8.t0 = _context8[\"catch\"](0);\n console.log(\"Error creating unit: \", _context8.t0);\n throw _context8.t0;\n case 13:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8, null, [[0, 9]]);\n }));\n}\n//adds a member to task\n// takes in ID, the added members hsaId, task id as string and if person is responsible as boolean\n// throws error if transaction failed\nfunction addMemberToTask(userHsaId, taskId, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var taskRef, userRef;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n _context9.prev = 0;\n // Atomically add a member to task.\n taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection, taskId);\n _context9.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(taskRef, {\n members: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)({\n userHsaId: userHsaId,\n isResponsibleFor: isResponsibleFor\n })\n });\n case 4:\n // Atomically add a task to user.\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, userHsaId);\n _context9.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(userRef, {\n tasks: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)({\n taskId: taskId,\n isResponsibleFor: isResponsibleFor\n })\n });\n case 7:\n _context9.next = 13;\n break;\n case 9:\n _context9.prev = 9;\n _context9.t0 = _context9[\"catch\"](0);\n console.log(\"Error adding member: \", _context9.t0);\n throw _context9.t0;\n case 13:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9, null, [[0, 9]]);\n }));\n}\n//creates a suggestion\n// takes in ID, the creators hsaId, name, content and the responding unitId as string\n// throws error if transaction failed\nfunction createSuggestion(id, creatorHsaId, name, area, content, purpose, measure, ideas,\n//need: boolean,\nunitId, departmentId, isPublic) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var suggestionRef, commentCollection;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n _context10.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, id);\n _context10.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(suggestionRef, {\n id: suggestionRef.id,\n creatorHsaId: creatorHsaId,\n name: name,\n area: area,\n content: content,\n purpose: purpose,\n measure: measure,\n ideas: ideas,\n //need: need,\n unitId: unitId,\n departmentId: departmentId,\n \"public\": isPublic,\n upvotes: [],\n comments: [],\n dateCreated: new Date()\n });\n case 4:\n _context10.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\");\n case 6:\n commentCollection = _context10.sent;\n _context10.next = 9;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(commentCollection);\n case 9:\n _context10.next = 15;\n break;\n case 11:\n _context10.prev = 11;\n _context10.t0 = _context10[\"catch\"](0);\n console.log(\"Error creating suggestion: \", _context10.t0);\n throw _context10.t0;\n case 15:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10, null, [[0, 11]]);\n }));\n}\n// Upvote a suggestion for a user\n// takes in suggestion id, user HSAid\n// returns error if transaction failed\nfunction upvoteSuggestion(suggestionId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var suggestionRef;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n _context11.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId); // Atomically add a update to the upvote array field.\n _context11.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(suggestionRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 4:\n _context11.next = 10;\n break;\n case 6:\n _context11.prev = 6;\n _context11.t0 = _context11[\"catch\"](0);\n console.log(\"Error upvoting suggestion: \", _context11.t0);\n throw _context11.t0;\n case 10:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11, null, [[0, 6]]);\n }));\n}\n//creates a comment\n// takes in commenters id, suggestion id and content as string\n// throws error if transaction failed\nfunction createComment(\n// change to subcollection\ncommenterHsaId, suggestionId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var suggestionRef, commentCollection, commentRef;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n _context12.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context12.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\");\n case 4:\n commentCollection = _context12.sent;\n _context12.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(commentCollection);\n case 7:\n commentRef = _context12.sent;\n _context12.next = 10;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(commentRef, {\n id: commentRef.id,\n commenterHsaId: commenterHsaId,\n content: content,\n dateCreated: new Date(),\n upvotes: []\n });\n case 10:\n _context12.next = 16;\n break;\n case 12:\n _context12.prev = 12;\n _context12.t0 = _context12[\"catch\"](0);\n console.log(\"Error creating comment: \", _context12.t0);\n throw _context12.t0;\n case 16:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12, null, [[0, 12]]);\n }));\n}\n// Upvote a comment for a user\n// takes in suggestionId, commentId and userId as strings\n// return error if transaction failed\nfunction upvoteComment(suggestionId, commentId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var suggestionRef, commentRef;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n _context13.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n commentRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionRef, \"comment\", commentId); // Atomically add a update to the upvote array field.\n _context13.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(commentRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 5:\n _context13.next = 11;\n break;\n case 7:\n _context13.prev = 7;\n _context13.t0 = _context13[\"catch\"](0);\n console.log(\"Error upvoting comment: \", _context13.t0);\n throw _context13.t0;\n case 11:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13, null, [[0, 7]]);\n }));\n}\n//add a note to a user\n// takes in userHsaId and content as string\n// throws error if transaction failed\nfunction addNoteToUser(userHsaId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var userRef, docRef;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n _context14.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, userHsaId);\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userRef, \"notes\");\n _context14.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n content: content,\n dateCreated: new Date()\n });\n case 5:\n _context14.next = 11;\n break;\n case 7:\n _context14.prev = 7;\n _context14.t0 = _context14[\"catch\"](0);\n console.log(\"Error adding document: \", _context14.t0);\n throw _context14.t0;\n case 11:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14, null, [[0, 7]]);\n }));\n}\n// export to setters to be able to use in other files\n\n//////////////////////////////////////////////GETTERS/////////////////////////////////////////////////////////////////////\n// Get any object\n// input is the database type as a string.\n// output is the whole collection of that type.\nfunction getObject(collectionPath) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n var collectionRef, querySnapshot, result;\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n _context15.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionPath);\n _context15.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n querySnapshot = _context15.sent;\n result = [];\n querySnapshot.forEach(function (doc) {\n result.push(doc.data());\n });\n return _context15.abrupt(\"return\", result);\n case 10:\n _context15.prev = 10;\n _context15.t0 = _context15[\"catch\"](0);\n console.error(\"Error getting collection data\", _context15.t0);\n throw _context15.t0;\n case 14:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15, null, [[0, 10]]);\n }));\n}\n/**\n * Asynchronously retrieves a single document object from the specified collection path and document ID.\n * If the document does not exist, logs a warning and returns null.\n *\n * @param {string} collectionPath - The path to the collection in the database (\"improvementWork\", \"hospital\", \"suggestion\", \"task\", \"unit\", \"users\")\n * @param {string} documentId - The ID of the document to retrieve.\n * @returns {Promise<any|null>} A promise that resolves to the document object if found, or null if not.\n *\n * @throws Will throw an error if there is an issue during retrieval from the database.\n */\nfunction getObjectById(collectionPath, documentId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {\n var docRef, docSnapshot;\n return _regeneratorRuntime().wrap(function _callee16$(_context16) {\n while (1) switch (_context16.prev = _context16.next) {\n case 0:\n _context16.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, collectionPath, documentId);\n _context16.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDoc)(docRef);\n case 4:\n docSnapshot = _context16.sent;\n if (!docSnapshot.exists()) {\n _context16.next = 9;\n break;\n }\n return _context16.abrupt(\"return\", docSnapshot.data());\n case 9:\n console.warn(\"No such document! \".concat(collectionPath, \"/\").concat(documentId));\n return _context16.abrupt(\"return\", null);\n case 11:\n _context16.next = 17;\n break;\n case 13:\n _context16.prev = 13;\n _context16.t0 = _context16[\"catch\"](0);\n console.error(\"Error getting object\", _context16.t0);\n throw _context16.t0;\n case 17:\n case \"end\":\n return _context16.stop();\n }\n }, _callee16, null, [[0, 13]]);\n }));\n}\n/**\n * Asynchronously retrieves comments for a given suggestion.\n *\n * @param {Object} params - The parameters for fetching comments.\n * @param {string} params.suggestionId - The ID of the suggestion to fetch comments for.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - The criterion to sort the comments by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Determines if the sorting should be in ascending order. Defaults to false (descending).\n * @returns {Promise<any[]>} A promise that resolves to an array of comment objects.\n *\n * @throws Will throw an error if the comments cannot be retrieved.\n */\nfunction getComments(_ref) {\n var suggestionId = _ref.suggestionId,\n _ref$sortBy = _ref.sortBy,\n sortBy = _ref$sortBy === void 0 ? \"dateCreated\" : _ref$sortBy,\n _ref$ascending = _ref.ascending,\n ascending = _ref$ascending === void 0 ? false : _ref$ascending;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {\n var suggestionRef, commentsQuery, commentsSnapshot, comments;\n return _regeneratorRuntime().wrap(function _callee17$(_context17) {\n while (1) switch (_context17.prev = _context17.next) {\n case 0:\n _context17.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, \"suggestionCollection\", suggestionId);\n commentsQuery = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\"), (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n _context17.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(commentsQuery);\n case 5:\n commentsSnapshot = _context17.sent;\n comments = [];\n commentsSnapshot.forEach(function (doc) {\n comments.push(doc.data());\n });\n return _context17.abrupt(\"return\", comments);\n case 11:\n _context17.prev = 11;\n _context17.t0 = _context17[\"catch\"](0);\n console.error(\"Error getting comments for suggestion: \", _context17.t0);\n throw _context17.t0;\n case 15:\n case \"end\":\n return _context17.stop();\n }\n }, _callee17, null, [[0, 11]]);\n }));\n}\n//Filtering suggestions on unitId AND creatorHsaId\n//Sort suggestions on dateCreated OR upvotes\n/**\n * Asynchronously retrieves an array of suggestions from the database, with various filters and sorting options.\n *\n * @param {Object} params - The parameters for filtering and sorting suggestions.\n * @param {string} [params.id] - Optional ID to filter suggestions by a specific identifier.\n * @param {string} [params.creatorHsaId] - Optional HSA ID to filter suggestions by the creator's HSA ID.\n * @param {string} [params.unitId] - Optional unit ID to filter suggestions by a specific unit.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - Criterion to sort the suggestions by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Flag indicating if sorting should be ascending. Defaults to false (descending order).\n * @param {boolean} [params.isPublic=true] - Flag indicating whether to filter for public suggestions. Defaults to true.\n * @returns {Promise<any[]>} A promise that resolves to an array of suggestion objects.\n *\n * @throws Will throw an error if there is an issue retrieving suggestions.\n */\nfunction getSuggestions(_ref2) {\n var id = _ref2.id,\n creatorHsaId = _ref2.creatorHsaId,\n unitId = _ref2.unitId,\n _ref2$sortBy = _ref2.sortBy,\n sortBy = _ref2$sortBy === void 0 ? \"dateCreated\" : _ref2$sortBy,\n _ref2$ascending = _ref2.ascending,\n ascending = _ref2$ascending === void 0 ? false : _ref2$ascending,\n _ref2$isPublic = _ref2.isPublic,\n isPublic = _ref2$isPublic === void 0 ? true : _ref2$isPublic;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {\n var collectionRef, constraints, q, querySnapshot, suggestions;\n return _regeneratorRuntime().wrap(function _callee18$(_context18) {\n while (1) switch (_context18.prev = _context18.next) {\n case 0:\n _context18.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (creatorHsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"creatorHsaId\", \"==\", creatorHsaId));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"public\", \"==\", isPublic));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context18.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 11:\n querySnapshot = _context18.sent;\n suggestions = [];\n querySnapshot.forEach(function (doc) {\n suggestions.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context18.abrupt(\"return\", suggestions);\n case 17:\n _context18.prev = 17;\n _context18.t0 = _context18[\"catch\"](0);\n console.log(\"Error retrieving suggestions by department: \", _context18.t0);\n throw _context18.t0;\n case 21:\n case \"end\":\n return _context18.stop();\n }\n }, _callee18, null, [[0, 17]]);\n }));\n}\n/**\n * Asynchronously searches for hospital documents in the database.\n * It can filter the results by the hospital's name, ID, or both.\n * If no parameters are provided, it retrieves all hospitals.\n *\n * @param {Object} params - An object containing the search parameters.\n * @param {string} [params.hospitalName] - Optional name of the hospital to filter the search.\n * @param {string} [params.hospitalId] - Optional unique identifier of the hospital to filter the search.\n * @returns {Promise<any[]>} A promise that resolves to an array of hospital objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getHospitals(_ref3) {\n var hospitalName = _ref3.hospitalName,\n hospitalId = _ref3.hospitalId;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {\n var collectionRef, constraints, q, querySnapshot, hospitals;\n return _regeneratorRuntime().wrap(function _callee19$(_context19) {\n while (1) switch (_context19.prev = _context19.next) {\n case 0:\n _context19.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\n constraints = [];\n if (hospitalName) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", hospitalName));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hospitalId));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context19.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context19.sent;\n hospitals = [];\n querySnapshot.forEach(function (doc) {\n hospitals.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context19.abrupt(\"return\", hospitals);\n case 14:\n _context19.prev = 14;\n _context19.t0 = _context19[\"catch\"](0);\n console.log(\"Error retrieving Hospitals\", _context19.t0);\n throw _context19.t0;\n case 18:\n case \"end\":\n return _context19.stop();\n }\n }, _callee19, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of improvement work documents based on various filter criteria.\n * It supports filtering by ID, Nolan stage, unit ID, completion status, ongoing status, and patient risk level.\n * It also supports sorting by the start date of the improvement work in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.id] - Optional identifier to filter the improvement works.\n * @param {string} [params.nolanStage] - Optional Nolan stage to filter the improvement works.\n * @param {string} [params.unitId] - Optional unit ID to filter the improvement works.\n * @param {boolean} [params.completed] - Optional flag to filter the improvement works by their completion status.\n * @param {boolean} [params.ongoing] - Optional flag to filter the improvement works by their ongoing status.\n * @param {string} [params.patientRiskLevel] - Optional patient risk level to filter the improvement works.\n * @param {boolean} [params.ascendingDates=false] - Optional flag for sorting by date in ascending order. Defaults to false.\n * @returns {Promise<any[]>} A promise that resolves to an array of improvement work objects that match the criteria.\n *\n * @throws Will throw an error if there is a problem retrieving the improvement works.\n */\nfunction getImprovementWorks(_ref4) {\n var id = _ref4.id,\n nolanStage = _ref4.nolanStage,\n unitId = _ref4.unitId,\n completed = _ref4.completed,\n ongoing = _ref4.ongoing,\n patientRiskLevel = _ref4.patientRiskLevel,\n _ref4$ascendingDates = _ref4.ascendingDates,\n ascendingDates = _ref4$ascendingDates === void 0 ? false : _ref4$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {\n var collectionRef, constraints, q, querySnapshot, improvementWorks;\n return _regeneratorRuntime().wrap(function _callee20$(_context20) {\n while (1) switch (_context20.prev = _context20.next) {\n case 0:\n _context20.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (nolanStage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"currentStage\", \"==\", nolanStage));\n }\n if (completed != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"completed\", \"==\", completed));\n }\n if (ongoing !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"ongoing\", \"==\", ongoing));\n }\n if (patientRiskLevel) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"patientRiskLevel\", \"==\", patientRiskLevel));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"dateStarted\", ascendingDates ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context20.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 13:\n querySnapshot = _context20.sent;\n improvementWorks = [];\n querySnapshot.forEach(function (doc) {\n improvementWorks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context20.abrupt(\"return\", improvementWorks);\n case 19:\n _context20.prev = 19;\n _context20.t0 = _context20[\"catch\"](0);\n console.log(\"Error retrieving improvementWorks: \", _context20.t0);\n throw _context20.t0;\n case 23:\n case \"end\":\n return _context20.stop();\n }\n }, _callee20, null, [[0, 19]]);\n }));\n}\n/**\n * Asynchronously retrieves user documents from the database based on various filter criteria.\n * It can filter by the Health Savings Account ID (hsaId), unit ID, and unique identifier (uid).\n * Additionally, it can sort the results by first name in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.hsaId] - Optional HSA ID to filter the users.\n * @param {string} [params.unitId] - Optional unit ID to filter the users.\n * @param {boolean} [params.ascendingFirstNames=false] - Optional flag to sort by first names in ascending order. Defaults to false (descending order).\n * @param {string} [params.uid] - Optional unique identifier to filter the users.\n * @returns {Promise<any[]>} A promise that resolves to an array of user objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUsers(_ref5) {\n var hsaId = _ref5.hsaId,\n unitId = _ref5.unitId,\n _ref5$ascendingFirstN = _ref5.ascendingFirstNames,\n ascendingFirstNames = _ref5$ascendingFirstN === void 0 ? false : _ref5$ascendingFirstN,\n uid = _ref5.uid;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {\n var collectionRef, constraints, q, querySnapshot, users;\n return _regeneratorRuntime().wrap(function _callee21$(_context21) {\n while (1) switch (_context21.prev = _context21.next) {\n case 0:\n _context21.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\n constraints = [];\n if (hsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hsaId));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (uid) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"uid\", \"==\", uid));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"firstName\", ascendingFirstNames ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context21.next = 10;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 10:\n querySnapshot = _context21.sent;\n users = [];\n querySnapshot.forEach(function (doc) {\n users.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context21.abrupt(\"return\", users);\n case 16:\n _context21.prev = 16;\n _context21.t0 = _context21[\"catch\"](0);\n console.log(\"Error retrieving users by department: \", _context21.t0);\n throw _context21.t0;\n case 20:\n case \"end\":\n return _context21.stop();\n }\n }, _callee21, null, [[0, 16]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of task documents from the database based on several filter and sorting criteria.\n * Filters include task ID, user ID and their responsibility status, and related improvement work ID.\n * Results can be sorted by date either in ascending or descending order.\n *\n * @param {Object} params - Parameters to filter and sort the task results.\n * @param {string} [params.taskId] - Optional task ID to filter the tasks.\n * @param {string} [params.userId] - Optional user ID to identify tasks related to a user.\n * @param {boolean} [params.isResponsibleFor] - Optional flag to filter tasks where the user is marked as responsible.\n * @param {string} [params.improvementWorkId] - Optional improvement work ID to filter tasks related to a specific improvement work.\n * @param {boolean} [params.ascendingDates=false] - Optional flag to sort tasks by date in ascending order; defaults to descending order.\n * @returns {Promise<any[]>} A promise that resolves to an array of task objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getTasks(_ref6) {\n var taskId = _ref6.taskId,\n userId = _ref6.userId,\n isResponsibleFor = _ref6.isResponsibleFor,\n improvementWorkId = _ref6.improvementWorkId,\n _ref6$ascendingDates = _ref6.ascendingDates,\n ascendingDates = _ref6$ascendingDates === void 0 ? false : _ref6$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {\n var collectionRef, constraints, q, querySnapshot, tasks;\n return _regeneratorRuntime().wrap(function _callee22$(_context22) {\n while (1) switch (_context22.prev = _context22.next) {\n case 0:\n _context22.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\n constraints = [];\n if (taskId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", taskId));\n }\n if (userId && isResponsibleFor !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"members\", \"array-contains\", {\n userHsaId: userId,\n isResponsibleFor: isResponsibleFor\n }));\n }\n if (improvementWorkId != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"startDate\", ascendingDates ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context22.next = 9;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 9:\n querySnapshot = _context22.sent;\n tasks = [];\n querySnapshot.forEach(function (doc) {\n tasks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context22.abrupt(\"return\", tasks);\n case 15:\n _context22.prev = 15;\n _context22.t0 = _context22[\"catch\"](0);\n console.log(\"Error retrieving task by department: \", _context22.t0);\n throw _context22.t0;\n case 19:\n case \"end\":\n return _context22.stop();\n }\n }, _callee22, null, [[0, 15]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of unit documents from the database based on various filter criteria.\n * Filters can be applied based on unit ID, hospital ID, and unit name.\n * Additionally, results can be sorted by unit names in ascending or descending order.\n *\n * @param {Object} params - The parameters object containing filter and sorting options.\n * @param {string} [params.unitId] - Optional unit ID to filter the units.\n * @param {string} [params.hospitalId] - Optional hospital ID to filter units within a specific hospital.\n * @param {string} [params.name] - Optional name to filter units by a specific name.\n * @param {boolean} [params.ascendingUnitNames=false] - Optional flag to sort units by name in ascending order, defaults to descending.\n * @returns {Promise<any[]>} A promise that resolves to an array of unit objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUnits(_ref7) {\n var unitId = _ref7.unitId,\n hospitalId = _ref7.hospitalId,\n name = _ref7.name,\n _ref7$ascendingUnitNa = _ref7.ascendingUnitNames,\n ascendingUnitNames = _ref7$ascendingUnitNa === void 0 ? false : _ref7$ascendingUnitNa;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {\n var collectionRef, constraints, q, querySnapshot, units;\n return _regeneratorRuntime().wrap(function _callee23$(_context23) {\n while (1) switch (_context23.prev = _context23.next) {\n case 0:\n _context23.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\n constraints = [];\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", unitId));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"hospitalId\", \"==\", hospitalId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"name\", ascendingUnitNames ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context23.next = 9;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 9:\n querySnapshot = _context23.sent;\n units = [];\n querySnapshot.forEach(function (doc) {\n units.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context23.abrupt(\"return\", units);\n case 15:\n _context23.prev = 15;\n _context23.t0 = _context23[\"catch\"](0);\n console.log(\"Error retrieving units by hospitalId: \", _context23.t0);\n throw _context23.t0;\n case 19:\n case \"end\":\n return _context23.stop();\n }\n }, _callee23, null, [[0, 15]]);\n }));\n}\n//getMembersFilteredAndSorted() -> Get all members of a project (sorted by firstName?)\n// export getters to be able to use in other files\n\n////////////////////////////////////DELETING/////////////////////////////////////////////\n// delete an instance of a type\nfunction deleteInstance(docType, docId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee24$(_context24) {\n while (1) switch (_context24.prev = _context24.next) {\n case 0:\n _context24.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context24.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(docRef);\n case 4:\n console.log(\"\".concat(docType, \" deleted successfully.\"));\n _context24.next = 11;\n break;\n case 7:\n _context24.prev = 7;\n _context24.t0 = _context24[\"catch\"](0);\n console.error(\"Error deleting \".concat(docType, \":\"), _context24.t0);\n throw _context24.t0;\n case 11:\n case \"end\":\n return _context24.stop();\n }\n }, _callee24, null, [[0, 7]]);\n }));\n}\n// delete all instances of a type\nfunction deleteAllDocumentsInCollection(collectionName) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {\n var _this = this;\n var collectionRef, snapshot, deletePromises;\n return _regeneratorRuntime().wrap(function _callee26$(_context26) {\n while (1) switch (_context26.prev = _context26.next) {\n case 0:\n _context26.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionName);\n _context26.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n snapshot = _context26.sent;\n // Delete all documents in the collection\n deletePromises = snapshot.docs.map(function (doc) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {\n return _regeneratorRuntime().wrap(function _callee25$(_context25) {\n while (1) switch (_context25.prev = _context25.next) {\n case 0:\n _context25.next = 2;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(doc.ref);\n case 2:\n case \"end\":\n return _context25.stop();\n }\n }, _callee25);\n }));\n });\n _context26.next = 8;\n return Promise.all(deletePromises);\n case 8:\n console.log(\"All documents in the \".concat(collectionName, \" collection deleted successfully.\"));\n _context26.next = 15;\n break;\n case 11:\n _context26.prev = 11;\n _context26.t0 = _context26[\"catch\"](0);\n console.error(\"Error deleting all documents in \".concat(collectionName, \":\"), _context26.t0);\n throw _context26.t0;\n case 15:\n case \"end\":\n return _context26.stop();\n }\n }, _callee26, null, [[0, 11]]);\n }));\n}\n////////////////////////////////////UPDATING/////////////////////////////////////////////\n// update a field in an instance\nfunction updateInstance(docType, docId, updates) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee27$(_context27) {\n while (1) switch (_context27.prev = _context27.next) {\n case 0:\n _context27.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context27.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(docRef, updates);\n case 4:\n console.log(\"\".concat(docType, \" updated successfully.\"));\n _context27.next = 11;\n break;\n case 7:\n _context27.prev = 7;\n _context27.t0 = _context27[\"catch\"](0);\n console.error(\"Error updating \".concat(docType, \":\"), _context27.t0);\n throw _context27.t0;\n case 11:\n case \"end\":\n return _context27.stop();\n }\n }, _callee27, null, [[0, 7]]);\n }));\n}\n// changes the ongoing status of an improvement work. if ongoing it is paused, if if paused onging.\n// user must be a manager\nfunction startOrPauseImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee28$(_context28) {\n while (1) switch (_context28.prev = _context28.next) {\n case 0:\n _context28.prev = 0;\n _context28.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context28.sent;\n _context28.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context28.sent;\n if (!(!user || !user.manager)) {\n _context28.next = 11;\n break;\n }\n throw new Error(\"User can't change improvementWork status\");\n case 11:\n if (!improvementWork) {\n _context28.next = 18;\n break;\n }\n update = {\n ongoing: !improvementWork.ongoing\n };\n _context28.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n _context28.next = 19;\n break;\n case 18:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n case 19:\n _context28.next = 25;\n break;\n case 21:\n _context28.prev = 21;\n _context28.t0 = _context28[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context28.t0);\n throw _context28.t0;\n case 25:\n case \"end\":\n return _context28.stop();\n }\n }, _callee28, null, [[0, 21]]);\n }));\n}\nfunction changePatientRiskLevel(userId, improvementWorkId, patientRiskLevel) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee29$(_context29) {\n while (1) switch (_context29.prev = _context29.next) {\n case 0:\n _context29.prev = 0;\n _context29.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context29.sent;\n _context29.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context29.sent;\n if (!(!user || !user.manager)) {\n _context29.next = 11;\n break;\n }\n throw new Error(\"User can't change patientRiskLevel in improvement work\");\n case 11:\n if (!improvementWork) {\n _context29.next = 18;\n break;\n }\n update = {\n patientRiskLevel: patientRiskLevel\n };\n _context29.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n _context29.next = 19;\n break;\n case 18:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n case 19:\n _context29.next = 25;\n break;\n case 21:\n _context29.prev = 21;\n _context29.t0 = _context29[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context29.t0);\n throw _context29.t0;\n case 25:\n case \"end\":\n return _context29.stop();\n }\n }, _callee29, null, [[0, 21]]);\n }));\n}\n// finalizes the improvement work. ongoing is set to false.\n// user must be a manager\nfunction finalizeImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {\n var user, update;\n return _regeneratorRuntime().wrap(function _callee30$(_context30) {\n while (1) switch (_context30.prev = _context30.next) {\n case 0:\n _context30.prev = 0;\n _context30.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context30.sent;\n if (!(!user || !user.manager)) {\n _context30.next = 8;\n break;\n }\n throw new Error(\"User can't finalize improvementWork status\");\n case 8:\n update = {\n completed: true,\n ongoing: false\n };\n _context30.next = 11;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 11:\n _context30.next = 16;\n break;\n case 13:\n _context30.prev = 13;\n _context30.t0 = _context30[\"catch\"](0);\n console.log(_context30.t0);\n case 16:\n case \"end\":\n return _context30.stop();\n }\n }, _callee30, null, [[0, 13]]);\n }));\n}\n\n//////////////////////////////// for later sprint\n//function add_upvotes\n//function add_notes\n//function add_intrested_users\n\n//# sourceURL=webpack://c3/./client/Database/database.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addDocumentToImprovementWork: () => (/* binding */ addDocumentToImprovementWork),\n/* harmony export */ addMemberToImprovementWork: () => (/* binding */ addMemberToImprovementWork),\n/* harmony export */ addMemberToTask: () => (/* binding */ addMemberToTask),\n/* harmony export */ addNoteToUser: () => (/* binding */ addNoteToUser),\n/* harmony export */ auth: () => (/* binding */ auth),\n/* harmony export */ changePatientRiskLevel: () => (/* binding */ changePatientRiskLevel),\n/* harmony export */ createComment: () => (/* binding */ createComment),\n/* harmony export */ createHospital: () => (/* binding */ createHospital),\n/* harmony export */ createImprovementWork: () => (/* binding */ createImprovementWork),\n/* harmony export */ createSuggestion: () => (/* binding */ createSuggestion),\n/* harmony export */ createTaskOnImprovementWork: () => (/* binding */ createTaskOnImprovementWork),\n/* harmony export */ createUnit: () => (/* binding */ createUnit),\n/* harmony export */ createUser: () => (/* binding */ createUser),\n/* harmony export */ createdDocumentInKnowledgeBank: () => (/* binding */ createdDocumentInKnowledgeBank),\n/* harmony export */ db: () => (/* binding */ db),\n/* harmony export */ deleteAllDocumentsInCollection: () => (/* binding */ deleteAllDocumentsInCollection),\n/* harmony export */ deleteInstance: () => (/* binding */ deleteInstance),\n/* harmony export */ finalizeImprovementWork: () => (/* binding */ finalizeImprovementWork),\n/* harmony export */ getComments: () => (/* binding */ getComments),\n/* harmony export */ getHospitals: () => (/* binding */ getHospitals),\n/* harmony export */ getImprovementWorkOwner: () => (/* binding */ getImprovementWorkOwner),\n/* harmony export */ getImprovementWorkResponsible: () => (/* binding */ getImprovementWorkResponsible),\n/* harmony export */ getImprovementWorks: () => (/* binding */ getImprovementWorks),\n/* harmony export */ getImprovementWorksForUser: () => (/* binding */ getImprovementWorksForUser),\n/* harmony export */ getObject: () => (/* binding */ getObject),\n/* harmony export */ getObjectById: () => (/* binding */ getObjectById),\n/* harmony export */ getSuggestions: () => (/* binding */ getSuggestions),\n/* harmony export */ getTasks: () => (/* binding */ getTasks),\n/* harmony export */ getUnits: () => (/* binding */ getUnits),\n/* harmony export */ getUsers: () => (/* binding */ getUsers),\n/* harmony export */ getUsersForImprovementWork: () => (/* binding */ getUsersForImprovementWork),\n/* harmony export */ startOrPauseImprovementWork: () => (/* binding */ startOrPauseImprovementWork),\n/* harmony export */ updateInstance: () => (/* binding */ updateInstance),\n/* harmony export */ upvoteComment: () => (/* binding */ upvoteComment),\n/* harmony export */ upvoteSuggestion: () => (/* binding */ upvoteSuggestion)\n/* harmony export */ });\n/* harmony import */ var firebase_app__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! firebase/app */ \"./node_modules/firebase/app/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_firestore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! firebase/firestore */ \"./node_modules/firebase/firestore/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_auth__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! firebase/auth */ \"./node_modules/firebase/auth/dist/esm/index.esm.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nvar firebaseConfig = {\n apiKey: \"AIzaSyDqkaVZMr11J4mfnR0auqoQilZyPfyD-x4\",\n authDomain: \"c3solutions-dc109.firebaseapp.com\",\n projectId: \"c3solutions-dc109\",\n storageBucket: \"c3solutions-dc109.appspot.com\",\n messagingSenderId: \"902143402555\",\n appId: \"1:902143402555:web:29213e81de0a0cba38b21e\"\n};\n/*const firebaseConfig = {\n apiKey: \"AIzaSyBIsZq_yOsJljp1woIxndJO1GkW6soh-g4\",\n authDomain: \"company3-456bb.firebaseapp.com\",\n projectId: \"company3-456bb\",\n storageBucket: \"company3-456bb.appspot.com\",\n messagingSenderId: \"310033686522\",\n appId: \"1:310033686522:web:63198bb0db679c98ee4e43\",\n measurementId: \"G-PFLDQY00DB\"\n};*/\n// const firebaseConfig = {\n// apiKey: \"AIzaSyBIsZq_yOsJljp1woIxndJO1GkW6soh-g4\",\n// authDomain: \"company3-456bb.firebaseapp.com\",\n// projectId: \"company3-456bb\",\n// storageBucket: \"company3-456bb.appspot.com\",\n// messagingSenderId: \"310033686522\",\n// appId: \"1:310033686522:web:63198bb0db679c98ee4e43\",\n// measurementId: \"G-PFLDQY00DB\"\n// };\nvar app = (0,firebase_app__WEBPACK_IMPORTED_MODULE_0__.initializeApp)(firebaseConfig);\nvar auth = (0,firebase_auth__WEBPACK_IMPORTED_MODULE_2__.getAuth)();\nvar db = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getFirestore)(app);\nvar userCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\nvar unitCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\nvar improvementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\nvar taskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\nvar hospitalCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\nvar suggestionCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\nvar knowledgeDocumentCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"knowledgeDocument\");\nvar userImprovementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"userImprovementWork\");\nvar userTaskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"userTask\");\n////////////////////////////////////////Setters///////////////////////////////////////////////////////////////////\n// Function to create user a new user in database\n// takes in userId, unitId, firstname, lastname, email and password as string\n// throws error if transaction failed\nfunction createUser(hsaId, unitId, firstName, lastName, email, manager, uid) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var userRef, unitRef;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, hsaId);\n _context.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(userRef, {\n id: userRef.id,\n uid: uid,\n unitId: unitId,\n firstName: firstName,\n lastName: lastName,\n email: email,\n // TODO Replace with userImprovementWork collection\n improvementWorks: [],\n tasks: [],\n manager: manager\n });\n case 4:\n // Atomically add user to unit.\n unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection, unitId);\n _context.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(unitRef, {\n members: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userRef.id)\n });\n case 7:\n _context.next = 12;\n break;\n case 9:\n _context.prev = 9;\n _context.t0 = _context[\"catch\"](0);\n console.log(_context.t0);\n case 12:\n case \"end\":\n return _context.stop();\n }\n }, _callee, null, [[0, 9]]);\n }));\n}\nfunction createImprovementWork(id, name, currentStage, content,\n// Är detta description bör detta förtydligas. \nunitId, purpose,\n//Bör tas bort motsvaras av p2- mål med projektet\npatientRiskLevel, area,\n//Questions in planning stage\np1, p2, p3, p4, p5, p6, p7,\n//Questions in Doing (G) stage\ng1, g2, g3, g4, g5,\n//Questions in stydy stage\ns1, s2, s3,\n//Questions in acting stage\na1, a2, a3, a4) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var improvementWorkData, improvementWorkRef, _improvementWorkRef;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.prev = 0;\n improvementWorkData = {\n name: name,\n currentStage: currentStage,\n content: content,\n purpose: purpose,\n dateStarted: new Date(),\n unitId: unitId,\n completed: false,\n ongoing: false,\n tasks: [],\n // TODO Remove members array\n members: [],\n patientRiskLevel: patientRiskLevel,\n area: area,\n p1: p1,\n p2: p2,\n p3: p3,\n p4: p4,\n p5: p5,\n p6: p6,\n p7: p7,\n g1: g1,\n g2: g2,\n g3: g3,\n g4: g4,\n g5: g5,\n s1: s1,\n s2: s2,\n s3: s3,\n a1: a1,\n a2: a2,\n a3: a3,\n a4: a4\n };\n if (!id) {\n _context2.next = 8;\n break;\n }\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, id);\n _context2.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(improvementWorkRef, Object.assign({\n id: improvementWorkRef.id\n }, improvementWorkData));\n case 6:\n _context2.next = 11;\n break;\n case 8:\n _improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection);\n _context2.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_improvementWorkRef, improvementWorkData);\n case 11:\n _context2.next = 17;\n break;\n case 13:\n _context2.prev = 13;\n _context2.t0 = _context2[\"catch\"](0);\n console.log(\"Error creating improvementWork: \", _context2.t0);\n throw _context2.t0;\n case 17:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, null, [[0, 13]]);\n }));\n}\nfunction addMemberToTask(userHsaId, taskId, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var relationRef;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.prev = 0;\n relationRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userTaskCollection);\n _context3.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(relationRef, {\n id: relationRef.id,\n userHsaId: userHsaId,\n taskId: taskId,\n isResponsibleFor: isResponsibleFor\n });\n case 4:\n _context3.next = 10;\n break;\n case 6:\n _context3.prev = 6;\n _context3.t0 = _context3[\"catch\"](0);\n console.log(\"Error adding member to task: \", _context3.t0);\n throw _context3.t0;\n case 10:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, null, [[0, 6]]);\n }));\n}\nfunction addMemberToImprovementWork(userHsaId, improvementWorkId, isOwner, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var relationRef;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n _context4.prev = 0;\n relationRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userImprovementWorkCollection);\n _context4.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(relationRef, {\n id: relationRef.id,\n userHsaId: userHsaId,\n improvementWorkId: improvementWorkId,\n isOwner: isOwner,\n isResponsibleFor: isResponsibleFor\n });\n case 4:\n _context4.next = 10;\n break;\n case 6:\n _context4.prev = 6;\n _context4.t0 = _context4[\"catch\"](0);\n console.log(\"Error adding member to improvementWork: \", _context4.t0);\n throw _context4.t0;\n case 10:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4, null, [[0, 6]]);\n }));\n}\nfunction createTaskOnImprovementWork(taskId, improvementWorkId, name, deadlineDate, startDate, stage, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var taskData, taskRef, _taskRef;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n _context5.prev = 0;\n taskData = {\n improvementWorkId: improvementWorkId,\n name: name,\n deadlineDate: deadlineDate,\n startDate: startDate,\n stage: stage,\n content: content,\n members: [] // Initialize with an empty array\n };\n if (!taskId) {\n _context5.next = 8;\n break;\n }\n taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection, taskId);\n _context5.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(taskRef, Object.assign({\n id: taskRef.id\n }, taskData));\n case 6:\n _context5.next = 11;\n break;\n case 8:\n _taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection);\n _context5.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_taskRef, taskData);\n case 11:\n _context5.next = 17;\n break;\n case 13:\n _context5.prev = 13;\n _context5.t0 = _context5[\"catch\"](0);\n console.log(\"Error creating task: \", _context5.t0);\n throw _context5.t0;\n case 17:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5, null, [[0, 13]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction createdDocumentInKnowledgeBank(documentUrl, name) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n _context6.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(knowledgeDocumentCollection);\n _context6.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n name: name\n });\n case 4:\n _context6.next = 10;\n break;\n case 6:\n _context6.prev = 6;\n _context6.t0 = _context6[\"catch\"](0);\n console.log(\"Error adding document: \", _context6.t0);\n throw _context6.t0;\n case 10:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6, null, [[0, 6]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction addDocumentToImprovementWork(documentUrl, name, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var improvementWorkRef, docRef;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.prev = 0;\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, improvementWorkId);\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkRef, \"documents\");\n _context7.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n timestamp: new Date(),\n name: name\n });\n case 5:\n _context7.next = 11;\n break;\n case 7:\n _context7.prev = 7;\n _context7.t0 = _context7[\"catch\"](0);\n console.log(\"Error adding document: \", _context7.t0);\n throw _context7.t0;\n case 11:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7, null, [[0, 7]]);\n }));\n}\nfunction createHospital(hospitalId,\n// should be auto?\nname) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var hospitalData, hospitalRef, _hospitalRef;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n _context8.prev = 0;\n hospitalData = {\n name: name,\n units: []\n };\n if (!hospitalId) {\n _context8.next = 8;\n break;\n }\n hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection, hospitalId);\n _context8.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(hospitalRef, Object.assign({\n id: hospitalRef.id\n }, hospitalData));\n case 6:\n _context8.next = 11;\n break;\n case 8:\n _hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection);\n _context8.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_hospitalRef, hospitalData);\n case 11:\n _context8.next = 17;\n break;\n case 13:\n _context8.prev = 13;\n _context8.t0 = _context8[\"catch\"](0);\n console.log(\"Error creating hospital: \", _context8.t0);\n throw _context8.t0;\n case 17:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8, null, [[0, 13]]);\n }));\n}\nfunction createUnit(unitId,\n//should be auto?\nhospitalId, name) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var unitData, unitRef, _unitRef;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n _context9.prev = 0;\n unitData = {\n hospitalId: hospitalId,\n name: name,\n members: []\n };\n if (!unitId) {\n _context9.next = 8;\n break;\n }\n unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection, unitId);\n _context9.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(unitRef, Object.assign({\n id: unitRef.id\n }, unitData));\n case 6:\n _context9.next = 11;\n break;\n case 8:\n _unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection);\n _context9.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_unitRef, unitData);\n case 11:\n _context9.next = 17;\n break;\n case 13:\n _context9.prev = 13;\n _context9.t0 = _context9[\"catch\"](0);\n console.log(\"Error creating unit: \", _context9.t0);\n throw _context9.t0;\n case 17:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9, null, [[0, 13]]);\n }));\n}\nfunction createSuggestion(id, creatorHsaId, name, area, content, purpose, measure, ideas,\n//need: boolean,\nunitId, departmentId, isPublic) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var suggestionData, suggestionRef, _suggestionRef;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n _context10.prev = 0;\n suggestionData = {\n creatorHsaId: creatorHsaId,\n name: name,\n area: area,\n content: content,\n purpose: purpose,\n measure: measure,\n ideas: ideas,\n //need,\n unitId: unitId,\n departmentId: departmentId,\n \"public\": isPublic,\n upvotes: [],\n comments: [],\n dateCreated: new Date()\n };\n if (!id) {\n _context10.next = 8;\n break;\n }\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, id);\n _context10.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(suggestionRef, Object.assign({\n id: suggestionRef.id\n }, suggestionData));\n case 6:\n _context10.next = 11;\n break;\n case 8:\n _suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection);\n _context10.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_suggestionRef, suggestionData);\n case 11:\n _context10.next = 17;\n break;\n case 13:\n _context10.prev = 13;\n _context10.t0 = _context10[\"catch\"](0);\n console.log(\"Error creating suggestion: \", _context10.t0);\n throw _context10.t0;\n case 17:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10, null, [[0, 13]]);\n }));\n}\n// Upvote a suggestion for a user\n// takes in suggestion id, user HSAid\n// returns error if transaction failed\nfunction upvoteSuggestion(suggestionId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var suggestionRef;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n _context11.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId); // Atomically add a update to the upvote array field.\n _context11.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(suggestionRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 4:\n _context11.next = 10;\n break;\n case 6:\n _context11.prev = 6;\n _context11.t0 = _context11[\"catch\"](0);\n console.log(\"Error upvoting suggestion: \", _context11.t0);\n throw _context11.t0;\n case 10:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11, null, [[0, 6]]);\n }));\n}\n//creates a comment\n// takes in commenters id, suggestion id and content as string\n// throws error if transaction failed\nfunction createComment(\n// change to subcollection\ncommenterHsaId, suggestionId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var suggestionRef, commentCollection, commentRef;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n _context12.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context12.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\");\n case 4:\n commentCollection = _context12.sent;\n _context12.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(commentCollection);\n case 7:\n commentRef = _context12.sent;\n _context12.next = 10;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(commentRef, {\n id: commentRef.id,\n commenterHsaId: commenterHsaId,\n content: content,\n dateCreated: new Date(),\n upvotes: []\n });\n case 10:\n _context12.next = 16;\n break;\n case 12:\n _context12.prev = 12;\n _context12.t0 = _context12[\"catch\"](0);\n console.log(\"Error creating comment: \", _context12.t0);\n throw _context12.t0;\n case 16:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12, null, [[0, 12]]);\n }));\n}\n// Upvote a comment for a user\n// takes in suggestionId, commentId and userId as strings\n// return error if transaction failed\nfunction upvoteComment(suggestionId, commentId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var suggestionRef, commentRef;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n _context13.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n commentRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionRef, \"comment\", commentId); // Atomically add a update to the upvote array field.\n _context13.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(commentRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 5:\n _context13.next = 11;\n break;\n case 7:\n _context13.prev = 7;\n _context13.t0 = _context13[\"catch\"](0);\n console.log(\"Error upvoting comment: \", _context13.t0);\n throw _context13.t0;\n case 11:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13, null, [[0, 7]]);\n }));\n}\n//add a note to a user\n// takes in userHsaId and content as string\n// throws error if transaction failed\nfunction addNoteToUser(userHsaId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var userRef, docRef;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n _context14.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, userHsaId);\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userRef, \"notes\");\n _context14.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n content: content,\n dateCreated: new Date()\n });\n case 5:\n _context14.next = 11;\n break;\n case 7:\n _context14.prev = 7;\n _context14.t0 = _context14[\"catch\"](0);\n console.log(\"Error adding document: \", _context14.t0);\n throw _context14.t0;\n case 11:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14, null, [[0, 7]]);\n }));\n}\n// export to setters to be able to use in other files\n\n//////////////////////////////////////////////GETTERS/////////////////////////////////////////////////////////////////////\n// Get any object\n// input is the database type as a string.\n// output is the whole collection of that type.\nfunction getObject(collectionPath) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n var collectionRef, querySnapshot, result;\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n _context15.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionPath);\n _context15.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n querySnapshot = _context15.sent;\n result = [];\n querySnapshot.forEach(function (doc) {\n result.push(doc.data());\n });\n return _context15.abrupt(\"return\", result);\n case 10:\n _context15.prev = 10;\n _context15.t0 = _context15[\"catch\"](0);\n console.error(\"Error getting collection data\", _context15.t0);\n throw _context15.t0;\n case 14:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15, null, [[0, 10]]);\n }));\n}\n/**\n * Asynchronously retrieves a single document object from the specified collection path and document ID.\n * If the document does not exist, logs a warning and returns null.\n *\n * @param {string} collectionPath - The path to the collection in the database (\"improvementWork\", \"hospital\", \"suggestion\", \"task\", \"unit\", \"users\")\n * @param {string} documentId - The ID of the document to retrieve.\n * @returns {Promise<any|null>} A promise that resolves to the document object if found, or null if not.\n *\n * @throws Will throw an error if there is an issue during retrieval from the database.\n */\nfunction getObjectById(collectionPath, documentId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {\n var docRef, docSnapshot;\n return _regeneratorRuntime().wrap(function _callee16$(_context16) {\n while (1) switch (_context16.prev = _context16.next) {\n case 0:\n _context16.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, collectionPath, documentId);\n _context16.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDoc)(docRef);\n case 4:\n docSnapshot = _context16.sent;\n if (!docSnapshot.exists()) {\n _context16.next = 9;\n break;\n }\n return _context16.abrupt(\"return\", Object.assign({\n id: docSnapshot.id\n }, docSnapshot.data()));\n case 9:\n console.warn(\"No such document! \".concat(collectionPath, \"/\").concat(documentId));\n return _context16.abrupt(\"return\", null);\n case 11:\n _context16.next = 17;\n break;\n case 13:\n _context16.prev = 13;\n _context16.t0 = _context16[\"catch\"](0);\n console.error(\"Error getting object\", _context16.t0);\n throw _context16.t0;\n case 17:\n case \"end\":\n return _context16.stop();\n }\n }, _callee16, null, [[0, 13]]);\n }));\n}\n/**\n * Asynchronously retrieves comments for a given suggestion.\n *\n * @param {Object} params - The parameters for fetching comments.\n * @param {string} params.suggestionId - The ID of the suggestion to fetch comments for.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - The criterion to sort the comments by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Determines if the sorting should be in ascending order. Defaults to false (descending).\n * @returns {Promise<any[]>} A promise that resolves to an array of comment objects.\n *\n * @throws Will throw an error if the comments cannot be retrieved.\n */\nfunction getComments(_ref) {\n var suggestionId = _ref.suggestionId,\n _ref$sortBy = _ref.sortBy,\n sortBy = _ref$sortBy === void 0 ? \"dateCreated\" : _ref$sortBy,\n _ref$ascending = _ref.ascending,\n ascending = _ref$ascending === void 0 ? false : _ref$ascending;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {\n var suggestionRef, commentsQuery, commentsSnapshot, comments;\n return _regeneratorRuntime().wrap(function _callee17$(_context17) {\n while (1) switch (_context17.prev = _context17.next) {\n case 0:\n _context17.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, \"suggestionCollection\", suggestionId);\n commentsQuery = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\"), (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n _context17.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(commentsQuery);\n case 5:\n commentsSnapshot = _context17.sent;\n comments = [];\n commentsSnapshot.forEach(function (doc) {\n comments.push(doc.data());\n });\n return _context17.abrupt(\"return\", comments);\n case 11:\n _context17.prev = 11;\n _context17.t0 = _context17[\"catch\"](0);\n console.error(\"Error getting comments for suggestion: \", _context17.t0);\n throw _context17.t0;\n case 15:\n case \"end\":\n return _context17.stop();\n }\n }, _callee17, null, [[0, 11]]);\n }));\n}\n//Filtering suggestions on unitId AND creatorHsaId\n//Sort suggestions on dateCreated OR upvotes\n/**\n * Asynchronously retrieves an array of suggestions from the database, with various filters and sorting options.\n *\n * @param {Object} params - The parameters for filtering and sorting suggestions.\n * @param {string} [params.id] - Optional ID to filter suggestions by a specific identifier.\n * @param {string} [params.creatorHsaId] - Optional HSA ID to filter suggestions by the creator's HSA ID.\n * @param {string} [params.unitId] - Optional unit ID to filter suggestions by a specific unit.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - Criterion to sort the suggestions by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Flag indicating if sorting should be ascending. Defaults to false (descending order).\n * @param {boolean} [params.isPublic=true] - Flag indicating whether to filter for public suggestions. Defaults to true.\n * @returns {Promise<any[]>} A promise that resolves to an array of suggestion objects.\n *\n * @throws Will throw an error if there is an issue retrieving suggestions.\n */\nfunction getSuggestions(_ref2) {\n var id = _ref2.id,\n creatorHsaId = _ref2.creatorHsaId,\n unitId = _ref2.unitId,\n _ref2$sortBy = _ref2.sortBy,\n sortBy = _ref2$sortBy === void 0 ? \"dateCreated\" : _ref2$sortBy,\n _ref2$ascending = _ref2.ascending,\n ascending = _ref2$ascending === void 0 ? false : _ref2$ascending,\n _ref2$isPublic = _ref2.isPublic,\n isPublic = _ref2$isPublic === void 0 ? true : _ref2$isPublic;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {\n var collectionRef, constraints, q, querySnapshot, suggestions;\n return _regeneratorRuntime().wrap(function _callee18$(_context18) {\n while (1) switch (_context18.prev = _context18.next) {\n case 0:\n _context18.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (creatorHsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"creatorHsaId\", \"==\", creatorHsaId));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"public\", \"==\", isPublic));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context18.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 11:\n querySnapshot = _context18.sent;\n suggestions = [];\n querySnapshot.forEach(function (doc) {\n suggestions.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context18.abrupt(\"return\", suggestions);\n case 17:\n _context18.prev = 17;\n _context18.t0 = _context18[\"catch\"](0);\n console.log(\"Error retrieving suggestions by department: \", _context18.t0);\n throw _context18.t0;\n case 21:\n case \"end\":\n return _context18.stop();\n }\n }, _callee18, null, [[0, 17]]);\n }));\n}\n/**\n * Asynchronously searches for hospital documents in the database.\n * It can filter the results by the hospital's name, ID, or both.\n * If no parameters are provided, it retrieves all hospitals.\n *\n * @param {Object} params - An object containing the search parameters.\n * @param {string} [params.hospitalName] - Optional name of the hospital to filter the search.\n * @param {string} [params.hospitalId] - Optional unique identifier of the hospital to filter the search.\n * @returns {Promise<any[]>} A promise that resolves to an array of hospital objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getHospitals(_ref3) {\n var hospitalName = _ref3.hospitalName,\n hospitalId = _ref3.hospitalId;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {\n var collectionRef, constraints, q, querySnapshot, hospitals;\n return _regeneratorRuntime().wrap(function _callee19$(_context19) {\n while (1) switch (_context19.prev = _context19.next) {\n case 0:\n _context19.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\n constraints = [];\n if (hospitalName) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", hospitalName));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hospitalId));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context19.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context19.sent;\n hospitals = [];\n querySnapshot.forEach(function (doc) {\n hospitals.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context19.abrupt(\"return\", hospitals);\n case 14:\n _context19.prev = 14;\n _context19.t0 = _context19[\"catch\"](0);\n console.log(\"Error retrieving Hospitals\", _context19.t0);\n throw _context19.t0;\n case 18:\n case \"end\":\n return _context19.stop();\n }\n }, _callee19, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of improvement work documents based on various filter criteria.\n * It supports filtering by ID, Nolan stage, unit ID, completion status, ongoing status, and patient risk level.\n * It also supports sorting by the start date of the improvement work in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.id] - Optional identifier to filter the improvement works.\n * @param {string} [params.nolanStage] - Optional Nolan stage to filter the improvement works.\n * @param {string} [params.unitId] - Optional unit ID to filter the improvement works.\n * @param {boolean} [params.completed] - Optional flag to filter the improvement works by their completion status.\n * @param {boolean} [params.ongoing] - Optional flag to filter the improvement works by their ongoing status.\n * @param {string} [params.patientRiskLevel] - Optional patient risk level to filter the improvement works.\n * @param {boolean} [params.ascendingDates=false] - Optional flag for sorting by date in ascending order. Defaults to false.\n * @returns {Promise<any[]>} A promise that resolves to an array of improvement work objects that match the criteria.\n *\n * @throws Will throw an error if there is a problem retrieving the improvement works.\n */\nfunction getImprovementWorks(_ref4) {\n var id = _ref4.id,\n nolanStage = _ref4.nolanStage,\n unitId = _ref4.unitId,\n completed = _ref4.completed,\n ongoing = _ref4.ongoing,\n patientRiskLevel = _ref4.patientRiskLevel,\n _ref4$ascendingDates = _ref4.ascendingDates,\n ascendingDates = _ref4$ascendingDates === void 0 ? false : _ref4$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {\n var collectionRef, constraints, q, querySnapshot, improvementWorks;\n return _regeneratorRuntime().wrap(function _callee20$(_context20) {\n while (1) switch (_context20.prev = _context20.next) {\n case 0:\n _context20.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (nolanStage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"currentStage\", \"==\", nolanStage));\n }\n if (completed != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"completed\", \"==\", completed));\n }\n if (ongoing !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"ongoing\", \"==\", ongoing));\n }\n if (patientRiskLevel) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"patientRiskLevel\", \"==\", patientRiskLevel));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"dateStarted\", ascendingDates ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context20.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 13:\n querySnapshot = _context20.sent;\n improvementWorks = [];\n querySnapshot.forEach(function (doc) {\n improvementWorks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context20.abrupt(\"return\", improvementWorks);\n case 19:\n _context20.prev = 19;\n _context20.t0 = _context20[\"catch\"](0);\n console.log(\"Error retrieving improvementWorks: \", _context20.t0);\n throw _context20.t0;\n case 23:\n case \"end\":\n return _context20.stop();\n }\n }, _callee20, null, [[0, 19]]);\n }));\n}\nfunction getImprovementWorkOwner(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {\n var constraints, q, querySnapshot, owner;\n return _regeneratorRuntime().wrap(function _callee21$(_context21) {\n while (1) switch (_context21.prev = _context21.next) {\n case 0:\n _context21.prev = 0;\n constraints = [];\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"isOwner\", \"==\", true));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context21.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 7:\n querySnapshot = _context21.sent;\n if (!querySnapshot.empty) {\n _context21.next = 13;\n break;\n }\n console.log(\"Improvement work \", improvementWorkId, \" has no owner\");\n return _context21.abrupt(\"return\", null);\n case 13:\n owner = querySnapshot.docs[0].data().userHsaId;\n return _context21.abrupt(\"return\", owner);\n case 15:\n _context21.next = 20;\n break;\n case 17:\n _context21.prev = 17;\n _context21.t0 = _context21[\"catch\"](0);\n console.log(_context21.t0);\n case 20:\n case \"end\":\n return _context21.stop();\n }\n }, _callee21, null, [[0, 17]]);\n }));\n}\nfunction getImprovementWorkResponsible(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {\n var constraints, q, querySnapshot, responsible;\n return _regeneratorRuntime().wrap(function _callee22$(_context22) {\n while (1) switch (_context22.prev = _context22.next) {\n case 0:\n _context22.prev = 0;\n constraints = [];\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"isResponsibleFor\", \"==\", true));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context22.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 7:\n querySnapshot = _context22.sent;\n if (!querySnapshot.empty) {\n _context22.next = 13;\n break;\n }\n console.log(\"Improvement work \", improvementWorkId, \" has no responsible\");\n return _context22.abrupt(\"return\", null);\n case 13:\n responsible = querySnapshot.docs[0].data().userHsaId;\n return _context22.abrupt(\"return\", responsible);\n case 15:\n _context22.next = 20;\n break;\n case 17:\n _context22.prev = 17;\n _context22.t0 = _context22[\"catch\"](0);\n console.log(_context22.t0);\n case 20:\n case \"end\":\n return _context22.stop();\n }\n }, _callee22, null, [[0, 17]]);\n }));\n}\n// TODO getUsersForTask!\n/**\n * Asynchronously retrieves user documents from the database based on various filter criteria.\n * It can filter by the Health Savings Account ID (hsaId), unit ID, and unique identifier (uid).\n * Additionally, it can sort the results by first name in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.hsaId] - Optional HSA ID to filter the users.\n * @param {string} [params.unitId] - Optional unit ID to filter the users.\n * @param {boolean} [params.ascendingFirstNames=false] - Optional flag to sort by first names in ascending order. Defaults to false (descending order).\n * @param {string} [params.uid] - Optional unique identifier to filter the users.\n * @returns {Promise<any[]>} A promise that resolves to an array of user objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUsers(_ref5) {\n var hsaId = _ref5.hsaId,\n unitId = _ref5.unitId,\n _ref5$ascendingFirstN = _ref5.ascendingFirstNames,\n ascendingFirstNames = _ref5$ascendingFirstN === void 0 ? false : _ref5$ascendingFirstN,\n uid = _ref5.uid;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {\n var collectionRef, constraints, q, querySnapshot, users;\n return _regeneratorRuntime().wrap(function _callee23$(_context23) {\n while (1) switch (_context23.prev = _context23.next) {\n case 0:\n _context23.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\n constraints = [];\n if (hsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hsaId));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (uid) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"uid\", \"==\", uid));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"firstName\", ascendingFirstNames ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context23.next = 10;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 10:\n querySnapshot = _context23.sent;\n users = [];\n querySnapshot.forEach(function (doc) {\n users.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context23.abrupt(\"return\", users);\n case 16:\n _context23.prev = 16;\n _context23.t0 = _context23[\"catch\"](0);\n console.log(\"Error retrieving users by department: \", _context23.t0);\n throw _context23.t0;\n case 20:\n case \"end\":\n return _context23.stop();\n }\n }, _callee23, null, [[0, 16]]);\n }));\n}\n// TODO getTasksForUser!\n/**\n * Asynchronously retrieves an array of task documents from the database based on several filter and sorting criteria.\n * Filters include task ID, user ID and their responsibility status, and related improvement work ID.\n * Results can be sorted by date either in ascending or descending order.\n *\n * @param {Object} params - Parameters to filter and sort the task results.\n * @param {string} [params.taskId] - Optional task ID to filter the tasks.\n * @param {string} [params.userId] - Optional user ID to identify tasks related to a user.\n * @param {boolean} [params.isResponsibleFor] - Optional flag to filter tasks where the user is marked as responsible.\n * @param {string} [params.improvementWorkId] - Optional improvement work ID to filter tasks related to a specific improvement work.\n * @param {boolean} [params.ascendingDates=false] - Optional flag to sort tasks by date in ascending order; defaults to descending order.\n * @returns {Promise<any[]>} A promise that resolves to an array of task objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getTasks(_ref6) {\n var improvementWorkId = _ref6.improvementWorkId,\n stage = _ref6.stage,\n _ref6$ascendingDates = _ref6.ascendingDates,\n ascendingDates = _ref6$ascendingDates === void 0 ? false : _ref6$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {\n var collectionRef, constraints, q, querySnapshot, tasks;\n return _regeneratorRuntime().wrap(function _callee24$(_context24) {\n while (1) switch (_context24.prev = _context24.next) {\n case 0:\n _context24.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\n constraints = []; // FUTURE FEATURE: Filter on userHsaId AND improvementWork\n // if (userHsaId && isResponsibleFor !== undefined) {\n // constraints.push(\n // where(\"members\", \"array-contains\", {\n // userHsaId: userHsaId,\n // isResponsibleFor: isResponsibleFor,\n // })\n // );\n // }\n if (stage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"stage\", \"==\", stage));\n }\n if (improvementWorkId != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"startDate\", ascendingDates ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context24.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context24.sent;\n tasks = [];\n querySnapshot.forEach(function (doc) {\n tasks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context24.abrupt(\"return\", tasks);\n case 14:\n _context24.prev = 14;\n _context24.t0 = _context24[\"catch\"](0);\n console.log(\"Error retrieving task by department: \", _context24.t0);\n throw _context24.t0;\n case 18:\n case \"end\":\n return _context24.stop();\n }\n }, _callee24, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of unit documents from the database based on various filter criteria.\n * Filters can be applied based on unit ID, hospital ID, and unit name.\n * Additionally, results can be sorted by unit names in ascending or descending order.\n *\n * @param {Object} params - The parameters object containing filter and sorting options.\n * @param {string} [params.unitId] - Optional unit ID to filter the units.\n * @param {string} [params.hospitalId] - Optional hospital ID to filter units within a specific hospital.\n * @param {string} [params.name] - Optional name to filter units by a specific name.\n * @param {boolean} [params.ascendingUnitNames=false] - Optional flag to sort units by name in ascending order, defaults to descending.\n * @returns {Promise<any[]>} A promise that resolves to an array of unit objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUnits(_ref7) {\n var unitId = _ref7.unitId,\n hospitalId = _ref7.hospitalId,\n name = _ref7.name,\n _ref7$ascendingUnitNa = _ref7.ascendingUnitNames,\n ascendingUnitNames = _ref7$ascendingUnitNa === void 0 ? false : _ref7$ascendingUnitNa;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {\n var collectionRef, constraints, q, querySnapshot, units;\n return _regeneratorRuntime().wrap(function _callee25$(_context25) {\n while (1) switch (_context25.prev = _context25.next) {\n case 0:\n _context25.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\n constraints = [];\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", unitId));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"hospitalId\", \"==\", hospitalId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"name\", ascendingUnitNames ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context25.next = 9;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 9:\n querySnapshot = _context25.sent;\n units = [];\n querySnapshot.forEach(function (doc) {\n units.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context25.abrupt(\"return\", units);\n case 15:\n _context25.prev = 15;\n _context25.t0 = _context25[\"catch\"](0);\n console.log(\"Error retrieving units by hospitalId: \", _context25.t0);\n throw _context25.t0;\n case 19:\n case \"end\":\n return _context25.stop();\n }\n }, _callee25, null, [[0, 15]]);\n }));\n}\nfunction getImprovementWorksForUser(userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {\n var q, querySnapshot, improvementWorks, _iterator, _step, _doc, improvementWorkId, improvementWorkDoc;\n return _regeneratorRuntime().wrap(function _callee26$(_context26) {\n while (1) switch (_context26.prev = _context26.next) {\n case 0:\n _context26.prev = 0;\n console.log(\"Getting improvementworks for user: \", userHsaId);\n // Query the userImprovementWork collection for relations involving this user\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(userImprovementWorkCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)('userHsaId', '==', userHsaId));\n _context26.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 5:\n querySnapshot = _context26.sent;\n // Fetch each related improvementWork document\n improvementWorks = [];\n _iterator = _createForOfIteratorHelper(querySnapshot.docs);\n _context26.prev = 8;\n _iterator.s();\n case 10:\n if ((_step = _iterator.n()).done) {\n _context26.next = 19;\n break;\n }\n _doc = _step.value;\n improvementWorkId = _doc.data().improvementWorkId;\n _context26.next = 15;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 15:\n improvementWorkDoc = _context26.sent;\n improvementWorks.push(improvementWorkDoc);\n case 17:\n _context26.next = 10;\n break;\n case 19:\n _context26.next = 24;\n break;\n case 21:\n _context26.prev = 21;\n _context26.t0 = _context26[\"catch\"](8);\n _iterator.e(_context26.t0);\n case 24:\n _context26.prev = 24;\n _iterator.f();\n return _context26.finish(24);\n case 27:\n return _context26.abrupt(\"return\", improvementWorks);\n case 30:\n _context26.prev = 30;\n _context26.t1 = _context26[\"catch\"](0);\n console.error(\"Error getting improvement works for user: \", _context26.t1);\n throw _context26.t1;\n case 34:\n case \"end\":\n return _context26.stop();\n }\n }, _callee26, null, [[0, 30], [8, 21, 24, 27]]);\n }));\n}\nfunction getUsersForImprovementWork(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {\n var q, querySnapshot, users, _iterator2, _step2, _doc2, userHsaId, userDoc;\n return _regeneratorRuntime().wrap(function _callee27$(_context27) {\n while (1) switch (_context27.prev = _context27.next) {\n case 0:\n _context27.prev = 0;\n console.log(\"Getting users for improvementwork: \", improvementWorkId);\n // Query the userImprovementWork collection for relations involving this improvementWork\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(userImprovementWorkCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)('improvementWorkId', '==', improvementWorkId));\n _context27.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 5:\n querySnapshot = _context27.sent;\n // Fetch each related user document\n users = [];\n _iterator2 = _createForOfIteratorHelper(querySnapshot.docs);\n _context27.prev = 8;\n _iterator2.s();\n case 10:\n if ((_step2 = _iterator2.n()).done) {\n _context27.next = 19;\n break;\n }\n _doc2 = _step2.value;\n userHsaId = _doc2.data().userHsaId;\n _context27.next = 15;\n return getObjectById(\"users\", userHsaId);\n case 15:\n userDoc = _context27.sent;\n users.push(userDoc);\n case 17:\n _context27.next = 10;\n break;\n case 19:\n _context27.next = 24;\n break;\n case 21:\n _context27.prev = 21;\n _context27.t0 = _context27[\"catch\"](8);\n _iterator2.e(_context27.t0);\n case 24:\n _context27.prev = 24;\n _iterator2.f();\n return _context27.finish(24);\n case 27:\n return _context27.abrupt(\"return\", users);\n case 30:\n _context27.prev = 30;\n _context27.t1 = _context27[\"catch\"](0);\n console.error(\"Error getting users for improvementWork: \", _context27.t1);\n throw _context27.t1;\n case 34:\n case \"end\":\n return _context27.stop();\n }\n }, _callee27, null, [[0, 30], [8, 21, 24, 27]]);\n }));\n}\n// export getters to be able to use in other files\n\n////////////////////////////////////DELETING/////////////////////////////////////////////\n// delete an instance of a type\nfunction deleteInstance(docType, docId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee28$(_context28) {\n while (1) switch (_context28.prev = _context28.next) {\n case 0:\n _context28.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context28.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(docRef);\n case 4:\n console.log(\"\".concat(docType, \" deleted successfully.\"));\n _context28.next = 11;\n break;\n case 7:\n _context28.prev = 7;\n _context28.t0 = _context28[\"catch\"](0);\n console.error(\"Error deleting \".concat(docType, \":\"), _context28.t0);\n throw _context28.t0;\n case 11:\n case \"end\":\n return _context28.stop();\n }\n }, _callee28, null, [[0, 7]]);\n }));\n}\n// delete all instances of a type\nfunction deleteAllDocumentsInCollection(collectionName) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {\n var _this = this;\n var collectionRef, snapshot, deletePromises;\n return _regeneratorRuntime().wrap(function _callee30$(_context30) {\n while (1) switch (_context30.prev = _context30.next) {\n case 0:\n _context30.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionName);\n _context30.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n snapshot = _context30.sent;\n // Delete all documents in the collection\n deletePromises = snapshot.docs.map(function (doc) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {\n return _regeneratorRuntime().wrap(function _callee29$(_context29) {\n while (1) switch (_context29.prev = _context29.next) {\n case 0:\n _context29.next = 2;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(doc.ref);\n case 2:\n case \"end\":\n return _context29.stop();\n }\n }, _callee29);\n }));\n });\n _context30.next = 8;\n return Promise.all(deletePromises);\n case 8:\n console.log(\"All documents in the \".concat(collectionName, \" collection deleted successfully.\"));\n _context30.next = 15;\n break;\n case 11:\n _context30.prev = 11;\n _context30.t0 = _context30[\"catch\"](0);\n console.error(\"Error deleting all documents in \".concat(collectionName, \":\"), _context30.t0);\n throw _context30.t0;\n case 15:\n case \"end\":\n return _context30.stop();\n }\n }, _callee30, null, [[0, 11]]);\n }));\n}\n////////////////////////////////////UPDATING/////////////////////////////////////////////\n// update a field in an instance\nfunction updateInstance(docType, docId, updates) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee31$(_context31) {\n while (1) switch (_context31.prev = _context31.next) {\n case 0:\n _context31.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context31.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(docRef, updates);\n case 4:\n console.log(\"\".concat(docType, \" updated successfully.\"));\n _context31.next = 11;\n break;\n case 7:\n _context31.prev = 7;\n _context31.t0 = _context31[\"catch\"](0);\n console.error(\"Error updating \".concat(docType, \":\"), _context31.t0);\n throw _context31.t0;\n case 11:\n case \"end\":\n return _context31.stop();\n }\n }, _callee31, null, [[0, 7]]);\n }));\n}\n// changes the ongoing status of an improvement work. if ongoing it is paused, if if paused onging.\n// user must be a manager\nfunction startOrPauseImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee32$(_context32) {\n while (1) switch (_context32.prev = _context32.next) {\n case 0:\n _context32.prev = 0;\n _context32.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context32.sent;\n _context32.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context32.sent;\n if (!(!user || !user.manager)) {\n _context32.next = 11;\n break;\n }\n throw new Error(\"User can't change improvementWork status\");\n case 11:\n if (!improvementWork) {\n _context32.next = 18;\n break;\n }\n update = {\n ongoing: !improvementWork.ongoing\n };\n _context32.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n _context32.next = 19;\n break;\n case 18:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n case 19:\n _context32.next = 25;\n break;\n case 21:\n _context32.prev = 21;\n _context32.t0 = _context32[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context32.t0);\n throw _context32.t0;\n case 25:\n case \"end\":\n return _context32.stop();\n }\n }, _callee32, null, [[0, 21]]);\n }));\n}\nfunction changePatientRiskLevel(userId, improvementWorkId, patientRiskLevel) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee33$(_context33) {\n while (1) switch (_context33.prev = _context33.next) {\n case 0:\n _context33.prev = 0;\n _context33.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context33.sent;\n _context33.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context33.sent;\n if (!(!user || !user.manager)) {\n _context33.next = 11;\n break;\n }\n throw new Error(\"User can't change patientRiskLevel in improvement work\");\n case 11:\n if (!improvementWork) {\n _context33.next = 18;\n break;\n }\n update = {\n patientRiskLevel: patientRiskLevel\n };\n _context33.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n _context33.next = 19;\n break;\n case 18:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n case 19:\n _context33.next = 25;\n break;\n case 21:\n _context33.prev = 21;\n _context33.t0 = _context33[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context33.t0);\n throw _context33.t0;\n case 25:\n case \"end\":\n return _context33.stop();\n }\n }, _callee33, null, [[0, 21]]);\n }));\n}\n// finalizes the improvement work. ongoing is set to false.\n// user must be a manager\nfunction finalizeImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {\n var user, update;\n return _regeneratorRuntime().wrap(function _callee34$(_context34) {\n while (1) switch (_context34.prev = _context34.next) {\n case 0:\n _context34.prev = 0;\n _context34.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context34.sent;\n if (!(!user || !user.manager)) {\n _context34.next = 8;\n break;\n }\n throw new Error(\"User can't finalize improvementWork status\");\n case 8:\n update = {\n completed: true,\n ongoing: false\n };\n _context34.next = 11;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 11:\n _context34.next = 16;\n break;\n case 13:\n _context34.prev = 13;\n _context34.t0 = _context34[\"catch\"](0);\n console.log(_context34.t0);\n case 16:\n case \"end\":\n return _context34.stop();\n }\n }, _callee34, null, [[0, 13]]);\n }));\n}\n\n//////////////////////////////// for later sprint\n//function add_upvotes\n//function add_notes\n//function add_intrested_users\n\n//# sourceURL=webpack://c3/./client/Database/database.js?"); /***/ }), @@ -106,7 +106,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \***************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n/*\n//SAMPLES, TO BE REPLACED BY DB\nconst sampleUnits: Unit[] = [\n {\n ID: \"1\",\n hospital_ID: \"1\",\n name: \"Akuten\"\n },\n\n {\n ID: \"2\",\n hospital_ID: \"1\",\n name: \"BB\"\n },\n {\n ID: \"3\",\n hospital_ID: \"1\",\n name: \"Onkolog\"\n },\n\n\n];\n\nconst unitNameLookup: Record<string, string> = {};\nsampleUnits.forEach((unit) => {\n unitNameLookup[unit.ID] = unit.name;\n});\n*/\n/*\nconst sampleProjects: Project[] = [\n {\n id: \"1\",\n name: \"Birthing of a Child\",\n current_stage: \"In Progress\",\n content: \"This is project 1.\",\n unitId: \"2\",\n dateStarted: new Date(\"2023-01-15\"),\n },\n {\n id: \"2\",\n name: \"How to save a life\",\n current_stage: \"Completed\",\n content: \"This is project 2.\",\n unitId: \"1\",\n dateStarted: new Date(\"2023-02-20\"),\n },\n {\n id: \"3\",\n name: \"BB tutorial\",\n current_stage: \"Completed\",\n content: \"This is project 3.\",\n unitId: \"2\",\n dateStarted: new Date(\"2023-06-05\"),\n },\n {\n id: \"4\",\n name: \"Cancerbehandling 101\",\n current_stage: \"Completed\",\n content: \"This is project 4.\",\n unitId: \"3\",\n dateStarted: new Date(\"2023-10-24\"),\n },\n];\n\n\n\nsampleProjects.sort((a,b) => b.dateStarted.getTime() - a.dateStarted.getTime()); //SORTING THE PROJECTS FROM NEWEST TO OLDEST\n*/\nfunction getCompletedProjects() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var CompletedProjects;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({\n completed: true\n });\n case 2:\n CompletedProjects = _context.sent;\n return _context.abrupt(\"return\", CompletedProjects);\n case 4:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\n//let completedImprovmentWorks = await getImprovementWorks({});\n//TO MAKE DATE APPEAR NICELY\nfunction formatDate(timeStamp) {\n var date = timeStamp.toDate();\n var day = String(date.getDate()).toString();\n var month = String(date.getMonth() + 1).toString(); // Adding 1 because months are zero-based\n var year = String(date.getFullYear()).toString();\n if (parseInt(month, 10) < 10) {\n return \"\".concat(day, \"/0\").concat(month, \"/\").concat(year);\n }\n return \"\".concat(day, \"/\").concat(month, \"/\").concat(year);\n}\n//TO CREATE GRID HTML ELEMENT OF PROJECTS \nfunction createGridRow(project) {\n var row = document.createElement(\"div\");\n row.className = \"grid-row\";\n var unitName = project.unitId || 'Unknown Unit';\n row.innerHTML = \"\\n <div class=\\\"column\\\">\".concat(project.name, \"</div>\\n <div class=\\\"column\\\">\").concat(unitName, \"</div>\\n <div class=\\\"column\\\">\").concat(formatDate(project.dateStarted), \"</div>\\n <div class=\\\"column\\\">Link-placeholder</div>\\n \");\n return row;\n}\n//TO ADD GRID ELEMENTS TO GRID-CONTAINER\nfunction addGridRows() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var gridContainer, projects;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n gridContainer = document.getElementById(\"grid-container\");\n _context2.next = 3;\n return getCompletedProjects();\n case 3:\n projects = _context2.sent;\n console.log(projects);\n projects.forEach(function (project) {\n var row = createGridRow(project);\n if (gridContainer != null) {\n gridContainer.appendChild(row);\n }\n });\n /*\n projects.forEach((project) => {\n const row = createGridRow(project);\n if(gridContainer != null) {\n gridContainer.appendChild(row);\n }\n });\n */\n case 6:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nvar departmentDropdown = document.getElementById(\"departmentDropdown\"); //INSTANCING THE FILTER HTLM ELEMENTS\nvar dateDropdown = document.getElementById(\"dateDropdown\");\nvar searchInput = document.getElementById(\"searchInput\");\nvar selectedDepartment = \"all\";\nvar selectedDateFilter = \"newest\";\nvar searchQuery;\n//TO MAKE DEPARTMENTDROPDOWN CONTAIN ALL THE UNITS FROM DB\n/*\nasync function fillDropdown() {\nsampleUnits.forEach((unit) => {\n const option = document.createElement(\"option\");\n option.value = unit.ID;\n option.textContent = unit.name;\n //departmentDropdown.appendChild(option);\n});\n}\n*/\n/*\n//FILTERING BY DEPARTMENT AND DATE\nfunction filterProjects(selectedDepartment: string, selectedDateFilter: string, searchQuery: String) {\n\n if(selectedDateFilter == \"oldest\") { //FILTER BY DATE\n sampleProjects.sort((a,b) => a.dateStarted.getTime() - b.dateStarted.getTime());\n }\n else {\n sampleProjects.sort((a,b) => b.dateStarted.getTime() - a.dateStarted.getTime());\n }\n\n let filteredProjects = sampleProjects; //FILTER BY DEPARTMENT\n if (selectedDepartment !== \"all\") {\n filteredProjects = filteredProjects.filter((project) => project.unitId === selectedDepartment);\n }\n\n if(searchQuery) { //SEARCH\n filteredProjects = filteredProjects.filter((project) =>\n project.name.toLowerCase().indexOf(searchQuery.toLowerCase()) !== -1\n );\n }\n\n if(gridContainer != null) { //PRINTING TO THE GRID\n gridContainer.innerHTML = ''; //CLEAR THE GRID\n filteredProjects.forEach((project) => {\n const row = createGridRow(project);\n if (gridContainer) {\n gridContainer.appendChild(row);\n }\n });\n}\n\n}\n*/\n//EVENT-LISTENERERS\n/*\ndepartmentDropdown.addEventListener(\"change\", () => {\n selectedDepartment = departmentDropdown.value;\n\n filterProjects(selectedDepartment, selectedDateFilter, searchQuery);\n});\n\ndateDropdown.addEventListener(\"change\", () => {\n selectedDateFilter = dateDropdown.value;\n filterProjects(selectedDepartment,selectedDateFilter, searchQuery);\n})\n\nsearchInput.addEventListener(\"input\", () => {\n searchQuery = searchInput.value.trim();\n filterProjects(selectedDepartment, selectedDateFilter, searchQuery);\n})\n\n*/\nfunction loadPage() {\n var container = document.querySelector('#container-fluid');\n if (!container) return; // Stop if the container isn't found\n fetch('Knowledgebank/completedProjects.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.maincontainer');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n //fillDropdown();\n addGridRows();\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n}\n\n//# sourceURL=webpack://c3/./client/KnowledgeBank/completedProjects.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\nfunction getCompletedProjects() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var CompletedProjects;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({\n completed: true\n });\n case 2:\n CompletedProjects = _context.sent;\n return _context.abrupt(\"return\", CompletedProjects);\n case 4:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\n//TO MAKE DATE APPEAR NICELY\nfunction formatDate(timeStamp) {\n var date = timeStamp.toDate();\n var day = String(date.getDate()).toString();\n var month = String(date.getMonth() + 1).toString(); // Adding 1 because months are zero-based\n var year = String(date.getFullYear()).toString();\n if (parseInt(month, 10) < 10) {\n return \"\".concat(day, \"/0\").concat(month, \"/\").concat(year);\n }\n return \"\".concat(day, \"/\").concat(month, \"/\").concat(year);\n}\n//TO CREATE GRID HTML ELEMENT OF PROJECTS \nfunction createGridRow(project) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var unit, row, unitName;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", project.unitId);\n case 2:\n unit = _context2.sent;\n row = document.createElement(\"div\");\n row.className = \"grid-row\";\n unitName = \"Unspecified Unit\";\n if (unit) {\n unitName = unit.name;\n }\n row.innerHTML = \"\\n <div class=\\\"column\\\">\".concat(project.name, \"</div>\\n <div class=\\\"column\\\">\").concat(unitName, \"</div>\\n <div class=\\\"column\\\">\").concat(formatDate(project.dateStarted), \"</div>\\n <div class=\\\"column\\\">Link-placeholder</div>\\n \");\n return _context2.abrupt(\"return\", row);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\n//TO ADD GRID ELEMENTS TO GRID-CONTAINER\nfunction addGridRows() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var _this = this;\n var gridContainer, projects;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n gridContainer = document.getElementById(\"grid-container\");\n _context4.next = 3;\n return getCompletedProjects();\n case 3:\n projects = _context4.sent;\n console.log(projects);\n projects.forEach(function (project) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var row;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n row = createGridRow(project);\n if (!(gridContainer != null)) {\n _context3.next = 7;\n break;\n }\n _context3.t0 = gridContainer;\n _context3.next = 5;\n return row;\n case 5:\n _context3.t1 = _context3.sent;\n _context3.t0.appendChild.call(_context3.t0, _context3.t1);\n case 7:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n case 6:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n}\nfunction fillDropdown() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var departmentDropdown, units;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n departmentDropdown = document.getElementById(\"departmentDropdown\");\n _context5.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({});\n case 3:\n units = _context5.sent;\n console.log(units);\n units.forEach(function (unit) {\n var option = document.createElement(\"option\");\n option.value = unit.Id;\n option.textContent = unit.name;\n departmentDropdown.appendChild(option);\n });\n case 6:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\n//FILTERING BY DEPARTMENT AND DATE\nfunction filterProjects(selectedDepartment, selectedDateFilter, searchQuery) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var _this2 = this;\n var projects, filteredProjects, gridContainer;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.next = 2;\n return getCompletedProjects();\n case 2:\n projects = _context7.sent;\n if (selectedDateFilter == \"oldest\") {\n //FILTER BY DATE\n projects.sort(function (a, b) {\n return a.dateStarted.getTime() - b.dateStarted.getTime();\n });\n } else {\n projects.sort(function (a, b) {\n return b.dateStarted.getTime() - a.dateStarted.getTime();\n });\n }\n filteredProjects = projects; //FILTER BY DEPARTMENT\n if (selectedDepartment !== \"all\") {\n filteredProjects = filteredProjects.filter(function (project) {\n return project.unitId === selectedDepartment;\n });\n }\n if (searchQuery) {\n //SEARCH\n filteredProjects = filteredProjects.filter(function (project) {\n return project.name.toLowerCase().indexOf(searchQuery.toLowerCase()) !== -1;\n });\n }\n gridContainer = document.getElementById(\"grid-container\");\n if (gridContainer != null) {\n //PRINTING TO THE GRID\n gridContainer.innerHTML = ''; //CLEAR THE GRID\n filteredProjects.forEach(function (project) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var row;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n row = createGridRow(project);\n if (!gridContainer) {\n _context6.next = 7;\n break;\n }\n _context6.t0 = gridContainer;\n _context6.next = 5;\n return row;\n case 5:\n _context6.t1 = _context6.sent;\n _context6.t0.appendChild.call(_context6.t0, _context6.t1);\n case 7:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n });\n }\n case 9:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\n//EVENT-LISTENERERS\n/*\ndepartmentDropdown.addEventListener(\"change\", () => {\n selectedDepartment = departmentDropdown.value;\n\n filterProjects(selectedDepartment, selectedDateFilter, searchQuery);\n});\n/*\ndateDropdown.addEventListener(\"change\", () => {\n selectedDateFilter = dateDropdown.value;\n filterProjects(selectedDepartment,selectedDateFilter, searchQuery);\n})\n\nsearchInput.addEventListener(\"input\", () => {\n searchQuery = searchInput.value.trim();\n filterProjects(selectedDepartment, selectedDateFilter, searchQuery);\n})\n\n*/\nfunction loadPage() {\n var container = document.querySelector('#container-fluid');\n if (!container) return; // Stop if the container isn't found\n fetch('Knowledgebank/completedProjects.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.maincontainer');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n var dateDropdown = document.getElementById(\"dateDropdown\");\n var searchInput = document.getElementById(\"searchInput\");\n var selectedDepartment = \"all\";\n var selectedDateFilter = \"newest\";\n var searchQuery;\n fillDropdown();\n addGridRows();\n console.log(getCompletedProjects());\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n}\n\n//# sourceURL=webpack://c3/./client/KnowledgeBank/completedProjects.js?"); /***/ }), diff --git a/client/dist/currentProjects.bundle.js b/client/dist/currentProjects.bundle.js index 976efe25161a55ef0c590b522b0478fba01e4c1d..8a7f2ce4aab309755daf756aecce2573bfa763a1 100644 --- a/client/dist/currentProjects.bundle.js +++ b/client/dist/currentProjects.bundle.js @@ -106,7 +106,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \*************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addDocumentToImprovementWork: () => (/* binding */ addDocumentToImprovementWork),\n/* harmony export */ addMemberToImprovementWork: () => (/* binding */ addMemberToImprovementWork),\n/* harmony export */ addMemberToTask: () => (/* binding */ addMemberToTask),\n/* harmony export */ addNoteToUser: () => (/* binding */ addNoteToUser),\n/* harmony export */ auth: () => (/* binding */ auth),\n/* harmony export */ changePatientRiskLevel: () => (/* binding */ changePatientRiskLevel),\n/* harmony export */ createComment: () => (/* binding */ createComment),\n/* harmony export */ createHospital: () => (/* binding */ createHospital),\n/* harmony export */ createImprovementWork: () => (/* binding */ createImprovementWork),\n/* harmony export */ createSuggestion: () => (/* binding */ createSuggestion),\n/* harmony export */ createTaskOnImprovementWork: () => (/* binding */ createTaskOnImprovementWork),\n/* harmony export */ createUnit: () => (/* binding */ createUnit),\n/* harmony export */ createUser: () => (/* binding */ createUser),\n/* harmony export */ createdDocumentInKnowledgeBank: () => (/* binding */ createdDocumentInKnowledgeBank),\n/* harmony export */ db: () => (/* binding */ db),\n/* harmony export */ deleteAllDocumentsInCollection: () => (/* binding */ deleteAllDocumentsInCollection),\n/* harmony export */ deleteInstance: () => (/* binding */ deleteInstance),\n/* harmony export */ finalizeImprovementWork: () => (/* binding */ finalizeImprovementWork),\n/* harmony export */ getComments: () => (/* binding */ getComments),\n/* harmony export */ getHospitals: () => (/* binding */ getHospitals),\n/* harmony export */ getImprovementWorks: () => (/* binding */ getImprovementWorks),\n/* harmony export */ getObject: () => (/* binding */ getObject),\n/* harmony export */ getObjectById: () => (/* binding */ getObjectById),\n/* harmony export */ getSuggestions: () => (/* binding */ getSuggestions),\n/* harmony export */ getTasks: () => (/* binding */ getTasks),\n/* harmony export */ getUnits: () => (/* binding */ getUnits),\n/* harmony export */ getUsers: () => (/* binding */ getUsers),\n/* harmony export */ startOrPauseImprovementWork: () => (/* binding */ startOrPauseImprovementWork),\n/* harmony export */ updateInstance: () => (/* binding */ updateInstance),\n/* harmony export */ upvoteComment: () => (/* binding */ upvoteComment),\n/* harmony export */ upvoteSuggestion: () => (/* binding */ upvoteSuggestion)\n/* harmony export */ });\n/* harmony import */ var firebase_app__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! firebase/app */ \"./node_modules/firebase/app/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_firestore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! firebase/firestore */ \"./node_modules/firebase/firestore/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_auth__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! firebase/auth */ \"./node_modules/firebase/auth/dist/esm/index.esm.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nvar firebaseConfig = {\n apiKey: \"AIzaSyDqkaVZMr11J4mfnR0auqoQilZyPfyD-x4\",\n authDomain: \"c3solutions-dc109.firebaseapp.com\",\n projectId: \"c3solutions-dc109\",\n storageBucket: \"c3solutions-dc109.appspot.com\",\n messagingSenderId: \"902143402555\",\n appId: \"1:902143402555:web:29213e81de0a0cba38b21e\"\n};\nvar app = (0,firebase_app__WEBPACK_IMPORTED_MODULE_0__.initializeApp)(firebaseConfig);\nvar auth = (0,firebase_auth__WEBPACK_IMPORTED_MODULE_2__.getAuth)();\nvar db = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getFirestore)(app);\nvar userCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\nvar unitCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\nvar improvementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\nvar taskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\nvar hospitalCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\nvar suggestionCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\nvar knowledgeDocumentCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"knowledgeDocument\");\n////////////////////////////////////////Setters///////////////////////////////////////////////////////////////////\n// Function to create user a new user in database\n// takes in userId, unitId, firstname, lastname, email and password as string\n// throws error if transaction failed\nfunction createUser(hsaId, unitId, firstName, lastName, email, manager, uid) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var userRef, unitRef;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, hsaId);\n _context.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(userRef, {\n id: userRef.id,\n uid: uid,\n unitId: unitId,\n firstName: firstName,\n lastName: lastName,\n email: email,\n improvementWorks: [],\n tasks: [],\n manager: manager\n });\n case 4:\n // Atomically add user to unit.\n unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection, unitId);\n _context.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(unitRef, {\n members: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userRef.id)\n });\n case 7:\n _context.next = 12;\n break;\n case 9:\n _context.prev = 9;\n _context.t0 = _context[\"catch\"](0);\n console.log(_context.t0);\n case 12:\n case \"end\":\n return _context.stop();\n }\n }, _callee, null, [[0, 9]]);\n }));\n}\n//Adds a new improvementWork to the database\n// takes in Id, name, currentStage in PDSA, content, unitId refers to as string and if completed as boolean\n// throws error if transaction failed\nfunction createImprovementWork(id, name, currentStage, content,\n// Är detta description bör detta förtydligas. \nunitId, purpose,\n//Bör tas bort motsvaras av p2- mål med projektet\npatientRiskLevel, area,\n// patientRiskLevel: \"Green\" | \"Blue\" | \"Orange\" | \"Red\"\n//Questions in planning stage\np1, p2, p3, p4, p5, p6, p7,\n//Questions in Doing (G) stage\ng1, g2, g3, g4, g5,\n//Questions in stydy stage\ns1, s2, s3,\n//Questions in acting stage\na1, a2, a3, a4) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var improvementWorkRef;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.prev = 0;\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, id);\n _context2.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(improvementWorkRef, {\n id: improvementWorkRef.id,\n currentStage: currentStage,\n name: name,\n content: content,\n purpose: purpose,\n dateStarted: new Date(),\n unitId: unitId,\n completed: false,\n ongoing: false,\n tasks: [],\n members: [],\n patientRiskLevel: patientRiskLevel,\n area: area,\n p1: p1,\n p2: p2,\n p3: p3,\n p4: p4,\n p5: p5,\n p6: p6,\n p7: p7,\n g1: g1,\n g2: g2,\n g3: g3,\n g4: g4,\n g5: g5,\n s1: s1,\n s2: s2,\n s3: s3,\n a1: a1,\n a2: a2,\n a3: a3,\n a4: a4\n });\n case 4:\n _context2.next = 10;\n break;\n case 6:\n _context2.prev = 6;\n _context2.t0 = _context2[\"catch\"](0);\n console.log(\"Error creating improvementWork: \", _context2.t0);\n throw _context2.t0;\n case 10:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, null, [[0, 6]]);\n }));\n}\n//create task to improvementWork\n// takes in improvementWorkId, name, deadline date, start date, stage in PDSA and content as string\n// throws error if transaction failed\nfunction createTaskOnImprovementWork(taskId, improvementWorkId, name, deadlineDate, startDate, stage, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var ref, improvementWorkRef;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.prev = 0;\n ref = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection, taskId);\n _context3.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(ref, {\n id: ref.id,\n improvementWorkId: improvementWorkId,\n name: name,\n deadlineDate: deadlineDate,\n startDate: startDate,\n stage: stage,\n content: content,\n members: []\n });\n case 4:\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, improvementWorkId); // Atomically add task to the tasks array field.\n _context3.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(improvementWorkRef, {\n tasks: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(taskId)\n });\n case 7:\n _context3.next = 13;\n break;\n case 9:\n _context3.prev = 9;\n _context3.t0 = _context3[\"catch\"](0);\n console.log(\"Error creating task: \", _context3.t0);\n throw _context3.t0;\n case 13:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, null, [[0, 9]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction createdDocumentInKnowledgeBank(documentUrl, name) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n _context4.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(knowledgeDocumentCollection);\n _context4.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n name: name\n });\n case 4:\n _context4.next = 10;\n break;\n case 6:\n _context4.prev = 6;\n _context4.t0 = _context4[\"catch\"](0);\n console.log(\"Error adding document: \", _context4.t0);\n throw _context4.t0;\n case 10:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4, null, [[0, 6]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction addDocumentToImprovementWork(documentUrl, name, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var improvementWorkRef, docRef;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n _context5.prev = 0;\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, improvementWorkId);\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkRef, \"documents\");\n _context5.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n timestamp: new Date(),\n name: name\n });\n case 5:\n _context5.next = 11;\n break;\n case 7:\n _context5.prev = 7;\n _context5.t0 = _context5[\"catch\"](0);\n console.log(\"Error adding document: \", _context5.t0);\n throw _context5.t0;\n case 11:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5, null, [[0, 7]]);\n }));\n}\n//add a member to a improvementWork\n// takes in id, users HSAid, improvementWorks id as string and if is owner, is responsible as boolean\n// throws error if transaction failed\nfunction addMemberToImprovementWork(userHsaId, improvementWorkId, isOwner, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var improvementWorkRef, userRef;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n _context6.prev = 0;\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, improvementWorkId); // return;\n // Atomically update the members array in the improvementWork document\n _context6.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(improvementWorkRef, {\n members: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)({\n userHsaId: userHsaId,\n isOwner: isOwner,\n isResponsibleFor: isResponsibleFor\n })\n });\n case 4:\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, userHsaId); // Atomically add improvementWork to user\n _context6.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(userRef, {\n improvementWorks: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)({\n improvementWorkId: improvementWorkId,\n isOwner: isOwner,\n isResponsibleFor: isResponsibleFor\n })\n });\n case 7:\n _context6.next = 13;\n break;\n case 9:\n _context6.prev = 9;\n _context6.t0 = _context6[\"catch\"](0);\n console.log(\"Error adding member: \", _context6.t0);\n throw _context6.t0;\n case 13:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6, null, [[0, 9]]);\n }));\n}\n//create a hospital\n// takes in ID, name as string\n// throws error if transaction failed\nfunction createHospital(hospitalId,\n// should be auto?\nname) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var ref;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.prev = 0;\n ref = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection, hospitalId);\n _context7.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(ref, {\n id: ref.id,\n name: name,\n units: []\n });\n case 4:\n _context7.next = 10;\n break;\n case 6:\n _context7.prev = 6;\n _context7.t0 = _context7[\"catch\"](0);\n console.log(\"Error creating hospital: \", _context7.t0);\n throw _context7.t0;\n case 10:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7, null, [[0, 6]]);\n }));\n}\n//create a unit\n// takes in id, hospitals id and name as string\n// throws error if transaction failed\nfunction createUnit(unitId,\n//should be auto?\nhospitalId, name) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var unitRef, hospitalRef;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n _context8.prev = 0;\n unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection, unitId);\n _context8.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(unitRef, {\n id: unitRef.id,\n hospitalId: hospitalId,\n name: name,\n members: []\n });\n case 4:\n // Atomically add unit to hospital.\n hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection, hospitalId);\n _context8.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(hospitalRef, {\n units: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(unitRef.id)\n });\n case 7:\n _context8.next = 13;\n break;\n case 9:\n _context8.prev = 9;\n _context8.t0 = _context8[\"catch\"](0);\n console.log(\"Error creating unit: \", _context8.t0);\n throw _context8.t0;\n case 13:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8, null, [[0, 9]]);\n }));\n}\n//adds a member to task\n// takes in ID, the added members hsaId, task id as string and if person is responsible as boolean\n// throws error if transaction failed\nfunction addMemberToTask(userHsaId, taskId, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var taskRef, userRef;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n _context9.prev = 0;\n // Atomically add a member to task.\n taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection, taskId);\n _context9.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(taskRef, {\n members: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)({\n userHsaId: userHsaId,\n isResponsibleFor: isResponsibleFor\n })\n });\n case 4:\n // Atomically add a task to user.\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, userHsaId);\n _context9.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(userRef, {\n tasks: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)({\n taskId: taskId,\n isResponsibleFor: isResponsibleFor\n })\n });\n case 7:\n _context9.next = 13;\n break;\n case 9:\n _context9.prev = 9;\n _context9.t0 = _context9[\"catch\"](0);\n console.log(\"Error adding member: \", _context9.t0);\n throw _context9.t0;\n case 13:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9, null, [[0, 9]]);\n }));\n}\n//creates a suggestion\n// takes in ID, the creators hsaId, name, content and the responding unitId as string\n// throws error if transaction failed\nfunction createSuggestion(id, creatorHsaId, name, area, content, purpose, measure, ideas,\n//need: boolean,\nunitId, departmentId, isPublic) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var suggestionRef, commentCollection;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n _context10.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, id);\n _context10.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(suggestionRef, {\n id: suggestionRef.id,\n creatorHsaId: creatorHsaId,\n name: name,\n area: area,\n content: content,\n purpose: purpose,\n measure: measure,\n ideas: ideas,\n //need: need,\n unitId: unitId,\n departmentId: departmentId,\n \"public\": isPublic,\n upvotes: [],\n comments: [],\n dateCreated: new Date()\n });\n case 4:\n _context10.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\");\n case 6:\n commentCollection = _context10.sent;\n _context10.next = 9;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(commentCollection);\n case 9:\n _context10.next = 15;\n break;\n case 11:\n _context10.prev = 11;\n _context10.t0 = _context10[\"catch\"](0);\n console.log(\"Error creating suggestion: \", _context10.t0);\n throw _context10.t0;\n case 15:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10, null, [[0, 11]]);\n }));\n}\n// Upvote a suggestion for a user\n// takes in suggestion id, user HSAid\n// returns error if transaction failed\nfunction upvoteSuggestion(suggestionId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var suggestionRef;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n _context11.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId); // Atomically add a update to the upvote array field.\n _context11.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(suggestionRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 4:\n _context11.next = 10;\n break;\n case 6:\n _context11.prev = 6;\n _context11.t0 = _context11[\"catch\"](0);\n console.log(\"Error upvoting suggestion: \", _context11.t0);\n throw _context11.t0;\n case 10:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11, null, [[0, 6]]);\n }));\n}\n//creates a comment\n// takes in commenters id, suggestion id and content as string\n// throws error if transaction failed\nfunction createComment(\n// change to subcollection\ncommenterHsaId, suggestionId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var suggestionRef, commentCollection, commentRef;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n _context12.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context12.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\");\n case 4:\n commentCollection = _context12.sent;\n _context12.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(commentCollection);\n case 7:\n commentRef = _context12.sent;\n _context12.next = 10;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(commentRef, {\n id: commentRef.id,\n commenterHsaId: commenterHsaId,\n content: content,\n dateCreated: new Date(),\n upvotes: []\n });\n case 10:\n _context12.next = 16;\n break;\n case 12:\n _context12.prev = 12;\n _context12.t0 = _context12[\"catch\"](0);\n console.log(\"Error creating comment: \", _context12.t0);\n throw _context12.t0;\n case 16:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12, null, [[0, 12]]);\n }));\n}\n// Upvote a comment for a user\n// takes in suggestionId, commentId and userId as strings\n// return error if transaction failed\nfunction upvoteComment(suggestionId, commentId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var suggestionRef, commentRef;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n _context13.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n commentRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionRef, \"comment\", commentId); // Atomically add a update to the upvote array field.\n _context13.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(commentRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 5:\n _context13.next = 11;\n break;\n case 7:\n _context13.prev = 7;\n _context13.t0 = _context13[\"catch\"](0);\n console.log(\"Error upvoting comment: \", _context13.t0);\n throw _context13.t0;\n case 11:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13, null, [[0, 7]]);\n }));\n}\n//add a note to a user\n// takes in userHsaId and content as string\n// throws error if transaction failed\nfunction addNoteToUser(userHsaId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var userRef, docRef;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n _context14.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, userHsaId);\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userRef, \"notes\");\n _context14.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n content: content,\n dateCreated: new Date()\n });\n case 5:\n _context14.next = 11;\n break;\n case 7:\n _context14.prev = 7;\n _context14.t0 = _context14[\"catch\"](0);\n console.log(\"Error adding document: \", _context14.t0);\n throw _context14.t0;\n case 11:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14, null, [[0, 7]]);\n }));\n}\n// export to setters to be able to use in other files\n\n//////////////////////////////////////////////GETTERS/////////////////////////////////////////////////////////////////////\n// Get any object\n// input is the database type as a string.\n// output is the whole collection of that type.\nfunction getObject(collectionPath) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n var collectionRef, querySnapshot, result;\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n _context15.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionPath);\n _context15.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n querySnapshot = _context15.sent;\n result = [];\n querySnapshot.forEach(function (doc) {\n result.push(doc.data());\n });\n return _context15.abrupt(\"return\", result);\n case 10:\n _context15.prev = 10;\n _context15.t0 = _context15[\"catch\"](0);\n console.error(\"Error getting collection data\", _context15.t0);\n throw _context15.t0;\n case 14:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15, null, [[0, 10]]);\n }));\n}\n/**\n * Asynchronously retrieves a single document object from the specified collection path and document ID.\n * If the document does not exist, logs a warning and returns null.\n *\n * @param {string} collectionPath - The path to the collection in the database (\"improvementWork\", \"hospital\", \"suggestion\", \"task\", \"unit\", \"users\")\n * @param {string} documentId - The ID of the document to retrieve.\n * @returns {Promise<any|null>} A promise that resolves to the document object if found, or null if not.\n *\n * @throws Will throw an error if there is an issue during retrieval from the database.\n */\nfunction getObjectById(collectionPath, documentId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {\n var docRef, docSnapshot;\n return _regeneratorRuntime().wrap(function _callee16$(_context16) {\n while (1) switch (_context16.prev = _context16.next) {\n case 0:\n _context16.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, collectionPath, documentId);\n _context16.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDoc)(docRef);\n case 4:\n docSnapshot = _context16.sent;\n if (!docSnapshot.exists()) {\n _context16.next = 9;\n break;\n }\n return _context16.abrupt(\"return\", docSnapshot.data());\n case 9:\n console.warn(\"No such document! \".concat(collectionPath, \"/\").concat(documentId));\n return _context16.abrupt(\"return\", null);\n case 11:\n _context16.next = 17;\n break;\n case 13:\n _context16.prev = 13;\n _context16.t0 = _context16[\"catch\"](0);\n console.error(\"Error getting object\", _context16.t0);\n throw _context16.t0;\n case 17:\n case \"end\":\n return _context16.stop();\n }\n }, _callee16, null, [[0, 13]]);\n }));\n}\n/**\n * Asynchronously retrieves comments for a given suggestion.\n *\n * @param {Object} params - The parameters for fetching comments.\n * @param {string} params.suggestionId - The ID of the suggestion to fetch comments for.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - The criterion to sort the comments by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Determines if the sorting should be in ascending order. Defaults to false (descending).\n * @returns {Promise<any[]>} A promise that resolves to an array of comment objects.\n *\n * @throws Will throw an error if the comments cannot be retrieved.\n */\nfunction getComments(_ref) {\n var suggestionId = _ref.suggestionId,\n _ref$sortBy = _ref.sortBy,\n sortBy = _ref$sortBy === void 0 ? \"dateCreated\" : _ref$sortBy,\n _ref$ascending = _ref.ascending,\n ascending = _ref$ascending === void 0 ? false : _ref$ascending;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {\n var suggestionRef, commentsQuery, commentsSnapshot, comments;\n return _regeneratorRuntime().wrap(function _callee17$(_context17) {\n while (1) switch (_context17.prev = _context17.next) {\n case 0:\n _context17.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, \"suggestionCollection\", suggestionId);\n commentsQuery = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\"), (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n _context17.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(commentsQuery);\n case 5:\n commentsSnapshot = _context17.sent;\n comments = [];\n commentsSnapshot.forEach(function (doc) {\n comments.push(doc.data());\n });\n return _context17.abrupt(\"return\", comments);\n case 11:\n _context17.prev = 11;\n _context17.t0 = _context17[\"catch\"](0);\n console.error(\"Error getting comments for suggestion: \", _context17.t0);\n throw _context17.t0;\n case 15:\n case \"end\":\n return _context17.stop();\n }\n }, _callee17, null, [[0, 11]]);\n }));\n}\n//Filtering suggestions on unitId AND creatorHsaId\n//Sort suggestions on dateCreated OR upvotes\n/**\n * Asynchronously retrieves an array of suggestions from the database, with various filters and sorting options.\n *\n * @param {Object} params - The parameters for filtering and sorting suggestions.\n * @param {string} [params.id] - Optional ID to filter suggestions by a specific identifier.\n * @param {string} [params.creatorHsaId] - Optional HSA ID to filter suggestions by the creator's HSA ID.\n * @param {string} [params.unitId] - Optional unit ID to filter suggestions by a specific unit.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - Criterion to sort the suggestions by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Flag indicating if sorting should be ascending. Defaults to false (descending order).\n * @param {boolean} [params.isPublic=true] - Flag indicating whether to filter for public suggestions. Defaults to true.\n * @returns {Promise<any[]>} A promise that resolves to an array of suggestion objects.\n *\n * @throws Will throw an error if there is an issue retrieving suggestions.\n */\nfunction getSuggestions(_ref2) {\n var id = _ref2.id,\n creatorHsaId = _ref2.creatorHsaId,\n unitId = _ref2.unitId,\n _ref2$sortBy = _ref2.sortBy,\n sortBy = _ref2$sortBy === void 0 ? \"dateCreated\" : _ref2$sortBy,\n _ref2$ascending = _ref2.ascending,\n ascending = _ref2$ascending === void 0 ? false : _ref2$ascending,\n _ref2$isPublic = _ref2.isPublic,\n isPublic = _ref2$isPublic === void 0 ? true : _ref2$isPublic;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {\n var collectionRef, constraints, q, querySnapshot, suggestions;\n return _regeneratorRuntime().wrap(function _callee18$(_context18) {\n while (1) switch (_context18.prev = _context18.next) {\n case 0:\n _context18.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (creatorHsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"creatorHsaId\", \"==\", creatorHsaId));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"public\", \"==\", isPublic));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context18.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 11:\n querySnapshot = _context18.sent;\n suggestions = [];\n querySnapshot.forEach(function (doc) {\n suggestions.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context18.abrupt(\"return\", suggestions);\n case 17:\n _context18.prev = 17;\n _context18.t0 = _context18[\"catch\"](0);\n console.log(\"Error retrieving suggestions by department: \", _context18.t0);\n throw _context18.t0;\n case 21:\n case \"end\":\n return _context18.stop();\n }\n }, _callee18, null, [[0, 17]]);\n }));\n}\n/**\n * Asynchronously searches for hospital documents in the database.\n * It can filter the results by the hospital's name, ID, or both.\n * If no parameters are provided, it retrieves all hospitals.\n *\n * @param {Object} params - An object containing the search parameters.\n * @param {string} [params.hospitalName] - Optional name of the hospital to filter the search.\n * @param {string} [params.hospitalId] - Optional unique identifier of the hospital to filter the search.\n * @returns {Promise<any[]>} A promise that resolves to an array of hospital objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getHospitals(_ref3) {\n var hospitalName = _ref3.hospitalName,\n hospitalId = _ref3.hospitalId;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {\n var collectionRef, constraints, q, querySnapshot, hospitals;\n return _regeneratorRuntime().wrap(function _callee19$(_context19) {\n while (1) switch (_context19.prev = _context19.next) {\n case 0:\n _context19.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\n constraints = [];\n if (hospitalName) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", hospitalName));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hospitalId));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context19.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context19.sent;\n hospitals = [];\n querySnapshot.forEach(function (doc) {\n hospitals.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context19.abrupt(\"return\", hospitals);\n case 14:\n _context19.prev = 14;\n _context19.t0 = _context19[\"catch\"](0);\n console.log(\"Error retrieving Hospitals\", _context19.t0);\n throw _context19.t0;\n case 18:\n case \"end\":\n return _context19.stop();\n }\n }, _callee19, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of improvement work documents based on various filter criteria.\n * It supports filtering by ID, Nolan stage, unit ID, completion status, ongoing status, and patient risk level.\n * It also supports sorting by the start date of the improvement work in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.id] - Optional identifier to filter the improvement works.\n * @param {string} [params.nolanStage] - Optional Nolan stage to filter the improvement works.\n * @param {string} [params.unitId] - Optional unit ID to filter the improvement works.\n * @param {boolean} [params.completed] - Optional flag to filter the improvement works by their completion status.\n * @param {boolean} [params.ongoing] - Optional flag to filter the improvement works by their ongoing status.\n * @param {string} [params.patientRiskLevel] - Optional patient risk level to filter the improvement works.\n * @param {boolean} [params.ascendingDates=false] - Optional flag for sorting by date in ascending order. Defaults to false.\n * @returns {Promise<any[]>} A promise that resolves to an array of improvement work objects that match the criteria.\n *\n * @throws Will throw an error if there is a problem retrieving the improvement works.\n */\nfunction getImprovementWorks(_ref4) {\n var id = _ref4.id,\n nolanStage = _ref4.nolanStage,\n unitId = _ref4.unitId,\n completed = _ref4.completed,\n ongoing = _ref4.ongoing,\n patientRiskLevel = _ref4.patientRiskLevel,\n _ref4$ascendingDates = _ref4.ascendingDates,\n ascendingDates = _ref4$ascendingDates === void 0 ? false : _ref4$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {\n var collectionRef, constraints, q, querySnapshot, improvementWorks;\n return _regeneratorRuntime().wrap(function _callee20$(_context20) {\n while (1) switch (_context20.prev = _context20.next) {\n case 0:\n _context20.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (nolanStage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"currentStage\", \"==\", nolanStage));\n }\n if (completed != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"completed\", \"==\", completed));\n }\n if (ongoing !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"ongoing\", \"==\", ongoing));\n }\n if (patientRiskLevel) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"patientRiskLevel\", \"==\", patientRiskLevel));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"dateStarted\", ascendingDates ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context20.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 13:\n querySnapshot = _context20.sent;\n improvementWorks = [];\n querySnapshot.forEach(function (doc) {\n improvementWorks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context20.abrupt(\"return\", improvementWorks);\n case 19:\n _context20.prev = 19;\n _context20.t0 = _context20[\"catch\"](0);\n console.log(\"Error retrieving improvementWorks: \", _context20.t0);\n throw _context20.t0;\n case 23:\n case \"end\":\n return _context20.stop();\n }\n }, _callee20, null, [[0, 19]]);\n }));\n}\n/**\n * Asynchronously retrieves user documents from the database based on various filter criteria.\n * It can filter by the Health Savings Account ID (hsaId), unit ID, and unique identifier (uid).\n * Additionally, it can sort the results by first name in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.hsaId] - Optional HSA ID to filter the users.\n * @param {string} [params.unitId] - Optional unit ID to filter the users.\n * @param {boolean} [params.ascendingFirstNames=false] - Optional flag to sort by first names in ascending order. Defaults to false (descending order).\n * @param {string} [params.uid] - Optional unique identifier to filter the users.\n * @returns {Promise<any[]>} A promise that resolves to an array of user objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUsers(_ref5) {\n var hsaId = _ref5.hsaId,\n unitId = _ref5.unitId,\n _ref5$ascendingFirstN = _ref5.ascendingFirstNames,\n ascendingFirstNames = _ref5$ascendingFirstN === void 0 ? false : _ref5$ascendingFirstN,\n uid = _ref5.uid;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {\n var collectionRef, constraints, q, querySnapshot, users;\n return _regeneratorRuntime().wrap(function _callee21$(_context21) {\n while (1) switch (_context21.prev = _context21.next) {\n case 0:\n _context21.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\n constraints = [];\n if (hsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hsaId));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (uid) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"uid\", \"==\", uid));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"firstName\", ascendingFirstNames ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context21.next = 10;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 10:\n querySnapshot = _context21.sent;\n users = [];\n querySnapshot.forEach(function (doc) {\n users.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context21.abrupt(\"return\", users);\n case 16:\n _context21.prev = 16;\n _context21.t0 = _context21[\"catch\"](0);\n console.log(\"Error retrieving users by department: \", _context21.t0);\n throw _context21.t0;\n case 20:\n case \"end\":\n return _context21.stop();\n }\n }, _callee21, null, [[0, 16]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of task documents from the database based on several filter and sorting criteria.\n * Filters include task ID, user ID and their responsibility status, and related improvement work ID.\n * Results can be sorted by date either in ascending or descending order.\n *\n * @param {Object} params - Parameters to filter and sort the task results.\n * @param {string} [params.taskId] - Optional task ID to filter the tasks.\n * @param {string} [params.userId] - Optional user ID to identify tasks related to a user.\n * @param {boolean} [params.isResponsibleFor] - Optional flag to filter tasks where the user is marked as responsible.\n * @param {string} [params.improvementWorkId] - Optional improvement work ID to filter tasks related to a specific improvement work.\n * @param {boolean} [params.ascendingDates=false] - Optional flag to sort tasks by date in ascending order; defaults to descending order.\n * @returns {Promise<any[]>} A promise that resolves to an array of task objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getTasks(_ref6) {\n var taskId = _ref6.taskId,\n userId = _ref6.userId,\n isResponsibleFor = _ref6.isResponsibleFor,\n improvementWorkId = _ref6.improvementWorkId,\n _ref6$ascendingDates = _ref6.ascendingDates,\n ascendingDates = _ref6$ascendingDates === void 0 ? false : _ref6$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {\n var collectionRef, constraints, q, querySnapshot, tasks;\n return _regeneratorRuntime().wrap(function _callee22$(_context22) {\n while (1) switch (_context22.prev = _context22.next) {\n case 0:\n _context22.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\n constraints = [];\n if (taskId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", taskId));\n }\n if (userId && isResponsibleFor !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"members\", \"array-contains\", {\n userHsaId: userId,\n isResponsibleFor: isResponsibleFor\n }));\n }\n if (improvementWorkId != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"startDate\", ascendingDates ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context22.next = 9;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 9:\n querySnapshot = _context22.sent;\n tasks = [];\n querySnapshot.forEach(function (doc) {\n tasks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context22.abrupt(\"return\", tasks);\n case 15:\n _context22.prev = 15;\n _context22.t0 = _context22[\"catch\"](0);\n console.log(\"Error retrieving task by department: \", _context22.t0);\n throw _context22.t0;\n case 19:\n case \"end\":\n return _context22.stop();\n }\n }, _callee22, null, [[0, 15]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of unit documents from the database based on various filter criteria.\n * Filters can be applied based on unit ID, hospital ID, and unit name.\n * Additionally, results can be sorted by unit names in ascending or descending order.\n *\n * @param {Object} params - The parameters object containing filter and sorting options.\n * @param {string} [params.unitId] - Optional unit ID to filter the units.\n * @param {string} [params.hospitalId] - Optional hospital ID to filter units within a specific hospital.\n * @param {string} [params.name] - Optional name to filter units by a specific name.\n * @param {boolean} [params.ascendingUnitNames=false] - Optional flag to sort units by name in ascending order, defaults to descending.\n * @returns {Promise<any[]>} A promise that resolves to an array of unit objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUnits(_ref7) {\n var unitId = _ref7.unitId,\n hospitalId = _ref7.hospitalId,\n name = _ref7.name,\n _ref7$ascendingUnitNa = _ref7.ascendingUnitNames,\n ascendingUnitNames = _ref7$ascendingUnitNa === void 0 ? false : _ref7$ascendingUnitNa;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {\n var collectionRef, constraints, q, querySnapshot, units;\n return _regeneratorRuntime().wrap(function _callee23$(_context23) {\n while (1) switch (_context23.prev = _context23.next) {\n case 0:\n _context23.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\n constraints = [];\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", unitId));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"hospitalId\", \"==\", hospitalId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"name\", ascendingUnitNames ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context23.next = 9;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 9:\n querySnapshot = _context23.sent;\n units = [];\n querySnapshot.forEach(function (doc) {\n units.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context23.abrupt(\"return\", units);\n case 15:\n _context23.prev = 15;\n _context23.t0 = _context23[\"catch\"](0);\n console.log(\"Error retrieving units by hospitalId: \", _context23.t0);\n throw _context23.t0;\n case 19:\n case \"end\":\n return _context23.stop();\n }\n }, _callee23, null, [[0, 15]]);\n }));\n}\n//getMembersFilteredAndSorted() -> Get all members of a project (sorted by firstName?)\n// export getters to be able to use in other files\n\n////////////////////////////////////DELETING/////////////////////////////////////////////\n// delete an instance of a type\nfunction deleteInstance(docType, docId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee24$(_context24) {\n while (1) switch (_context24.prev = _context24.next) {\n case 0:\n _context24.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context24.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(docRef);\n case 4:\n console.log(\"\".concat(docType, \" deleted successfully.\"));\n _context24.next = 11;\n break;\n case 7:\n _context24.prev = 7;\n _context24.t0 = _context24[\"catch\"](0);\n console.error(\"Error deleting \".concat(docType, \":\"), _context24.t0);\n throw _context24.t0;\n case 11:\n case \"end\":\n return _context24.stop();\n }\n }, _callee24, null, [[0, 7]]);\n }));\n}\n// delete all instances of a type\nfunction deleteAllDocumentsInCollection(collectionName) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {\n var _this = this;\n var collectionRef, snapshot, deletePromises;\n return _regeneratorRuntime().wrap(function _callee26$(_context26) {\n while (1) switch (_context26.prev = _context26.next) {\n case 0:\n _context26.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionName);\n _context26.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n snapshot = _context26.sent;\n // Delete all documents in the collection\n deletePromises = snapshot.docs.map(function (doc) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {\n return _regeneratorRuntime().wrap(function _callee25$(_context25) {\n while (1) switch (_context25.prev = _context25.next) {\n case 0:\n _context25.next = 2;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(doc.ref);\n case 2:\n case \"end\":\n return _context25.stop();\n }\n }, _callee25);\n }));\n });\n _context26.next = 8;\n return Promise.all(deletePromises);\n case 8:\n console.log(\"All documents in the \".concat(collectionName, \" collection deleted successfully.\"));\n _context26.next = 15;\n break;\n case 11:\n _context26.prev = 11;\n _context26.t0 = _context26[\"catch\"](0);\n console.error(\"Error deleting all documents in \".concat(collectionName, \":\"), _context26.t0);\n throw _context26.t0;\n case 15:\n case \"end\":\n return _context26.stop();\n }\n }, _callee26, null, [[0, 11]]);\n }));\n}\n////////////////////////////////////UPDATING/////////////////////////////////////////////\n// update a field in an instance\nfunction updateInstance(docType, docId, updates) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee27$(_context27) {\n while (1) switch (_context27.prev = _context27.next) {\n case 0:\n _context27.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context27.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(docRef, updates);\n case 4:\n console.log(\"\".concat(docType, \" updated successfully.\"));\n _context27.next = 11;\n break;\n case 7:\n _context27.prev = 7;\n _context27.t0 = _context27[\"catch\"](0);\n console.error(\"Error updating \".concat(docType, \":\"), _context27.t0);\n throw _context27.t0;\n case 11:\n case \"end\":\n return _context27.stop();\n }\n }, _callee27, null, [[0, 7]]);\n }));\n}\n// changes the ongoing status of an improvement work. if ongoing it is paused, if if paused onging.\n// user must be a manager\nfunction startOrPauseImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee28$(_context28) {\n while (1) switch (_context28.prev = _context28.next) {\n case 0:\n _context28.prev = 0;\n _context28.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context28.sent;\n _context28.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context28.sent;\n if (!(!user || !user.manager)) {\n _context28.next = 11;\n break;\n }\n throw new Error(\"User can't change improvementWork status\");\n case 11:\n if (!improvementWork) {\n _context28.next = 18;\n break;\n }\n update = {\n ongoing: !improvementWork.ongoing\n };\n _context28.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n _context28.next = 19;\n break;\n case 18:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n case 19:\n _context28.next = 25;\n break;\n case 21:\n _context28.prev = 21;\n _context28.t0 = _context28[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context28.t0);\n throw _context28.t0;\n case 25:\n case \"end\":\n return _context28.stop();\n }\n }, _callee28, null, [[0, 21]]);\n }));\n}\nfunction changePatientRiskLevel(userId, improvementWorkId, patientRiskLevel) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee29$(_context29) {\n while (1) switch (_context29.prev = _context29.next) {\n case 0:\n _context29.prev = 0;\n _context29.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context29.sent;\n _context29.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context29.sent;\n if (!(!user || !user.manager)) {\n _context29.next = 11;\n break;\n }\n throw new Error(\"User can't change patientRiskLevel in improvement work\");\n case 11:\n if (!improvementWork) {\n _context29.next = 18;\n break;\n }\n update = {\n patientRiskLevel: patientRiskLevel\n };\n _context29.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n _context29.next = 19;\n break;\n case 18:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n case 19:\n _context29.next = 25;\n break;\n case 21:\n _context29.prev = 21;\n _context29.t0 = _context29[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context29.t0);\n throw _context29.t0;\n case 25:\n case \"end\":\n return _context29.stop();\n }\n }, _callee29, null, [[0, 21]]);\n }));\n}\n// finalizes the improvement work. ongoing is set to false.\n// user must be a manager\nfunction finalizeImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {\n var user, update;\n return _regeneratorRuntime().wrap(function _callee30$(_context30) {\n while (1) switch (_context30.prev = _context30.next) {\n case 0:\n _context30.prev = 0;\n _context30.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context30.sent;\n if (!(!user || !user.manager)) {\n _context30.next = 8;\n break;\n }\n throw new Error(\"User can't finalize improvementWork status\");\n case 8:\n update = {\n completed: true,\n ongoing: false\n };\n _context30.next = 11;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 11:\n _context30.next = 16;\n break;\n case 13:\n _context30.prev = 13;\n _context30.t0 = _context30[\"catch\"](0);\n console.log(_context30.t0);\n case 16:\n case \"end\":\n return _context30.stop();\n }\n }, _callee30, null, [[0, 13]]);\n }));\n}\n\n//////////////////////////////// for later sprint\n//function add_upvotes\n//function add_notes\n//function add_intrested_users\n\n//# sourceURL=webpack://c3/./client/Database/database.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addDocumentToImprovementWork: () => (/* binding */ addDocumentToImprovementWork),\n/* harmony export */ addMemberToImprovementWork: () => (/* binding */ addMemberToImprovementWork),\n/* harmony export */ addMemberToTask: () => (/* binding */ addMemberToTask),\n/* harmony export */ addNoteToUser: () => (/* binding */ addNoteToUser),\n/* harmony export */ auth: () => (/* binding */ auth),\n/* harmony export */ changePatientRiskLevel: () => (/* binding */ changePatientRiskLevel),\n/* harmony export */ createComment: () => (/* binding */ createComment),\n/* harmony export */ createHospital: () => (/* binding */ createHospital),\n/* harmony export */ createImprovementWork: () => (/* binding */ createImprovementWork),\n/* harmony export */ createSuggestion: () => (/* binding */ createSuggestion),\n/* harmony export */ createTaskOnImprovementWork: () => (/* binding */ createTaskOnImprovementWork),\n/* harmony export */ createUnit: () => (/* binding */ createUnit),\n/* harmony export */ createUser: () => (/* binding */ createUser),\n/* harmony export */ createdDocumentInKnowledgeBank: () => (/* binding */ createdDocumentInKnowledgeBank),\n/* harmony export */ db: () => (/* binding */ db),\n/* harmony export */ deleteAllDocumentsInCollection: () => (/* binding */ deleteAllDocumentsInCollection),\n/* harmony export */ deleteInstance: () => (/* binding */ deleteInstance),\n/* harmony export */ finalizeImprovementWork: () => (/* binding */ finalizeImprovementWork),\n/* harmony export */ getComments: () => (/* binding */ getComments),\n/* harmony export */ getHospitals: () => (/* binding */ getHospitals),\n/* harmony export */ getImprovementWorkOwner: () => (/* binding */ getImprovementWorkOwner),\n/* harmony export */ getImprovementWorkResponsible: () => (/* binding */ getImprovementWorkResponsible),\n/* harmony export */ getImprovementWorks: () => (/* binding */ getImprovementWorks),\n/* harmony export */ getImprovementWorksForUser: () => (/* binding */ getImprovementWorksForUser),\n/* harmony export */ getObject: () => (/* binding */ getObject),\n/* harmony export */ getObjectById: () => (/* binding */ getObjectById),\n/* harmony export */ getSuggestions: () => (/* binding */ getSuggestions),\n/* harmony export */ getTasks: () => (/* binding */ getTasks),\n/* harmony export */ getUnits: () => (/* binding */ getUnits),\n/* harmony export */ getUsers: () => (/* binding */ getUsers),\n/* harmony export */ getUsersForImprovementWork: () => (/* binding */ getUsersForImprovementWork),\n/* harmony export */ startOrPauseImprovementWork: () => (/* binding */ startOrPauseImprovementWork),\n/* harmony export */ updateInstance: () => (/* binding */ updateInstance),\n/* harmony export */ upvoteComment: () => (/* binding */ upvoteComment),\n/* harmony export */ upvoteSuggestion: () => (/* binding */ upvoteSuggestion)\n/* harmony export */ });\n/* harmony import */ var firebase_app__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! firebase/app */ \"./node_modules/firebase/app/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_firestore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! firebase/firestore */ \"./node_modules/firebase/firestore/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_auth__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! firebase/auth */ \"./node_modules/firebase/auth/dist/esm/index.esm.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nvar firebaseConfig = {\n apiKey: \"AIzaSyDqkaVZMr11J4mfnR0auqoQilZyPfyD-x4\",\n authDomain: \"c3solutions-dc109.firebaseapp.com\",\n projectId: \"c3solutions-dc109\",\n storageBucket: \"c3solutions-dc109.appspot.com\",\n messagingSenderId: \"902143402555\",\n appId: \"1:902143402555:web:29213e81de0a0cba38b21e\"\n};\n/*const firebaseConfig = {\n apiKey: \"AIzaSyBIsZq_yOsJljp1woIxndJO1GkW6soh-g4\",\n authDomain: \"company3-456bb.firebaseapp.com\",\n projectId: \"company3-456bb\",\n storageBucket: \"company3-456bb.appspot.com\",\n messagingSenderId: \"310033686522\",\n appId: \"1:310033686522:web:63198bb0db679c98ee4e43\",\n measurementId: \"G-PFLDQY00DB\"\n};*/\n// const firebaseConfig = {\n// apiKey: \"AIzaSyBIsZq_yOsJljp1woIxndJO1GkW6soh-g4\",\n// authDomain: \"company3-456bb.firebaseapp.com\",\n// projectId: \"company3-456bb\",\n// storageBucket: \"company3-456bb.appspot.com\",\n// messagingSenderId: \"310033686522\",\n// appId: \"1:310033686522:web:63198bb0db679c98ee4e43\",\n// measurementId: \"G-PFLDQY00DB\"\n// };\nvar app = (0,firebase_app__WEBPACK_IMPORTED_MODULE_0__.initializeApp)(firebaseConfig);\nvar auth = (0,firebase_auth__WEBPACK_IMPORTED_MODULE_2__.getAuth)();\nvar db = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getFirestore)(app);\nvar userCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\nvar unitCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\nvar improvementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\nvar taskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\nvar hospitalCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\nvar suggestionCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\nvar knowledgeDocumentCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"knowledgeDocument\");\nvar userImprovementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"userImprovementWork\");\nvar userTaskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"userTask\");\n////////////////////////////////////////Setters///////////////////////////////////////////////////////////////////\n// Function to create user a new user in database\n// takes in userId, unitId, firstname, lastname, email and password as string\n// throws error if transaction failed\nfunction createUser(hsaId, unitId, firstName, lastName, email, manager, uid) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var userRef, unitRef;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, hsaId);\n _context.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(userRef, {\n id: userRef.id,\n uid: uid,\n unitId: unitId,\n firstName: firstName,\n lastName: lastName,\n email: email,\n // TODO Replace with userImprovementWork collection\n improvementWorks: [],\n tasks: [],\n manager: manager\n });\n case 4:\n // Atomically add user to unit.\n unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection, unitId);\n _context.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(unitRef, {\n members: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userRef.id)\n });\n case 7:\n _context.next = 12;\n break;\n case 9:\n _context.prev = 9;\n _context.t0 = _context[\"catch\"](0);\n console.log(_context.t0);\n case 12:\n case \"end\":\n return _context.stop();\n }\n }, _callee, null, [[0, 9]]);\n }));\n}\nfunction createImprovementWork(id, name, currentStage, content,\n// Är detta description bör detta förtydligas. \nunitId, purpose,\n//Bör tas bort motsvaras av p2- mål med projektet\npatientRiskLevel, area,\n//Questions in planning stage\np1, p2, p3, p4, p5, p6, p7,\n//Questions in Doing (G) stage\ng1, g2, g3, g4, g5,\n//Questions in stydy stage\ns1, s2, s3,\n//Questions in acting stage\na1, a2, a3, a4) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var improvementWorkData, improvementWorkRef, _improvementWorkRef;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.prev = 0;\n improvementWorkData = {\n name: name,\n currentStage: currentStage,\n content: content,\n purpose: purpose,\n dateStarted: new Date(),\n unitId: unitId,\n completed: false,\n ongoing: false,\n tasks: [],\n // TODO Remove members array\n members: [],\n patientRiskLevel: patientRiskLevel,\n area: area,\n p1: p1,\n p2: p2,\n p3: p3,\n p4: p4,\n p5: p5,\n p6: p6,\n p7: p7,\n g1: g1,\n g2: g2,\n g3: g3,\n g4: g4,\n g5: g5,\n s1: s1,\n s2: s2,\n s3: s3,\n a1: a1,\n a2: a2,\n a3: a3,\n a4: a4\n };\n if (!id) {\n _context2.next = 8;\n break;\n }\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, id);\n _context2.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(improvementWorkRef, Object.assign({\n id: improvementWorkRef.id\n }, improvementWorkData));\n case 6:\n _context2.next = 11;\n break;\n case 8:\n _improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection);\n _context2.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_improvementWorkRef, improvementWorkData);\n case 11:\n _context2.next = 17;\n break;\n case 13:\n _context2.prev = 13;\n _context2.t0 = _context2[\"catch\"](0);\n console.log(\"Error creating improvementWork: \", _context2.t0);\n throw _context2.t0;\n case 17:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, null, [[0, 13]]);\n }));\n}\nfunction addMemberToTask(userHsaId, taskId, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var relationRef;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.prev = 0;\n relationRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userTaskCollection);\n _context3.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(relationRef, {\n id: relationRef.id,\n userHsaId: userHsaId,\n taskId: taskId,\n isResponsibleFor: isResponsibleFor\n });\n case 4:\n _context3.next = 10;\n break;\n case 6:\n _context3.prev = 6;\n _context3.t0 = _context3[\"catch\"](0);\n console.log(\"Error adding member to task: \", _context3.t0);\n throw _context3.t0;\n case 10:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, null, [[0, 6]]);\n }));\n}\nfunction addMemberToImprovementWork(userHsaId, improvementWorkId, isOwner, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var relationRef;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n _context4.prev = 0;\n relationRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userImprovementWorkCollection);\n _context4.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(relationRef, {\n id: relationRef.id,\n userHsaId: userHsaId,\n improvementWorkId: improvementWorkId,\n isOwner: isOwner,\n isResponsibleFor: isResponsibleFor\n });\n case 4:\n _context4.next = 10;\n break;\n case 6:\n _context4.prev = 6;\n _context4.t0 = _context4[\"catch\"](0);\n console.log(\"Error adding member to improvementWork: \", _context4.t0);\n throw _context4.t0;\n case 10:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4, null, [[0, 6]]);\n }));\n}\nfunction createTaskOnImprovementWork(taskId, improvementWorkId, name, deadlineDate, startDate, stage, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var taskData, taskRef, _taskRef;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n _context5.prev = 0;\n taskData = {\n improvementWorkId: improvementWorkId,\n name: name,\n deadlineDate: deadlineDate,\n startDate: startDate,\n stage: stage,\n content: content,\n members: [] // Initialize with an empty array\n };\n if (!taskId) {\n _context5.next = 8;\n break;\n }\n taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection, taskId);\n _context5.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(taskRef, Object.assign({\n id: taskRef.id\n }, taskData));\n case 6:\n _context5.next = 11;\n break;\n case 8:\n _taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection);\n _context5.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_taskRef, taskData);\n case 11:\n _context5.next = 17;\n break;\n case 13:\n _context5.prev = 13;\n _context5.t0 = _context5[\"catch\"](0);\n console.log(\"Error creating task: \", _context5.t0);\n throw _context5.t0;\n case 17:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5, null, [[0, 13]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction createdDocumentInKnowledgeBank(documentUrl, name) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n _context6.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(knowledgeDocumentCollection);\n _context6.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n name: name\n });\n case 4:\n _context6.next = 10;\n break;\n case 6:\n _context6.prev = 6;\n _context6.t0 = _context6[\"catch\"](0);\n console.log(\"Error adding document: \", _context6.t0);\n throw _context6.t0;\n case 10:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6, null, [[0, 6]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction addDocumentToImprovementWork(documentUrl, name, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var improvementWorkRef, docRef;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.prev = 0;\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, improvementWorkId);\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkRef, \"documents\");\n _context7.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n timestamp: new Date(),\n name: name\n });\n case 5:\n _context7.next = 11;\n break;\n case 7:\n _context7.prev = 7;\n _context7.t0 = _context7[\"catch\"](0);\n console.log(\"Error adding document: \", _context7.t0);\n throw _context7.t0;\n case 11:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7, null, [[0, 7]]);\n }));\n}\nfunction createHospital(hospitalId,\n// should be auto?\nname) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var hospitalData, hospitalRef, _hospitalRef;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n _context8.prev = 0;\n hospitalData = {\n name: name,\n units: []\n };\n if (!hospitalId) {\n _context8.next = 8;\n break;\n }\n hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection, hospitalId);\n _context8.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(hospitalRef, Object.assign({\n id: hospitalRef.id\n }, hospitalData));\n case 6:\n _context8.next = 11;\n break;\n case 8:\n _hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection);\n _context8.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_hospitalRef, hospitalData);\n case 11:\n _context8.next = 17;\n break;\n case 13:\n _context8.prev = 13;\n _context8.t0 = _context8[\"catch\"](0);\n console.log(\"Error creating hospital: \", _context8.t0);\n throw _context8.t0;\n case 17:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8, null, [[0, 13]]);\n }));\n}\nfunction createUnit(unitId,\n//should be auto?\nhospitalId, name) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var unitData, unitRef, _unitRef;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n _context9.prev = 0;\n unitData = {\n hospitalId: hospitalId,\n name: name,\n members: []\n };\n if (!unitId) {\n _context9.next = 8;\n break;\n }\n unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection, unitId);\n _context9.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(unitRef, Object.assign({\n id: unitRef.id\n }, unitData));\n case 6:\n _context9.next = 11;\n break;\n case 8:\n _unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection);\n _context9.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_unitRef, unitData);\n case 11:\n _context9.next = 17;\n break;\n case 13:\n _context9.prev = 13;\n _context9.t0 = _context9[\"catch\"](0);\n console.log(\"Error creating unit: \", _context9.t0);\n throw _context9.t0;\n case 17:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9, null, [[0, 13]]);\n }));\n}\nfunction createSuggestion(id, creatorHsaId, name, area, content, purpose, measure, ideas,\n//need: boolean,\nunitId, departmentId, isPublic) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var suggestionData, suggestionRef, _suggestionRef;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n _context10.prev = 0;\n suggestionData = {\n creatorHsaId: creatorHsaId,\n name: name,\n area: area,\n content: content,\n purpose: purpose,\n measure: measure,\n ideas: ideas,\n //need,\n unitId: unitId,\n departmentId: departmentId,\n \"public\": isPublic,\n upvotes: [],\n comments: [],\n dateCreated: new Date()\n };\n if (!id) {\n _context10.next = 8;\n break;\n }\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, id);\n _context10.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(suggestionRef, Object.assign({\n id: suggestionRef.id\n }, suggestionData));\n case 6:\n _context10.next = 11;\n break;\n case 8:\n _suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection);\n _context10.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_suggestionRef, suggestionData);\n case 11:\n _context10.next = 17;\n break;\n case 13:\n _context10.prev = 13;\n _context10.t0 = _context10[\"catch\"](0);\n console.log(\"Error creating suggestion: \", _context10.t0);\n throw _context10.t0;\n case 17:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10, null, [[0, 13]]);\n }));\n}\n// Upvote a suggestion for a user\n// takes in suggestion id, user HSAid\n// returns error if transaction failed\nfunction upvoteSuggestion(suggestionId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var suggestionRef;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n _context11.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId); // Atomically add a update to the upvote array field.\n _context11.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(suggestionRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 4:\n _context11.next = 10;\n break;\n case 6:\n _context11.prev = 6;\n _context11.t0 = _context11[\"catch\"](0);\n console.log(\"Error upvoting suggestion: \", _context11.t0);\n throw _context11.t0;\n case 10:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11, null, [[0, 6]]);\n }));\n}\n//creates a comment\n// takes in commenters id, suggestion id and content as string\n// throws error if transaction failed\nfunction createComment(\n// change to subcollection\ncommenterHsaId, suggestionId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var suggestionRef, commentCollection, commentRef;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n _context12.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context12.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\");\n case 4:\n commentCollection = _context12.sent;\n _context12.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(commentCollection);\n case 7:\n commentRef = _context12.sent;\n _context12.next = 10;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(commentRef, {\n id: commentRef.id,\n commenterHsaId: commenterHsaId,\n content: content,\n dateCreated: new Date(),\n upvotes: []\n });\n case 10:\n _context12.next = 16;\n break;\n case 12:\n _context12.prev = 12;\n _context12.t0 = _context12[\"catch\"](0);\n console.log(\"Error creating comment: \", _context12.t0);\n throw _context12.t0;\n case 16:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12, null, [[0, 12]]);\n }));\n}\n// Upvote a comment for a user\n// takes in suggestionId, commentId and userId as strings\n// return error if transaction failed\nfunction upvoteComment(suggestionId, commentId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var suggestionRef, commentRef;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n _context13.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n commentRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionRef, \"comment\", commentId); // Atomically add a update to the upvote array field.\n _context13.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(commentRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 5:\n _context13.next = 11;\n break;\n case 7:\n _context13.prev = 7;\n _context13.t0 = _context13[\"catch\"](0);\n console.log(\"Error upvoting comment: \", _context13.t0);\n throw _context13.t0;\n case 11:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13, null, [[0, 7]]);\n }));\n}\n//add a note to a user\n// takes in userHsaId and content as string\n// throws error if transaction failed\nfunction addNoteToUser(userHsaId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var userRef, docRef;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n _context14.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, userHsaId);\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userRef, \"notes\");\n _context14.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n content: content,\n dateCreated: new Date()\n });\n case 5:\n _context14.next = 11;\n break;\n case 7:\n _context14.prev = 7;\n _context14.t0 = _context14[\"catch\"](0);\n console.log(\"Error adding document: \", _context14.t0);\n throw _context14.t0;\n case 11:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14, null, [[0, 7]]);\n }));\n}\n// export to setters to be able to use in other files\n\n//////////////////////////////////////////////GETTERS/////////////////////////////////////////////////////////////////////\n// Get any object\n// input is the database type as a string.\n// output is the whole collection of that type.\nfunction getObject(collectionPath) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n var collectionRef, querySnapshot, result;\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n _context15.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionPath);\n _context15.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n querySnapshot = _context15.sent;\n result = [];\n querySnapshot.forEach(function (doc) {\n result.push(doc.data());\n });\n return _context15.abrupt(\"return\", result);\n case 10:\n _context15.prev = 10;\n _context15.t0 = _context15[\"catch\"](0);\n console.error(\"Error getting collection data\", _context15.t0);\n throw _context15.t0;\n case 14:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15, null, [[0, 10]]);\n }));\n}\n/**\n * Asynchronously retrieves a single document object from the specified collection path and document ID.\n * If the document does not exist, logs a warning and returns null.\n *\n * @param {string} collectionPath - The path to the collection in the database (\"improvementWork\", \"hospital\", \"suggestion\", \"task\", \"unit\", \"users\")\n * @param {string} documentId - The ID of the document to retrieve.\n * @returns {Promise<any|null>} A promise that resolves to the document object if found, or null if not.\n *\n * @throws Will throw an error if there is an issue during retrieval from the database.\n */\nfunction getObjectById(collectionPath, documentId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {\n var docRef, docSnapshot;\n return _regeneratorRuntime().wrap(function _callee16$(_context16) {\n while (1) switch (_context16.prev = _context16.next) {\n case 0:\n _context16.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, collectionPath, documentId);\n _context16.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDoc)(docRef);\n case 4:\n docSnapshot = _context16.sent;\n if (!docSnapshot.exists()) {\n _context16.next = 9;\n break;\n }\n return _context16.abrupt(\"return\", Object.assign({\n id: docSnapshot.id\n }, docSnapshot.data()));\n case 9:\n console.warn(\"No such document! \".concat(collectionPath, \"/\").concat(documentId));\n return _context16.abrupt(\"return\", null);\n case 11:\n _context16.next = 17;\n break;\n case 13:\n _context16.prev = 13;\n _context16.t0 = _context16[\"catch\"](0);\n console.error(\"Error getting object\", _context16.t0);\n throw _context16.t0;\n case 17:\n case \"end\":\n return _context16.stop();\n }\n }, _callee16, null, [[0, 13]]);\n }));\n}\n/**\n * Asynchronously retrieves comments for a given suggestion.\n *\n * @param {Object} params - The parameters for fetching comments.\n * @param {string} params.suggestionId - The ID of the suggestion to fetch comments for.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - The criterion to sort the comments by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Determines if the sorting should be in ascending order. Defaults to false (descending).\n * @returns {Promise<any[]>} A promise that resolves to an array of comment objects.\n *\n * @throws Will throw an error if the comments cannot be retrieved.\n */\nfunction getComments(_ref) {\n var suggestionId = _ref.suggestionId,\n _ref$sortBy = _ref.sortBy,\n sortBy = _ref$sortBy === void 0 ? \"dateCreated\" : _ref$sortBy,\n _ref$ascending = _ref.ascending,\n ascending = _ref$ascending === void 0 ? false : _ref$ascending;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {\n var suggestionRef, commentsQuery, commentsSnapshot, comments;\n return _regeneratorRuntime().wrap(function _callee17$(_context17) {\n while (1) switch (_context17.prev = _context17.next) {\n case 0:\n _context17.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, \"suggestionCollection\", suggestionId);\n commentsQuery = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\"), (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n _context17.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(commentsQuery);\n case 5:\n commentsSnapshot = _context17.sent;\n comments = [];\n commentsSnapshot.forEach(function (doc) {\n comments.push(doc.data());\n });\n return _context17.abrupt(\"return\", comments);\n case 11:\n _context17.prev = 11;\n _context17.t0 = _context17[\"catch\"](0);\n console.error(\"Error getting comments for suggestion: \", _context17.t0);\n throw _context17.t0;\n case 15:\n case \"end\":\n return _context17.stop();\n }\n }, _callee17, null, [[0, 11]]);\n }));\n}\n//Filtering suggestions on unitId AND creatorHsaId\n//Sort suggestions on dateCreated OR upvotes\n/**\n * Asynchronously retrieves an array of suggestions from the database, with various filters and sorting options.\n *\n * @param {Object} params - The parameters for filtering and sorting suggestions.\n * @param {string} [params.id] - Optional ID to filter suggestions by a specific identifier.\n * @param {string} [params.creatorHsaId] - Optional HSA ID to filter suggestions by the creator's HSA ID.\n * @param {string} [params.unitId] - Optional unit ID to filter suggestions by a specific unit.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - Criterion to sort the suggestions by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Flag indicating if sorting should be ascending. Defaults to false (descending order).\n * @param {boolean} [params.isPublic=true] - Flag indicating whether to filter for public suggestions. Defaults to true.\n * @returns {Promise<any[]>} A promise that resolves to an array of suggestion objects.\n *\n * @throws Will throw an error if there is an issue retrieving suggestions.\n */\nfunction getSuggestions(_ref2) {\n var id = _ref2.id,\n creatorHsaId = _ref2.creatorHsaId,\n unitId = _ref2.unitId,\n _ref2$sortBy = _ref2.sortBy,\n sortBy = _ref2$sortBy === void 0 ? \"dateCreated\" : _ref2$sortBy,\n _ref2$ascending = _ref2.ascending,\n ascending = _ref2$ascending === void 0 ? false : _ref2$ascending,\n _ref2$isPublic = _ref2.isPublic,\n isPublic = _ref2$isPublic === void 0 ? true : _ref2$isPublic;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {\n var collectionRef, constraints, q, querySnapshot, suggestions;\n return _regeneratorRuntime().wrap(function _callee18$(_context18) {\n while (1) switch (_context18.prev = _context18.next) {\n case 0:\n _context18.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (creatorHsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"creatorHsaId\", \"==\", creatorHsaId));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"public\", \"==\", isPublic));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context18.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 11:\n querySnapshot = _context18.sent;\n suggestions = [];\n querySnapshot.forEach(function (doc) {\n suggestions.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context18.abrupt(\"return\", suggestions);\n case 17:\n _context18.prev = 17;\n _context18.t0 = _context18[\"catch\"](0);\n console.log(\"Error retrieving suggestions by department: \", _context18.t0);\n throw _context18.t0;\n case 21:\n case \"end\":\n return _context18.stop();\n }\n }, _callee18, null, [[0, 17]]);\n }));\n}\n/**\n * Asynchronously searches for hospital documents in the database.\n * It can filter the results by the hospital's name, ID, or both.\n * If no parameters are provided, it retrieves all hospitals.\n *\n * @param {Object} params - An object containing the search parameters.\n * @param {string} [params.hospitalName] - Optional name of the hospital to filter the search.\n * @param {string} [params.hospitalId] - Optional unique identifier of the hospital to filter the search.\n * @returns {Promise<any[]>} A promise that resolves to an array of hospital objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getHospitals(_ref3) {\n var hospitalName = _ref3.hospitalName,\n hospitalId = _ref3.hospitalId;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {\n var collectionRef, constraints, q, querySnapshot, hospitals;\n return _regeneratorRuntime().wrap(function _callee19$(_context19) {\n while (1) switch (_context19.prev = _context19.next) {\n case 0:\n _context19.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\n constraints = [];\n if (hospitalName) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", hospitalName));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hospitalId));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context19.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context19.sent;\n hospitals = [];\n querySnapshot.forEach(function (doc) {\n hospitals.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context19.abrupt(\"return\", hospitals);\n case 14:\n _context19.prev = 14;\n _context19.t0 = _context19[\"catch\"](0);\n console.log(\"Error retrieving Hospitals\", _context19.t0);\n throw _context19.t0;\n case 18:\n case \"end\":\n return _context19.stop();\n }\n }, _callee19, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of improvement work documents based on various filter criteria.\n * It supports filtering by ID, Nolan stage, unit ID, completion status, ongoing status, and patient risk level.\n * It also supports sorting by the start date of the improvement work in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.id] - Optional identifier to filter the improvement works.\n * @param {string} [params.nolanStage] - Optional Nolan stage to filter the improvement works.\n * @param {string} [params.unitId] - Optional unit ID to filter the improvement works.\n * @param {boolean} [params.completed] - Optional flag to filter the improvement works by their completion status.\n * @param {boolean} [params.ongoing] - Optional flag to filter the improvement works by their ongoing status.\n * @param {string} [params.patientRiskLevel] - Optional patient risk level to filter the improvement works.\n * @param {boolean} [params.ascendingDates=false] - Optional flag for sorting by date in ascending order. Defaults to false.\n * @returns {Promise<any[]>} A promise that resolves to an array of improvement work objects that match the criteria.\n *\n * @throws Will throw an error if there is a problem retrieving the improvement works.\n */\nfunction getImprovementWorks(_ref4) {\n var id = _ref4.id,\n nolanStage = _ref4.nolanStage,\n unitId = _ref4.unitId,\n completed = _ref4.completed,\n ongoing = _ref4.ongoing,\n patientRiskLevel = _ref4.patientRiskLevel,\n _ref4$ascendingDates = _ref4.ascendingDates,\n ascendingDates = _ref4$ascendingDates === void 0 ? false : _ref4$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {\n var collectionRef, constraints, q, querySnapshot, improvementWorks;\n return _regeneratorRuntime().wrap(function _callee20$(_context20) {\n while (1) switch (_context20.prev = _context20.next) {\n case 0:\n _context20.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (nolanStage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"currentStage\", \"==\", nolanStage));\n }\n if (completed != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"completed\", \"==\", completed));\n }\n if (ongoing !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"ongoing\", \"==\", ongoing));\n }\n if (patientRiskLevel) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"patientRiskLevel\", \"==\", patientRiskLevel));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"dateStarted\", ascendingDates ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context20.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 13:\n querySnapshot = _context20.sent;\n improvementWorks = [];\n querySnapshot.forEach(function (doc) {\n improvementWorks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context20.abrupt(\"return\", improvementWorks);\n case 19:\n _context20.prev = 19;\n _context20.t0 = _context20[\"catch\"](0);\n console.log(\"Error retrieving improvementWorks: \", _context20.t0);\n throw _context20.t0;\n case 23:\n case \"end\":\n return _context20.stop();\n }\n }, _callee20, null, [[0, 19]]);\n }));\n}\nfunction getImprovementWorkOwner(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {\n var constraints, q, querySnapshot, owner;\n return _regeneratorRuntime().wrap(function _callee21$(_context21) {\n while (1) switch (_context21.prev = _context21.next) {\n case 0:\n _context21.prev = 0;\n constraints = [];\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"isOwner\", \"==\", true));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context21.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 7:\n querySnapshot = _context21.sent;\n if (!querySnapshot.empty) {\n _context21.next = 13;\n break;\n }\n console.log(\"Improvement work \", improvementWorkId, \" has no owner\");\n return _context21.abrupt(\"return\", null);\n case 13:\n owner = querySnapshot.docs[0].data().userHsaId;\n return _context21.abrupt(\"return\", owner);\n case 15:\n _context21.next = 20;\n break;\n case 17:\n _context21.prev = 17;\n _context21.t0 = _context21[\"catch\"](0);\n console.log(_context21.t0);\n case 20:\n case \"end\":\n return _context21.stop();\n }\n }, _callee21, null, [[0, 17]]);\n }));\n}\nfunction getImprovementWorkResponsible(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {\n var constraints, q, querySnapshot, responsible;\n return _regeneratorRuntime().wrap(function _callee22$(_context22) {\n while (1) switch (_context22.prev = _context22.next) {\n case 0:\n _context22.prev = 0;\n constraints = [];\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"isResponsibleFor\", \"==\", true));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context22.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 7:\n querySnapshot = _context22.sent;\n if (!querySnapshot.empty) {\n _context22.next = 13;\n break;\n }\n console.log(\"Improvement work \", improvementWorkId, \" has no responsible\");\n return _context22.abrupt(\"return\", null);\n case 13:\n responsible = querySnapshot.docs[0].data().userHsaId;\n return _context22.abrupt(\"return\", responsible);\n case 15:\n _context22.next = 20;\n break;\n case 17:\n _context22.prev = 17;\n _context22.t0 = _context22[\"catch\"](0);\n console.log(_context22.t0);\n case 20:\n case \"end\":\n return _context22.stop();\n }\n }, _callee22, null, [[0, 17]]);\n }));\n}\n// TODO getUsersForTask!\n/**\n * Asynchronously retrieves user documents from the database based on various filter criteria.\n * It can filter by the Health Savings Account ID (hsaId), unit ID, and unique identifier (uid).\n * Additionally, it can sort the results by first name in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.hsaId] - Optional HSA ID to filter the users.\n * @param {string} [params.unitId] - Optional unit ID to filter the users.\n * @param {boolean} [params.ascendingFirstNames=false] - Optional flag to sort by first names in ascending order. Defaults to false (descending order).\n * @param {string} [params.uid] - Optional unique identifier to filter the users.\n * @returns {Promise<any[]>} A promise that resolves to an array of user objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUsers(_ref5) {\n var hsaId = _ref5.hsaId,\n unitId = _ref5.unitId,\n _ref5$ascendingFirstN = _ref5.ascendingFirstNames,\n ascendingFirstNames = _ref5$ascendingFirstN === void 0 ? false : _ref5$ascendingFirstN,\n uid = _ref5.uid;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {\n var collectionRef, constraints, q, querySnapshot, users;\n return _regeneratorRuntime().wrap(function _callee23$(_context23) {\n while (1) switch (_context23.prev = _context23.next) {\n case 0:\n _context23.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\n constraints = [];\n if (hsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hsaId));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (uid) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"uid\", \"==\", uid));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"firstName\", ascendingFirstNames ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context23.next = 10;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 10:\n querySnapshot = _context23.sent;\n users = [];\n querySnapshot.forEach(function (doc) {\n users.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context23.abrupt(\"return\", users);\n case 16:\n _context23.prev = 16;\n _context23.t0 = _context23[\"catch\"](0);\n console.log(\"Error retrieving users by department: \", _context23.t0);\n throw _context23.t0;\n case 20:\n case \"end\":\n return _context23.stop();\n }\n }, _callee23, null, [[0, 16]]);\n }));\n}\n// TODO getTasksForUser!\n/**\n * Asynchronously retrieves an array of task documents from the database based on several filter and sorting criteria.\n * Filters include task ID, user ID and their responsibility status, and related improvement work ID.\n * Results can be sorted by date either in ascending or descending order.\n *\n * @param {Object} params - Parameters to filter and sort the task results.\n * @param {string} [params.taskId] - Optional task ID to filter the tasks.\n * @param {string} [params.userId] - Optional user ID to identify tasks related to a user.\n * @param {boolean} [params.isResponsibleFor] - Optional flag to filter tasks where the user is marked as responsible.\n * @param {string} [params.improvementWorkId] - Optional improvement work ID to filter tasks related to a specific improvement work.\n * @param {boolean} [params.ascendingDates=false] - Optional flag to sort tasks by date in ascending order; defaults to descending order.\n * @returns {Promise<any[]>} A promise that resolves to an array of task objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getTasks(_ref6) {\n var improvementWorkId = _ref6.improvementWorkId,\n stage = _ref6.stage,\n _ref6$ascendingDates = _ref6.ascendingDates,\n ascendingDates = _ref6$ascendingDates === void 0 ? false : _ref6$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {\n var collectionRef, constraints, q, querySnapshot, tasks;\n return _regeneratorRuntime().wrap(function _callee24$(_context24) {\n while (1) switch (_context24.prev = _context24.next) {\n case 0:\n _context24.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\n constraints = []; // FUTURE FEATURE: Filter on userHsaId AND improvementWork\n // if (userHsaId && isResponsibleFor !== undefined) {\n // constraints.push(\n // where(\"members\", \"array-contains\", {\n // userHsaId: userHsaId,\n // isResponsibleFor: isResponsibleFor,\n // })\n // );\n // }\n if (stage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"stage\", \"==\", stage));\n }\n if (improvementWorkId != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"startDate\", ascendingDates ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context24.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context24.sent;\n tasks = [];\n querySnapshot.forEach(function (doc) {\n tasks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context24.abrupt(\"return\", tasks);\n case 14:\n _context24.prev = 14;\n _context24.t0 = _context24[\"catch\"](0);\n console.log(\"Error retrieving task by department: \", _context24.t0);\n throw _context24.t0;\n case 18:\n case \"end\":\n return _context24.stop();\n }\n }, _callee24, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of unit documents from the database based on various filter criteria.\n * Filters can be applied based on unit ID, hospital ID, and unit name.\n * Additionally, results can be sorted by unit names in ascending or descending order.\n *\n * @param {Object} params - The parameters object containing filter and sorting options.\n * @param {string} [params.unitId] - Optional unit ID to filter the units.\n * @param {string} [params.hospitalId] - Optional hospital ID to filter units within a specific hospital.\n * @param {string} [params.name] - Optional name to filter units by a specific name.\n * @param {boolean} [params.ascendingUnitNames=false] - Optional flag to sort units by name in ascending order, defaults to descending.\n * @returns {Promise<any[]>} A promise that resolves to an array of unit objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUnits(_ref7) {\n var unitId = _ref7.unitId,\n hospitalId = _ref7.hospitalId,\n name = _ref7.name,\n _ref7$ascendingUnitNa = _ref7.ascendingUnitNames,\n ascendingUnitNames = _ref7$ascendingUnitNa === void 0 ? false : _ref7$ascendingUnitNa;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {\n var collectionRef, constraints, q, querySnapshot, units;\n return _regeneratorRuntime().wrap(function _callee25$(_context25) {\n while (1) switch (_context25.prev = _context25.next) {\n case 0:\n _context25.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\n constraints = [];\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", unitId));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"hospitalId\", \"==\", hospitalId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"name\", ascendingUnitNames ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context25.next = 9;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 9:\n querySnapshot = _context25.sent;\n units = [];\n querySnapshot.forEach(function (doc) {\n units.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context25.abrupt(\"return\", units);\n case 15:\n _context25.prev = 15;\n _context25.t0 = _context25[\"catch\"](0);\n console.log(\"Error retrieving units by hospitalId: \", _context25.t0);\n throw _context25.t0;\n case 19:\n case \"end\":\n return _context25.stop();\n }\n }, _callee25, null, [[0, 15]]);\n }));\n}\nfunction getImprovementWorksForUser(userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {\n var q, querySnapshot, improvementWorks, _iterator, _step, _doc, improvementWorkId, improvementWorkDoc;\n return _regeneratorRuntime().wrap(function _callee26$(_context26) {\n while (1) switch (_context26.prev = _context26.next) {\n case 0:\n _context26.prev = 0;\n console.log(\"Getting improvementworks for user: \", userHsaId);\n // Query the userImprovementWork collection for relations involving this user\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(userImprovementWorkCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)('userHsaId', '==', userHsaId));\n _context26.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 5:\n querySnapshot = _context26.sent;\n // Fetch each related improvementWork document\n improvementWorks = [];\n _iterator = _createForOfIteratorHelper(querySnapshot.docs);\n _context26.prev = 8;\n _iterator.s();\n case 10:\n if ((_step = _iterator.n()).done) {\n _context26.next = 19;\n break;\n }\n _doc = _step.value;\n improvementWorkId = _doc.data().improvementWorkId;\n _context26.next = 15;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 15:\n improvementWorkDoc = _context26.sent;\n improvementWorks.push(improvementWorkDoc);\n case 17:\n _context26.next = 10;\n break;\n case 19:\n _context26.next = 24;\n break;\n case 21:\n _context26.prev = 21;\n _context26.t0 = _context26[\"catch\"](8);\n _iterator.e(_context26.t0);\n case 24:\n _context26.prev = 24;\n _iterator.f();\n return _context26.finish(24);\n case 27:\n return _context26.abrupt(\"return\", improvementWorks);\n case 30:\n _context26.prev = 30;\n _context26.t1 = _context26[\"catch\"](0);\n console.error(\"Error getting improvement works for user: \", _context26.t1);\n throw _context26.t1;\n case 34:\n case \"end\":\n return _context26.stop();\n }\n }, _callee26, null, [[0, 30], [8, 21, 24, 27]]);\n }));\n}\nfunction getUsersForImprovementWork(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {\n var q, querySnapshot, users, _iterator2, _step2, _doc2, userHsaId, userDoc;\n return _regeneratorRuntime().wrap(function _callee27$(_context27) {\n while (1) switch (_context27.prev = _context27.next) {\n case 0:\n _context27.prev = 0;\n console.log(\"Getting users for improvementwork: \", improvementWorkId);\n // Query the userImprovementWork collection for relations involving this improvementWork\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(userImprovementWorkCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)('improvementWorkId', '==', improvementWorkId));\n _context27.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 5:\n querySnapshot = _context27.sent;\n // Fetch each related user document\n users = [];\n _iterator2 = _createForOfIteratorHelper(querySnapshot.docs);\n _context27.prev = 8;\n _iterator2.s();\n case 10:\n if ((_step2 = _iterator2.n()).done) {\n _context27.next = 19;\n break;\n }\n _doc2 = _step2.value;\n userHsaId = _doc2.data().userHsaId;\n _context27.next = 15;\n return getObjectById(\"users\", userHsaId);\n case 15:\n userDoc = _context27.sent;\n users.push(userDoc);\n case 17:\n _context27.next = 10;\n break;\n case 19:\n _context27.next = 24;\n break;\n case 21:\n _context27.prev = 21;\n _context27.t0 = _context27[\"catch\"](8);\n _iterator2.e(_context27.t0);\n case 24:\n _context27.prev = 24;\n _iterator2.f();\n return _context27.finish(24);\n case 27:\n return _context27.abrupt(\"return\", users);\n case 30:\n _context27.prev = 30;\n _context27.t1 = _context27[\"catch\"](0);\n console.error(\"Error getting users for improvementWork: \", _context27.t1);\n throw _context27.t1;\n case 34:\n case \"end\":\n return _context27.stop();\n }\n }, _callee27, null, [[0, 30], [8, 21, 24, 27]]);\n }));\n}\n// export getters to be able to use in other files\n\n////////////////////////////////////DELETING/////////////////////////////////////////////\n// delete an instance of a type\nfunction deleteInstance(docType, docId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee28$(_context28) {\n while (1) switch (_context28.prev = _context28.next) {\n case 0:\n _context28.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context28.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(docRef);\n case 4:\n console.log(\"\".concat(docType, \" deleted successfully.\"));\n _context28.next = 11;\n break;\n case 7:\n _context28.prev = 7;\n _context28.t0 = _context28[\"catch\"](0);\n console.error(\"Error deleting \".concat(docType, \":\"), _context28.t0);\n throw _context28.t0;\n case 11:\n case \"end\":\n return _context28.stop();\n }\n }, _callee28, null, [[0, 7]]);\n }));\n}\n// delete all instances of a type\nfunction deleteAllDocumentsInCollection(collectionName) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {\n var _this = this;\n var collectionRef, snapshot, deletePromises;\n return _regeneratorRuntime().wrap(function _callee30$(_context30) {\n while (1) switch (_context30.prev = _context30.next) {\n case 0:\n _context30.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionName);\n _context30.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n snapshot = _context30.sent;\n // Delete all documents in the collection\n deletePromises = snapshot.docs.map(function (doc) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {\n return _regeneratorRuntime().wrap(function _callee29$(_context29) {\n while (1) switch (_context29.prev = _context29.next) {\n case 0:\n _context29.next = 2;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(doc.ref);\n case 2:\n case \"end\":\n return _context29.stop();\n }\n }, _callee29);\n }));\n });\n _context30.next = 8;\n return Promise.all(deletePromises);\n case 8:\n console.log(\"All documents in the \".concat(collectionName, \" collection deleted successfully.\"));\n _context30.next = 15;\n break;\n case 11:\n _context30.prev = 11;\n _context30.t0 = _context30[\"catch\"](0);\n console.error(\"Error deleting all documents in \".concat(collectionName, \":\"), _context30.t0);\n throw _context30.t0;\n case 15:\n case \"end\":\n return _context30.stop();\n }\n }, _callee30, null, [[0, 11]]);\n }));\n}\n////////////////////////////////////UPDATING/////////////////////////////////////////////\n// update a field in an instance\nfunction updateInstance(docType, docId, updates) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee31$(_context31) {\n while (1) switch (_context31.prev = _context31.next) {\n case 0:\n _context31.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context31.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(docRef, updates);\n case 4:\n console.log(\"\".concat(docType, \" updated successfully.\"));\n _context31.next = 11;\n break;\n case 7:\n _context31.prev = 7;\n _context31.t0 = _context31[\"catch\"](0);\n console.error(\"Error updating \".concat(docType, \":\"), _context31.t0);\n throw _context31.t0;\n case 11:\n case \"end\":\n return _context31.stop();\n }\n }, _callee31, null, [[0, 7]]);\n }));\n}\n// changes the ongoing status of an improvement work. if ongoing it is paused, if if paused onging.\n// user must be a manager\nfunction startOrPauseImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee32$(_context32) {\n while (1) switch (_context32.prev = _context32.next) {\n case 0:\n _context32.prev = 0;\n _context32.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context32.sent;\n _context32.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context32.sent;\n if (!(!user || !user.manager)) {\n _context32.next = 11;\n break;\n }\n throw new Error(\"User can't change improvementWork status\");\n case 11:\n if (!improvementWork) {\n _context32.next = 18;\n break;\n }\n update = {\n ongoing: !improvementWork.ongoing\n };\n _context32.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n _context32.next = 19;\n break;\n case 18:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n case 19:\n _context32.next = 25;\n break;\n case 21:\n _context32.prev = 21;\n _context32.t0 = _context32[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context32.t0);\n throw _context32.t0;\n case 25:\n case \"end\":\n return _context32.stop();\n }\n }, _callee32, null, [[0, 21]]);\n }));\n}\nfunction changePatientRiskLevel(userId, improvementWorkId, patientRiskLevel) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee33$(_context33) {\n while (1) switch (_context33.prev = _context33.next) {\n case 0:\n _context33.prev = 0;\n _context33.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context33.sent;\n _context33.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context33.sent;\n if (!(!user || !user.manager)) {\n _context33.next = 11;\n break;\n }\n throw new Error(\"User can't change patientRiskLevel in improvement work\");\n case 11:\n if (!improvementWork) {\n _context33.next = 18;\n break;\n }\n update = {\n patientRiskLevel: patientRiskLevel\n };\n _context33.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n _context33.next = 19;\n break;\n case 18:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n case 19:\n _context33.next = 25;\n break;\n case 21:\n _context33.prev = 21;\n _context33.t0 = _context33[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context33.t0);\n throw _context33.t0;\n case 25:\n case \"end\":\n return _context33.stop();\n }\n }, _callee33, null, [[0, 21]]);\n }));\n}\n// finalizes the improvement work. ongoing is set to false.\n// user must be a manager\nfunction finalizeImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {\n var user, update;\n return _regeneratorRuntime().wrap(function _callee34$(_context34) {\n while (1) switch (_context34.prev = _context34.next) {\n case 0:\n _context34.prev = 0;\n _context34.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context34.sent;\n if (!(!user || !user.manager)) {\n _context34.next = 8;\n break;\n }\n throw new Error(\"User can't finalize improvementWork status\");\n case 8:\n update = {\n completed: true,\n ongoing: false\n };\n _context34.next = 11;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 11:\n _context34.next = 16;\n break;\n case 13:\n _context34.prev = 13;\n _context34.t0 = _context34[\"catch\"](0);\n console.log(_context34.t0);\n case 16:\n case \"end\":\n return _context34.stop();\n }\n }, _callee34, null, [[0, 13]]);\n }));\n}\n\n//////////////////////////////// for later sprint\n//function add_upvotes\n//function add_notes\n//function add_intrested_users\n\n//# sourceURL=webpack://c3/./client/Database/database.js?"); /***/ }), @@ -206,7 +206,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \***************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n/*\n//SAMPLES, TO BE REPLACED BY DB\nconst sampleUnits: Unit[] = [\n {\n ID: \"1\",\n hospital_ID: \"1\",\n name: \"Akuten\"\n },\n\n {\n ID: \"2\",\n hospital_ID: \"1\",\n name: \"BB\"\n },\n {\n ID: \"3\",\n hospital_ID: \"1\",\n name: \"Onkolog\"\n },\n\n\n];\n\nconst unitNameLookup: Record<string, string> = {};\nsampleUnits.forEach((unit) => {\n unitNameLookup[unit.ID] = unit.name;\n});\n*/\n/*\nconst sampleProjects: Project[] = [\n {\n id: \"1\",\n name: \"Birthing of a Child\",\n current_stage: \"In Progress\",\n content: \"This is project 1.\",\n unitId: \"2\",\n dateStarted: new Date(\"2023-01-15\"),\n },\n {\n id: \"2\",\n name: \"How to save a life\",\n current_stage: \"Completed\",\n content: \"This is project 2.\",\n unitId: \"1\",\n dateStarted: new Date(\"2023-02-20\"),\n },\n {\n id: \"3\",\n name: \"BB tutorial\",\n current_stage: \"Completed\",\n content: \"This is project 3.\",\n unitId: \"2\",\n dateStarted: new Date(\"2023-06-05\"),\n },\n {\n id: \"4\",\n name: \"Cancerbehandling 101\",\n current_stage: \"Completed\",\n content: \"This is project 4.\",\n unitId: \"3\",\n dateStarted: new Date(\"2023-10-24\"),\n },\n];\n\n\n\nsampleProjects.sort((a,b) => b.dateStarted.getTime() - a.dateStarted.getTime()); //SORTING THE PROJECTS FROM NEWEST TO OLDEST\n*/\nfunction getCompletedProjects() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var CompletedProjects;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({\n completed: true\n });\n case 2:\n CompletedProjects = _context.sent;\n return _context.abrupt(\"return\", CompletedProjects);\n case 4:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\n//let completedImprovmentWorks = await getImprovementWorks({});\n//TO MAKE DATE APPEAR NICELY\nfunction formatDate(timeStamp) {\n var date = timeStamp.toDate();\n var day = String(date.getDate()).toString();\n var month = String(date.getMonth() + 1).toString(); // Adding 1 because months are zero-based\n var year = String(date.getFullYear()).toString();\n if (parseInt(month, 10) < 10) {\n return \"\".concat(day, \"/0\").concat(month, \"/\").concat(year);\n }\n return \"\".concat(day, \"/\").concat(month, \"/\").concat(year);\n}\n//TO CREATE GRID HTML ELEMENT OF PROJECTS \nfunction createGridRow(project) {\n var row = document.createElement(\"div\");\n row.className = \"grid-row\";\n var unitName = project.unitId || 'Unknown Unit';\n row.innerHTML = \"\\n <div class=\\\"column\\\">\".concat(project.name, \"</div>\\n <div class=\\\"column\\\">\").concat(unitName, \"</div>\\n <div class=\\\"column\\\">\").concat(formatDate(project.dateStarted), \"</div>\\n <div class=\\\"column\\\">Link-placeholder</div>\\n \");\n return row;\n}\n//TO ADD GRID ELEMENTS TO GRID-CONTAINER\nfunction addGridRows() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var gridContainer, projects;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n gridContainer = document.getElementById(\"grid-container\");\n _context2.next = 3;\n return getCompletedProjects();\n case 3:\n projects = _context2.sent;\n console.log(projects);\n projects.forEach(function (project) {\n var row = createGridRow(project);\n if (gridContainer != null) {\n gridContainer.appendChild(row);\n }\n });\n /*\n projects.forEach((project) => {\n const row = createGridRow(project);\n if(gridContainer != null) {\n gridContainer.appendChild(row);\n }\n });\n */\n case 6:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nvar departmentDropdown = document.getElementById(\"departmentDropdown\"); //INSTANCING THE FILTER HTLM ELEMENTS\nvar dateDropdown = document.getElementById(\"dateDropdown\");\nvar searchInput = document.getElementById(\"searchInput\");\nvar selectedDepartment = \"all\";\nvar selectedDateFilter = \"newest\";\nvar searchQuery;\n//TO MAKE DEPARTMENTDROPDOWN CONTAIN ALL THE UNITS FROM DB\n/*\nasync function fillDropdown() {\nsampleUnits.forEach((unit) => {\n const option = document.createElement(\"option\");\n option.value = unit.ID;\n option.textContent = unit.name;\n //departmentDropdown.appendChild(option);\n});\n}\n*/\n/*\n//FILTERING BY DEPARTMENT AND DATE\nfunction filterProjects(selectedDepartment: string, selectedDateFilter: string, searchQuery: String) {\n\n if(selectedDateFilter == \"oldest\") { //FILTER BY DATE\n sampleProjects.sort((a,b) => a.dateStarted.getTime() - b.dateStarted.getTime());\n }\n else {\n sampleProjects.sort((a,b) => b.dateStarted.getTime() - a.dateStarted.getTime());\n }\n\n let filteredProjects = sampleProjects; //FILTER BY DEPARTMENT\n if (selectedDepartment !== \"all\") {\n filteredProjects = filteredProjects.filter((project) => project.unitId === selectedDepartment);\n }\n\n if(searchQuery) { //SEARCH\n filteredProjects = filteredProjects.filter((project) =>\n project.name.toLowerCase().indexOf(searchQuery.toLowerCase()) !== -1\n );\n }\n\n if(gridContainer != null) { //PRINTING TO THE GRID\n gridContainer.innerHTML = ''; //CLEAR THE GRID\n filteredProjects.forEach((project) => {\n const row = createGridRow(project);\n if (gridContainer) {\n gridContainer.appendChild(row);\n }\n });\n}\n\n}\n*/\n//EVENT-LISTENERERS\n/*\ndepartmentDropdown.addEventListener(\"change\", () => {\n selectedDepartment = departmentDropdown.value;\n\n filterProjects(selectedDepartment, selectedDateFilter, searchQuery);\n});\n\ndateDropdown.addEventListener(\"change\", () => {\n selectedDateFilter = dateDropdown.value;\n filterProjects(selectedDepartment,selectedDateFilter, searchQuery);\n})\n\nsearchInput.addEventListener(\"input\", () => {\n searchQuery = searchInput.value.trim();\n filterProjects(selectedDepartment, selectedDateFilter, searchQuery);\n})\n\n*/\nfunction loadPage() {\n var container = document.querySelector('#container-fluid');\n if (!container) return; // Stop if the container isn't found\n fetch('Knowledgebank/completedProjects.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.maincontainer');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n //fillDropdown();\n addGridRows();\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n}\n\n//# sourceURL=webpack://c3/./client/KnowledgeBank/completedProjects.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\nfunction getCompletedProjects() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var CompletedProjects;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({\n completed: true\n });\n case 2:\n CompletedProjects = _context.sent;\n return _context.abrupt(\"return\", CompletedProjects);\n case 4:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\n//TO MAKE DATE APPEAR NICELY\nfunction formatDate(timeStamp) {\n var date = timeStamp.toDate();\n var day = String(date.getDate()).toString();\n var month = String(date.getMonth() + 1).toString(); // Adding 1 because months are zero-based\n var year = String(date.getFullYear()).toString();\n if (parseInt(month, 10) < 10) {\n return \"\".concat(day, \"/0\").concat(month, \"/\").concat(year);\n }\n return \"\".concat(day, \"/\").concat(month, \"/\").concat(year);\n}\n//TO CREATE GRID HTML ELEMENT OF PROJECTS \nfunction createGridRow(project) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var unit, row, unitName;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", project.unitId);\n case 2:\n unit = _context2.sent;\n row = document.createElement(\"div\");\n row.className = \"grid-row\";\n unitName = \"Unspecified Unit\";\n if (unit) {\n unitName = unit.name;\n }\n row.innerHTML = \"\\n <div class=\\\"column\\\">\".concat(project.name, \"</div>\\n <div class=\\\"column\\\">\").concat(unitName, \"</div>\\n <div class=\\\"column\\\">\").concat(formatDate(project.dateStarted), \"</div>\\n <div class=\\\"column\\\">Link-placeholder</div>\\n \");\n return _context2.abrupt(\"return\", row);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\n//TO ADD GRID ELEMENTS TO GRID-CONTAINER\nfunction addGridRows() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var _this = this;\n var gridContainer, projects;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n gridContainer = document.getElementById(\"grid-container\");\n _context4.next = 3;\n return getCompletedProjects();\n case 3:\n projects = _context4.sent;\n console.log(projects);\n projects.forEach(function (project) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var row;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n row = createGridRow(project);\n if (!(gridContainer != null)) {\n _context3.next = 7;\n break;\n }\n _context3.t0 = gridContainer;\n _context3.next = 5;\n return row;\n case 5:\n _context3.t1 = _context3.sent;\n _context3.t0.appendChild.call(_context3.t0, _context3.t1);\n case 7:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n case 6:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n}\nfunction fillDropdown() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var departmentDropdown, units;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n departmentDropdown = document.getElementById(\"departmentDropdown\");\n _context5.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({});\n case 3:\n units = _context5.sent;\n console.log(units);\n units.forEach(function (unit) {\n var option = document.createElement(\"option\");\n option.value = unit.Id;\n option.textContent = unit.name;\n departmentDropdown.appendChild(option);\n });\n case 6:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\n//FILTERING BY DEPARTMENT AND DATE\nfunction filterProjects(selectedDepartment, selectedDateFilter, searchQuery) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var _this2 = this;\n var projects, filteredProjects, gridContainer;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.next = 2;\n return getCompletedProjects();\n case 2:\n projects = _context7.sent;\n if (selectedDateFilter == \"oldest\") {\n //FILTER BY DATE\n projects.sort(function (a, b) {\n return a.dateStarted.getTime() - b.dateStarted.getTime();\n });\n } else {\n projects.sort(function (a, b) {\n return b.dateStarted.getTime() - a.dateStarted.getTime();\n });\n }\n filteredProjects = projects; //FILTER BY DEPARTMENT\n if (selectedDepartment !== \"all\") {\n filteredProjects = filteredProjects.filter(function (project) {\n return project.unitId === selectedDepartment;\n });\n }\n if (searchQuery) {\n //SEARCH\n filteredProjects = filteredProjects.filter(function (project) {\n return project.name.toLowerCase().indexOf(searchQuery.toLowerCase()) !== -1;\n });\n }\n gridContainer = document.getElementById(\"grid-container\");\n if (gridContainer != null) {\n //PRINTING TO THE GRID\n gridContainer.innerHTML = ''; //CLEAR THE GRID\n filteredProjects.forEach(function (project) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var row;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n row = createGridRow(project);\n if (!gridContainer) {\n _context6.next = 7;\n break;\n }\n _context6.t0 = gridContainer;\n _context6.next = 5;\n return row;\n case 5:\n _context6.t1 = _context6.sent;\n _context6.t0.appendChild.call(_context6.t0, _context6.t1);\n case 7:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n });\n }\n case 9:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\n//EVENT-LISTENERERS\n/*\ndepartmentDropdown.addEventListener(\"change\", () => {\n selectedDepartment = departmentDropdown.value;\n\n filterProjects(selectedDepartment, selectedDateFilter, searchQuery);\n});\n/*\ndateDropdown.addEventListener(\"change\", () => {\n selectedDateFilter = dateDropdown.value;\n filterProjects(selectedDepartment,selectedDateFilter, searchQuery);\n})\n\nsearchInput.addEventListener(\"input\", () => {\n searchQuery = searchInput.value.trim();\n filterProjects(selectedDepartment, selectedDateFilter, searchQuery);\n})\n\n*/\nfunction loadPage() {\n var container = document.querySelector('#container-fluid');\n if (!container) return; // Stop if the container isn't found\n fetch('Knowledgebank/completedProjects.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.maincontainer');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n var dateDropdown = document.getElementById(\"dateDropdown\");\n var searchInput = document.getElementById(\"searchInput\");\n var selectedDepartment = \"all\";\n var selectedDateFilter = \"newest\";\n var searchQuery;\n fillDropdown();\n addGridRows();\n console.log(getCompletedProjects());\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n}\n\n//# sourceURL=webpack://c3/./client/KnowledgeBank/completedProjects.js?"); /***/ }), @@ -236,7 +236,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \*******************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ submitHandler: () => (/* binding */ submitHandler)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n\n\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\nfunction loadFilter() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var selectHospitalHTML, selectUnitHTML, allHospitals, allUnits;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n selectHospitalHTML = $('#selectHospital'); // loads the select type from html\n selectUnitHTML = $('#selectDepartment'); // loads the select type from html\n _context.next = 4;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({});\n case 4:\n allHospitals = _context.sent;\n _context.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({});\n case 7:\n allUnits = _context.sent;\n //here you can put constraints\n console.log(allHospitals);\n console.log(allUnits);\n allHospitals.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(user.name);\n selectHospitalHTML.append(optionElement);\n });\n allUnits.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(user.name);\n selectUnitHTML.append(optionElement);\n });\n case 12:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction populateOptions(object, selectElement) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var options;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObject)(object);\n case 2:\n options = _context2.sent;\n options.forEach(function (option) {\n var optionElement = document.createElement(\"option\");\n optionElement.value = option.id; // Set the value\n optionElement.text = option.name; // Set the text\n optionElement.classList.add(\"option\"); // Add the 'option' class\n selectElement.appendChild(optionElement);\n });\n case 4:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\n// Define the submitHandler function\nfunction submitHandler() {\n var selectDepartment = document.getElementById(\"selectHospital\");\n var selectUnit = document.getElementById(\"selectDepartment\");\n //populateOptions(\"hospital\", selectDepartment);\n //populateOptions(\"unit\", selectUnit);\n // JavaScript to get the inputted text when the form is submitted\n var inputBoxFormNameInput = document.getElementById(\"inputBoxFormNameInput\");\n var inputBoxFormName = document.getElementById(\"inputBoxFormName\");\n var inputBoxFormAreaInput = document.getElementById(\"inputBoxFormAreaInput\");\n var inputBoxFormArea = document.getElementById(\"inputBoxFormArea\");\n var inputBoxFormContentInput = document.getElementById(\"inputBoxFormContentInput\");\n var inputBoxFormContent = document.getElementById(\"inputBoxFormContent\");\n var inputBoxFormPurposeInput = document.getElementById(\"inputBoxFormPurposeInput\");\n var inputBoxFormPurpose = document.getElementById(\"inputBoxFormPurpose\");\n var inputBoxFormMeasureInput = document.getElementById(\"inputBoxFormMeasureInput\");\n var inputBoxFormMeasure = document.getElementById(\"inputBoxFormMeasure\");\n var inputBoxFormIdeasInput = document.getElementById(\"inputBoxFormIdeasInput\");\n var inputBoxFormIdeas = document.getElementById(\"inputBoxFormIdeas\");\n var submitButton = document.getElementById(\"suggestionButton\");\n inputBoxFormName.addEventListener(\"submit\", function (e) {\n e.preventDefault();\n });\n inputBoxFormArea.addEventListener(\"submit\", function (e) {\n e.preventDefault();\n });\n inputBoxFormContent.addEventListener(\"submit\", function (e) {\n e.preventDefault();\n });\n inputBoxFormPurpose.addEventListener(\"submit\", function (e) {\n e.preventDefault();\n });\n inputBoxFormMeasure.addEventListener(\"submit\", function (e) {\n e.preventDefault();\n });\n inputBoxFormIdeas.addEventListener(\"submit\", function (e) {\n e.preventDefault();\n });\n // Get values from each form and do something with them\n var nameInput = inputBoxFormNameInput.value;\n var areaInput = inputBoxFormAreaInput.value;\n var contentInput = inputBoxFormContentInput.value;\n var purposeInput = inputBoxFormPurposeInput.value;\n var measureInput = inputBoxFormMeasureInput.value;\n var ideasInput = inputBoxFormIdeasInput.value;\n try {\n // Call the createSuggestion function with the obtained values\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.createSuggestion)(\"<Header>\", \"<Department>\", nameInput, areaInput, contentInput, purposeInput, measureInput, ideasInput, selectUnit.value, selectDepartment.value, true);\n alert(\"created successfully\");\n } catch (_a) {\n alert(\"Error creating\");\n }\n}\nfunction loadPage() {\n var container = document.querySelector('#container-fluid');\n if (!container) return; // Stop if the container isn't found\n var scriptElement = document.createElement('script');\n scriptElement.src = '../dist/makeSuggestion.bundle.js';\n container.appendChild(scriptElement);\n var linkElement1 = document.createElement('link');\n linkElement1.rel = 'stylesheet';\n linkElement1.href = 'Make_Suggestion_Code/makeSuggestion.css';\n document.head.appendChild(linkElement1);\n var linkElement2 = document.createElement('link');\n linkElement2.rel = 'stylesheet';\n linkElement2.href = 'Activity_card_code/activitity_card.css';\n document.head.appendChild(linkElement2);\n fetch('Make_Suggestion_Code/makeSuggestion.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n var suggestionPage = tempContainer.querySelector('#suggestionPage');\n if (suggestionPage) {\n container.insertBefore(suggestionPage, container.firstChild);\n var submitButton = document.getElementById('suggestionButton');\n if (submitButton) {\n submitButton.addEventListener('click', submitHandler);\n } else {\n console.error(\"Error: 'suggestionButton' not found\");\n }\n loadFilter();\n }\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n}\n\n//# sourceURL=webpack://c3/./client/Make_Suggestion_Code/makeSuggestion.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ submitHandler: () => (/* binding */ submitHandler)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n\n\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\nfunction loadFilter() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var selectHospitalHTML, selectUnitHTML, allHospitals, allUnits;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n selectHospitalHTML = $('#selectHospital'); // loads the select type from html\n selectUnitHTML = $('#selectDepartment'); // loads the select type from html\n _context.next = 4;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({});\n case 4:\n allHospitals = _context.sent;\n _context.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({});\n case 7:\n allUnits = _context.sent;\n //here you can put constraints\n console.log(allHospitals);\n console.log(allUnits);\n allHospitals.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(user.name);\n selectHospitalHTML.append(optionElement);\n });\n allUnits.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(user.name);\n selectUnitHTML.append(optionElement);\n });\n case 12:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction populateOptions(object, selectElement) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var options;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObject)(object);\n case 2:\n options = _context2.sent;\n options.forEach(function (option) {\n var optionElement = document.createElement(\"option\");\n optionElement.value = option.id; // Set the value\n optionElement.text = option.name; // Set the text\n optionElement.classList.add(\"option\"); // Add the 'option' class\n selectElement.appendChild(optionElement);\n });\n case 4:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\n// Define the submitHandler function\nfunction submitHandler() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var selectDepartment, selectUnit, inputBoxFormNameInput, inputBoxFormName, inputBoxFormAreaInput, inputBoxFormArea, inputBoxFormContentInput, inputBoxFormContent, inputBoxFormPurposeInput, inputBoxFormPurpose, inputBoxFormMeasureInput, inputBoxFormMeasure, inputBoxFormIdeasInput, inputBoxFormIdeas, submitButton, nameInput, areaInput, contentInput, purposeInput, measureInput, ideasInput, tmp, uid, user;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n selectDepartment = document.getElementById(\"selectHospital\");\n selectUnit = document.getElementById(\"selectDepartment\"); //populateOptions(\"hospital\", selectDepartment);\n //populateOptions(\"unit\", selectUnit);\n // JavaScript to get the inputted text when the form is submitted\n inputBoxFormNameInput = document.getElementById(\"inputBoxFormNameInput\");\n inputBoxFormName = document.getElementById(\"inputBoxFormName\");\n inputBoxFormAreaInput = document.getElementById(\"inputBoxFormAreaInput\");\n inputBoxFormArea = document.getElementById(\"inputBoxFormArea\");\n inputBoxFormContentInput = document.getElementById(\"inputBoxFormContentInput\");\n inputBoxFormContent = document.getElementById(\"inputBoxFormContent\");\n inputBoxFormPurposeInput = document.getElementById(\"inputBoxFormPurposeInput\");\n inputBoxFormPurpose = document.getElementById(\"inputBoxFormPurpose\");\n inputBoxFormMeasureInput = document.getElementById(\"inputBoxFormMeasureInput\");\n inputBoxFormMeasure = document.getElementById(\"inputBoxFormMeasure\");\n inputBoxFormIdeasInput = document.getElementById(\"inputBoxFormIdeasInput\");\n inputBoxFormIdeas = document.getElementById(\"inputBoxFormIdeas\");\n submitButton = document.getElementById(\"suggestionButton\");\n inputBoxFormName.addEventListener(\"submit\", function (e) {\n e.preventDefault();\n });\n inputBoxFormArea.addEventListener(\"submit\", function (e) {\n e.preventDefault();\n });\n inputBoxFormContent.addEventListener(\"submit\", function (e) {\n e.preventDefault();\n });\n inputBoxFormPurpose.addEventListener(\"submit\", function (e) {\n e.preventDefault();\n });\n inputBoxFormMeasure.addEventListener(\"submit\", function (e) {\n e.preventDefault();\n });\n inputBoxFormIdeas.addEventListener(\"submit\", function (e) {\n e.preventDefault();\n });\n // Get values from each form and do something with them\n nameInput = inputBoxFormNameInput.value;\n areaInput = inputBoxFormAreaInput.value;\n contentInput = inputBoxFormContentInput.value;\n purposeInput = inputBoxFormPurposeInput.value;\n measureInput = inputBoxFormMeasureInput.value;\n ideasInput = inputBoxFormIdeasInput.value;\n tmp = localStorage.getItem('user');\n if (tmp) {\n _context3.next = 31;\n break;\n }\n console.log(\"there is not an user in localStorage\");\n return _context3.abrupt(\"return\");\n case 31:\n uid = JSON.parse(tmp)[0].uid;\n _context3.next = 34;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({\n uid: uid\n });\n case 34:\n user = _context3.sent;\n console.log(user);\n console.log(user[0].uid);\n console.log(user[0].id);\n console.log(user[0].creatorHsaId);\n try {\n if (user[0].id) {\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.createSuggestion)(null, user[0].id,\n //The unique identifyer for the user, not the idea\n nameInput, areaInput, contentInput, purposeInput, measureInput, ideasInput, selectUnit.value, selectDepartment.value, true);\n }\n // Call the createSuggestion function with the obtained values \n alert(\"created successfully\");\n } catch (_a) {\n alert(\"Error creating\");\n }\n case 40:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction loadPage() {\n var container = document.querySelector('#container-fluid');\n if (!container) return; // Stop if the container isn't found\n var scriptElement = document.createElement('script');\n scriptElement.src = '../dist/makeSuggestion.bundle.js';\n container.appendChild(scriptElement);\n var linkElement1 = document.createElement('link');\n linkElement1.rel = 'stylesheet';\n linkElement1.href = 'Make_Suggestion_Code/makeSuggestion.css';\n document.head.appendChild(linkElement1);\n var linkElement2 = document.createElement('link');\n linkElement2.rel = 'stylesheet';\n linkElement2.href = 'Activity_card_code/activitity_card.css';\n document.head.appendChild(linkElement2);\n fetch('Make_Suggestion_Code/makeSuggestion.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n var suggestionPage = tempContainer.querySelector('#suggestionPage');\n if (suggestionPage) {\n container.insertBefore(suggestionPage, container.firstChild);\n var submitButton = document.getElementById('suggestionButton');\n if (submitButton) {\n submitButton.addEventListener('click', submitHandler);\n } else {\n console.error(\"Error: 'suggestionButton' not found\");\n }\n loadFilter();\n }\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n}\n\n//# sourceURL=webpack://c3/./client/Make_Suggestion_Code/makeSuggestion.js?"); /***/ }), @@ -246,7 +246,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadCurrentProjects: () => (/* binding */ loadCurrentProjects),\n/* harmony export */ loadProjectPageA: () => (/* binding */ loadProjectPageA),\n/* harmony export */ loadProjectPageG: () => (/* binding */ loadProjectPageG),\n/* harmony export */ loadProjectPageP: () => (/* binding */ loadProjectPageP),\n/* harmony export */ loadProjectPageS: () => (/* binding */ loadProjectPageS)\n/* harmony export */ });\n/* harmony import */ var _currentProjects_currentProjects_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../currentProjects/currentProjects.js */ \"./client/currentProjects/currentProjects.js\");\n/* harmony import */ var _Make_Suggestion_Code_makeSuggestion_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Make_Suggestion_Code/makeSuggestion.js */ \"./client/Make_Suggestion_Code/makeSuggestion.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _KnowledgeBank_knowledgeBank_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../KnowledgeBank/knowledgeBank.js */ \"./client/KnowledgeBank/knowledgeBank.js\");\n/* harmony import */ var _KnowledgeBank_completedProjects_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../KnowledgeBank/completedProjects.js */ \"./client/KnowledgeBank/completedProjects.js\");\n/* harmony import */ var _KnowledgeBank_Nolans_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../KnowledgeBank/Nolans.js */ \"./client/KnowledgeBank/Nolans.js\");\n/* harmony import */ var _KnowledgeBank_genImprovMethods_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../KnowledgeBank/genImprovMethods.js */ \"./client/KnowledgeBank/genImprovMethods.js\");\n/* harmony import */ var _KnowledgeBank_ContactOrganization_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../KnowledgeBank/ContactOrganization.js */ \"./client/KnowledgeBank/ContactOrganization.js\");\n/* harmony import */ var _KnowledgeBank_Nolans1_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../KnowledgeBank/Nolans1.js */ \"./client/KnowledgeBank/Nolans1.js\");\n/* harmony import */ var _KnowledgeBank_Nolans2_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../KnowledgeBank/Nolans2.js */ \"./client/KnowledgeBank/Nolans2.js\");\n/* harmony import */ var _KnowledgeBank_Nolans3_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../KnowledgeBank/Nolans3.js */ \"./client/KnowledgeBank/Nolans3.js\");\n/* harmony import */ var _KnowledgeBank_Nolans4_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../KnowledgeBank/Nolans4.js */ \"./client/KnowledgeBank/Nolans4.js\");\n/* harmony import */ var _KnowledgeBank_Nolans5_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../KnowledgeBank/Nolans5.js */ \"./client/KnowledgeBank/Nolans5.js\");\n/* harmony import */ var _KnowledgeBank_Nolans6_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../KnowledgeBank/Nolans6.js */ \"./client/KnowledgeBank/Nolans6.js\");\n/* harmony import */ var _KnowledgeBank_Nolans7_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../KnowledgeBank/Nolans7.js */ \"./client/KnowledgeBank/Nolans7.js\");\n/* harmony import */ var _homePage_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../homePage.js */ \"./client/homePage.js\");\n/* harmony import */ var _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../projectPage/projectPageP.js */ \"./client/projectPage/projectPageP.js\");\n/* harmony import */ var _projectPage_projectPageG_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../projectPage/projectPageG.js */ \"./client/projectPage/projectPageG.js\");\n/* harmony import */ var _projectPage_projectPageS_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../projectPage/projectPageS.js */ \"./client/projectPage/projectPageS.js\");\n/* harmony import */ var _projectPage_projectPageA_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../projectPage/projectPageA.js */ \"./client/projectPage/projectPageA.js\");\n/* harmony import */ var _login_login_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../login/login.js */ \"./client/login/login.js\");\n/* harmony import */ var _login_register_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../login/register.js */ \"./client/login/register.js\");\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../initiateForbattringsarbete/initiateIdea.js */ \"./client/initiateForbattringsarbete/initiateIdea.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n//loading elements\nvar currentProjectButton = document.getElementById(\"currentProjects\");\nvar ideaBankButton = document.getElementById(\"ideaBankView\");\nvar knowledgeBankButton = document.getElementById(\"knowledgeBankView\");\nvar logOutButton = document.getElementById(\"log-out-button\");\nvar myProfileButton = document.getElementById(\"profileView\");\nvar makeSuggestionButton = document.getElementById(\"suggestionView\");\nvar settingsButton = document.getElementById(\"settingsView\");\nvar supportButton = document.getElementById(\"supportView\");\n//Event-listener checks, to make sure they only load once\nvar NolansEventListenersAdded = false;\nvar knowledgeBankListenersAdded = false;\nvar currentProjectsListenersAdded = false;\n//Loads loginPage as first view\nloadLoginPage();\nfunction setTitle(text) {\n var title = document.getElementById(\"titleCurrentPage\");\n if (title) {\n title.textContent = text;\n }\n}\n//Function to hide HTML elements\nfunction hideElement(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"none\";\n }\n}\nfunction removeDisplayStyle(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"\";\n }\n}\nfunction setFlexDisplay(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"flex\";\n }\n}\nfunction loadRegisterPage() {\n clearContent();\n _login_register_js__WEBPACK_IMPORTED_MODULE_21__.loadPage();\n var eventListener = function eventListener(event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var target;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n target = event.target;\n if (!(target.id === \"register-button\")) {\n _context.next = 8;\n break;\n }\n _context.next = 4;\n return _login_register_js__WEBPACK_IMPORTED_MODULE_21__.handleRegister();\n case 4:\n if (!_context.sent) {\n _context.next = 8;\n break;\n }\n hideElement(\"register-container\");\n loggedIn();\n document.removeEventListener(\"click\", eventListener);\n case 8:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n };\n document.addEventListener(\"click\", eventListener);\n}\nfunction loadLoginPage() {\n clearContent();\n _login_login_js__WEBPACK_IMPORTED_MODULE_20__.loadPage();\n var eventListener = function eventListener(event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var target;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n target = event.target;\n if (!(target.id === \"button-login\")) {\n _context2.next = 7;\n break;\n }\n _context2.next = 4;\n return _login_login_js__WEBPACK_IMPORTED_MODULE_20__.handleLogin();\n case 4:\n if (!_context2.sent) {\n _context2.next = 7;\n break;\n }\n hideElement(\"login-container\");\n loggedIn();\n case 7:\n if (target.id === \"button-register\") {\n loadRegisterPage();\n hideElement(\"login-container\");\n setFlexDisplay(\"register-container\");\n }\n case 8:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n };\n document.addEventListener(\"click\", eventListener);\n}\n//help function after logging in successfully \nfunction loggedIn() {\n setFlexDisplay(\"main\");\n loadMyProfile();\n}\nfunction logOut() {\n hideElement(\"main\");\n removeDisplayStyle(\"login-container\");\n console.log(\"du klickade på logga ut knappen\");\n _Database_authentication_js__WEBPACK_IMPORTED_MODULE_22__.logout();\n}\nfunction clearContent() {\n var container = $(\"#container-fluid\");\n container.empty();\n var clonedContainer = container.clone();\n container.replaceWith(clonedContainer);\n}\nfunction loadCurrentProjects() {\n clearContent();\n setTitle(\"Pågående förbättringsarbeten\");\n _currentProjects_currentProjects_js__WEBPACK_IMPORTED_MODULE_0__.loadPage(currentProjectsListenersAdded);\n currentProjectsListenersAdded = true;\n}\nfunction loadSuggestionPage() {\n clearContent();\n setTitle(\"Ge förslag\");\n _Make_Suggestion_Code_makeSuggestion_js__WEBPACK_IMPORTED_MODULE_1__.loadPage();\n}\nfunction loadInitiatePage(id) {\n clearContent();\n setTitle(\"Gör ditt förslag till ett förbättringsarbete!\");\n _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_23__.loadPage(id);\n}\nfunction loadIdeaBank() {\n clearContent();\n setTitle(\"Alla Idéer\");\n _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadPage();\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n //adds an event listener for the initiate page \n if (target && target.className === \"initiateProjectButton\") {\n var cardId = \"suggestion\" + target.id.replace(\"initiateProjectFromCard\", \"\");\n loadInitiatePage(cardId);\n }\n });\n}\nfunction loadKnowledgeBank() {\n clearContent();\n setTitle(\"Kunskapsbanken\");\n _KnowledgeBank_knowledgeBank_js__WEBPACK_IMPORTED_MODULE_3__.loadPage();\n //Loading Page-specific eventlistneres\n if (!knowledgeBankListenersAdded) {\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"buttons-kunskapsbanken-button1\") {\n loadNolansMain();\n } else if (target.id === \"buttons-kunskapsbanken-button2\") {\n loadGenImprovMethods();\n } else if (target.id === \"buttons-kunskapsbanken-button3\") {\n loadCompletedProjects();\n } else if (target.id === \"buttons-kunskapsbanken-button4\") {\n loadContactOrganizations();\n } else if (target.id === \"knowledge-backbutton\") {\n loadKnowledgeBank();\n }\n });\n knowledgeBankListenersAdded = true;\n }\n}\nfunction loadGenImprovMethods() {\n clearContent();\n setTitle(\"Generella förbättringsmetoder\");\n _KnowledgeBank_genImprovMethods_js__WEBPACK_IMPORTED_MODULE_6__.loadPage();\n}\nfunction loadContactOrganizations() {\n clearContent();\n setTitle(\"Kontaktinformation\");\n _KnowledgeBank_ContactOrganization_js__WEBPACK_IMPORTED_MODULE_7__.loadPage();\n}\nfunction loadNolansMain() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans_js__WEBPACK_IMPORTED_MODULE_5__.loadPage();\n if (!NolansEventListenersAdded) {\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"SattaMalSyfte\") {\n clearContent();\n loadNolans1();\n } else if (target.id === \"MataFoljaUpp\") {\n clearContent();\n loadNolans2();\n } else if (target.id === \"SamlaIdeer\") {\n clearContent();\n loadNolans3();\n } else if (target.id === \"nolansBackButton\") {\n clearContent();\n loadKnowledgeBank();\n } else if (target.id === \"nolans4\") {\n clearContent();\n loadNolans4();\n } else if (target.id === \"nolans5\") {\n clearContent();\n loadNolans5();\n } else if (target.id === \"nolans6\") {\n clearContent();\n loadNolans6();\n } else if (target.id === \"nolans7\") {\n clearContent();\n loadNolans7();\n }\n });\n NolansEventListenersAdded = true;\n }\n}\nfunction loadNolans1() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans1_js__WEBPACK_IMPORTED_MODULE_8__.loadPage();\n}\nfunction loadNolans2() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans2_js__WEBPACK_IMPORTED_MODULE_9__.loadPage();\n}\nfunction loadNolans3() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans3_js__WEBPACK_IMPORTED_MODULE_10__.loadPage();\n}\nfunction loadNolans4() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans4_js__WEBPACK_IMPORTED_MODULE_11__.loadPage();\n}\nfunction loadNolans5() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans5_js__WEBPACK_IMPORTED_MODULE_12__.loadPage();\n}\nfunction loadNolans6() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans6_js__WEBPACK_IMPORTED_MODULE_13__.loadPage();\n}\nfunction loadNolans7() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans7_js__WEBPACK_IMPORTED_MODULE_14__.loadPage();\n}\nfunction loadProjectPageP(projectId) {\n clearContent();\n setTitle(\"Planera\");\n _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_16__.loadPage(projectId);\n}\nfunction loadProjectPageG(projectId) {\n clearContent();\n setTitle(\"Göra\");\n _projectPage_projectPageG_js__WEBPACK_IMPORTED_MODULE_17__.loadPage(projectId);\n}\nfunction loadProjectPageS(projectId) {\n clearContent();\n setTitle(\"Studera\");\n _projectPage_projectPageS_js__WEBPACK_IMPORTED_MODULE_18__.loadPage(projectId);\n}\nfunction loadProjectPageA(projectId) {\n clearContent();\n setTitle(\"Agera\");\n _projectPage_projectPageA_js__WEBPACK_IMPORTED_MODULE_19__.loadPage(projectId);\n}\nfunction loadCompletedProjects() {\n clearContent();\n setTitle(\"Avslutade förbättringsarbeten\");\n _KnowledgeBank_completedProjects_js__WEBPACK_IMPORTED_MODULE_4__.loadPage();\n //Page-specific eventlisteners\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"departmentDropdown\") {} else if (target.id === \"dateDropdown\") {}\n });\n}\nfunction loadMyProfile() {\n clearContent();\n setTitle(\"Din Profil\");\n _homePage_js__WEBPACK_IMPORTED_MODULE_15__.loadPage(); //fix containers\n}\n\nfunction loadSettings() {\n clearContent();\n setTitle(\"Inställningar\");\n //load settings function\n}\n\nfunction loadSupport() {\n clearContent();\n setTitle(\"Hjälp och Support\");\n //load support function\n}\n\nlogOutButton.addEventListener(\"click\", logOut);\ncurrentProjectButton.addEventListener(\"click\", loadCurrentProjects);\nideaBankButton.addEventListener(\"click\", loadIdeaBank);\nmakeSuggestionButton.addEventListener(\"click\", loadSuggestionPage);\nknowledgeBankButton.addEventListener(\"click\", loadKnowledgeBank);\nmyProfileButton.addEventListener(\"click\", loadMyProfile);\nsettingsButton.addEventListener(\"click\", loadSettings);\nsupportButton.addEventListener(\"click\", loadSupport);\n\n//# sourceURL=webpack://c3/./client/SidebarAndHeader/pageHandler.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadCurrentProjects: () => (/* binding */ loadCurrentProjects),\n/* harmony export */ loadProjectPageA: () => (/* binding */ loadProjectPageA),\n/* harmony export */ loadProjectPageG: () => (/* binding */ loadProjectPageG),\n/* harmony export */ loadProjectPageP: () => (/* binding */ loadProjectPageP),\n/* harmony export */ loadProjectPageS: () => (/* binding */ loadProjectPageS)\n/* harmony export */ });\n/* harmony import */ var _currentProjects_currentProjects_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../currentProjects/currentProjects.js */ \"./client/currentProjects/currentProjects.js\");\n/* harmony import */ var _Make_Suggestion_Code_makeSuggestion_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Make_Suggestion_Code/makeSuggestion.js */ \"./client/Make_Suggestion_Code/makeSuggestion.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _KnowledgeBank_knowledgeBank_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../KnowledgeBank/knowledgeBank.js */ \"./client/KnowledgeBank/knowledgeBank.js\");\n/* harmony import */ var _KnowledgeBank_completedProjects_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../KnowledgeBank/completedProjects.js */ \"./client/KnowledgeBank/completedProjects.js\");\n/* harmony import */ var _KnowledgeBank_Nolans_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../KnowledgeBank/Nolans.js */ \"./client/KnowledgeBank/Nolans.js\");\n/* harmony import */ var _KnowledgeBank_genImprovMethods_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../KnowledgeBank/genImprovMethods.js */ \"./client/KnowledgeBank/genImprovMethods.js\");\n/* harmony import */ var _KnowledgeBank_ContactOrganization_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../KnowledgeBank/ContactOrganization.js */ \"./client/KnowledgeBank/ContactOrganization.js\");\n/* harmony import */ var _KnowledgeBank_Nolans1_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../KnowledgeBank/Nolans1.js */ \"./client/KnowledgeBank/Nolans1.js\");\n/* harmony import */ var _KnowledgeBank_Nolans2_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../KnowledgeBank/Nolans2.js */ \"./client/KnowledgeBank/Nolans2.js\");\n/* harmony import */ var _KnowledgeBank_Nolans3_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../KnowledgeBank/Nolans3.js */ \"./client/KnowledgeBank/Nolans3.js\");\n/* harmony import */ var _KnowledgeBank_Nolans4_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../KnowledgeBank/Nolans4.js */ \"./client/KnowledgeBank/Nolans4.js\");\n/* harmony import */ var _KnowledgeBank_Nolans5_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../KnowledgeBank/Nolans5.js */ \"./client/KnowledgeBank/Nolans5.js\");\n/* harmony import */ var _KnowledgeBank_Nolans6_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../KnowledgeBank/Nolans6.js */ \"./client/KnowledgeBank/Nolans6.js\");\n/* harmony import */ var _KnowledgeBank_Nolans7_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../KnowledgeBank/Nolans7.js */ \"./client/KnowledgeBank/Nolans7.js\");\n/* harmony import */ var _homePage_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../homePage.js */ \"./client/homePage.js\");\n/* harmony import */ var _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../projectPage/projectPageP.js */ \"./client/projectPage/projectPageP.js\");\n/* harmony import */ var _projectPage_projectPageG_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../projectPage/projectPageG.js */ \"./client/projectPage/projectPageG.js\");\n/* harmony import */ var _projectPage_projectPageS_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../projectPage/projectPageS.js */ \"./client/projectPage/projectPageS.js\");\n/* harmony import */ var _projectPage_projectPageA_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../projectPage/projectPageA.js */ \"./client/projectPage/projectPageA.js\");\n/* harmony import */ var _login_login_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../login/login.js */ \"./client/login/login.js\");\n/* harmony import */ var _login_register_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../login/register.js */ \"./client/login/register.js\");\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../initiateForbattringsarbete/initiateIdea.js */ \"./client/initiateForbattringsarbete/initiateIdea.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n//loading elements\nvar currentProjectButton = document.getElementById(\"currentProjects\");\nvar ideaBankButton = document.getElementById(\"ideaBankView\");\nvar knowledgeBankButton = document.getElementById(\"knowledgeBankView\");\nvar logOutButton = document.getElementById(\"log-out-button\");\nvar myProfileButton = document.getElementById(\"profileView\");\nvar makeSuggestionButton = document.getElementById(\"suggestionView\");\nvar settingsButton = document.getElementById(\"settingsView\");\nvar supportButton = document.getElementById(\"supportView\");\n//Event-listener checks, to make sure they only load once\nvar NolansEventListenersAdded = false;\nvar knowledgeBankListenersAdded = false;\nvar currentProjectsListenersAdded = false;\n//Loads loginPage as first view\nloadLoginPage();\nfunction setTitle(text) {\n var title = document.getElementById(\"titleCurrentPage\");\n if (title) {\n title.textContent = text;\n }\n}\n//Function to hide HTML elements\nfunction hideElement(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"none\";\n }\n}\nfunction removeDisplayStyle(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"\";\n }\n}\nfunction setFlexDisplay(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"flex\";\n }\n}\nfunction loadRegisterPage() {\n clearContent();\n _login_register_js__WEBPACK_IMPORTED_MODULE_21__.loadPage();\n var eventListener = function eventListener(event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var target;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n target = event.target;\n if (!(target.id === \"register-button\")) {\n _context.next = 8;\n break;\n }\n _context.next = 4;\n return _login_register_js__WEBPACK_IMPORTED_MODULE_21__.handleRegister();\n case 4:\n if (!_context.sent) {\n _context.next = 8;\n break;\n }\n hideElement(\"register-container\");\n loggedIn();\n document.removeEventListener(\"click\", eventListener);\n case 8:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n };\n document.addEventListener(\"click\", eventListener);\n}\nfunction loadLoginPage() {\n clearContent();\n _login_login_js__WEBPACK_IMPORTED_MODULE_20__.loadPage();\n var eventListener = function eventListener(event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var target;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n target = event.target;\n if (!(target.id === \"button-login\")) {\n _context2.next = 7;\n break;\n }\n _context2.next = 4;\n return _login_login_js__WEBPACK_IMPORTED_MODULE_20__.handleLogin();\n case 4:\n if (!_context2.sent) {\n _context2.next = 7;\n break;\n }\n hideElement(\"login-container\");\n loggedIn();\n case 7:\n if (target.id === \"button-register\") {\n loadRegisterPage();\n hideElement(\"login-container\");\n setFlexDisplay(\"register-container\");\n }\n case 8:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n };\n document.addEventListener(\"click\", eventListener);\n}\n//help function after logging in successfully \nfunction loggedIn() {\n setFlexDisplay(\"main\");\n loadMyProfile();\n}\nfunction logOut() {\n hideElement(\"main\");\n removeDisplayStyle(\"login-container\");\n console.log(\"du klickade på logga ut knappen\");\n _Database_authentication_js__WEBPACK_IMPORTED_MODULE_22__.logout();\n}\nfunction clearContent() {\n var container = $(\"#container-fluid\");\n container.empty();\n var clonedContainer = container.clone();\n container.replaceWith(clonedContainer);\n}\nfunction loadCurrentProjects() {\n clearContent();\n setTitle(\"Pågående förbättringsarbeten\");\n _currentProjects_currentProjects_js__WEBPACK_IMPORTED_MODULE_0__.loadPage(currentProjectsListenersAdded);\n currentProjectsListenersAdded = true;\n}\nfunction loadSuggestionPage() {\n clearContent();\n setTitle(\"Ge förslag\");\n _Make_Suggestion_Code_makeSuggestion_js__WEBPACK_IMPORTED_MODULE_1__.loadPage();\n}\nfunction loadInitiatePage(id) {\n clearContent();\n setTitle(\"Gör ditt förslag till ett förbättringsarbete!\");\n _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_23__.loadPage(id);\n}\nfunction loadIdeaBank() {\n clearContent();\n setTitle(\"Alla Idéer\");\n _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadPage();\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n //adds an event listener for the initiate page \n if (target && target.className === \"initiateProjectButton\") {\n var cardId = target.id.replace(\"initiateProjectFromCard\", \"\");\n loadInitiatePage(cardId);\n }\n });\n}\nfunction loadKnowledgeBank() {\n clearContent();\n setTitle(\"Kunskapsbanken\");\n _KnowledgeBank_knowledgeBank_js__WEBPACK_IMPORTED_MODULE_3__.loadPage();\n //Loading Page-specific eventlistneres\n if (!knowledgeBankListenersAdded) {\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"buttons-kunskapsbanken-button1\") {\n loadNolansMain();\n } else if (target.id === \"buttons-kunskapsbanken-button2\") {\n loadGenImprovMethods();\n } else if (target.id === \"buttons-kunskapsbanken-button3\") {\n loadCompletedProjects();\n } else if (target.id === \"buttons-kunskapsbanken-button4\") {\n loadContactOrganizations();\n } else if (target.id === \"knowledge-backbutton\") {\n loadKnowledgeBank();\n }\n });\n knowledgeBankListenersAdded = true;\n }\n}\nfunction loadGenImprovMethods() {\n clearContent();\n setTitle(\"Generella förbättringsmetoder\");\n _KnowledgeBank_genImprovMethods_js__WEBPACK_IMPORTED_MODULE_6__.loadPage();\n}\nfunction loadContactOrganizations() {\n clearContent();\n setTitle(\"Kontaktinformation\");\n _KnowledgeBank_ContactOrganization_js__WEBPACK_IMPORTED_MODULE_7__.loadPage();\n}\nfunction loadNolansMain() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans_js__WEBPACK_IMPORTED_MODULE_5__.loadPage();\n if (!NolansEventListenersAdded) {\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"SattaMalSyfte\") {\n clearContent();\n loadNolans1();\n } else if (target.id === \"MataFoljaUpp\") {\n clearContent();\n loadNolans2();\n } else if (target.id === \"SamlaIdeer\") {\n clearContent();\n loadNolans3();\n } else if (target.id === \"nolansBackButton\") {\n clearContent();\n loadKnowledgeBank();\n } else if (target.id === \"nolans4\") {\n clearContent();\n loadNolans4();\n } else if (target.id === \"nolans5\") {\n clearContent();\n loadNolans5();\n } else if (target.id === \"nolans6\") {\n clearContent();\n loadNolans6();\n } else if (target.id === \"nolans7\") {\n clearContent();\n loadNolans7();\n }\n });\n NolansEventListenersAdded = true;\n }\n}\nfunction loadNolans1() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans1_js__WEBPACK_IMPORTED_MODULE_8__.loadPage();\n}\nfunction loadNolans2() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans2_js__WEBPACK_IMPORTED_MODULE_9__.loadPage();\n}\nfunction loadNolans3() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans3_js__WEBPACK_IMPORTED_MODULE_10__.loadPage();\n}\nfunction loadNolans4() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans4_js__WEBPACK_IMPORTED_MODULE_11__.loadPage();\n}\nfunction loadNolans5() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans5_js__WEBPACK_IMPORTED_MODULE_12__.loadPage();\n}\nfunction loadNolans6() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans6_js__WEBPACK_IMPORTED_MODULE_13__.loadPage();\n}\nfunction loadNolans7() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans7_js__WEBPACK_IMPORTED_MODULE_14__.loadPage();\n}\nfunction loadProjectPageP(projectId) {\n clearContent();\n setTitle(\"Planera\");\n _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_16__.loadPage(projectId);\n}\nfunction loadProjectPageG(projectId) {\n clearContent();\n setTitle(\"Göra\");\n _projectPage_projectPageG_js__WEBPACK_IMPORTED_MODULE_17__.loadPage(projectId);\n}\nfunction loadProjectPageS(projectId) {\n clearContent();\n setTitle(\"Studera\");\n _projectPage_projectPageS_js__WEBPACK_IMPORTED_MODULE_18__.loadPage(projectId);\n}\nfunction loadProjectPageA(projectId) {\n clearContent();\n setTitle(\"Agera\");\n _projectPage_projectPageA_js__WEBPACK_IMPORTED_MODULE_19__.loadPage(projectId);\n}\nfunction loadCompletedProjects() {\n clearContent();\n setTitle(\"Avslutade förbättringsarbeten\");\n _KnowledgeBank_completedProjects_js__WEBPACK_IMPORTED_MODULE_4__.loadPage();\n //Page-specific eventlisteners\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"departmentDropdown\") {} else if (target.id === \"dateDropdown\") {}\n });\n}\nfunction loadMyProfile() {\n clearContent();\n setTitle(\"Din Profil\");\n _homePage_js__WEBPACK_IMPORTED_MODULE_15__.loadPage(); //fix containers\n}\n\nfunction loadSettings() {\n clearContent();\n setTitle(\"Inställningar\");\n //load settings function\n}\n\nfunction loadSupport() {\n clearContent();\n setTitle(\"Hjälp och Support\");\n //load support function\n}\n\nlogOutButton.addEventListener(\"click\", logOut);\ncurrentProjectButton.addEventListener(\"click\", loadCurrentProjects);\nideaBankButton.addEventListener(\"click\", loadIdeaBank);\nmakeSuggestionButton.addEventListener(\"click\", loadSuggestionPage);\nknowledgeBankButton.addEventListener(\"click\", loadKnowledgeBank);\nmyProfileButton.addEventListener(\"click\", loadMyProfile);\nsettingsButton.addEventListener(\"click\", loadSettings);\nsupportButton.addEventListener(\"click\", loadSupport);\n\n//# sourceURL=webpack://c3/./client/SidebarAndHeader/pageHandler.js?"); /***/ }), @@ -256,7 +256,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \***************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n\n\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\nvar projectCards = {};\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = '^ Stäng detaljer';\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = '> Mer information';\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert('The initiate project page should now be loaded');\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"totalExpandedOngoingWorkCard\\\">\\n <div class=\\\"flex-container ongoingCard\\\" id=\\\"\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\" id=\\\"pinkFaded\\\"></div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n </div>\\n\\n <button data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton\\\" role=\\\"button\\\">G\\xE5 till projektsidan</button>\\n\\n\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n <p id=\\\"ongoingSeeDetailsButton\").concat(this.id, \"\\\" class = \\\"moreInfoClass\\\">> Mer information</p>\\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}();\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var container;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n container = document.querySelector('#container-fluid');\n if (container) {\n _context.next = 3;\n break;\n }\n return _context.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n projectCards = {};\n fetch('currentProjects/currentProjects.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.filterBar');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n getProjects(container, listenersLoaded);\n case 6:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction getProjects(selectElement, listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var _this = this;\n var data, id;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({});\n case 2:\n data = _context3.sent;\n id = 0;\n data.forEach(function (project) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var title, department, name, description, i, card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n title = project.name;\n _context2.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)('unit', project.unitId);\n case 3:\n department = _context2.sent;\n if (!department) {\n _context2.next = 21;\n break;\n }\n name = \"Projektledare\"; //Waiting for backend fix\n description = project.content;\n i = id;\n card = new projectCard(i, name, department.name, title, description, project.id);\n projectCards[i] = card;\n cardHTML = card.generateHTML();\n addEventListener(listenersLoaded, project.id, card);\n div = document.createElement('div');\n div.className = 'projectCardCardDiv'; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context2.next = 17;\n break;\n }\n return _context2.abrupt(\"return\");\n case 17:\n selectElement.appendChild(div); // Stop if the container isn't found\n id++;\n _context2.next = 22;\n break;\n case 21:\n console.log(project.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist \n case 22:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n });\n case 5:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction addEventListener(listenersLoaded, projectId, card) {\n if (!listenersLoaded) {\n $(document).on('click', '#' + projectId, function (event) {\n var element = event.target;\n if (element.classList.contains('moreInfoClass')) {\n var expandedDiv = document.getElementById('expandedOngoingWorkCard' + projectId);\n if (expandedDiv && expandedDiv.style.display === 'none') {\n card.showMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"ongoingSeeDetailsButton\" + projectId);\n } else {\n card.closeMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"ongoingSeeDetailsButton\" + projectId);\n }\n } else {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n }\n });\n }\n}\n\n//# sourceURL=webpack://c3/./client/currentProjects/currentProjects.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n\n\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\nvar projectCards = {};\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId, currentStage) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n this.stage = currentStage;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = '^ Stäng detaljer';\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = '> Mer information';\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert('The initiate project page should now be loaded');\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"totalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: pointer;\\\" class=\\\"flex-container ongoingCard\\\" id=\\\"\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\" id=\\\"pinkFaded\\\"></div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n </div>\\n\\n <button data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton\\\" role=\\\"button\\\">G\\xE5 till projektsidan</button>\\n\\n <div class=\\\"statusText\\\">\\n Status: \").concat(this.stage, \"\\n </div>\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n <p id=\\\"ongoingSeeDetailsButton\").concat(this.projectId, \"\\\" class = \\\"moreInfoClass\\\">> Mer information</p>\\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}();\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var container;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n container = document.querySelector('#container-fluid');\n if (container) {\n _context.next = 3;\n break;\n }\n return _context.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n projectCards = {};\n fetch('currentProjects/currentProjects.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.filterBar');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n getProjects(container, listenersLoaded);\n case 6:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction getProjects(selectElement, listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var _this = this;\n var data, id;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({});\n case 2:\n data = _context3.sent;\n id = 0;\n data.forEach(function (project) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var title, department, name, description, i, card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n title = project.name;\n _context2.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)('unit', project.unitId);\n case 3:\n department = _context2.sent;\n if (!department) {\n _context2.next = 21;\n break;\n }\n name = \"Projektledare\"; //Waiting for backend fix\n description = project.content;\n i = id;\n card = new projectCard(i, name, department.name, title, description, project.id, project.currentStage);\n projectCards[i] = card;\n cardHTML = card.generateHTML();\n addEventListener(listenersLoaded, project.id, card);\n div = document.createElement('div');\n div.className = 'projectCardCardDiv'; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context2.next = 17;\n break;\n }\n return _context2.abrupt(\"return\");\n case 17:\n selectElement.appendChild(div); // Stop if the container isn't found\n id++;\n _context2.next = 22;\n break;\n case 21:\n console.log(project.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist \n case 22:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n });\n case 5:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction addEventListener(listenersLoaded, projectId, card) {\n if (!listenersLoaded) {\n $(document).on('click', '#' + projectId, function (event) {\n var element = event.target;\n if (element.classList.contains('moreInfoClass')) {\n var expandedDiv = document.getElementById('expandedOngoingWorkCard' + projectId);\n if (expandedDiv && expandedDiv.style.display === 'none') {\n card.showMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"ongoingSeeDetailsButton\" + projectId);\n } else {\n card.closeMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"ongoingSeeDetailsButton\" + projectId);\n }\n } else if (element.classList.contains('projectButton')) {\n var currentStage = card.stage;\n if (currentStage === 'Agera') {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageA)(projectId);\n } else if (currentStage === 'Studera') {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageS)(projectId);\n } else if (currentStage === 'Göra') {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageG)(projectId);\n } else if (currentStage === 'Planera') {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n } else if (currentStage === 'Avslutat') {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n }\n }\n });\n }\n}\n\n//# sourceURL=webpack://c3/./client/currentProjects/currentProjects.js?"); /***/ }), @@ -266,7 +266,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \****************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../client/Database/database.js */ \"./client/Database/database.js\");\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\nfunction logoutUser(event) {\n event.preventDefault();\n alert('logout');\n (0,_Database_authentication_js__WEBPACK_IMPORTED_MODULE_0__.logout)();\n}\n//Mock-data, to be replaced\nvar homePageSampleProjects = [{\n ID: \"1\",\n name: \"Birthing of a Child\",\n current_stage: \"In Progress\",\n content: \"This is project 1.\",\n unit_ID: \"2\",\n date_started: new Date(\"2023-01-15\")\n}, {\n ID: \"2\",\n name: \"How to save a life\",\n current_stage: \"Completed\",\n content: \"This is project 2.\",\n unit_ID: \"1\",\n date_started: new Date(\"2023-02-20\")\n}, {\n ID: \"3\",\n name: \"BB tutorial\",\n current_stage: \"Completed\",\n content: \"This is project 3.\",\n unit_ID: \"2\",\n date_started: new Date(\"2023-06-05\")\n}, {\n ID: \"4\",\n name: \"Cancerbehandling 101\",\n current_stage: \"Completed\",\n content: \"This is project 4.\",\n unit_ID: \"3\",\n date_started: new Date(\"2023-10-24\")\n}, {\n ID: \"5\",\n name: \"Cancerbehandling 101\",\n current_stage: \"Completed\",\n content: \"This is project 4.\",\n unit_ID: \"3\",\n date_started: new Date(\"2023-10-24\")\n}, {\n ID: \"6\",\n name: \"Cancerbehandling 101\",\n current_stage: \"Completed\",\n content: \"This is project 4.\",\n unit_ID: \"3\",\n date_started: new Date(\"2023-10-24\")\n}];\nvar signedInUserHsaID = \"alijoh234\";\nvar myIdeaCards = {};\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n }\n _createClass(IdeaCard, [{\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImage\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFaded\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n </div>\\n <div class=\\\"ideaCardUpvotes\\\">\\n <img src=\\\"images/upvoteIcon.png\\\" class =\\\"upvoteIcon\\\" alt=\\\"upvoteIcon\\\">\\n <p id =\\\"upvoteNumber\\\" class=\\\"ideaCardFont\\\">\").concat(this.upvoteCount, \"</p>\\n </div>\\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <p class=\\\"ideaCardFont\\\">Kommentarer</p>\\n <p class=\\\"ideaCardFont\\\">Komment 1</p>\\n <p class=\\\"ideaCardFont\\\">K0mment 2</p>\\n </div>\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProject\\\" onclick=\\\"myIdeaCards[\").concat(this.id, \"].loadInitiatePage()\\\">Initiera Project</button>\\n </div>\\n </div>\\n </div>\\n </div>\");\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var user, userSuggestions, counter;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"users\", signedInUserHsaID);\n case 2:\n user = _context2.sent;\n _context2.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 5:\n userSuggestions = _context2.sent;\n //If there exist filter use those instead to get matching suggestions rest should not need to be changed\n counter = 0;\n userSuggestions.forEach(function (suggestion) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context.sent;\n _context.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context.sent;\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter);\n counter = counter + 1;\n case 8:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n case 8:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount);\n cardHTML = card.generateHTML();\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n container.appendChild(div);\n case 7:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction loadPage() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this2 = this;\n var container;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n container = document.querySelector('#container-fluid');\n if (container) {\n _context5.next = 3;\n break;\n }\n return _context5.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n fetch('homePage.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var tempContainer, specificElement, tmp, user, suggestionContainer, nameHeaderElement, nameElement, emailElement, roleElement, unitElement, userFullName, userUnits, userUnit;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n // Create a temporary container element to hold the loaded content\n tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n specificElement = tempContainer.querySelector('.main-content');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n tmp = localStorage.getItem('user');\n console.log(tmp);\n if (tmp) {\n _context4.next = 9;\n break;\n }\n console.log(\"there is not an user in localStorage\");\n return _context4.abrupt(\"return\");\n case 9:\n user = JSON.parse(tmp)[0];\n displayProjects(user);\n //displaySuggestions(user);\n suggestionContainer = document.getElementById(\"suggestion-container\");\n if (!suggestionContainer) {\n _context4.next = 15;\n break;\n }\n _context4.next = 15;\n return createNewCards(\"HomePageIdeaCardDiv\", suggestionContainer);\n case 15:\n console.log(user.firstName + \"user.firstname\");\n nameHeaderElement = document.getElementById('user-name-header');\n nameElement = document.getElementById('user-name');\n emailElement = document.getElementById('user-email');\n roleElement = document.getElementById('user-role');\n unitElement = document.getElementById(\"user-unit\");\n userFullName = user.firstName + \" \" + user.lastName;\n _context4.next = 24;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getUnits)({\n unitId: user.unitId\n });\n case 24:\n userUnits = _context4.sent;\n userUnit = userUnits[0];\n if (emailElement && roleElement && nameElement && unitElement && nameHeaderElement) {\n nameHeaderElement.textContent = userFullName;\n nameElement.textContent = userFullName;\n unitElement.textContent = userUnit.name;\n emailElement.textContent = user.email;\n roleElement.textContent = \"undefined\";\n }\n case 27:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n case 4:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction displayProjects(user) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var container, userImprovementWorks;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n container = document.getElementById('project-container');\n userImprovementWorks = user.improvementWorks;\n userImprovementWorks.forEach(function (project) {\n console.log(project.improvementWorkId);\n var improvementWork = (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"improvementWork\", project.improvementWorkId);\n var projectBox = document.createElement('div');\n projectBox.classList.add('project-box');\n var projectName = document.createElement('h2');\n projectName.textContent = project.name;\n projectBox.appendChild(projectName);\n container === null || container === void 0 ? void 0 : container.appendChild(projectBox);\n });\n case 3:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction displaySuggestions(user) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var container, userSuggestions;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n container = document.getElementById('suggestion-container');\n _context7.next = 3;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 3:\n userSuggestions = _context7.sent;\n userSuggestions.forEach(function (suggestion) {\n var suggestionBox = document.createElement('div');\n suggestionBox.classList.add('suggestion-box');\n var suggestionName = document.createElement('h2');\n suggestionName.textContent = suggestion.name;\n var suggestionDescription = document.createElement('p');\n suggestionDescription.textContent = suggestion.area;\n suggestionDescription.classList.add('suggestion-description');\n suggestionDescription.style.display = 'none'; // Initially hide the description\n var expandButton = document.createElement('button');\n expandButton.textContent = 'Expand';\n expandButton.addEventListener('click', function () {\n if (suggestionDescription.style.display === 'none') {\n suggestionDescription.style.display = 'block';\n expandButton.textContent = 'Collapse';\n } else {\n suggestionDescription.style.display = 'none';\n expandButton.textContent = 'Expand';\n }\n });\n suggestionBox.appendChild(suggestionName);\n suggestionBox.appendChild(expandButton);\n suggestionBox.appendChild(suggestionDescription);\n container === null || container === void 0 ? void 0 : container.appendChild(suggestionBox);\n });\n case 5:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/homePage.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../client/Database/database.js */ \"./client/Database/database.js\");\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\nfunction logoutUser(event) {\n event.preventDefault();\n alert('logout');\n (0,_Database_authentication_js__WEBPACK_IMPORTED_MODULE_0__.logout)();\n}\nvar myIdeaCards = {};\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n }\n _createClass(IdeaCard, [{\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImage\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFaded\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n </div>\\n <div class=\\\"ideaCardUpvotes\\\">\\n <img src=\\\"images/upvoteIcon.png\\\" class =\\\"upvoteIcon\\\" alt=\\\"upvoteIcon\\\">\\n <p id =\\\"upvoteNumber\\\" class=\\\"ideaCardFont\\\">\").concat(this.upvoteCount, \"</p>\\n </div>\\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <p class=\\\"ideaCardFont\\\">Kommentarer</p>\\n <p class=\\\"ideaCardFont\\\">Komment 1</p>\\n <p class=\\\"ideaCardFont\\\">K0mment 2</p>\\n </div>\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProject\\\" onclick=\\\"myIdeaCards[\").concat(this.id, \"].loadInitiatePage()\\\">Initiera Project</button>\\n </div>\\n </div>\\n </div>\\n </div>\");\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container, signedInUserHsaID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var user, userSuggestions, counter;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"users\", signedInUserHsaID);\n case 2:\n user = _context2.sent;\n _context2.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 5:\n userSuggestions = _context2.sent;\n //If there exist filter use those instead to get matching suggestions rest should not need to be changed\n counter = 0;\n userSuggestions.forEach(function (suggestion) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context.sent;\n _context.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context.sent;\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter);\n counter = counter + 1;\n case 8:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n case 8:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount);\n cardHTML = card.generateHTML();\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n container.appendChild(div);\n case 7:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction loadPage() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this2 = this;\n var container;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n container = document.querySelector('#container-fluid');\n if (container) {\n _context5.next = 3;\n break;\n }\n return _context5.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n fetch('homePage.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var tempContainer, specificElement, tmp, user, suggestionContainer, nameHeaderElement, nameElement, emailElement, roleElement, unitElement, userFullName, userUnits, userUnit, projectContainer;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n // Create a temporary container element to hold the loaded content\n tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n specificElement = tempContainer.querySelector('.main-content');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n tmp = localStorage.getItem('user');\n console.log(tmp);\n if (tmp) {\n _context4.next = 9;\n break;\n }\n console.log(\"there is not an user in localStorage\");\n return _context4.abrupt(\"return\");\n case 9:\n user = JSON.parse(tmp)[0];\n suggestionContainer = document.getElementById(\"suggestion-container\");\n if (!suggestionContainer) {\n _context4.next = 14;\n break;\n }\n _context4.next = 14;\n return createNewCards(\"HomePageIdeaCardDiv\", suggestionContainer, user.id);\n case 14:\n console.log(user.firstName + \"user.firstname\");\n nameHeaderElement = document.getElementById('user-name-header');\n nameElement = document.getElementById('user-name');\n emailElement = document.getElementById('user-email');\n roleElement = document.getElementById('user-role');\n unitElement = document.getElementById(\"user-unit\");\n userFullName = user.firstName + \" \" + user.lastName;\n _context4.next = 23;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getUnits)({\n unitId: user.unitId\n });\n case 23:\n userUnits = _context4.sent;\n userUnit = userUnits[0];\n if (emailElement && roleElement && nameElement && unitElement && nameHeaderElement) {\n nameHeaderElement.textContent = userFullName;\n nameElement.textContent = userFullName;\n unitElement.textContent = userUnit.name;\n emailElement.textContent = user.email;\n roleElement.textContent = \"undefined\";\n }\n projectContainer = document.getElementById(\"project-container\");\n if (!projectContainer) {\n _context4.next = 30;\n break;\n }\n _context4.next = 30;\n return getProjects(projectContainer, user.id);\n case 30:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n case 4:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction getProjects(selectElement, /*listenersLoaded:boolean,*/userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var _this3 = this;\n var data, id;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getImprovementWorksForUser)(userHsaId);\n case 2:\n data = _context7.sent;\n id = 0;\n data.forEach(function (project) {\n return __awaiter(_this3, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var title, department, name, description, i, card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n title = project.name;\n _context6.next = 3;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)('unit', project.unitId);\n case 3:\n department = _context6.sent;\n if (!department) {\n _context6.next = 20;\n break;\n }\n name = \"Projektledare\"; //Waiting for backend fix\n description = project.content;\n i = id;\n card = new projectCard(i, name, department.name, title, description, project.id);\n projectCards[i] = card;\n cardHTML = card.generateHTML(); //addEventListener(listenersLoaded, project.id, card);\n div = document.createElement('div');\n div.className = 'homePageProjectCardDiv'; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context6.next = 16;\n break;\n }\n return _context6.abrupt(\"return\");\n case 16:\n selectElement.appendChild(div); // Stop if the container isn't found\n id++;\n _context6.next = 21;\n break;\n case 20:\n console.log(project.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist \n case 21:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n });\n case 5:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nvar projectCards = {};\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = '^ Stäng detaljer';\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = '> Mer information';\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert('The initiate project page should now be loaded');\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"homeTotalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: pointer;\\\" class=\\\"flex-container ongoingCard\\\" id=\\\"\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\" id=\\\"pinkFaded\\\"></div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n </div>\\n\\n <!--<button data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton\\\" role=\\\"button\\\">G\\xE5 till projektsidan</button>-->\\n\\n\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n <p id=\\\"ongoingSeeDetailsButton\").concat(this.projectId, \"\\\" class = \\\"moreInfoClass\\\">> Mer information</p>\\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}();\n\n//# sourceURL=webpack://c3/./client/homePage.js?"); /***/ }), @@ -276,7 +276,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \*************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ testFunc: () => (/* binding */ testFunc)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n//import {loadInitiatePage} from \"../SidebarAndHeader/pageHandler.js\";\nvar myIdeaCards = {};\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n }\n _createClass(IdeaCard, [{\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImage\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFaded\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n </div>\\n <div class=\\\"ideaCardUpvotes\\\">\\n <img src=\\\"images/upvoteIcon.png\\\" class =\\\"upvoteIcon\\\" alt=\\\"upvoteIcon\\\">\\n <p id =\\\"upvoteNumber\\\" class=\\\"ideaCardFont\\\">\").concat(this.upvoteCount, \"</p>\\n </div>\\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <p class=\\\"ideaCardFont\\\">Kommentarer</p>\\n <p class=\\\"ideaCardFont\\\">Komment 7</p>\\n <p class=\\\"ideaCardFont\\\">K0mment 2</p>\\n </div>\\n\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.id, \"\\\">Initiera Project</button>\\n </div>\\n </div>\\n </div>\\n </div>\");\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n window.location.href = '../client/projectPage/projectPageP.html';\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var suggestions, counter;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 2:\n suggestions = _context2.sent;\n //If there exist filter use those instead to get matching suggestions rest should not need to be changed\n counter = 1;\n suggestions.forEach(function (suggestion) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context.sent;\n _context.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context.sent;\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter);\n counter = counter + 1;\n case 8:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n case 5:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount);\n cardHTML = card.generateHTML();\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n container.appendChild(div);\n case 7:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction testFunc() {\n console.log(\"Test func works\");\n}\nfunction loadPage() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var container, scriptElement;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context4.next = 3;\n break;\n }\n return _context4.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n scriptElement = document.createElement(\"script\");\n scriptElement.src = \"../dist/ideaBank.bundle.js\";\n container.appendChild(scriptElement);\n fetch(\"ideaBank/ideaBank.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBar\");\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n myIdeaCards = {};\n _context4.next = 10;\n return createNewCards(\"IdeaCardDiv\", container);\n case 10:\n addListner(myIdeaCards, container);\n case 11:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n}\nfunction addListner(cardArray, element) {\n element.addEventListener(\"click\", function (event) {\n var target = event.target;\n //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n var cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n var card = cardArray[cardId];\n var expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n //adds an event listener for the initiate page \n // if (target && target.className === \"initiateProjectButton\") {\n // const cardId = parseInt(target.id.replace(\"initiateProjectFromCard\", \"\"), 10);\n // if (cardArray[cardId]) {\n // $(\"#container-fluid\").empty();\n // loadInitiatePage(cardId);\n // }\n //}\n });\n}\n\n//# sourceURL=webpack://c3/./client/ideaBank/ideaBank.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ testFunc: () => (/* binding */ testFunc)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n//import {loadInitiatePage} from \"../SidebarAndHeader/pageHandler.js\";\nvar myIdeaCards = {};\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount, suggestionID) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n this.suggestionID = suggestionID;\n }\n _createClass(IdeaCard, [{\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImage\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFaded\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n </div>\\n <div class=\\\"ideaCardUpvotes\\\">\\n <img src=\\\"images/upvoteIcon.png\\\" class =\\\"upvoteIcon\\\" alt=\\\"upvoteIcon\\\">\\n <p id =\\\"upvoteNumber\\\" class=\\\"ideaCardFont\\\">\").concat(this.upvoteCount, \"</p>\\n </div>\\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <p class=\\\"ideaCardFont\\\">Kommentarer</p>\\n <p class=\\\"ideaCardFont\\\">Komment 7</p>\\n <p class=\\\"ideaCardFont\\\">K0mment 2</p>\\n </div>\\n\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.suggestionID, \"\\\">Initiera Project</button>\\n </div>\\n </div>\\n </div>\\n </div>\");\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n window.location.href = '../client/projectPage/projectPageP.html';\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var suggestions, counter;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 2:\n suggestions = _context2.sent;\n //If there exist filter use those instead to get matching suggestions rest should not need to be changed\n counter = 1;\n suggestions.forEach(function (suggestion) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context.sent;\n _context.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context.sent;\n console.log(suggestion);\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter, suggestion.id);\n counter = counter + 1;\n case 9:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n case 5:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID, suggestionID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount, suggestionID);\n cardHTML = card.generateHTML();\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n container.appendChild(div);\n case 7:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction testFunc() {\n console.log(\"Test func works\");\n}\nfunction loadPage() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var container, scriptElement;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context4.next = 3;\n break;\n }\n return _context4.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n scriptElement = document.createElement(\"script\");\n scriptElement.src = \"../dist/ideaBank.bundle.js\";\n container.appendChild(scriptElement);\n fetch(\"ideaBank/ideaBank.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBar\");\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n myIdeaCards = {};\n _context4.next = 10;\n return createNewCards(\"IdeaCardDiv\", container);\n case 10:\n addListner(myIdeaCards, container);\n case 11:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n}\nfunction addListner(cardArray, element) {\n element.addEventListener(\"click\", function (event) {\n var target = event.target;\n //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n var cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n var card = cardArray[cardId];\n var expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n //adds an event listener for the initiate page \n // if (target && target.className === \"initiateProjectButton\") {\n // const cardId = parseInt(target.id.replace(\"initiateProjectFromCard\", \"\"), 10);\n // if (cardArray[cardId]) {\n // $(\"#container-fluid\").empty();\n // loadInitiatePage(cardId);\n // }\n //}\n });\n}\n\n//# sourceURL=webpack://c3/./client/ideaBank/ideaBank.js?"); /***/ }), @@ -286,7 +286,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \***********************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n//Globala varibler för projekledare & Users\nvar selectedEmployees = [];\nfunction loadEmployees() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var selectProjectLeaderHTML, selectEmployeeHTML, allUsers, allProjectLeaders, selectHospitalHTML, selectUnitHTML, allHospitals, allUnits;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n selectProjectLeaderHTML = $('#projectLeader'); // loads the select type from html\n selectEmployeeHTML = $('#selectEmployee'); // loads the select type from html\n _context.next = 4;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 4:\n allUsers = _context.sent;\n _context.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 7:\n allProjectLeaders = _context.sent;\n //here you can put constraints\n allUsers.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(\"\".concat(user.firstName) + \" \" + \"\".concat(user.lastName));\n selectEmployeeHTML.append(optionElement);\n });\n allProjectLeaders.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(\"\".concat(user.firstName) + \" \" + \"\".concat(user.lastName));\n selectProjectLeaderHTML.append(optionElement);\n });\n selectHospitalHTML = $('#selectHospital'); // loads the select type from html\n selectUnitHTML = $('#selectDepartment'); // loads the select type from html\n _context.next = 14;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({});\n case 14:\n allHospitals = _context.sent;\n _context.next = 17;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({});\n case 17:\n allUnits = _context.sent;\n //here you can put constraints\n console.log(allHospitals);\n console.log(allUnits);\n allHospitals.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(user.name);\n selectHospitalHTML.append(optionElement);\n });\n allUnits.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(user.name);\n selectUnitHTML.append(optionElement);\n });\n case 22:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction assignedEmployer() {\n var employeeList = $('#selectEmployee');\n var selectedBox = $('#selectedEmployees');\n var selectedOption = employeeList.find('option:selected');\n var selectedText = selectedOption.text();\n selectedBox.append(createAssignedEmployeeDesign(selectedText, selectedOption, employeeList));\n selectedEmployees.push(String(selectedOption.val()));\n employeeList.find('option:selected').remove();\n employeeList.prop('selectedIndex', 0);\n}\nfunction createAssignedEmployeeDesign(s, x, employeeList) {\n var container = $('<div>').addClass('selectedEmployeeBubble'); // Create a div element and add a class\n var textSpan = $('<span>').addClass('ideaCardFont').text(s); // Create a span element, set text, and add a class\n var deleteButton = $('<button>').addClass('employeeDeleteButton').text('X'); // Create a button element, set text, and add a class\n deleteButton.on('click', function () {\n container.remove();\n employeeList.append(x);\n employeeList.prop('selectedIndex', 0);\n //removes from global list\n var index = selectedEmployees.indexOf(String(x.val()));\n if (index !== -1) {\n selectedEmployees.splice(index, 1);\n }\n });\n container.append(textSpan, deleteButton); // Append the span and button to the div container\n return container;\n}\n//Functions to load the page\nfunction loadPage(id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var container, linkelementCSS, linkQuestionCSS, linkActivitycardCSS, scriptElement, generatedHTML, generatedElement;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n container = document.querySelector('#container-fluid');\n if (container) {\n _context2.next = 3;\n break;\n }\n return _context2.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n linkelementCSS = document.createElement('link');\n linkelementCSS.rel = 'styleSheet';\n linkelementCSS.href = 'initiateForbattringsarbete/initiateIdea.css';\n document.head.appendChild(linkelementCSS);\n linkQuestionCSS = document.createElement('link');\n linkQuestionCSS.rel = 'styleSheet';\n linkQuestionCSS.href = 'Make_Suggestion_Code/makeSuggestion.css';\n document.head.appendChild(linkQuestionCSS);\n linkActivitycardCSS = document.createElement(\"link\");\n linkActivitycardCSS.rel = \"stylesheet\";\n linkActivitycardCSS.href = 'Activity_card_code/activitity_card.css';\n document.head.appendChild(linkActivitycardCSS);\n scriptElement = document.createElement(\"script\");\n scriptElement.src = \"../dist/initiateIdea.bundle.js\";\n container.appendChild(scriptElement);\n _context2.next = 20;\n return generateQuestionHTML(id);\n case 20:\n generatedHTML = _context2.sent;\n generatedElement = document.createRange().createContextualFragment(generatedHTML);\n fetch('initiateForbattringsarbete/initiateIdea.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.initiateIdeaWholePage');\n //Eventlistenerbuttons:\n var createButton = document.getElementById('createProjectFromSuggestionButton');\n var selectEmployeeButton = document.getElementById('selectEmployee');\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n //adds an event listener for the initiate page \n if (target.id === \"createProjectFromSuggestionButton\") {\n createProject();\n }\n });\n document.addEventListener(\"change\", function (event) {\n var target = event.target;\n //adds an event listener for the initiate page \n if (target.id === \"selectEmployee\") {\n assignedEmployer();\n }\n });\n if (specificElement) {\n // Insert the generated element before the specific element\n container.insertBefore(generatedElement, container.firstChild);\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n selectedEmployees = []; //clears the global employee list\n loadEmployees();\n }\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n case 23:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction createProject() {\n var inputSelectProjectleaderInput = document.getElementById(\"projectLeader\");\n var selectDepartment = document.getElementById(\"selectHospital\");\n var selectUnit = document.getElementById(\"selectDepartment\");\n var inputBoxFormNameInput = document.getElementById(\"inputBoxFormNameInput\");\n var inputBoxFormAreaInput = document.getElementById(\"inputBoxFormAreaInput\");\n var inputBoxFormContentInput = document.getElementById(\"inputBoxFormContentInput\");\n var inputBoxFormPurposeInput = document.getElementById(\"inputBoxFormPurposeInput\");\n var inputBoxFormMeasureInput = document.getElementById(\"inputBoxFormMeasureInput\");\n var inputBoxFormIdeasInput = document.getElementById(\"inputBoxFormIdeasInput\");\n alert(\"Kul att du försöker! Detta är inte klart ännu... \\n Däremot är värdena följande: \\n\" + inputSelectProjectleaderInput.options[inputSelectProjectleaderInput.selectedIndex].value + \"\\n\" + selectDepartment.options[selectDepartment.selectedIndex].value + \"\\n\" + selectUnit.options[selectUnit.selectedIndex].value + \"\\n\" + selectedEmployees + \"\\n\" + inputBoxFormNameInput.value + \"\\n\" + inputBoxFormAreaInput.value + \"\\n\" + inputBoxFormContentInput.value + \"\\n\" + inputBoxFormPurposeInput.value + \"\\n\" + inputBoxFormMeasureInput.value + \"\\n\" + inputBoxFormIdeasInput.value + \"\\n\");\n console.log(selectedEmployees);\n}\nfunction generateQuestionHTML(suggestionID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var suggestionData;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"suggestion\", suggestionID);\n case 2:\n suggestionData = _context3.sent;\n return _context3.abrupt(\"return\", \"\\n <div class=\\\"filter-section\\\">\\n <div class=\\\"makeSuggestionFilterButtons\\\">\\n <select name=\\\"department\\\" id=\\\"selectHospital\\\" class=\\\"filterButtons\\\"> </select>\\n\\n <select name=\\\"section\\\" id=\\\"selectDepartment\\\" class=\\\"filterButtons\\\">\\n </select>\\n\\n </div>\\n</div>\\n\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">Rubrik *</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormName\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormNameInput\\\"\\n placeholder=\\\"Vad vill du kalla ditt f\\xF6rslag?\\\"\\n value = \\\"\" + suggestionData.name + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Vilket \\xE4r omr\\xE5det f\\xF6r f\\xF6rb\\xE4ttringen? *\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormArea\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormAreaInput\\\"\\n placeholder=\\\"Ber\\xE4tta om omr\\xE5de ditt f\\xF6rslag hade f\\xF6rb\\xE4ttrat.\\\"\\n value = \\\"\" + suggestionData.area + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\" id=\\\"middleShadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">Bakgrund *</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormContent\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormContentInput\\\"\\n placeholder=\\\"Beskriv problemet\\\"\\n value = \\\"\" + suggestionData.content + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Vilket syfte har f\\xF6rb\\xE4ttringen? *\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormPurpose\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormPurposeInput\\\"\\n placeholder=\\\"Vad ska \\xE5stadkommas och varf\\xF6r? Kom ih\\xE5g att f\\xE5 med patientperspektivet\\\"\\n value = \\\"\" + suggestionData.purpose + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Hur ska det m\\xE4tas?\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormMeasure\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormMeasureInput\\\"\\n placeholder=\\\"Hur vet vi att en f\\xF6r\\xE4ndring \\xE4r en f\\xF6rb\\xE4ttring?\\\"\\n value = \\\"\" + suggestionData.measure + \"\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">Id\\xE9er</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeas\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeasInput\\\"\\n placeholder=\\\"Vilka f\\xF6r\\xE4ndringar kan pr\\xF6vas f\\xF6r att uppn\\xE5 en f\\xF6rb\\xE4ttring?\\\"\\n value = \\\"\" + suggestionData.ideas + \"\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n<button id=\\\"createProjectFromSuggestionButton\\\">Skapa f\\xF6rb\\xE4ttringsarbete!</button>\");\n case 4:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/initiateForbattringsarbete/initiateIdea.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n//Globala varibler för projekledare & Users\nvar selectedEmployees = [];\nfunction loadEmployees() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var selectProjectLeaderHTML, selectEmployeeHTML, allUsers, allProjectLeaders, selectHospitalHTML, selectUnitHTML, allHospitals, allUnits;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n selectProjectLeaderHTML = $('#projectLeader'); // loads the select type from html\n selectEmployeeHTML = $('#selectEmployee'); // loads the select type from html\n _context.next = 4;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 4:\n allUsers = _context.sent;\n _context.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 7:\n allProjectLeaders = _context.sent;\n //here you can put constraints\n allUsers.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(\"\".concat(user.firstName) + \" \" + \"\".concat(user.lastName));\n selectEmployeeHTML.append(optionElement);\n });\n allProjectLeaders.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(\"\".concat(user.firstName) + \" \" + \"\".concat(user.lastName));\n selectProjectLeaderHTML.append(optionElement);\n });\n selectHospitalHTML = $('#selectHospital'); // loads the select type from html\n selectUnitHTML = $('#selectDepartment'); // loads the select type from html\n _context.next = 14;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({});\n case 14:\n allHospitals = _context.sent;\n _context.next = 17;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({});\n case 17:\n allUnits = _context.sent;\n //here you can put constraints\n console.log(allHospitals);\n console.log(allUnits);\n allHospitals.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(user.name);\n selectHospitalHTML.append(optionElement);\n });\n allUnits.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(user.name);\n selectUnitHTML.append(optionElement);\n });\n case 22:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction assignedEmployer() {\n var employeeList = $('#selectEmployee');\n var selectedBox = $('#selectedEmployees');\n var selectedOption = employeeList.find('option:selected');\n var selectedText = selectedOption.text();\n selectedBox.append(createAssignedEmployeeDesign(selectedText, selectedOption, employeeList));\n selectedEmployees.push(String(selectedOption.val()));\n employeeList.find('option:selected').remove();\n employeeList.prop('selectedIndex', 0);\n}\nfunction createAssignedEmployeeDesign(s, x, employeeList) {\n var container = $('<div>').addClass('selectedEmployeeBubble'); // Create a div element and add a class\n var textSpan = $('<span>').addClass('ideaCardFont').text(s); // Create a span element, set text, and add a class\n var deleteButton = $('<button>').addClass('employeeDeleteButton').text('X'); // Create a button element, set text, and add a class\n deleteButton.on('click', function () {\n container.remove();\n employeeList.append(x);\n employeeList.prop('selectedIndex', 0);\n //removes from global list\n var index = selectedEmployees.indexOf(String(x.val()));\n if (index !== -1) {\n selectedEmployees.splice(index, 1);\n }\n });\n container.append(textSpan, deleteButton); // Append the span and button to the div container\n return container;\n}\n//Functions to load the page\nfunction clearFromEventListeners(container) {\n var clonedContainer = container.cloneNode(true);\n container.replaceWith(clonedContainer);\n console.log(\"cleared\");\n}\nfunction loadPage(id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var container, linkelementCSS, linkQuestionCSS, linkActivitycardCSS, scriptElement, generatedHTML, generatedElement;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n console.log(id);\n container = document.querySelector('#container-fluid');\n if (container) {\n _context2.next = 4;\n break;\n }\n return _context2.abrupt(\"return\");\n case 4:\n // Stop if the container isn't found\n linkelementCSS = document.createElement('link');\n linkelementCSS.rel = 'styleSheet';\n linkelementCSS.href = 'initiateForbattringsarbete/initiateIdea.css';\n document.head.appendChild(linkelementCSS);\n linkQuestionCSS = document.createElement('link');\n linkQuestionCSS.rel = 'styleSheet';\n linkQuestionCSS.href = 'Make_Suggestion_Code/makeSuggestion.css';\n document.head.appendChild(linkQuestionCSS);\n linkActivitycardCSS = document.createElement(\"link\");\n linkActivitycardCSS.rel = \"stylesheet\";\n linkActivitycardCSS.href = 'Activity_card_code/activitity_card.css';\n document.head.appendChild(linkActivitycardCSS);\n scriptElement = document.createElement(\"script\");\n scriptElement.src = \"../dist/initiateIdea.bundle.js\";\n container.appendChild(scriptElement);\n _context2.next = 21;\n return generateQuestionHTML(id);\n case 21:\n generatedHTML = _context2.sent;\n generatedElement = document.createRange().createContextualFragment(generatedHTML);\n fetch('initiateForbattringsarbete/initiateIdea.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.initiateIdeaWholePage');\n //Eventlistenerbuttons:\n var createButton = document.getElementById('createProjectFromSuggestionButton');\n var selectEmployeeButton = document.getElementById('selectEmployee');\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n //adds an event listener for the initiate page \n if (target.id === \"createProjectFromSuggestionButton\") {\n createProject();\n }\n });\n document.addEventListener(\"change\", function (event) {\n var target = event.target;\n //adds an event listener for the initiate page \n if (target.id === \"selectEmployee\") {\n assignedEmployer();\n }\n });\n if (specificElement) {\n // Insert the generated element before the specific element\n container.insertBefore(generatedElement, container.firstChild);\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n selectedEmployees = []; //clears the global employee list\n loadEmployees();\n }\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n case 24:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction createProject() {\n var inputSelectProjectleaderInput = document.getElementById(\"projectLeader\");\n var selectDepartment = document.getElementById(\"selectHospital\");\n var selectUnit = document.getElementById(\"selectDepartment\");\n var inputBoxFormNameInput = document.getElementById(\"inputBoxFormNameInput\");\n var inputBoxFormAreaInput = document.getElementById(\"inputBoxFormAreaInput\");\n var inputBoxFormContentInput = document.getElementById(\"inputBoxFormContentInput\");\n var inputBoxFormPurposeInput = document.getElementById(\"inputBoxFormPurposeInput\");\n var inputBoxFormMeasureInput = document.getElementById(\"inputBoxFormMeasureInput\");\n var inputBoxFormIdeasInput = document.getElementById(\"inputBoxFormIdeasInput\");\n alert(\"Kul att du försöker! Detta är inte klart ännu... \\n Däremot är värdena följande: \\n\" + inputSelectProjectleaderInput.options[inputSelectProjectleaderInput.selectedIndex].value + \"\\n\" + selectDepartment.options[selectDepartment.selectedIndex].value + \"\\n\" + selectUnit.options[selectUnit.selectedIndex].value + \"\\n\" + selectedEmployees + \"\\n\" + inputBoxFormNameInput.value + \"\\n\" + inputBoxFormAreaInput.value + \"\\n\" + inputBoxFormContentInput.value + \"\\n\" + inputBoxFormPurposeInput.value + \"\\n\" + inputBoxFormMeasureInput.value + \"\\n\" + inputBoxFormIdeasInput.value + \"\\n\");\n console.log(selectedEmployees);\n}\nfunction generateQuestionHTML(suggestionID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var suggestionData;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"suggestion\", suggestionID);\n case 2:\n suggestionData = _context3.sent;\n return _context3.abrupt(\"return\", \"\\n <div class=\\\"filter-section\\\">\\n <div class=\\\"makeSuggestionFilterButtons\\\">\\n <select name=\\\"department\\\" id=\\\"selectHospital\\\" class=\\\"filterButtons\\\"> </select>\\n\\n <select name=\\\"section\\\" id=\\\"selectDepartment\\\" class=\\\"filterButtons\\\">\\n </select>\\n\\n </div>\\n</div>\\n\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">Rubrik *</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormName\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormNameInput\\\"\\n placeholder=\\\"Vad vill du kalla ditt f\\xF6rslag?\\\"\\n value = \\\"\" + suggestionData.name + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Vilket \\xE4r omr\\xE5det f\\xF6r f\\xF6rb\\xE4ttringen? *\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormArea\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormAreaInput\\\"\\n placeholder=\\\"Ber\\xE4tta om omr\\xE5de ditt f\\xF6rslag hade f\\xF6rb\\xE4ttrat.\\\"\\n value = \\\"\" + suggestionData.area + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\" id=\\\"middleShadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">Bakgrund *</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormContent\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormContentInput\\\"\\n placeholder=\\\"Beskriv problemet\\\"\\n value = \\\"\" + suggestionData.content + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Vilket syfte har f\\xF6rb\\xE4ttringen? *\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormPurpose\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormPurposeInput\\\"\\n placeholder=\\\"Vad ska \\xE5stadkommas och varf\\xF6r? Kom ih\\xE5g att f\\xE5 med patientperspektivet\\\"\\n value = \\\"\" + suggestionData.purpose + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Hur ska det m\\xE4tas?\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormMeasure\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormMeasureInput\\\"\\n placeholder=\\\"Hur vet vi att en f\\xF6r\\xE4ndring \\xE4r en f\\xF6rb\\xE4ttring?\\\"\\n value = \\\"\" + suggestionData.measure + \"\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">Id\\xE9er</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeas\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeasInput\\\"\\n placeholder=\\\"Vilka f\\xF6r\\xE4ndringar kan pr\\xF6vas f\\xF6r att uppn\\xE5 en f\\xF6rb\\xE4ttring?\\\"\\n value = \\\"\" + suggestionData.ideas + \"\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n<button id=\\\"createProjectFromSuggestionButton\\\">Skapa f\\xF6rb\\xE4ttringsarbete!</button>\");\n case 4:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/initiateForbattringsarbete/initiateIdea.js?"); /***/ }), @@ -316,7 +316,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \********************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nfunction loadPage(projectId) {\n var container = document.querySelector('#container-fluid');\n var nextPageButton = document.getElementById('toCurrentProjects');\n if (!container) return; // Stop if the container isn't found\n fetch('projectPage/ProjectPageA.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.wholePageA');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n initializeTooltips();\n }\n });\n container.addEventListener('click', function (event) {\n var target = event.target; // Type assertion\n if (target.id === 'toCurrentProjects') {\n finalize(projectId);\n } else if (target.id === 'toP') {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageP)(projectId);\n } else if (target.id === 'toG') {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageG)(projectId);\n } else if (target.id === 'toS') {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageS)(projectId);\n }\n });\n function initializeTooltips() {\n // Use jQuery to select the elements and initialize the tooltip\n $('[data-toggle=\"tooltip\"]').tooltip({\n delay: {\n \"show\": 0,\n \"hide\": 100\n }\n });\n }\n}\nfunction finalize(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var user, userId;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n user = localStorage.getItem('user');\n if (user) {\n userId = JSON.parse(user)[0].id;\n }\n console.log(userId);\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.finalizeImprovementWork)(userId, projectId);\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadCurrentProjects)();\n case 5:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPageA.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nfunction updateStage(stage, id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", id, {\n currentStage: stage\n });\n case 1:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction loadPage(projectId) {\n var container = document.querySelector('#container-fluid');\n var nextPageButton = document.getElementById('toCurrentProjects');\n if (!container) return; // Stop if the container isn't found\n updateStage(\"Agera\", projectId);\n fetch('projectPage/ProjectPageA.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.wholePageA');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n initializeTooltips();\n }\n });\n container.addEventListener('click', function (event) {\n var target = event.target; // Type assertion\n if (target.id === 'toCurrentProjects') {\n updateStage(\"Avslutat\", projectId);\n finalize(projectId);\n } else if (target.id === 'toP') {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageP)(projectId);\n } else if (target.id === 'toG') {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageG)(projectId);\n } else if (target.id === 'toS') {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageS)(projectId);\n } else if (target.id === \"saveEditBtnA\") {\n saveImprovementWorkEditA(projectId);\n }\n });\n function initializeTooltips() {\n // Use jQuery to select the elements and initialize the tooltip\n $('[data-toggle=\"tooltip\"]').tooltip({\n delay: {\n \"show\": 0,\n \"hide\": 100\n }\n });\n }\n loadImprovementWorkDataPageA(projectId);\n}\nfunction loadImprovementWorkDataPageA(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var improvementWork, title, a1, a2, a3, a4;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)('improvementWork', projectId);\n case 2:\n improvementWork = _context2.sent;\n title = document.getElementById(\"title\");\n a1 = document.getElementById(\"a1\");\n a2 = document.getElementById(\"a2\");\n a3 = document.getElementById(\"a3\");\n a4 = document.getElementById(\"a4\");\n title.textContent = improvementWork.name;\n a1.value = improvementWork.a1;\n a2.value = improvementWork.a2;\n a3.value = improvementWork.a3;\n a4.value = improvementWork.a4;\n case 13:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction finalize(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var user, userId;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n user = localStorage.getItem('user');\n if (user) {\n userId = JSON.parse(user)[0].id;\n }\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.finalizeImprovementWork)(userId, projectId);\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadCurrentProjects)();\n case 4:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction saveImprovementWorkEditA(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var a1, a2, a3, a4, update;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n a1 = document.getElementById(\"a1\");\n a2 = document.getElementById(\"a2\");\n a3 = document.getElementById(\"a3\");\n a4 = document.getElementById(\"a4\");\n update = {\n a1: a1.value,\n a2: a2.value,\n a3: a3.value,\n a4: a4.value\n };\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", projectId, update);\n case 6:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPageA.js?"); /***/ }), @@ -326,7 +326,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \********************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n\nfunction loadPage(projectId) {\n var container = document.querySelector('#container-fluid');\n var nextPageButton = document.getElementById('toS');\n if (!container) return; // Stop if the container isn't found\n fetch('projectPage/ProjectPageG.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.wholePageG');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n initializeTooltips();\n }\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n container.addEventListener('click', function (event) {\n var target = event.target; // Type assertion\n if (target.id === 'toS') {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageS)(projectId);\n } else if (target.id === 'toP') {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageP)(projectId);\n }\n });\n function initializeTooltips() {\n // Use jQuery to select the elements and initialize the tooltip\n $('[data-toggle=\"tooltip\"]').tooltip({\n delay: {\n \"show\": 0,\n \"hide\": 100\n }\n });\n }\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPageG.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\nfunction updateStage(stage, id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", id, {\n currentStage: stage\n });\n case 1:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction loadPage(projectId) {\n var container = document.querySelector('#container-fluid');\n var nextPageButton = document.getElementById('toS');\n if (!container) return; // Stop if the container isn't found\n updateStage(\"Göra\", projectId);\n fetch('projectPage/ProjectPageG.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.wholePageG');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n initializeTooltips();\n }\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n container.addEventListener('click', function (event) {\n var target = event.target; // Type assertion\n if (target.id === 'toS') {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageS)(projectId);\n } else if (target.id === 'toP') {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageP)(projectId);\n } else if (target.id === \"saveEditBtnG\") {\n saveImprovementWorkEditG(projectId);\n }\n });\n loadImprovementWorkDataPageG(projectId);\n function initializeTooltips() {\n // Use jQuery to select the elements and initialize the tooltip\n $('[data-toggle=\"tooltip\"]').tooltip({\n delay: {\n \"show\": 0,\n \"hide\": 100\n }\n });\n }\n}\nfunction loadImprovementWorkDataPageG(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var improvementWork, title, g1, g2, g3, g4, g5;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)('improvementWork', projectId);\n case 2:\n improvementWork = _context2.sent;\n title = document.getElementById(\"title\");\n g1 = document.getElementById(\"g1\");\n g2 = document.getElementById(\"g2\");\n g3 = document.getElementById(\"g3\");\n g4 = document.getElementById(\"g4\");\n g5 = document.getElementById(\"g5\");\n title.textContent = improvementWork.name;\n g1.value = improvementWork.g1;\n g2.value = improvementWork.g2;\n g3.value = improvementWork.g3;\n g4.value = improvementWork.g4;\n g5.value = improvementWork.g5;\n case 15:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction saveImprovementWorkEditG(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var g1, g2, g3, g4, g5, update;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n g1 = document.getElementById(\"g1\");\n g2 = document.getElementById(\"g2\");\n g3 = document.getElementById(\"g3\");\n g4 = document.getElementById(\"g4\");\n g5 = document.getElementById(\"g5\");\n update = {\n g1: g1.value,\n g2: g2.value,\n g3: g3.value,\n g4: g4.value,\n g5: g5.value\n };\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", projectId, update);\n case 7:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPageG.js?"); /***/ }), @@ -336,7 +336,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \********************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\nfunction loadPage(projectId) {\n var container = document.querySelector('#container-fluid');\n var nextPageButton = document.getElementById('toG');\n if (!container) return; // Stop if the container isn't found\n fetch('projectPage/ProjectPageP.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.wholePageP');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n initializeTooltips();\n }\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n container.addEventListener('click', function (event) {\n var target = event.target; // Type assertion\n if (target.matches('[data-toggle=\"tooltip\"]') && !target.dataset.tooltipInitialized) {\n $(target).tooltip();\n target.dataset.tooltipInitialized = 'true';\n }\n if (target.id === 'toG') {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageG)(projectId);\n }\n });\n loadImprovementWorkDataPageP(projectId);\n}\nfunction initializeTooltips() {\n // Use jQuery to select the elements and initialize the tooltip\n $('[data-toggle=\"tooltip\"]').tooltip({\n delay: {\n \"show\": 0,\n \"hide\": 100\n }\n });\n}\nfunction loadImprovementWorkDataPageP(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var data;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)('improvementWork', projectId);\n case 2:\n data = _context.sent;\n console.log(data.name);\n case 4:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPageP.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\nfunction updateStage(stage, id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", id, {\n currentStage: stage\n });\n case 1:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction loadPage(projectId) {\n var container = document.querySelector('#container-fluid');\n var nextPageButton = document.getElementById('toG');\n if (!container) return; // Stop if the container isn't found\n updateStage(\"Planera\", projectId);\n fetch('projectPage/ProjectPageP.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.wholePageP');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n initializeTooltips();\n }\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n container.addEventListener('click', function (event) {\n var target = event.target; // Type assertion\n if (target.matches('[data-toggle=\"tooltip\"]') && !target.dataset.tooltipInitialized) {\n $(target).tooltip();\n target.dataset.tooltipInitialized = 'true';\n }\n if (target.id === 'toG') {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageG)(projectId);\n }\n if (target.id === \"saveEditBtnP\") {\n saveImprovementWorkEditP(projectId);\n }\n });\n loadImprovementWorkDataPageP(projectId);\n}\nfunction initializeTooltips() {\n // Use jQuery to select the elements and initialize the tooltip\n $('[data-toggle=\"tooltip\"]').tooltip({\n delay: {\n \"show\": 0,\n \"hide\": 100\n }\n });\n}\nfunction loadImprovementWorkDataPageP(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var improvementWork, titleP, p1, p2, p3, p4, p5, p6, p7;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)('improvementWork', projectId);\n case 2:\n improvementWork = _context2.sent;\n titleP = document.getElementById(\"title\");\n p1 = document.getElementById(\"p1\");\n p2 = document.getElementById(\"p2\");\n p3 = document.getElementById(\"p3\");\n p4 = document.getElementById(\"p4\");\n p5 = document.getElementById(\"p5\");\n p6 = document.getElementById(\"p6\");\n p7 = document.getElementById(\"p7\");\n titleP.textContent = improvementWork.name;\n p1.value = improvementWork.p1;\n p2.value = improvementWork.p2;\n p3.value = improvementWork.p3;\n p4.value = improvementWork.p4;\n p5.value = improvementWork.p5;\n p6.value = improvementWork.p6;\n p7.value = improvementWork.p7;\n case 19:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction saveImprovementWorkEditP(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var p1, p2, p3, p4, p5, p6, p7, update;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n p1 = document.getElementById(\"p1\");\n p2 = document.getElementById(\"p2\");\n p3 = document.getElementById(\"p3\");\n p4 = document.getElementById(\"p4\");\n p5 = document.getElementById(\"p5\");\n p6 = document.getElementById(\"p6\");\n p7 = document.getElementById(\"p7\");\n update = {\n p1: p1.value,\n p2: p2.value,\n p3: p3.value,\n p4: p4.value,\n p5: p5.value,\n p6: p6.value,\n p7: p7.value\n };\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", projectId, update);\n case 9:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPageP.js?"); /***/ }), @@ -346,7 +346,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \********************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n\nfunction loadPage(projectId) {\n var container = document.querySelector('#container-fluid');\n var nextPageButton = document.getElementById('toA');\n if (!container) return; // Stop if the container isn't found\n fetch('projectPage/ProjectPageS.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.wholePageS');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n initializeTooltips();\n }\n });\n container.addEventListener('click', function (event) {\n var target = event.target; // Type assertion\n if (target.id === 'toA') {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageA)(projectId);\n } else if (target.id === 'toP') {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageP)(projectId);\n } else if (target.id === 'toG') {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageG)(projectId);\n }\n });\n function initializeTooltips() {\n // Use jQuery to select the elements and initialize the tooltip\n $('[data-toggle=\"tooltip\"]').tooltip({\n delay: {\n \"show\": 0,\n \"hide\": 100\n }\n });\n }\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPageS.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\nfunction updateStage(stage, id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", id, {\n currentStage: stage\n });\n case 1:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction loadPage(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var container, nextPageButton, initializeTooltips;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n initializeTooltips = function _initializeTooltips() {\n // Use jQuery to select the elements and initialize the tooltip\n $('[data-toggle=\"tooltip\"]').tooltip({\n delay: {\n \"show\": 0,\n \"hide\": 100\n }\n });\n };\n container = document.querySelector('#container-fluid');\n nextPageButton = document.getElementById('toA');\n if (container) {\n _context2.next = 5;\n break;\n }\n return _context2.abrupt(\"return\");\n case 5:\n // Stop if the container isn't found\n updateStage(\"Studera\", projectId);\n fetch('projectPage/ProjectPageS.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.wholePageS');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n initializeTooltips();\n }\n });\n container.addEventListener('click', function (event) {\n var target = event.target; // Type assertion\n if (target.id === 'toA') {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageA)(projectId);\n } else if (target.id === 'toP') {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageP)(projectId);\n } else if (target.id === 'toG') {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageG)(projectId);\n } else if (target.id === \"saveEditBtnS\") {\n saveImprovementWorkEditS(projectId);\n }\n });\n loadImprovementWorkDataPageS(projectId);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction loadImprovementWorkDataPageS(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var improvementWork, title, s1, s2, s3;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)('improvementWork', projectId);\n case 2:\n improvementWork = _context3.sent;\n title = document.getElementById(\"title\");\n s1 = document.getElementById(\"s1\");\n s2 = document.getElementById(\"s2\");\n s3 = document.getElementById(\"s3\");\n title.textContent = improvementWork.name;\n s1.value = improvementWork.s1;\n s2.value = improvementWork.s2;\n s3.value = improvementWork.s3;\n case 11:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction saveImprovementWorkEditS(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var s1, s2, s3, update;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n s1 = document.getElementById(\"s1\");\n s2 = document.getElementById(\"s2\");\n s3 = document.getElementById(\"s3\");\n update = {\n s1: s1.value,\n s2: s2.value,\n s3: s3.value\n };\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", projectId, update);\n case 5:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPageS.js?"); /***/ }), diff --git a/client/dist/homePage.bundle.js b/client/dist/homePage.bundle.js index 6333bbe0d8780a6c629fe4c01f1c6829ab078418..4790291efa6336a7ab874210689cdeedbdaf4a83 100644 --- a/client/dist/homePage.bundle.js +++ b/client/dist/homePage.bundle.js @@ -106,7 +106,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \*************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addDocumentToImprovementWork: () => (/* binding */ addDocumentToImprovementWork),\n/* harmony export */ addMemberToImprovementWork: () => (/* binding */ addMemberToImprovementWork),\n/* harmony export */ addMemberToTask: () => (/* binding */ addMemberToTask),\n/* harmony export */ addNoteToUser: () => (/* binding */ addNoteToUser),\n/* harmony export */ auth: () => (/* binding */ auth),\n/* harmony export */ changePatientRiskLevel: () => (/* binding */ changePatientRiskLevel),\n/* harmony export */ createComment: () => (/* binding */ createComment),\n/* harmony export */ createHospital: () => (/* binding */ createHospital),\n/* harmony export */ createImprovementWork: () => (/* binding */ createImprovementWork),\n/* harmony export */ createSuggestion: () => (/* binding */ createSuggestion),\n/* harmony export */ createTaskOnImprovementWork: () => (/* binding */ createTaskOnImprovementWork),\n/* harmony export */ createUnit: () => (/* binding */ createUnit),\n/* harmony export */ createUser: () => (/* binding */ createUser),\n/* harmony export */ createdDocumentInKnowledgeBank: () => (/* binding */ createdDocumentInKnowledgeBank),\n/* harmony export */ db: () => (/* binding */ db),\n/* harmony export */ deleteAllDocumentsInCollection: () => (/* binding */ deleteAllDocumentsInCollection),\n/* harmony export */ deleteInstance: () => (/* binding */ deleteInstance),\n/* harmony export */ finalizeImprovementWork: () => (/* binding */ finalizeImprovementWork),\n/* harmony export */ getComments: () => (/* binding */ getComments),\n/* harmony export */ getHospitals: () => (/* binding */ getHospitals),\n/* harmony export */ getImprovementWorks: () => (/* binding */ getImprovementWorks),\n/* harmony export */ getObject: () => (/* binding */ getObject),\n/* harmony export */ getObjectById: () => (/* binding */ getObjectById),\n/* harmony export */ getSuggestions: () => (/* binding */ getSuggestions),\n/* harmony export */ getTasks: () => (/* binding */ getTasks),\n/* harmony export */ getUnits: () => (/* binding */ getUnits),\n/* harmony export */ getUsers: () => (/* binding */ getUsers),\n/* harmony export */ startOrPauseImprovementWork: () => (/* binding */ startOrPauseImprovementWork),\n/* harmony export */ updateInstance: () => (/* binding */ updateInstance),\n/* harmony export */ upvoteComment: () => (/* binding */ upvoteComment),\n/* harmony export */ upvoteSuggestion: () => (/* binding */ upvoteSuggestion)\n/* harmony export */ });\n/* harmony import */ var firebase_app__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! firebase/app */ \"./node_modules/firebase/app/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_firestore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! firebase/firestore */ \"./node_modules/firebase/firestore/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_auth__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! firebase/auth */ \"./node_modules/firebase/auth/dist/esm/index.esm.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nvar firebaseConfig = {\n apiKey: \"AIzaSyDqkaVZMr11J4mfnR0auqoQilZyPfyD-x4\",\n authDomain: \"c3solutions-dc109.firebaseapp.com\",\n projectId: \"c3solutions-dc109\",\n storageBucket: \"c3solutions-dc109.appspot.com\",\n messagingSenderId: \"902143402555\",\n appId: \"1:902143402555:web:29213e81de0a0cba38b21e\"\n};\nvar app = (0,firebase_app__WEBPACK_IMPORTED_MODULE_0__.initializeApp)(firebaseConfig);\nvar auth = (0,firebase_auth__WEBPACK_IMPORTED_MODULE_2__.getAuth)();\nvar db = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getFirestore)(app);\nvar userCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\nvar unitCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\nvar improvementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\nvar taskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\nvar hospitalCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\nvar suggestionCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\nvar knowledgeDocumentCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"knowledgeDocument\");\n////////////////////////////////////////Setters///////////////////////////////////////////////////////////////////\n// Function to create user a new user in database\n// takes in userId, unitId, firstname, lastname, email and password as string\n// throws error if transaction failed\nfunction createUser(hsaId, unitId, firstName, lastName, email, manager, uid) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var userRef, unitRef;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, hsaId);\n _context.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(userRef, {\n id: userRef.id,\n uid: uid,\n unitId: unitId,\n firstName: firstName,\n lastName: lastName,\n email: email,\n improvementWorks: [],\n tasks: [],\n manager: manager\n });\n case 4:\n // Atomically add user to unit.\n unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection, unitId);\n _context.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(unitRef, {\n members: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userRef.id)\n });\n case 7:\n _context.next = 12;\n break;\n case 9:\n _context.prev = 9;\n _context.t0 = _context[\"catch\"](0);\n console.log(_context.t0);\n case 12:\n case \"end\":\n return _context.stop();\n }\n }, _callee, null, [[0, 9]]);\n }));\n}\n//Adds a new improvementWork to the database\n// takes in Id, name, currentStage in PDSA, content, unitId refers to as string and if completed as boolean\n// throws error if transaction failed\nfunction createImprovementWork(id, name, currentStage, content,\n// Är detta description bör detta förtydligas. \nunitId, purpose,\n//Bör tas bort motsvaras av p2- mål med projektet\npatientRiskLevel, area,\n// patientRiskLevel: \"Green\" | \"Blue\" | \"Orange\" | \"Red\"\n//Questions in planning stage\np1, p2, p3, p4, p5, p6, p7,\n//Questions in Doing (G) stage\ng1, g2, g3, g4, g5,\n//Questions in stydy stage\ns1, s2, s3,\n//Questions in acting stage\na1, a2, a3, a4) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var improvementWorkRef;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.prev = 0;\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, id);\n _context2.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(improvementWorkRef, {\n id: improvementWorkRef.id,\n currentStage: currentStage,\n name: name,\n content: content,\n purpose: purpose,\n dateStarted: new Date(),\n unitId: unitId,\n completed: false,\n ongoing: false,\n tasks: [],\n members: [],\n patientRiskLevel: patientRiskLevel,\n area: area,\n p1: p1,\n p2: p2,\n p3: p3,\n p4: p4,\n p5: p5,\n p6: p6,\n p7: p7,\n g1: g1,\n g2: g2,\n g3: g3,\n g4: g4,\n g5: g5,\n s1: s1,\n s2: s2,\n s3: s3,\n a1: a1,\n a2: a2,\n a3: a3,\n a4: a4\n });\n case 4:\n _context2.next = 10;\n break;\n case 6:\n _context2.prev = 6;\n _context2.t0 = _context2[\"catch\"](0);\n console.log(\"Error creating improvementWork: \", _context2.t0);\n throw _context2.t0;\n case 10:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, null, [[0, 6]]);\n }));\n}\n//create task to improvementWork\n// takes in improvementWorkId, name, deadline date, start date, stage in PDSA and content as string\n// throws error if transaction failed\nfunction createTaskOnImprovementWork(taskId, improvementWorkId, name, deadlineDate, startDate, stage, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var ref, improvementWorkRef;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.prev = 0;\n ref = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection, taskId);\n _context3.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(ref, {\n id: ref.id,\n improvementWorkId: improvementWorkId,\n name: name,\n deadlineDate: deadlineDate,\n startDate: startDate,\n stage: stage,\n content: content,\n members: []\n });\n case 4:\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, improvementWorkId); // Atomically add task to the tasks array field.\n _context3.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(improvementWorkRef, {\n tasks: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(taskId)\n });\n case 7:\n _context3.next = 13;\n break;\n case 9:\n _context3.prev = 9;\n _context3.t0 = _context3[\"catch\"](0);\n console.log(\"Error creating task: \", _context3.t0);\n throw _context3.t0;\n case 13:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, null, [[0, 9]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction createdDocumentInKnowledgeBank(documentUrl, name) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n _context4.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(knowledgeDocumentCollection);\n _context4.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n name: name\n });\n case 4:\n _context4.next = 10;\n break;\n case 6:\n _context4.prev = 6;\n _context4.t0 = _context4[\"catch\"](0);\n console.log(\"Error adding document: \", _context4.t0);\n throw _context4.t0;\n case 10:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4, null, [[0, 6]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction addDocumentToImprovementWork(documentUrl, name, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var improvementWorkRef, docRef;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n _context5.prev = 0;\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, improvementWorkId);\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkRef, \"documents\");\n _context5.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n timestamp: new Date(),\n name: name\n });\n case 5:\n _context5.next = 11;\n break;\n case 7:\n _context5.prev = 7;\n _context5.t0 = _context5[\"catch\"](0);\n console.log(\"Error adding document: \", _context5.t0);\n throw _context5.t0;\n case 11:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5, null, [[0, 7]]);\n }));\n}\n//add a member to a improvementWork\n// takes in id, users HSAid, improvementWorks id as string and if is owner, is responsible as boolean\n// throws error if transaction failed\nfunction addMemberToImprovementWork(userHsaId, improvementWorkId, isOwner, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var improvementWorkRef, userRef;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n _context6.prev = 0;\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, improvementWorkId); // return;\n // Atomically update the members array in the improvementWork document\n _context6.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(improvementWorkRef, {\n members: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)({\n userHsaId: userHsaId,\n isOwner: isOwner,\n isResponsibleFor: isResponsibleFor\n })\n });\n case 4:\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, userHsaId); // Atomically add improvementWork to user\n _context6.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(userRef, {\n improvementWorks: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)({\n improvementWorkId: improvementWorkId,\n isOwner: isOwner,\n isResponsibleFor: isResponsibleFor\n })\n });\n case 7:\n _context6.next = 13;\n break;\n case 9:\n _context6.prev = 9;\n _context6.t0 = _context6[\"catch\"](0);\n console.log(\"Error adding member: \", _context6.t0);\n throw _context6.t0;\n case 13:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6, null, [[0, 9]]);\n }));\n}\n//create a hospital\n// takes in ID, name as string\n// throws error if transaction failed\nfunction createHospital(hospitalId,\n// should be auto?\nname) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var ref;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.prev = 0;\n ref = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection, hospitalId);\n _context7.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(ref, {\n id: ref.id,\n name: name,\n units: []\n });\n case 4:\n _context7.next = 10;\n break;\n case 6:\n _context7.prev = 6;\n _context7.t0 = _context7[\"catch\"](0);\n console.log(\"Error creating hospital: \", _context7.t0);\n throw _context7.t0;\n case 10:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7, null, [[0, 6]]);\n }));\n}\n//create a unit\n// takes in id, hospitals id and name as string\n// throws error if transaction failed\nfunction createUnit(unitId,\n//should be auto?\nhospitalId, name) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var unitRef, hospitalRef;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n _context8.prev = 0;\n unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection, unitId);\n _context8.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(unitRef, {\n id: unitRef.id,\n hospitalId: hospitalId,\n name: name,\n members: []\n });\n case 4:\n // Atomically add unit to hospital.\n hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection, hospitalId);\n _context8.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(hospitalRef, {\n units: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(unitRef.id)\n });\n case 7:\n _context8.next = 13;\n break;\n case 9:\n _context8.prev = 9;\n _context8.t0 = _context8[\"catch\"](0);\n console.log(\"Error creating unit: \", _context8.t0);\n throw _context8.t0;\n case 13:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8, null, [[0, 9]]);\n }));\n}\n//adds a member to task\n// takes in ID, the added members hsaId, task id as string and if person is responsible as boolean\n// throws error if transaction failed\nfunction addMemberToTask(userHsaId, taskId, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var taskRef, userRef;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n _context9.prev = 0;\n // Atomically add a member to task.\n taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection, taskId);\n _context9.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(taskRef, {\n members: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)({\n userHsaId: userHsaId,\n isResponsibleFor: isResponsibleFor\n })\n });\n case 4:\n // Atomically add a task to user.\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, userHsaId);\n _context9.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(userRef, {\n tasks: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)({\n taskId: taskId,\n isResponsibleFor: isResponsibleFor\n })\n });\n case 7:\n _context9.next = 13;\n break;\n case 9:\n _context9.prev = 9;\n _context9.t0 = _context9[\"catch\"](0);\n console.log(\"Error adding member: \", _context9.t0);\n throw _context9.t0;\n case 13:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9, null, [[0, 9]]);\n }));\n}\n//creates a suggestion\n// takes in ID, the creators hsaId, name, content and the responding unitId as string\n// throws error if transaction failed\nfunction createSuggestion(id, creatorHsaId, name, area, content, purpose, measure, ideas,\n//need: boolean,\nunitId, departmentId, isPublic) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var suggestionRef, commentCollection;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n _context10.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, id);\n _context10.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(suggestionRef, {\n id: suggestionRef.id,\n creatorHsaId: creatorHsaId,\n name: name,\n area: area,\n content: content,\n purpose: purpose,\n measure: measure,\n ideas: ideas,\n //need: need,\n unitId: unitId,\n departmentId: departmentId,\n \"public\": isPublic,\n upvotes: [],\n comments: [],\n dateCreated: new Date()\n });\n case 4:\n _context10.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\");\n case 6:\n commentCollection = _context10.sent;\n _context10.next = 9;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(commentCollection);\n case 9:\n _context10.next = 15;\n break;\n case 11:\n _context10.prev = 11;\n _context10.t0 = _context10[\"catch\"](0);\n console.log(\"Error creating suggestion: \", _context10.t0);\n throw _context10.t0;\n case 15:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10, null, [[0, 11]]);\n }));\n}\n// Upvote a suggestion for a user\n// takes in suggestion id, user HSAid\n// returns error if transaction failed\nfunction upvoteSuggestion(suggestionId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var suggestionRef;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n _context11.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId); // Atomically add a update to the upvote array field.\n _context11.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(suggestionRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 4:\n _context11.next = 10;\n break;\n case 6:\n _context11.prev = 6;\n _context11.t0 = _context11[\"catch\"](0);\n console.log(\"Error upvoting suggestion: \", _context11.t0);\n throw _context11.t0;\n case 10:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11, null, [[0, 6]]);\n }));\n}\n//creates a comment\n// takes in commenters id, suggestion id and content as string\n// throws error if transaction failed\nfunction createComment(\n// change to subcollection\ncommenterHsaId, suggestionId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var suggestionRef, commentCollection, commentRef;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n _context12.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context12.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\");\n case 4:\n commentCollection = _context12.sent;\n _context12.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(commentCollection);\n case 7:\n commentRef = _context12.sent;\n _context12.next = 10;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(commentRef, {\n id: commentRef.id,\n commenterHsaId: commenterHsaId,\n content: content,\n dateCreated: new Date(),\n upvotes: []\n });\n case 10:\n _context12.next = 16;\n break;\n case 12:\n _context12.prev = 12;\n _context12.t0 = _context12[\"catch\"](0);\n console.log(\"Error creating comment: \", _context12.t0);\n throw _context12.t0;\n case 16:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12, null, [[0, 12]]);\n }));\n}\n// Upvote a comment for a user\n// takes in suggestionId, commentId and userId as strings\n// return error if transaction failed\nfunction upvoteComment(suggestionId, commentId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var suggestionRef, commentRef;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n _context13.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n commentRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionRef, \"comment\", commentId); // Atomically add a update to the upvote array field.\n _context13.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(commentRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 5:\n _context13.next = 11;\n break;\n case 7:\n _context13.prev = 7;\n _context13.t0 = _context13[\"catch\"](0);\n console.log(\"Error upvoting comment: \", _context13.t0);\n throw _context13.t0;\n case 11:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13, null, [[0, 7]]);\n }));\n}\n//add a note to a user\n// takes in userHsaId and content as string\n// throws error if transaction failed\nfunction addNoteToUser(userHsaId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var userRef, docRef;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n _context14.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, userHsaId);\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userRef, \"notes\");\n _context14.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n content: content,\n dateCreated: new Date()\n });\n case 5:\n _context14.next = 11;\n break;\n case 7:\n _context14.prev = 7;\n _context14.t0 = _context14[\"catch\"](0);\n console.log(\"Error adding document: \", _context14.t0);\n throw _context14.t0;\n case 11:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14, null, [[0, 7]]);\n }));\n}\n// export to setters to be able to use in other files\n\n//////////////////////////////////////////////GETTERS/////////////////////////////////////////////////////////////////////\n// Get any object\n// input is the database type as a string.\n// output is the whole collection of that type.\nfunction getObject(collectionPath) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n var collectionRef, querySnapshot, result;\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n _context15.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionPath);\n _context15.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n querySnapshot = _context15.sent;\n result = [];\n querySnapshot.forEach(function (doc) {\n result.push(doc.data());\n });\n return _context15.abrupt(\"return\", result);\n case 10:\n _context15.prev = 10;\n _context15.t0 = _context15[\"catch\"](0);\n console.error(\"Error getting collection data\", _context15.t0);\n throw _context15.t0;\n case 14:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15, null, [[0, 10]]);\n }));\n}\n/**\n * Asynchronously retrieves a single document object from the specified collection path and document ID.\n * If the document does not exist, logs a warning and returns null.\n *\n * @param {string} collectionPath - The path to the collection in the database (\"improvementWork\", \"hospital\", \"suggestion\", \"task\", \"unit\", \"users\")\n * @param {string} documentId - The ID of the document to retrieve.\n * @returns {Promise<any|null>} A promise that resolves to the document object if found, or null if not.\n *\n * @throws Will throw an error if there is an issue during retrieval from the database.\n */\nfunction getObjectById(collectionPath, documentId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {\n var docRef, docSnapshot;\n return _regeneratorRuntime().wrap(function _callee16$(_context16) {\n while (1) switch (_context16.prev = _context16.next) {\n case 0:\n _context16.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, collectionPath, documentId);\n _context16.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDoc)(docRef);\n case 4:\n docSnapshot = _context16.sent;\n if (!docSnapshot.exists()) {\n _context16.next = 9;\n break;\n }\n return _context16.abrupt(\"return\", docSnapshot.data());\n case 9:\n console.warn(\"No such document! \".concat(collectionPath, \"/\").concat(documentId));\n return _context16.abrupt(\"return\", null);\n case 11:\n _context16.next = 17;\n break;\n case 13:\n _context16.prev = 13;\n _context16.t0 = _context16[\"catch\"](0);\n console.error(\"Error getting object\", _context16.t0);\n throw _context16.t0;\n case 17:\n case \"end\":\n return _context16.stop();\n }\n }, _callee16, null, [[0, 13]]);\n }));\n}\n/**\n * Asynchronously retrieves comments for a given suggestion.\n *\n * @param {Object} params - The parameters for fetching comments.\n * @param {string} params.suggestionId - The ID of the suggestion to fetch comments for.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - The criterion to sort the comments by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Determines if the sorting should be in ascending order. Defaults to false (descending).\n * @returns {Promise<any[]>} A promise that resolves to an array of comment objects.\n *\n * @throws Will throw an error if the comments cannot be retrieved.\n */\nfunction getComments(_ref) {\n var suggestionId = _ref.suggestionId,\n _ref$sortBy = _ref.sortBy,\n sortBy = _ref$sortBy === void 0 ? \"dateCreated\" : _ref$sortBy,\n _ref$ascending = _ref.ascending,\n ascending = _ref$ascending === void 0 ? false : _ref$ascending;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {\n var suggestionRef, commentsQuery, commentsSnapshot, comments;\n return _regeneratorRuntime().wrap(function _callee17$(_context17) {\n while (1) switch (_context17.prev = _context17.next) {\n case 0:\n _context17.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, \"suggestionCollection\", suggestionId);\n commentsQuery = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\"), (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n _context17.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(commentsQuery);\n case 5:\n commentsSnapshot = _context17.sent;\n comments = [];\n commentsSnapshot.forEach(function (doc) {\n comments.push(doc.data());\n });\n return _context17.abrupt(\"return\", comments);\n case 11:\n _context17.prev = 11;\n _context17.t0 = _context17[\"catch\"](0);\n console.error(\"Error getting comments for suggestion: \", _context17.t0);\n throw _context17.t0;\n case 15:\n case \"end\":\n return _context17.stop();\n }\n }, _callee17, null, [[0, 11]]);\n }));\n}\n//Filtering suggestions on unitId AND creatorHsaId\n//Sort suggestions on dateCreated OR upvotes\n/**\n * Asynchronously retrieves an array of suggestions from the database, with various filters and sorting options.\n *\n * @param {Object} params - The parameters for filtering and sorting suggestions.\n * @param {string} [params.id] - Optional ID to filter suggestions by a specific identifier.\n * @param {string} [params.creatorHsaId] - Optional HSA ID to filter suggestions by the creator's HSA ID.\n * @param {string} [params.unitId] - Optional unit ID to filter suggestions by a specific unit.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - Criterion to sort the suggestions by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Flag indicating if sorting should be ascending. Defaults to false (descending order).\n * @param {boolean} [params.isPublic=true] - Flag indicating whether to filter for public suggestions. Defaults to true.\n * @returns {Promise<any[]>} A promise that resolves to an array of suggestion objects.\n *\n * @throws Will throw an error if there is an issue retrieving suggestions.\n */\nfunction getSuggestions(_ref2) {\n var id = _ref2.id,\n creatorHsaId = _ref2.creatorHsaId,\n unitId = _ref2.unitId,\n _ref2$sortBy = _ref2.sortBy,\n sortBy = _ref2$sortBy === void 0 ? \"dateCreated\" : _ref2$sortBy,\n _ref2$ascending = _ref2.ascending,\n ascending = _ref2$ascending === void 0 ? false : _ref2$ascending,\n _ref2$isPublic = _ref2.isPublic,\n isPublic = _ref2$isPublic === void 0 ? true : _ref2$isPublic;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {\n var collectionRef, constraints, q, querySnapshot, suggestions;\n return _regeneratorRuntime().wrap(function _callee18$(_context18) {\n while (1) switch (_context18.prev = _context18.next) {\n case 0:\n _context18.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (creatorHsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"creatorHsaId\", \"==\", creatorHsaId));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"public\", \"==\", isPublic));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context18.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 11:\n querySnapshot = _context18.sent;\n suggestions = [];\n querySnapshot.forEach(function (doc) {\n suggestions.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context18.abrupt(\"return\", suggestions);\n case 17:\n _context18.prev = 17;\n _context18.t0 = _context18[\"catch\"](0);\n console.log(\"Error retrieving suggestions by department: \", _context18.t0);\n throw _context18.t0;\n case 21:\n case \"end\":\n return _context18.stop();\n }\n }, _callee18, null, [[0, 17]]);\n }));\n}\n/**\n * Asynchronously searches for hospital documents in the database.\n * It can filter the results by the hospital's name, ID, or both.\n * If no parameters are provided, it retrieves all hospitals.\n *\n * @param {Object} params - An object containing the search parameters.\n * @param {string} [params.hospitalName] - Optional name of the hospital to filter the search.\n * @param {string} [params.hospitalId] - Optional unique identifier of the hospital to filter the search.\n * @returns {Promise<any[]>} A promise that resolves to an array of hospital objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getHospitals(_ref3) {\n var hospitalName = _ref3.hospitalName,\n hospitalId = _ref3.hospitalId;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {\n var collectionRef, constraints, q, querySnapshot, hospitals;\n return _regeneratorRuntime().wrap(function _callee19$(_context19) {\n while (1) switch (_context19.prev = _context19.next) {\n case 0:\n _context19.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\n constraints = [];\n if (hospitalName) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", hospitalName));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hospitalId));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context19.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context19.sent;\n hospitals = [];\n querySnapshot.forEach(function (doc) {\n hospitals.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context19.abrupt(\"return\", hospitals);\n case 14:\n _context19.prev = 14;\n _context19.t0 = _context19[\"catch\"](0);\n console.log(\"Error retrieving Hospitals\", _context19.t0);\n throw _context19.t0;\n case 18:\n case \"end\":\n return _context19.stop();\n }\n }, _callee19, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of improvement work documents based on various filter criteria.\n * It supports filtering by ID, Nolan stage, unit ID, completion status, ongoing status, and patient risk level.\n * It also supports sorting by the start date of the improvement work in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.id] - Optional identifier to filter the improvement works.\n * @param {string} [params.nolanStage] - Optional Nolan stage to filter the improvement works.\n * @param {string} [params.unitId] - Optional unit ID to filter the improvement works.\n * @param {boolean} [params.completed] - Optional flag to filter the improvement works by their completion status.\n * @param {boolean} [params.ongoing] - Optional flag to filter the improvement works by their ongoing status.\n * @param {string} [params.patientRiskLevel] - Optional patient risk level to filter the improvement works.\n * @param {boolean} [params.ascendingDates=false] - Optional flag for sorting by date in ascending order. Defaults to false.\n * @returns {Promise<any[]>} A promise that resolves to an array of improvement work objects that match the criteria.\n *\n * @throws Will throw an error if there is a problem retrieving the improvement works.\n */\nfunction getImprovementWorks(_ref4) {\n var id = _ref4.id,\n nolanStage = _ref4.nolanStage,\n unitId = _ref4.unitId,\n completed = _ref4.completed,\n ongoing = _ref4.ongoing,\n patientRiskLevel = _ref4.patientRiskLevel,\n _ref4$ascendingDates = _ref4.ascendingDates,\n ascendingDates = _ref4$ascendingDates === void 0 ? false : _ref4$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {\n var collectionRef, constraints, q, querySnapshot, improvementWorks;\n return _regeneratorRuntime().wrap(function _callee20$(_context20) {\n while (1) switch (_context20.prev = _context20.next) {\n case 0:\n _context20.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (nolanStage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"currentStage\", \"==\", nolanStage));\n }\n if (completed != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"completed\", \"==\", completed));\n }\n if (ongoing !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"ongoing\", \"==\", ongoing));\n }\n if (patientRiskLevel) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"patientRiskLevel\", \"==\", patientRiskLevel));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"dateStarted\", ascendingDates ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context20.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 13:\n querySnapshot = _context20.sent;\n improvementWorks = [];\n querySnapshot.forEach(function (doc) {\n improvementWorks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context20.abrupt(\"return\", improvementWorks);\n case 19:\n _context20.prev = 19;\n _context20.t0 = _context20[\"catch\"](0);\n console.log(\"Error retrieving improvementWorks: \", _context20.t0);\n throw _context20.t0;\n case 23:\n case \"end\":\n return _context20.stop();\n }\n }, _callee20, null, [[0, 19]]);\n }));\n}\n/**\n * Asynchronously retrieves user documents from the database based on various filter criteria.\n * It can filter by the Health Savings Account ID (hsaId), unit ID, and unique identifier (uid).\n * Additionally, it can sort the results by first name in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.hsaId] - Optional HSA ID to filter the users.\n * @param {string} [params.unitId] - Optional unit ID to filter the users.\n * @param {boolean} [params.ascendingFirstNames=false] - Optional flag to sort by first names in ascending order. Defaults to false (descending order).\n * @param {string} [params.uid] - Optional unique identifier to filter the users.\n * @returns {Promise<any[]>} A promise that resolves to an array of user objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUsers(_ref5) {\n var hsaId = _ref5.hsaId,\n unitId = _ref5.unitId,\n _ref5$ascendingFirstN = _ref5.ascendingFirstNames,\n ascendingFirstNames = _ref5$ascendingFirstN === void 0 ? false : _ref5$ascendingFirstN,\n uid = _ref5.uid;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {\n var collectionRef, constraints, q, querySnapshot, users;\n return _regeneratorRuntime().wrap(function _callee21$(_context21) {\n while (1) switch (_context21.prev = _context21.next) {\n case 0:\n _context21.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\n constraints = [];\n if (hsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hsaId));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (uid) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"uid\", \"==\", uid));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"firstName\", ascendingFirstNames ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context21.next = 10;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 10:\n querySnapshot = _context21.sent;\n users = [];\n querySnapshot.forEach(function (doc) {\n users.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context21.abrupt(\"return\", users);\n case 16:\n _context21.prev = 16;\n _context21.t0 = _context21[\"catch\"](0);\n console.log(\"Error retrieving users by department: \", _context21.t0);\n throw _context21.t0;\n case 20:\n case \"end\":\n return _context21.stop();\n }\n }, _callee21, null, [[0, 16]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of task documents from the database based on several filter and sorting criteria.\n * Filters include task ID, user ID and their responsibility status, and related improvement work ID.\n * Results can be sorted by date either in ascending or descending order.\n *\n * @param {Object} params - Parameters to filter and sort the task results.\n * @param {string} [params.taskId] - Optional task ID to filter the tasks.\n * @param {string} [params.userId] - Optional user ID to identify tasks related to a user.\n * @param {boolean} [params.isResponsibleFor] - Optional flag to filter tasks where the user is marked as responsible.\n * @param {string} [params.improvementWorkId] - Optional improvement work ID to filter tasks related to a specific improvement work.\n * @param {boolean} [params.ascendingDates=false] - Optional flag to sort tasks by date in ascending order; defaults to descending order.\n * @returns {Promise<any[]>} A promise that resolves to an array of task objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getTasks(_ref6) {\n var taskId = _ref6.taskId,\n userId = _ref6.userId,\n isResponsibleFor = _ref6.isResponsibleFor,\n improvementWorkId = _ref6.improvementWorkId,\n _ref6$ascendingDates = _ref6.ascendingDates,\n ascendingDates = _ref6$ascendingDates === void 0 ? false : _ref6$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {\n var collectionRef, constraints, q, querySnapshot, tasks;\n return _regeneratorRuntime().wrap(function _callee22$(_context22) {\n while (1) switch (_context22.prev = _context22.next) {\n case 0:\n _context22.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\n constraints = [];\n if (taskId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", taskId));\n }\n if (userId && isResponsibleFor !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"members\", \"array-contains\", {\n userHsaId: userId,\n isResponsibleFor: isResponsibleFor\n }));\n }\n if (improvementWorkId != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"startDate\", ascendingDates ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context22.next = 9;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 9:\n querySnapshot = _context22.sent;\n tasks = [];\n querySnapshot.forEach(function (doc) {\n tasks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context22.abrupt(\"return\", tasks);\n case 15:\n _context22.prev = 15;\n _context22.t0 = _context22[\"catch\"](0);\n console.log(\"Error retrieving task by department: \", _context22.t0);\n throw _context22.t0;\n case 19:\n case \"end\":\n return _context22.stop();\n }\n }, _callee22, null, [[0, 15]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of unit documents from the database based on various filter criteria.\n * Filters can be applied based on unit ID, hospital ID, and unit name.\n * Additionally, results can be sorted by unit names in ascending or descending order.\n *\n * @param {Object} params - The parameters object containing filter and sorting options.\n * @param {string} [params.unitId] - Optional unit ID to filter the units.\n * @param {string} [params.hospitalId] - Optional hospital ID to filter units within a specific hospital.\n * @param {string} [params.name] - Optional name to filter units by a specific name.\n * @param {boolean} [params.ascendingUnitNames=false] - Optional flag to sort units by name in ascending order, defaults to descending.\n * @returns {Promise<any[]>} A promise that resolves to an array of unit objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUnits(_ref7) {\n var unitId = _ref7.unitId,\n hospitalId = _ref7.hospitalId,\n name = _ref7.name,\n _ref7$ascendingUnitNa = _ref7.ascendingUnitNames,\n ascendingUnitNames = _ref7$ascendingUnitNa === void 0 ? false : _ref7$ascendingUnitNa;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {\n var collectionRef, constraints, q, querySnapshot, units;\n return _regeneratorRuntime().wrap(function _callee23$(_context23) {\n while (1) switch (_context23.prev = _context23.next) {\n case 0:\n _context23.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\n constraints = [];\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", unitId));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"hospitalId\", \"==\", hospitalId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"name\", ascendingUnitNames ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context23.next = 9;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 9:\n querySnapshot = _context23.sent;\n units = [];\n querySnapshot.forEach(function (doc) {\n units.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context23.abrupt(\"return\", units);\n case 15:\n _context23.prev = 15;\n _context23.t0 = _context23[\"catch\"](0);\n console.log(\"Error retrieving units by hospitalId: \", _context23.t0);\n throw _context23.t0;\n case 19:\n case \"end\":\n return _context23.stop();\n }\n }, _callee23, null, [[0, 15]]);\n }));\n}\n//getMembersFilteredAndSorted() -> Get all members of a project (sorted by firstName?)\n// export getters to be able to use in other files\n\n////////////////////////////////////DELETING/////////////////////////////////////////////\n// delete an instance of a type\nfunction deleteInstance(docType, docId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee24$(_context24) {\n while (1) switch (_context24.prev = _context24.next) {\n case 0:\n _context24.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context24.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(docRef);\n case 4:\n console.log(\"\".concat(docType, \" deleted successfully.\"));\n _context24.next = 11;\n break;\n case 7:\n _context24.prev = 7;\n _context24.t0 = _context24[\"catch\"](0);\n console.error(\"Error deleting \".concat(docType, \":\"), _context24.t0);\n throw _context24.t0;\n case 11:\n case \"end\":\n return _context24.stop();\n }\n }, _callee24, null, [[0, 7]]);\n }));\n}\n// delete all instances of a type\nfunction deleteAllDocumentsInCollection(collectionName) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {\n var _this = this;\n var collectionRef, snapshot, deletePromises;\n return _regeneratorRuntime().wrap(function _callee26$(_context26) {\n while (1) switch (_context26.prev = _context26.next) {\n case 0:\n _context26.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionName);\n _context26.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n snapshot = _context26.sent;\n // Delete all documents in the collection\n deletePromises = snapshot.docs.map(function (doc) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {\n return _regeneratorRuntime().wrap(function _callee25$(_context25) {\n while (1) switch (_context25.prev = _context25.next) {\n case 0:\n _context25.next = 2;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(doc.ref);\n case 2:\n case \"end\":\n return _context25.stop();\n }\n }, _callee25);\n }));\n });\n _context26.next = 8;\n return Promise.all(deletePromises);\n case 8:\n console.log(\"All documents in the \".concat(collectionName, \" collection deleted successfully.\"));\n _context26.next = 15;\n break;\n case 11:\n _context26.prev = 11;\n _context26.t0 = _context26[\"catch\"](0);\n console.error(\"Error deleting all documents in \".concat(collectionName, \":\"), _context26.t0);\n throw _context26.t0;\n case 15:\n case \"end\":\n return _context26.stop();\n }\n }, _callee26, null, [[0, 11]]);\n }));\n}\n////////////////////////////////////UPDATING/////////////////////////////////////////////\n// update a field in an instance\nfunction updateInstance(docType, docId, updates) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee27$(_context27) {\n while (1) switch (_context27.prev = _context27.next) {\n case 0:\n _context27.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context27.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(docRef, updates);\n case 4:\n console.log(\"\".concat(docType, \" updated successfully.\"));\n _context27.next = 11;\n break;\n case 7:\n _context27.prev = 7;\n _context27.t0 = _context27[\"catch\"](0);\n console.error(\"Error updating \".concat(docType, \":\"), _context27.t0);\n throw _context27.t0;\n case 11:\n case \"end\":\n return _context27.stop();\n }\n }, _callee27, null, [[0, 7]]);\n }));\n}\n// changes the ongoing status of an improvement work. if ongoing it is paused, if if paused onging.\n// user must be a manager\nfunction startOrPauseImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee28$(_context28) {\n while (1) switch (_context28.prev = _context28.next) {\n case 0:\n _context28.prev = 0;\n _context28.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context28.sent;\n _context28.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context28.sent;\n if (!(!user || !user.manager)) {\n _context28.next = 11;\n break;\n }\n throw new Error(\"User can't change improvementWork status\");\n case 11:\n if (!improvementWork) {\n _context28.next = 18;\n break;\n }\n update = {\n ongoing: !improvementWork.ongoing\n };\n _context28.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n _context28.next = 19;\n break;\n case 18:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n case 19:\n _context28.next = 25;\n break;\n case 21:\n _context28.prev = 21;\n _context28.t0 = _context28[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context28.t0);\n throw _context28.t0;\n case 25:\n case \"end\":\n return _context28.stop();\n }\n }, _callee28, null, [[0, 21]]);\n }));\n}\nfunction changePatientRiskLevel(userId, improvementWorkId, patientRiskLevel) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee29$(_context29) {\n while (1) switch (_context29.prev = _context29.next) {\n case 0:\n _context29.prev = 0;\n _context29.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context29.sent;\n _context29.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context29.sent;\n if (!(!user || !user.manager)) {\n _context29.next = 11;\n break;\n }\n throw new Error(\"User can't change patientRiskLevel in improvement work\");\n case 11:\n if (!improvementWork) {\n _context29.next = 18;\n break;\n }\n update = {\n patientRiskLevel: patientRiskLevel\n };\n _context29.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n _context29.next = 19;\n break;\n case 18:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n case 19:\n _context29.next = 25;\n break;\n case 21:\n _context29.prev = 21;\n _context29.t0 = _context29[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context29.t0);\n throw _context29.t0;\n case 25:\n case \"end\":\n return _context29.stop();\n }\n }, _callee29, null, [[0, 21]]);\n }));\n}\n// finalizes the improvement work. ongoing is set to false.\n// user must be a manager\nfunction finalizeImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {\n var user, update;\n return _regeneratorRuntime().wrap(function _callee30$(_context30) {\n while (1) switch (_context30.prev = _context30.next) {\n case 0:\n _context30.prev = 0;\n _context30.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context30.sent;\n if (!(!user || !user.manager)) {\n _context30.next = 8;\n break;\n }\n throw new Error(\"User can't finalize improvementWork status\");\n case 8:\n update = {\n completed: true,\n ongoing: false\n };\n _context30.next = 11;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 11:\n _context30.next = 16;\n break;\n case 13:\n _context30.prev = 13;\n _context30.t0 = _context30[\"catch\"](0);\n console.log(_context30.t0);\n case 16:\n case \"end\":\n return _context30.stop();\n }\n }, _callee30, null, [[0, 13]]);\n }));\n}\n\n//////////////////////////////// for later sprint\n//function add_upvotes\n//function add_notes\n//function add_intrested_users\n\n//# sourceURL=webpack://c3/./client/Database/database.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addDocumentToImprovementWork: () => (/* binding */ addDocumentToImprovementWork),\n/* harmony export */ addMemberToImprovementWork: () => (/* binding */ addMemberToImprovementWork),\n/* harmony export */ addMemberToTask: () => (/* binding */ addMemberToTask),\n/* harmony export */ addNoteToUser: () => (/* binding */ addNoteToUser),\n/* harmony export */ auth: () => (/* binding */ auth),\n/* harmony export */ changePatientRiskLevel: () => (/* binding */ changePatientRiskLevel),\n/* harmony export */ createComment: () => (/* binding */ createComment),\n/* harmony export */ createHospital: () => (/* binding */ createHospital),\n/* harmony export */ createImprovementWork: () => (/* binding */ createImprovementWork),\n/* harmony export */ createSuggestion: () => (/* binding */ createSuggestion),\n/* harmony export */ createTaskOnImprovementWork: () => (/* binding */ createTaskOnImprovementWork),\n/* harmony export */ createUnit: () => (/* binding */ createUnit),\n/* harmony export */ createUser: () => (/* binding */ createUser),\n/* harmony export */ createdDocumentInKnowledgeBank: () => (/* binding */ createdDocumentInKnowledgeBank),\n/* harmony export */ db: () => (/* binding */ db),\n/* harmony export */ deleteAllDocumentsInCollection: () => (/* binding */ deleteAllDocumentsInCollection),\n/* harmony export */ deleteInstance: () => (/* binding */ deleteInstance),\n/* harmony export */ finalizeImprovementWork: () => (/* binding */ finalizeImprovementWork),\n/* harmony export */ getComments: () => (/* binding */ getComments),\n/* harmony export */ getHospitals: () => (/* binding */ getHospitals),\n/* harmony export */ getImprovementWorkOwner: () => (/* binding */ getImprovementWorkOwner),\n/* harmony export */ getImprovementWorkResponsible: () => (/* binding */ getImprovementWorkResponsible),\n/* harmony export */ getImprovementWorks: () => (/* binding */ getImprovementWorks),\n/* harmony export */ getImprovementWorksForUser: () => (/* binding */ getImprovementWorksForUser),\n/* harmony export */ getObject: () => (/* binding */ getObject),\n/* harmony export */ getObjectById: () => (/* binding */ getObjectById),\n/* harmony export */ getSuggestions: () => (/* binding */ getSuggestions),\n/* harmony export */ getTasks: () => (/* binding */ getTasks),\n/* harmony export */ getUnits: () => (/* binding */ getUnits),\n/* harmony export */ getUsers: () => (/* binding */ getUsers),\n/* harmony export */ getUsersForImprovementWork: () => (/* binding */ getUsersForImprovementWork),\n/* harmony export */ startOrPauseImprovementWork: () => (/* binding */ startOrPauseImprovementWork),\n/* harmony export */ updateInstance: () => (/* binding */ updateInstance),\n/* harmony export */ upvoteComment: () => (/* binding */ upvoteComment),\n/* harmony export */ upvoteSuggestion: () => (/* binding */ upvoteSuggestion)\n/* harmony export */ });\n/* harmony import */ var firebase_app__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! firebase/app */ \"./node_modules/firebase/app/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_firestore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! firebase/firestore */ \"./node_modules/firebase/firestore/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_auth__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! firebase/auth */ \"./node_modules/firebase/auth/dist/esm/index.esm.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nvar firebaseConfig = {\n apiKey: \"AIzaSyDqkaVZMr11J4mfnR0auqoQilZyPfyD-x4\",\n authDomain: \"c3solutions-dc109.firebaseapp.com\",\n projectId: \"c3solutions-dc109\",\n storageBucket: \"c3solutions-dc109.appspot.com\",\n messagingSenderId: \"902143402555\",\n appId: \"1:902143402555:web:29213e81de0a0cba38b21e\"\n};\n/*const firebaseConfig = {\n apiKey: \"AIzaSyBIsZq_yOsJljp1woIxndJO1GkW6soh-g4\",\n authDomain: \"company3-456bb.firebaseapp.com\",\n projectId: \"company3-456bb\",\n storageBucket: \"company3-456bb.appspot.com\",\n messagingSenderId: \"310033686522\",\n appId: \"1:310033686522:web:63198bb0db679c98ee4e43\",\n measurementId: \"G-PFLDQY00DB\"\n};*/\n// const firebaseConfig = {\n// apiKey: \"AIzaSyBIsZq_yOsJljp1woIxndJO1GkW6soh-g4\",\n// authDomain: \"company3-456bb.firebaseapp.com\",\n// projectId: \"company3-456bb\",\n// storageBucket: \"company3-456bb.appspot.com\",\n// messagingSenderId: \"310033686522\",\n// appId: \"1:310033686522:web:63198bb0db679c98ee4e43\",\n// measurementId: \"G-PFLDQY00DB\"\n// };\nvar app = (0,firebase_app__WEBPACK_IMPORTED_MODULE_0__.initializeApp)(firebaseConfig);\nvar auth = (0,firebase_auth__WEBPACK_IMPORTED_MODULE_2__.getAuth)();\nvar db = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getFirestore)(app);\nvar userCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\nvar unitCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\nvar improvementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\nvar taskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\nvar hospitalCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\nvar suggestionCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\nvar knowledgeDocumentCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"knowledgeDocument\");\nvar userImprovementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"userImprovementWork\");\nvar userTaskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"userTask\");\n////////////////////////////////////////Setters///////////////////////////////////////////////////////////////////\n// Function to create user a new user in database\n// takes in userId, unitId, firstname, lastname, email and password as string\n// throws error if transaction failed\nfunction createUser(hsaId, unitId, firstName, lastName, email, manager, uid) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var userRef, unitRef;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, hsaId);\n _context.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(userRef, {\n id: userRef.id,\n uid: uid,\n unitId: unitId,\n firstName: firstName,\n lastName: lastName,\n email: email,\n // TODO Replace with userImprovementWork collection\n improvementWorks: [],\n tasks: [],\n manager: manager\n });\n case 4:\n // Atomically add user to unit.\n unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection, unitId);\n _context.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(unitRef, {\n members: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userRef.id)\n });\n case 7:\n _context.next = 12;\n break;\n case 9:\n _context.prev = 9;\n _context.t0 = _context[\"catch\"](0);\n console.log(_context.t0);\n case 12:\n case \"end\":\n return _context.stop();\n }\n }, _callee, null, [[0, 9]]);\n }));\n}\nfunction createImprovementWork(id, name, currentStage, content,\n// Är detta description bör detta förtydligas. \nunitId, purpose,\n//Bör tas bort motsvaras av p2- mål med projektet\npatientRiskLevel, area,\n//Questions in planning stage\np1, p2, p3, p4, p5, p6, p7,\n//Questions in Doing (G) stage\ng1, g2, g3, g4, g5,\n//Questions in stydy stage\ns1, s2, s3,\n//Questions in acting stage\na1, a2, a3, a4) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var improvementWorkData, improvementWorkRef, _improvementWorkRef;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.prev = 0;\n improvementWorkData = {\n name: name,\n currentStage: currentStage,\n content: content,\n purpose: purpose,\n dateStarted: new Date(),\n unitId: unitId,\n completed: false,\n ongoing: false,\n tasks: [],\n // TODO Remove members array\n members: [],\n patientRiskLevel: patientRiskLevel,\n area: area,\n p1: p1,\n p2: p2,\n p3: p3,\n p4: p4,\n p5: p5,\n p6: p6,\n p7: p7,\n g1: g1,\n g2: g2,\n g3: g3,\n g4: g4,\n g5: g5,\n s1: s1,\n s2: s2,\n s3: s3,\n a1: a1,\n a2: a2,\n a3: a3,\n a4: a4\n };\n if (!id) {\n _context2.next = 8;\n break;\n }\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, id);\n _context2.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(improvementWorkRef, Object.assign({\n id: improvementWorkRef.id\n }, improvementWorkData));\n case 6:\n _context2.next = 11;\n break;\n case 8:\n _improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection);\n _context2.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_improvementWorkRef, improvementWorkData);\n case 11:\n _context2.next = 17;\n break;\n case 13:\n _context2.prev = 13;\n _context2.t0 = _context2[\"catch\"](0);\n console.log(\"Error creating improvementWork: \", _context2.t0);\n throw _context2.t0;\n case 17:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, null, [[0, 13]]);\n }));\n}\nfunction addMemberToTask(userHsaId, taskId, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var relationRef;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.prev = 0;\n relationRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userTaskCollection);\n _context3.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(relationRef, {\n id: relationRef.id,\n userHsaId: userHsaId,\n taskId: taskId,\n isResponsibleFor: isResponsibleFor\n });\n case 4:\n _context3.next = 10;\n break;\n case 6:\n _context3.prev = 6;\n _context3.t0 = _context3[\"catch\"](0);\n console.log(\"Error adding member to task: \", _context3.t0);\n throw _context3.t0;\n case 10:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, null, [[0, 6]]);\n }));\n}\nfunction addMemberToImprovementWork(userHsaId, improvementWorkId, isOwner, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var relationRef;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n _context4.prev = 0;\n relationRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userImprovementWorkCollection);\n _context4.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(relationRef, {\n id: relationRef.id,\n userHsaId: userHsaId,\n improvementWorkId: improvementWorkId,\n isOwner: isOwner,\n isResponsibleFor: isResponsibleFor\n });\n case 4:\n _context4.next = 10;\n break;\n case 6:\n _context4.prev = 6;\n _context4.t0 = _context4[\"catch\"](0);\n console.log(\"Error adding member to improvementWork: \", _context4.t0);\n throw _context4.t0;\n case 10:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4, null, [[0, 6]]);\n }));\n}\nfunction createTaskOnImprovementWork(taskId, improvementWorkId, name, deadlineDate, startDate, stage, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var taskData, taskRef, _taskRef;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n _context5.prev = 0;\n taskData = {\n improvementWorkId: improvementWorkId,\n name: name,\n deadlineDate: deadlineDate,\n startDate: startDate,\n stage: stage,\n content: content,\n members: [] // Initialize with an empty array\n };\n if (!taskId) {\n _context5.next = 8;\n break;\n }\n taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection, taskId);\n _context5.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(taskRef, Object.assign({\n id: taskRef.id\n }, taskData));\n case 6:\n _context5.next = 11;\n break;\n case 8:\n _taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection);\n _context5.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_taskRef, taskData);\n case 11:\n _context5.next = 17;\n break;\n case 13:\n _context5.prev = 13;\n _context5.t0 = _context5[\"catch\"](0);\n console.log(\"Error creating task: \", _context5.t0);\n throw _context5.t0;\n case 17:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5, null, [[0, 13]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction createdDocumentInKnowledgeBank(documentUrl, name) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n _context6.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(knowledgeDocumentCollection);\n _context6.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n name: name\n });\n case 4:\n _context6.next = 10;\n break;\n case 6:\n _context6.prev = 6;\n _context6.t0 = _context6[\"catch\"](0);\n console.log(\"Error adding document: \", _context6.t0);\n throw _context6.t0;\n case 10:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6, null, [[0, 6]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction addDocumentToImprovementWork(documentUrl, name, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var improvementWorkRef, docRef;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.prev = 0;\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, improvementWorkId);\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkRef, \"documents\");\n _context7.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n timestamp: new Date(),\n name: name\n });\n case 5:\n _context7.next = 11;\n break;\n case 7:\n _context7.prev = 7;\n _context7.t0 = _context7[\"catch\"](0);\n console.log(\"Error adding document: \", _context7.t0);\n throw _context7.t0;\n case 11:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7, null, [[0, 7]]);\n }));\n}\nfunction createHospital(hospitalId,\n// should be auto?\nname) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var hospitalData, hospitalRef, _hospitalRef;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n _context8.prev = 0;\n hospitalData = {\n name: name,\n units: []\n };\n if (!hospitalId) {\n _context8.next = 8;\n break;\n }\n hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection, hospitalId);\n _context8.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(hospitalRef, Object.assign({\n id: hospitalRef.id\n }, hospitalData));\n case 6:\n _context8.next = 11;\n break;\n case 8:\n _hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection);\n _context8.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_hospitalRef, hospitalData);\n case 11:\n _context8.next = 17;\n break;\n case 13:\n _context8.prev = 13;\n _context8.t0 = _context8[\"catch\"](0);\n console.log(\"Error creating hospital: \", _context8.t0);\n throw _context8.t0;\n case 17:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8, null, [[0, 13]]);\n }));\n}\nfunction createUnit(unitId,\n//should be auto?\nhospitalId, name) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var unitData, unitRef, _unitRef;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n _context9.prev = 0;\n unitData = {\n hospitalId: hospitalId,\n name: name,\n members: []\n };\n if (!unitId) {\n _context9.next = 8;\n break;\n }\n unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection, unitId);\n _context9.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(unitRef, Object.assign({\n id: unitRef.id\n }, unitData));\n case 6:\n _context9.next = 11;\n break;\n case 8:\n _unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection);\n _context9.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_unitRef, unitData);\n case 11:\n _context9.next = 17;\n break;\n case 13:\n _context9.prev = 13;\n _context9.t0 = _context9[\"catch\"](0);\n console.log(\"Error creating unit: \", _context9.t0);\n throw _context9.t0;\n case 17:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9, null, [[0, 13]]);\n }));\n}\nfunction createSuggestion(id, creatorHsaId, name, area, content, purpose, measure, ideas,\n//need: boolean,\nunitId, departmentId, isPublic) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var suggestionData, suggestionRef, _suggestionRef;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n _context10.prev = 0;\n suggestionData = {\n creatorHsaId: creatorHsaId,\n name: name,\n area: area,\n content: content,\n purpose: purpose,\n measure: measure,\n ideas: ideas,\n //need,\n unitId: unitId,\n departmentId: departmentId,\n \"public\": isPublic,\n upvotes: [],\n comments: [],\n dateCreated: new Date()\n };\n if (!id) {\n _context10.next = 8;\n break;\n }\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, id);\n _context10.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(suggestionRef, Object.assign({\n id: suggestionRef.id\n }, suggestionData));\n case 6:\n _context10.next = 11;\n break;\n case 8:\n _suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection);\n _context10.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_suggestionRef, suggestionData);\n case 11:\n _context10.next = 17;\n break;\n case 13:\n _context10.prev = 13;\n _context10.t0 = _context10[\"catch\"](0);\n console.log(\"Error creating suggestion: \", _context10.t0);\n throw _context10.t0;\n case 17:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10, null, [[0, 13]]);\n }));\n}\n// Upvote a suggestion for a user\n// takes in suggestion id, user HSAid\n// returns error if transaction failed\nfunction upvoteSuggestion(suggestionId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var suggestionRef;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n _context11.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId); // Atomically add a update to the upvote array field.\n _context11.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(suggestionRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 4:\n _context11.next = 10;\n break;\n case 6:\n _context11.prev = 6;\n _context11.t0 = _context11[\"catch\"](0);\n console.log(\"Error upvoting suggestion: \", _context11.t0);\n throw _context11.t0;\n case 10:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11, null, [[0, 6]]);\n }));\n}\n//creates a comment\n// takes in commenters id, suggestion id and content as string\n// throws error if transaction failed\nfunction createComment(\n// change to subcollection\ncommenterHsaId, suggestionId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var suggestionRef, commentCollection, commentRef;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n _context12.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context12.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\");\n case 4:\n commentCollection = _context12.sent;\n _context12.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(commentCollection);\n case 7:\n commentRef = _context12.sent;\n _context12.next = 10;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(commentRef, {\n id: commentRef.id,\n commenterHsaId: commenterHsaId,\n content: content,\n dateCreated: new Date(),\n upvotes: []\n });\n case 10:\n _context12.next = 16;\n break;\n case 12:\n _context12.prev = 12;\n _context12.t0 = _context12[\"catch\"](0);\n console.log(\"Error creating comment: \", _context12.t0);\n throw _context12.t0;\n case 16:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12, null, [[0, 12]]);\n }));\n}\n// Upvote a comment for a user\n// takes in suggestionId, commentId and userId as strings\n// return error if transaction failed\nfunction upvoteComment(suggestionId, commentId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var suggestionRef, commentRef;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n _context13.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n commentRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionRef, \"comment\", commentId); // Atomically add a update to the upvote array field.\n _context13.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(commentRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 5:\n _context13.next = 11;\n break;\n case 7:\n _context13.prev = 7;\n _context13.t0 = _context13[\"catch\"](0);\n console.log(\"Error upvoting comment: \", _context13.t0);\n throw _context13.t0;\n case 11:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13, null, [[0, 7]]);\n }));\n}\n//add a note to a user\n// takes in userHsaId and content as string\n// throws error if transaction failed\nfunction addNoteToUser(userHsaId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var userRef, docRef;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n _context14.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, userHsaId);\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userRef, \"notes\");\n _context14.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n content: content,\n dateCreated: new Date()\n });\n case 5:\n _context14.next = 11;\n break;\n case 7:\n _context14.prev = 7;\n _context14.t0 = _context14[\"catch\"](0);\n console.log(\"Error adding document: \", _context14.t0);\n throw _context14.t0;\n case 11:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14, null, [[0, 7]]);\n }));\n}\n// export to setters to be able to use in other files\n\n//////////////////////////////////////////////GETTERS/////////////////////////////////////////////////////////////////////\n// Get any object\n// input is the database type as a string.\n// output is the whole collection of that type.\nfunction getObject(collectionPath) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n var collectionRef, querySnapshot, result;\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n _context15.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionPath);\n _context15.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n querySnapshot = _context15.sent;\n result = [];\n querySnapshot.forEach(function (doc) {\n result.push(doc.data());\n });\n return _context15.abrupt(\"return\", result);\n case 10:\n _context15.prev = 10;\n _context15.t0 = _context15[\"catch\"](0);\n console.error(\"Error getting collection data\", _context15.t0);\n throw _context15.t0;\n case 14:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15, null, [[0, 10]]);\n }));\n}\n/**\n * Asynchronously retrieves a single document object from the specified collection path and document ID.\n * If the document does not exist, logs a warning and returns null.\n *\n * @param {string} collectionPath - The path to the collection in the database (\"improvementWork\", \"hospital\", \"suggestion\", \"task\", \"unit\", \"users\")\n * @param {string} documentId - The ID of the document to retrieve.\n * @returns {Promise<any|null>} A promise that resolves to the document object if found, or null if not.\n *\n * @throws Will throw an error if there is an issue during retrieval from the database.\n */\nfunction getObjectById(collectionPath, documentId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {\n var docRef, docSnapshot;\n return _regeneratorRuntime().wrap(function _callee16$(_context16) {\n while (1) switch (_context16.prev = _context16.next) {\n case 0:\n _context16.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, collectionPath, documentId);\n _context16.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDoc)(docRef);\n case 4:\n docSnapshot = _context16.sent;\n if (!docSnapshot.exists()) {\n _context16.next = 9;\n break;\n }\n return _context16.abrupt(\"return\", Object.assign({\n id: docSnapshot.id\n }, docSnapshot.data()));\n case 9:\n console.warn(\"No such document! \".concat(collectionPath, \"/\").concat(documentId));\n return _context16.abrupt(\"return\", null);\n case 11:\n _context16.next = 17;\n break;\n case 13:\n _context16.prev = 13;\n _context16.t0 = _context16[\"catch\"](0);\n console.error(\"Error getting object\", _context16.t0);\n throw _context16.t0;\n case 17:\n case \"end\":\n return _context16.stop();\n }\n }, _callee16, null, [[0, 13]]);\n }));\n}\n/**\n * Asynchronously retrieves comments for a given suggestion.\n *\n * @param {Object} params - The parameters for fetching comments.\n * @param {string} params.suggestionId - The ID of the suggestion to fetch comments for.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - The criterion to sort the comments by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Determines if the sorting should be in ascending order. Defaults to false (descending).\n * @returns {Promise<any[]>} A promise that resolves to an array of comment objects.\n *\n * @throws Will throw an error if the comments cannot be retrieved.\n */\nfunction getComments(_ref) {\n var suggestionId = _ref.suggestionId,\n _ref$sortBy = _ref.sortBy,\n sortBy = _ref$sortBy === void 0 ? \"dateCreated\" : _ref$sortBy,\n _ref$ascending = _ref.ascending,\n ascending = _ref$ascending === void 0 ? false : _ref$ascending;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {\n var suggestionRef, commentsQuery, commentsSnapshot, comments;\n return _regeneratorRuntime().wrap(function _callee17$(_context17) {\n while (1) switch (_context17.prev = _context17.next) {\n case 0:\n _context17.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, \"suggestionCollection\", suggestionId);\n commentsQuery = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\"), (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n _context17.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(commentsQuery);\n case 5:\n commentsSnapshot = _context17.sent;\n comments = [];\n commentsSnapshot.forEach(function (doc) {\n comments.push(doc.data());\n });\n return _context17.abrupt(\"return\", comments);\n case 11:\n _context17.prev = 11;\n _context17.t0 = _context17[\"catch\"](0);\n console.error(\"Error getting comments for suggestion: \", _context17.t0);\n throw _context17.t0;\n case 15:\n case \"end\":\n return _context17.stop();\n }\n }, _callee17, null, [[0, 11]]);\n }));\n}\n//Filtering suggestions on unitId AND creatorHsaId\n//Sort suggestions on dateCreated OR upvotes\n/**\n * Asynchronously retrieves an array of suggestions from the database, with various filters and sorting options.\n *\n * @param {Object} params - The parameters for filtering and sorting suggestions.\n * @param {string} [params.id] - Optional ID to filter suggestions by a specific identifier.\n * @param {string} [params.creatorHsaId] - Optional HSA ID to filter suggestions by the creator's HSA ID.\n * @param {string} [params.unitId] - Optional unit ID to filter suggestions by a specific unit.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - Criterion to sort the suggestions by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Flag indicating if sorting should be ascending. Defaults to false (descending order).\n * @param {boolean} [params.isPublic=true] - Flag indicating whether to filter for public suggestions. Defaults to true.\n * @returns {Promise<any[]>} A promise that resolves to an array of suggestion objects.\n *\n * @throws Will throw an error if there is an issue retrieving suggestions.\n */\nfunction getSuggestions(_ref2) {\n var id = _ref2.id,\n creatorHsaId = _ref2.creatorHsaId,\n unitId = _ref2.unitId,\n _ref2$sortBy = _ref2.sortBy,\n sortBy = _ref2$sortBy === void 0 ? \"dateCreated\" : _ref2$sortBy,\n _ref2$ascending = _ref2.ascending,\n ascending = _ref2$ascending === void 0 ? false : _ref2$ascending,\n _ref2$isPublic = _ref2.isPublic,\n isPublic = _ref2$isPublic === void 0 ? true : _ref2$isPublic;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {\n var collectionRef, constraints, q, querySnapshot, suggestions;\n return _regeneratorRuntime().wrap(function _callee18$(_context18) {\n while (1) switch (_context18.prev = _context18.next) {\n case 0:\n _context18.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (creatorHsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"creatorHsaId\", \"==\", creatorHsaId));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"public\", \"==\", isPublic));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context18.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 11:\n querySnapshot = _context18.sent;\n suggestions = [];\n querySnapshot.forEach(function (doc) {\n suggestions.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context18.abrupt(\"return\", suggestions);\n case 17:\n _context18.prev = 17;\n _context18.t0 = _context18[\"catch\"](0);\n console.log(\"Error retrieving suggestions by department: \", _context18.t0);\n throw _context18.t0;\n case 21:\n case \"end\":\n return _context18.stop();\n }\n }, _callee18, null, [[0, 17]]);\n }));\n}\n/**\n * Asynchronously searches for hospital documents in the database.\n * It can filter the results by the hospital's name, ID, or both.\n * If no parameters are provided, it retrieves all hospitals.\n *\n * @param {Object} params - An object containing the search parameters.\n * @param {string} [params.hospitalName] - Optional name of the hospital to filter the search.\n * @param {string} [params.hospitalId] - Optional unique identifier of the hospital to filter the search.\n * @returns {Promise<any[]>} A promise that resolves to an array of hospital objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getHospitals(_ref3) {\n var hospitalName = _ref3.hospitalName,\n hospitalId = _ref3.hospitalId;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {\n var collectionRef, constraints, q, querySnapshot, hospitals;\n return _regeneratorRuntime().wrap(function _callee19$(_context19) {\n while (1) switch (_context19.prev = _context19.next) {\n case 0:\n _context19.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\n constraints = [];\n if (hospitalName) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", hospitalName));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hospitalId));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context19.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context19.sent;\n hospitals = [];\n querySnapshot.forEach(function (doc) {\n hospitals.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context19.abrupt(\"return\", hospitals);\n case 14:\n _context19.prev = 14;\n _context19.t0 = _context19[\"catch\"](0);\n console.log(\"Error retrieving Hospitals\", _context19.t0);\n throw _context19.t0;\n case 18:\n case \"end\":\n return _context19.stop();\n }\n }, _callee19, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of improvement work documents based on various filter criteria.\n * It supports filtering by ID, Nolan stage, unit ID, completion status, ongoing status, and patient risk level.\n * It also supports sorting by the start date of the improvement work in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.id] - Optional identifier to filter the improvement works.\n * @param {string} [params.nolanStage] - Optional Nolan stage to filter the improvement works.\n * @param {string} [params.unitId] - Optional unit ID to filter the improvement works.\n * @param {boolean} [params.completed] - Optional flag to filter the improvement works by their completion status.\n * @param {boolean} [params.ongoing] - Optional flag to filter the improvement works by their ongoing status.\n * @param {string} [params.patientRiskLevel] - Optional patient risk level to filter the improvement works.\n * @param {boolean} [params.ascendingDates=false] - Optional flag for sorting by date in ascending order. Defaults to false.\n * @returns {Promise<any[]>} A promise that resolves to an array of improvement work objects that match the criteria.\n *\n * @throws Will throw an error if there is a problem retrieving the improvement works.\n */\nfunction getImprovementWorks(_ref4) {\n var id = _ref4.id,\n nolanStage = _ref4.nolanStage,\n unitId = _ref4.unitId,\n completed = _ref4.completed,\n ongoing = _ref4.ongoing,\n patientRiskLevel = _ref4.patientRiskLevel,\n _ref4$ascendingDates = _ref4.ascendingDates,\n ascendingDates = _ref4$ascendingDates === void 0 ? false : _ref4$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {\n var collectionRef, constraints, q, querySnapshot, improvementWorks;\n return _regeneratorRuntime().wrap(function _callee20$(_context20) {\n while (1) switch (_context20.prev = _context20.next) {\n case 0:\n _context20.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (nolanStage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"currentStage\", \"==\", nolanStage));\n }\n if (completed != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"completed\", \"==\", completed));\n }\n if (ongoing !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"ongoing\", \"==\", ongoing));\n }\n if (patientRiskLevel) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"patientRiskLevel\", \"==\", patientRiskLevel));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"dateStarted\", ascendingDates ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context20.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 13:\n querySnapshot = _context20.sent;\n improvementWorks = [];\n querySnapshot.forEach(function (doc) {\n improvementWorks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context20.abrupt(\"return\", improvementWorks);\n case 19:\n _context20.prev = 19;\n _context20.t0 = _context20[\"catch\"](0);\n console.log(\"Error retrieving improvementWorks: \", _context20.t0);\n throw _context20.t0;\n case 23:\n case \"end\":\n return _context20.stop();\n }\n }, _callee20, null, [[0, 19]]);\n }));\n}\nfunction getImprovementWorkOwner(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {\n var constraints, q, querySnapshot, owner;\n return _regeneratorRuntime().wrap(function _callee21$(_context21) {\n while (1) switch (_context21.prev = _context21.next) {\n case 0:\n _context21.prev = 0;\n constraints = [];\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"isOwner\", \"==\", true));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context21.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 7:\n querySnapshot = _context21.sent;\n if (!querySnapshot.empty) {\n _context21.next = 13;\n break;\n }\n console.log(\"Improvement work \", improvementWorkId, \" has no owner\");\n return _context21.abrupt(\"return\", null);\n case 13:\n owner = querySnapshot.docs[0].data().userHsaId;\n return _context21.abrupt(\"return\", owner);\n case 15:\n _context21.next = 20;\n break;\n case 17:\n _context21.prev = 17;\n _context21.t0 = _context21[\"catch\"](0);\n console.log(_context21.t0);\n case 20:\n case \"end\":\n return _context21.stop();\n }\n }, _callee21, null, [[0, 17]]);\n }));\n}\nfunction getImprovementWorkResponsible(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {\n var constraints, q, querySnapshot, responsible;\n return _regeneratorRuntime().wrap(function _callee22$(_context22) {\n while (1) switch (_context22.prev = _context22.next) {\n case 0:\n _context22.prev = 0;\n constraints = [];\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"isResponsibleFor\", \"==\", true));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context22.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 7:\n querySnapshot = _context22.sent;\n if (!querySnapshot.empty) {\n _context22.next = 13;\n break;\n }\n console.log(\"Improvement work \", improvementWorkId, \" has no responsible\");\n return _context22.abrupt(\"return\", null);\n case 13:\n responsible = querySnapshot.docs[0].data().userHsaId;\n return _context22.abrupt(\"return\", responsible);\n case 15:\n _context22.next = 20;\n break;\n case 17:\n _context22.prev = 17;\n _context22.t0 = _context22[\"catch\"](0);\n console.log(_context22.t0);\n case 20:\n case \"end\":\n return _context22.stop();\n }\n }, _callee22, null, [[0, 17]]);\n }));\n}\n// TODO getUsersForTask!\n/**\n * Asynchronously retrieves user documents from the database based on various filter criteria.\n * It can filter by the Health Savings Account ID (hsaId), unit ID, and unique identifier (uid).\n * Additionally, it can sort the results by first name in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.hsaId] - Optional HSA ID to filter the users.\n * @param {string} [params.unitId] - Optional unit ID to filter the users.\n * @param {boolean} [params.ascendingFirstNames=false] - Optional flag to sort by first names in ascending order. Defaults to false (descending order).\n * @param {string} [params.uid] - Optional unique identifier to filter the users.\n * @returns {Promise<any[]>} A promise that resolves to an array of user objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUsers(_ref5) {\n var hsaId = _ref5.hsaId,\n unitId = _ref5.unitId,\n _ref5$ascendingFirstN = _ref5.ascendingFirstNames,\n ascendingFirstNames = _ref5$ascendingFirstN === void 0 ? false : _ref5$ascendingFirstN,\n uid = _ref5.uid;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {\n var collectionRef, constraints, q, querySnapshot, users;\n return _regeneratorRuntime().wrap(function _callee23$(_context23) {\n while (1) switch (_context23.prev = _context23.next) {\n case 0:\n _context23.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\n constraints = [];\n if (hsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hsaId));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (uid) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"uid\", \"==\", uid));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"firstName\", ascendingFirstNames ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context23.next = 10;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 10:\n querySnapshot = _context23.sent;\n users = [];\n querySnapshot.forEach(function (doc) {\n users.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context23.abrupt(\"return\", users);\n case 16:\n _context23.prev = 16;\n _context23.t0 = _context23[\"catch\"](0);\n console.log(\"Error retrieving users by department: \", _context23.t0);\n throw _context23.t0;\n case 20:\n case \"end\":\n return _context23.stop();\n }\n }, _callee23, null, [[0, 16]]);\n }));\n}\n// TODO getTasksForUser!\n/**\n * Asynchronously retrieves an array of task documents from the database based on several filter and sorting criteria.\n * Filters include task ID, user ID and their responsibility status, and related improvement work ID.\n * Results can be sorted by date either in ascending or descending order.\n *\n * @param {Object} params - Parameters to filter and sort the task results.\n * @param {string} [params.taskId] - Optional task ID to filter the tasks.\n * @param {string} [params.userId] - Optional user ID to identify tasks related to a user.\n * @param {boolean} [params.isResponsibleFor] - Optional flag to filter tasks where the user is marked as responsible.\n * @param {string} [params.improvementWorkId] - Optional improvement work ID to filter tasks related to a specific improvement work.\n * @param {boolean} [params.ascendingDates=false] - Optional flag to sort tasks by date in ascending order; defaults to descending order.\n * @returns {Promise<any[]>} A promise that resolves to an array of task objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getTasks(_ref6) {\n var improvementWorkId = _ref6.improvementWorkId,\n stage = _ref6.stage,\n _ref6$ascendingDates = _ref6.ascendingDates,\n ascendingDates = _ref6$ascendingDates === void 0 ? false : _ref6$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {\n var collectionRef, constraints, q, querySnapshot, tasks;\n return _regeneratorRuntime().wrap(function _callee24$(_context24) {\n while (1) switch (_context24.prev = _context24.next) {\n case 0:\n _context24.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\n constraints = []; // FUTURE FEATURE: Filter on userHsaId AND improvementWork\n // if (userHsaId && isResponsibleFor !== undefined) {\n // constraints.push(\n // where(\"members\", \"array-contains\", {\n // userHsaId: userHsaId,\n // isResponsibleFor: isResponsibleFor,\n // })\n // );\n // }\n if (stage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"stage\", \"==\", stage));\n }\n if (improvementWorkId != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"startDate\", ascendingDates ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context24.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context24.sent;\n tasks = [];\n querySnapshot.forEach(function (doc) {\n tasks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context24.abrupt(\"return\", tasks);\n case 14:\n _context24.prev = 14;\n _context24.t0 = _context24[\"catch\"](0);\n console.log(\"Error retrieving task by department: \", _context24.t0);\n throw _context24.t0;\n case 18:\n case \"end\":\n return _context24.stop();\n }\n }, _callee24, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of unit documents from the database based on various filter criteria.\n * Filters can be applied based on unit ID, hospital ID, and unit name.\n * Additionally, results can be sorted by unit names in ascending or descending order.\n *\n * @param {Object} params - The parameters object containing filter and sorting options.\n * @param {string} [params.unitId] - Optional unit ID to filter the units.\n * @param {string} [params.hospitalId] - Optional hospital ID to filter units within a specific hospital.\n * @param {string} [params.name] - Optional name to filter units by a specific name.\n * @param {boolean} [params.ascendingUnitNames=false] - Optional flag to sort units by name in ascending order, defaults to descending.\n * @returns {Promise<any[]>} A promise that resolves to an array of unit objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUnits(_ref7) {\n var unitId = _ref7.unitId,\n hospitalId = _ref7.hospitalId,\n name = _ref7.name,\n _ref7$ascendingUnitNa = _ref7.ascendingUnitNames,\n ascendingUnitNames = _ref7$ascendingUnitNa === void 0 ? false : _ref7$ascendingUnitNa;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {\n var collectionRef, constraints, q, querySnapshot, units;\n return _regeneratorRuntime().wrap(function _callee25$(_context25) {\n while (1) switch (_context25.prev = _context25.next) {\n case 0:\n _context25.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\n constraints = [];\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", unitId));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"hospitalId\", \"==\", hospitalId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"name\", ascendingUnitNames ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context25.next = 9;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 9:\n querySnapshot = _context25.sent;\n units = [];\n querySnapshot.forEach(function (doc) {\n units.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context25.abrupt(\"return\", units);\n case 15:\n _context25.prev = 15;\n _context25.t0 = _context25[\"catch\"](0);\n console.log(\"Error retrieving units by hospitalId: \", _context25.t0);\n throw _context25.t0;\n case 19:\n case \"end\":\n return _context25.stop();\n }\n }, _callee25, null, [[0, 15]]);\n }));\n}\nfunction getImprovementWorksForUser(userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {\n var q, querySnapshot, improvementWorks, _iterator, _step, _doc, improvementWorkId, improvementWorkDoc;\n return _regeneratorRuntime().wrap(function _callee26$(_context26) {\n while (1) switch (_context26.prev = _context26.next) {\n case 0:\n _context26.prev = 0;\n console.log(\"Getting improvementworks for user: \", userHsaId);\n // Query the userImprovementWork collection for relations involving this user\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(userImprovementWorkCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)('userHsaId', '==', userHsaId));\n _context26.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 5:\n querySnapshot = _context26.sent;\n // Fetch each related improvementWork document\n improvementWorks = [];\n _iterator = _createForOfIteratorHelper(querySnapshot.docs);\n _context26.prev = 8;\n _iterator.s();\n case 10:\n if ((_step = _iterator.n()).done) {\n _context26.next = 19;\n break;\n }\n _doc = _step.value;\n improvementWorkId = _doc.data().improvementWorkId;\n _context26.next = 15;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 15:\n improvementWorkDoc = _context26.sent;\n improvementWorks.push(improvementWorkDoc);\n case 17:\n _context26.next = 10;\n break;\n case 19:\n _context26.next = 24;\n break;\n case 21:\n _context26.prev = 21;\n _context26.t0 = _context26[\"catch\"](8);\n _iterator.e(_context26.t0);\n case 24:\n _context26.prev = 24;\n _iterator.f();\n return _context26.finish(24);\n case 27:\n return _context26.abrupt(\"return\", improvementWorks);\n case 30:\n _context26.prev = 30;\n _context26.t1 = _context26[\"catch\"](0);\n console.error(\"Error getting improvement works for user: \", _context26.t1);\n throw _context26.t1;\n case 34:\n case \"end\":\n return _context26.stop();\n }\n }, _callee26, null, [[0, 30], [8, 21, 24, 27]]);\n }));\n}\nfunction getUsersForImprovementWork(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {\n var q, querySnapshot, users, _iterator2, _step2, _doc2, userHsaId, userDoc;\n return _regeneratorRuntime().wrap(function _callee27$(_context27) {\n while (1) switch (_context27.prev = _context27.next) {\n case 0:\n _context27.prev = 0;\n console.log(\"Getting users for improvementwork: \", improvementWorkId);\n // Query the userImprovementWork collection for relations involving this improvementWork\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(userImprovementWorkCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)('improvementWorkId', '==', improvementWorkId));\n _context27.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 5:\n querySnapshot = _context27.sent;\n // Fetch each related user document\n users = [];\n _iterator2 = _createForOfIteratorHelper(querySnapshot.docs);\n _context27.prev = 8;\n _iterator2.s();\n case 10:\n if ((_step2 = _iterator2.n()).done) {\n _context27.next = 19;\n break;\n }\n _doc2 = _step2.value;\n userHsaId = _doc2.data().userHsaId;\n _context27.next = 15;\n return getObjectById(\"users\", userHsaId);\n case 15:\n userDoc = _context27.sent;\n users.push(userDoc);\n case 17:\n _context27.next = 10;\n break;\n case 19:\n _context27.next = 24;\n break;\n case 21:\n _context27.prev = 21;\n _context27.t0 = _context27[\"catch\"](8);\n _iterator2.e(_context27.t0);\n case 24:\n _context27.prev = 24;\n _iterator2.f();\n return _context27.finish(24);\n case 27:\n return _context27.abrupt(\"return\", users);\n case 30:\n _context27.prev = 30;\n _context27.t1 = _context27[\"catch\"](0);\n console.error(\"Error getting users for improvementWork: \", _context27.t1);\n throw _context27.t1;\n case 34:\n case \"end\":\n return _context27.stop();\n }\n }, _callee27, null, [[0, 30], [8, 21, 24, 27]]);\n }));\n}\n// export getters to be able to use in other files\n\n////////////////////////////////////DELETING/////////////////////////////////////////////\n// delete an instance of a type\nfunction deleteInstance(docType, docId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee28$(_context28) {\n while (1) switch (_context28.prev = _context28.next) {\n case 0:\n _context28.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context28.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(docRef);\n case 4:\n console.log(\"\".concat(docType, \" deleted successfully.\"));\n _context28.next = 11;\n break;\n case 7:\n _context28.prev = 7;\n _context28.t0 = _context28[\"catch\"](0);\n console.error(\"Error deleting \".concat(docType, \":\"), _context28.t0);\n throw _context28.t0;\n case 11:\n case \"end\":\n return _context28.stop();\n }\n }, _callee28, null, [[0, 7]]);\n }));\n}\n// delete all instances of a type\nfunction deleteAllDocumentsInCollection(collectionName) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {\n var _this = this;\n var collectionRef, snapshot, deletePromises;\n return _regeneratorRuntime().wrap(function _callee30$(_context30) {\n while (1) switch (_context30.prev = _context30.next) {\n case 0:\n _context30.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionName);\n _context30.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n snapshot = _context30.sent;\n // Delete all documents in the collection\n deletePromises = snapshot.docs.map(function (doc) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {\n return _regeneratorRuntime().wrap(function _callee29$(_context29) {\n while (1) switch (_context29.prev = _context29.next) {\n case 0:\n _context29.next = 2;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(doc.ref);\n case 2:\n case \"end\":\n return _context29.stop();\n }\n }, _callee29);\n }));\n });\n _context30.next = 8;\n return Promise.all(deletePromises);\n case 8:\n console.log(\"All documents in the \".concat(collectionName, \" collection deleted successfully.\"));\n _context30.next = 15;\n break;\n case 11:\n _context30.prev = 11;\n _context30.t0 = _context30[\"catch\"](0);\n console.error(\"Error deleting all documents in \".concat(collectionName, \":\"), _context30.t0);\n throw _context30.t0;\n case 15:\n case \"end\":\n return _context30.stop();\n }\n }, _callee30, null, [[0, 11]]);\n }));\n}\n////////////////////////////////////UPDATING/////////////////////////////////////////////\n// update a field in an instance\nfunction updateInstance(docType, docId, updates) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee31$(_context31) {\n while (1) switch (_context31.prev = _context31.next) {\n case 0:\n _context31.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context31.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(docRef, updates);\n case 4:\n console.log(\"\".concat(docType, \" updated successfully.\"));\n _context31.next = 11;\n break;\n case 7:\n _context31.prev = 7;\n _context31.t0 = _context31[\"catch\"](0);\n console.error(\"Error updating \".concat(docType, \":\"), _context31.t0);\n throw _context31.t0;\n case 11:\n case \"end\":\n return _context31.stop();\n }\n }, _callee31, null, [[0, 7]]);\n }));\n}\n// changes the ongoing status of an improvement work. if ongoing it is paused, if if paused onging.\n// user must be a manager\nfunction startOrPauseImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee32$(_context32) {\n while (1) switch (_context32.prev = _context32.next) {\n case 0:\n _context32.prev = 0;\n _context32.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context32.sent;\n _context32.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context32.sent;\n if (!(!user || !user.manager)) {\n _context32.next = 11;\n break;\n }\n throw new Error(\"User can't change improvementWork status\");\n case 11:\n if (!improvementWork) {\n _context32.next = 18;\n break;\n }\n update = {\n ongoing: !improvementWork.ongoing\n };\n _context32.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n _context32.next = 19;\n break;\n case 18:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n case 19:\n _context32.next = 25;\n break;\n case 21:\n _context32.prev = 21;\n _context32.t0 = _context32[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context32.t0);\n throw _context32.t0;\n case 25:\n case \"end\":\n return _context32.stop();\n }\n }, _callee32, null, [[0, 21]]);\n }));\n}\nfunction changePatientRiskLevel(userId, improvementWorkId, patientRiskLevel) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee33$(_context33) {\n while (1) switch (_context33.prev = _context33.next) {\n case 0:\n _context33.prev = 0;\n _context33.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context33.sent;\n _context33.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context33.sent;\n if (!(!user || !user.manager)) {\n _context33.next = 11;\n break;\n }\n throw new Error(\"User can't change patientRiskLevel in improvement work\");\n case 11:\n if (!improvementWork) {\n _context33.next = 18;\n break;\n }\n update = {\n patientRiskLevel: patientRiskLevel\n };\n _context33.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n _context33.next = 19;\n break;\n case 18:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n case 19:\n _context33.next = 25;\n break;\n case 21:\n _context33.prev = 21;\n _context33.t0 = _context33[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context33.t0);\n throw _context33.t0;\n case 25:\n case \"end\":\n return _context33.stop();\n }\n }, _callee33, null, [[0, 21]]);\n }));\n}\n// finalizes the improvement work. ongoing is set to false.\n// user must be a manager\nfunction finalizeImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {\n var user, update;\n return _regeneratorRuntime().wrap(function _callee34$(_context34) {\n while (1) switch (_context34.prev = _context34.next) {\n case 0:\n _context34.prev = 0;\n _context34.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context34.sent;\n if (!(!user || !user.manager)) {\n _context34.next = 8;\n break;\n }\n throw new Error(\"User can't finalize improvementWork status\");\n case 8:\n update = {\n completed: true,\n ongoing: false\n };\n _context34.next = 11;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 11:\n _context34.next = 16;\n break;\n case 13:\n _context34.prev = 13;\n _context34.t0 = _context34[\"catch\"](0);\n console.log(_context34.t0);\n case 16:\n case \"end\":\n return _context34.stop();\n }\n }, _callee34, null, [[0, 13]]);\n }));\n}\n\n//////////////////////////////// for later sprint\n//function add_upvotes\n//function add_notes\n//function add_intrested_users\n\n//# sourceURL=webpack://c3/./client/Database/database.js?"); /***/ }), @@ -116,7 +116,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \****************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../client/Database/database.js */ \"./client/Database/database.js\");\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\nfunction logoutUser(event) {\n event.preventDefault();\n alert('logout');\n (0,_Database_authentication_js__WEBPACK_IMPORTED_MODULE_0__.logout)();\n}\n//Mock-data, to be replaced\nvar homePageSampleProjects = [{\n ID: \"1\",\n name: \"Birthing of a Child\",\n current_stage: \"In Progress\",\n content: \"This is project 1.\",\n unit_ID: \"2\",\n date_started: new Date(\"2023-01-15\")\n}, {\n ID: \"2\",\n name: \"How to save a life\",\n current_stage: \"Completed\",\n content: \"This is project 2.\",\n unit_ID: \"1\",\n date_started: new Date(\"2023-02-20\")\n}, {\n ID: \"3\",\n name: \"BB tutorial\",\n current_stage: \"Completed\",\n content: \"This is project 3.\",\n unit_ID: \"2\",\n date_started: new Date(\"2023-06-05\")\n}, {\n ID: \"4\",\n name: \"Cancerbehandling 101\",\n current_stage: \"Completed\",\n content: \"This is project 4.\",\n unit_ID: \"3\",\n date_started: new Date(\"2023-10-24\")\n}, {\n ID: \"5\",\n name: \"Cancerbehandling 101\",\n current_stage: \"Completed\",\n content: \"This is project 4.\",\n unit_ID: \"3\",\n date_started: new Date(\"2023-10-24\")\n}, {\n ID: \"6\",\n name: \"Cancerbehandling 101\",\n current_stage: \"Completed\",\n content: \"This is project 4.\",\n unit_ID: \"3\",\n date_started: new Date(\"2023-10-24\")\n}];\nvar signedInUserHsaID = \"alijoh234\";\nvar myIdeaCards = {};\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n }\n _createClass(IdeaCard, [{\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImage\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFaded\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n </div>\\n <div class=\\\"ideaCardUpvotes\\\">\\n <img src=\\\"images/upvoteIcon.png\\\" class =\\\"upvoteIcon\\\" alt=\\\"upvoteIcon\\\">\\n <p id =\\\"upvoteNumber\\\" class=\\\"ideaCardFont\\\">\").concat(this.upvoteCount, \"</p>\\n </div>\\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <p class=\\\"ideaCardFont\\\">Kommentarer</p>\\n <p class=\\\"ideaCardFont\\\">Komment 1</p>\\n <p class=\\\"ideaCardFont\\\">K0mment 2</p>\\n </div>\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProject\\\" onclick=\\\"myIdeaCards[\").concat(this.id, \"].loadInitiatePage()\\\">Initiera Project</button>\\n </div>\\n </div>\\n </div>\\n </div>\");\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var user, userSuggestions, counter;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"users\", signedInUserHsaID);\n case 2:\n user = _context2.sent;\n _context2.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 5:\n userSuggestions = _context2.sent;\n //If there exist filter use those instead to get matching suggestions rest should not need to be changed\n counter = 0;\n userSuggestions.forEach(function (suggestion) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context.sent;\n _context.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context.sent;\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter);\n counter = counter + 1;\n case 8:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n case 8:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount);\n cardHTML = card.generateHTML();\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n container.appendChild(div);\n case 7:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction loadPage() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this2 = this;\n var container;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n container = document.querySelector('#container-fluid');\n if (container) {\n _context5.next = 3;\n break;\n }\n return _context5.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n fetch('homePage.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var tempContainer, specificElement, tmp, user, suggestionContainer, nameHeaderElement, nameElement, emailElement, roleElement, unitElement, userFullName, userUnits, userUnit;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n // Create a temporary container element to hold the loaded content\n tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n specificElement = tempContainer.querySelector('.main-content');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n tmp = localStorage.getItem('user');\n console.log(tmp);\n if (tmp) {\n _context4.next = 9;\n break;\n }\n console.log(\"there is not an user in localStorage\");\n return _context4.abrupt(\"return\");\n case 9:\n user = JSON.parse(tmp)[0];\n displayProjects(user);\n //displaySuggestions(user);\n suggestionContainer = document.getElementById(\"suggestion-container\");\n if (!suggestionContainer) {\n _context4.next = 15;\n break;\n }\n _context4.next = 15;\n return createNewCards(\"HomePageIdeaCardDiv\", suggestionContainer);\n case 15:\n console.log(user.firstName + \"user.firstname\");\n nameHeaderElement = document.getElementById('user-name-header');\n nameElement = document.getElementById('user-name');\n emailElement = document.getElementById('user-email');\n roleElement = document.getElementById('user-role');\n unitElement = document.getElementById(\"user-unit\");\n userFullName = user.firstName + \" \" + user.lastName;\n _context4.next = 24;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getUnits)({\n unitId: user.unitId\n });\n case 24:\n userUnits = _context4.sent;\n userUnit = userUnits[0];\n if (emailElement && roleElement && nameElement && unitElement && nameHeaderElement) {\n nameHeaderElement.textContent = userFullName;\n nameElement.textContent = userFullName;\n unitElement.textContent = userUnit.name;\n emailElement.textContent = user.email;\n roleElement.textContent = \"undefined\";\n }\n case 27:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n case 4:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction displayProjects(user) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var container, userImprovementWorks;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n container = document.getElementById('project-container');\n userImprovementWorks = user.improvementWorks;\n userImprovementWorks.forEach(function (project) {\n console.log(project.improvementWorkId);\n var improvementWork = (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"improvementWork\", project.improvementWorkId);\n var projectBox = document.createElement('div');\n projectBox.classList.add('project-box');\n var projectName = document.createElement('h2');\n projectName.textContent = project.name;\n projectBox.appendChild(projectName);\n container === null || container === void 0 ? void 0 : container.appendChild(projectBox);\n });\n case 3:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction displaySuggestions(user) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var container, userSuggestions;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n container = document.getElementById('suggestion-container');\n _context7.next = 3;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 3:\n userSuggestions = _context7.sent;\n userSuggestions.forEach(function (suggestion) {\n var suggestionBox = document.createElement('div');\n suggestionBox.classList.add('suggestion-box');\n var suggestionName = document.createElement('h2');\n suggestionName.textContent = suggestion.name;\n var suggestionDescription = document.createElement('p');\n suggestionDescription.textContent = suggestion.area;\n suggestionDescription.classList.add('suggestion-description');\n suggestionDescription.style.display = 'none'; // Initially hide the description\n var expandButton = document.createElement('button');\n expandButton.textContent = 'Expand';\n expandButton.addEventListener('click', function () {\n if (suggestionDescription.style.display === 'none') {\n suggestionDescription.style.display = 'block';\n expandButton.textContent = 'Collapse';\n } else {\n suggestionDescription.style.display = 'none';\n expandButton.textContent = 'Expand';\n }\n });\n suggestionBox.appendChild(suggestionName);\n suggestionBox.appendChild(expandButton);\n suggestionBox.appendChild(suggestionDescription);\n container === null || container === void 0 ? void 0 : container.appendChild(suggestionBox);\n });\n case 5:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/homePage.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../client/Database/database.js */ \"./client/Database/database.js\");\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\nfunction logoutUser(event) {\n event.preventDefault();\n alert('logout');\n (0,_Database_authentication_js__WEBPACK_IMPORTED_MODULE_0__.logout)();\n}\nvar myIdeaCards = {};\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n }\n _createClass(IdeaCard, [{\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImage\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFaded\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n </div>\\n <div class=\\\"ideaCardUpvotes\\\">\\n <img src=\\\"images/upvoteIcon.png\\\" class =\\\"upvoteIcon\\\" alt=\\\"upvoteIcon\\\">\\n <p id =\\\"upvoteNumber\\\" class=\\\"ideaCardFont\\\">\").concat(this.upvoteCount, \"</p>\\n </div>\\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <p class=\\\"ideaCardFont\\\">Kommentarer</p>\\n <p class=\\\"ideaCardFont\\\">Komment 1</p>\\n <p class=\\\"ideaCardFont\\\">K0mment 2</p>\\n </div>\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProject\\\" onclick=\\\"myIdeaCards[\").concat(this.id, \"].loadInitiatePage()\\\">Initiera Project</button>\\n </div>\\n </div>\\n </div>\\n </div>\");\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container, signedInUserHsaID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var user, userSuggestions, counter;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"users\", signedInUserHsaID);\n case 2:\n user = _context2.sent;\n _context2.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 5:\n userSuggestions = _context2.sent;\n //If there exist filter use those instead to get matching suggestions rest should not need to be changed\n counter = 0;\n userSuggestions.forEach(function (suggestion) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context.sent;\n _context.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context.sent;\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter);\n counter = counter + 1;\n case 8:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n case 8:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount);\n cardHTML = card.generateHTML();\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n container.appendChild(div);\n case 7:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction loadPage() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this2 = this;\n var container;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n container = document.querySelector('#container-fluid');\n if (container) {\n _context5.next = 3;\n break;\n }\n return _context5.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n fetch('homePage.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var tempContainer, specificElement, tmp, user, suggestionContainer, nameHeaderElement, nameElement, emailElement, roleElement, unitElement, userFullName, userUnits, userUnit, projectContainer;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n // Create a temporary container element to hold the loaded content\n tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n specificElement = tempContainer.querySelector('.main-content');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n tmp = localStorage.getItem('user');\n console.log(tmp);\n if (tmp) {\n _context4.next = 9;\n break;\n }\n console.log(\"there is not an user in localStorage\");\n return _context4.abrupt(\"return\");\n case 9:\n user = JSON.parse(tmp)[0];\n suggestionContainer = document.getElementById(\"suggestion-container\");\n if (!suggestionContainer) {\n _context4.next = 14;\n break;\n }\n _context4.next = 14;\n return createNewCards(\"HomePageIdeaCardDiv\", suggestionContainer, user.id);\n case 14:\n console.log(user.firstName + \"user.firstname\");\n nameHeaderElement = document.getElementById('user-name-header');\n nameElement = document.getElementById('user-name');\n emailElement = document.getElementById('user-email');\n roleElement = document.getElementById('user-role');\n unitElement = document.getElementById(\"user-unit\");\n userFullName = user.firstName + \" \" + user.lastName;\n _context4.next = 23;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getUnits)({\n unitId: user.unitId\n });\n case 23:\n userUnits = _context4.sent;\n userUnit = userUnits[0];\n if (emailElement && roleElement && nameElement && unitElement && nameHeaderElement) {\n nameHeaderElement.textContent = userFullName;\n nameElement.textContent = userFullName;\n unitElement.textContent = userUnit.name;\n emailElement.textContent = user.email;\n roleElement.textContent = \"undefined\";\n }\n projectContainer = document.getElementById(\"project-container\");\n if (!projectContainer) {\n _context4.next = 30;\n break;\n }\n _context4.next = 30;\n return getProjects(projectContainer, user.id);\n case 30:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n case 4:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction getProjects(selectElement, /*listenersLoaded:boolean,*/userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var _this3 = this;\n var data, id;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getImprovementWorksForUser)(userHsaId);\n case 2:\n data = _context7.sent;\n id = 0;\n data.forEach(function (project) {\n return __awaiter(_this3, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var title, department, name, description, i, card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n title = project.name;\n _context6.next = 3;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)('unit', project.unitId);\n case 3:\n department = _context6.sent;\n if (!department) {\n _context6.next = 20;\n break;\n }\n name = \"Projektledare\"; //Waiting for backend fix\n description = project.content;\n i = id;\n card = new projectCard(i, name, department.name, title, description, project.id);\n projectCards[i] = card;\n cardHTML = card.generateHTML(); //addEventListener(listenersLoaded, project.id, card);\n div = document.createElement('div');\n div.className = 'homePageProjectCardDiv'; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context6.next = 16;\n break;\n }\n return _context6.abrupt(\"return\");\n case 16:\n selectElement.appendChild(div); // Stop if the container isn't found\n id++;\n _context6.next = 21;\n break;\n case 20:\n console.log(project.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist \n case 21:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n });\n case 5:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nvar projectCards = {};\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = '^ Stäng detaljer';\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = '> Mer information';\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert('The initiate project page should now be loaded');\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"homeTotalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: pointer;\\\" class=\\\"flex-container ongoingCard\\\" id=\\\"\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\" id=\\\"pinkFaded\\\"></div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n </div>\\n\\n <!--<button data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton\\\" role=\\\"button\\\">G\\xE5 till projektsidan</button>-->\\n\\n\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n <p id=\\\"ongoingSeeDetailsButton\").concat(this.projectId, \"\\\" class = \\\"moreInfoClass\\\">> Mer information</p>\\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}();\n\n//# sourceURL=webpack://c3/./client/homePage.js?"); /***/ }), diff --git a/client/dist/ideaBank.bundle.js b/client/dist/ideaBank.bundle.js index b05cf7aa70f42420700ecf94c5596a0eea3745c5..9c6a41c107a3214cf8ad2373be360d00e95cf859 100644 --- a/client/dist/ideaBank.bundle.js +++ b/client/dist/ideaBank.bundle.js @@ -96,7 +96,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \*************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addDocumentToImprovementWork: () => (/* binding */ addDocumentToImprovementWork),\n/* harmony export */ addMemberToImprovementWork: () => (/* binding */ addMemberToImprovementWork),\n/* harmony export */ addMemberToTask: () => (/* binding */ addMemberToTask),\n/* harmony export */ addNoteToUser: () => (/* binding */ addNoteToUser),\n/* harmony export */ auth: () => (/* binding */ auth),\n/* harmony export */ changePatientRiskLevel: () => (/* binding */ changePatientRiskLevel),\n/* harmony export */ createComment: () => (/* binding */ createComment),\n/* harmony export */ createHospital: () => (/* binding */ createHospital),\n/* harmony export */ createImprovementWork: () => (/* binding */ createImprovementWork),\n/* harmony export */ createSuggestion: () => (/* binding */ createSuggestion),\n/* harmony export */ createTaskOnImprovementWork: () => (/* binding */ createTaskOnImprovementWork),\n/* harmony export */ createUnit: () => (/* binding */ createUnit),\n/* harmony export */ createUser: () => (/* binding */ createUser),\n/* harmony export */ createdDocumentInKnowledgeBank: () => (/* binding */ createdDocumentInKnowledgeBank),\n/* harmony export */ db: () => (/* binding */ db),\n/* harmony export */ deleteAllDocumentsInCollection: () => (/* binding */ deleteAllDocumentsInCollection),\n/* harmony export */ deleteInstance: () => (/* binding */ deleteInstance),\n/* harmony export */ finalizeImprovementWork: () => (/* binding */ finalizeImprovementWork),\n/* harmony export */ getComments: () => (/* binding */ getComments),\n/* harmony export */ getHospitals: () => (/* binding */ getHospitals),\n/* harmony export */ getImprovementWorks: () => (/* binding */ getImprovementWorks),\n/* harmony export */ getObject: () => (/* binding */ getObject),\n/* harmony export */ getObjectById: () => (/* binding */ getObjectById),\n/* harmony export */ getSuggestions: () => (/* binding */ getSuggestions),\n/* harmony export */ getTasks: () => (/* binding */ getTasks),\n/* harmony export */ getUnits: () => (/* binding */ getUnits),\n/* harmony export */ getUsers: () => (/* binding */ getUsers),\n/* harmony export */ startOrPauseImprovementWork: () => (/* binding */ startOrPauseImprovementWork),\n/* harmony export */ updateInstance: () => (/* binding */ updateInstance),\n/* harmony export */ upvoteComment: () => (/* binding */ upvoteComment),\n/* harmony export */ upvoteSuggestion: () => (/* binding */ upvoteSuggestion)\n/* harmony export */ });\n/* harmony import */ var firebase_app__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! firebase/app */ \"./node_modules/firebase/app/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_firestore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! firebase/firestore */ \"./node_modules/firebase/firestore/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_auth__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! firebase/auth */ \"./node_modules/firebase/auth/dist/esm/index.esm.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nvar firebaseConfig = {\n apiKey: \"AIzaSyDqkaVZMr11J4mfnR0auqoQilZyPfyD-x4\",\n authDomain: \"c3solutions-dc109.firebaseapp.com\",\n projectId: \"c3solutions-dc109\",\n storageBucket: \"c3solutions-dc109.appspot.com\",\n messagingSenderId: \"902143402555\",\n appId: \"1:902143402555:web:29213e81de0a0cba38b21e\"\n};\nvar app = (0,firebase_app__WEBPACK_IMPORTED_MODULE_0__.initializeApp)(firebaseConfig);\nvar auth = (0,firebase_auth__WEBPACK_IMPORTED_MODULE_2__.getAuth)();\nvar db = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getFirestore)(app);\nvar userCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\nvar unitCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\nvar improvementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\nvar taskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\nvar hospitalCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\nvar suggestionCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\nvar knowledgeDocumentCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"knowledgeDocument\");\n////////////////////////////////////////Setters///////////////////////////////////////////////////////////////////\n// Function to create user a new user in database\n// takes in userId, unitId, firstname, lastname, email and password as string\n// throws error if transaction failed\nfunction createUser(hsaId, unitId, firstName, lastName, email, manager, uid) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var userRef, unitRef;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, hsaId);\n _context.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(userRef, {\n id: userRef.id,\n uid: uid,\n unitId: unitId,\n firstName: firstName,\n lastName: lastName,\n email: email,\n improvementWorks: [],\n tasks: [],\n manager: manager\n });\n case 4:\n // Atomically add user to unit.\n unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection, unitId);\n _context.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(unitRef, {\n members: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userRef.id)\n });\n case 7:\n _context.next = 12;\n break;\n case 9:\n _context.prev = 9;\n _context.t0 = _context[\"catch\"](0);\n console.log(_context.t0);\n case 12:\n case \"end\":\n return _context.stop();\n }\n }, _callee, null, [[0, 9]]);\n }));\n}\n//Adds a new improvementWork to the database\n// takes in Id, name, currentStage in PDSA, content, unitId refers to as string and if completed as boolean\n// throws error if transaction failed\nfunction createImprovementWork(id, name, currentStage, content,\n// Är detta description bör detta förtydligas. \nunitId, purpose,\n//Bör tas bort motsvaras av p2- mål med projektet\npatientRiskLevel, area,\n// patientRiskLevel: \"Green\" | \"Blue\" | \"Orange\" | \"Red\"\n//Questions in planning stage\np1, p2, p3, p4, p5, p6, p7,\n//Questions in Doing (G) stage\ng1, g2, g3, g4, g5,\n//Questions in stydy stage\ns1, s2, s3,\n//Questions in acting stage\na1, a2, a3, a4) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var improvementWorkRef;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.prev = 0;\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, id);\n _context2.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(improvementWorkRef, {\n id: improvementWorkRef.id,\n currentStage: currentStage,\n name: name,\n content: content,\n purpose: purpose,\n dateStarted: new Date(),\n unitId: unitId,\n completed: false,\n ongoing: false,\n tasks: [],\n members: [],\n patientRiskLevel: patientRiskLevel,\n area: area,\n p1: p1,\n p2: p2,\n p3: p3,\n p4: p4,\n p5: p5,\n p6: p6,\n p7: p7,\n g1: g1,\n g2: g2,\n g3: g3,\n g4: g4,\n g5: g5,\n s1: s1,\n s2: s2,\n s3: s3,\n a1: a1,\n a2: a2,\n a3: a3,\n a4: a4\n });\n case 4:\n _context2.next = 10;\n break;\n case 6:\n _context2.prev = 6;\n _context2.t0 = _context2[\"catch\"](0);\n console.log(\"Error creating improvementWork: \", _context2.t0);\n throw _context2.t0;\n case 10:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, null, [[0, 6]]);\n }));\n}\n//create task to improvementWork\n// takes in improvementWorkId, name, deadline date, start date, stage in PDSA and content as string\n// throws error if transaction failed\nfunction createTaskOnImprovementWork(taskId, improvementWorkId, name, deadlineDate, startDate, stage, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var ref, improvementWorkRef;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.prev = 0;\n ref = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection, taskId);\n _context3.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(ref, {\n id: ref.id,\n improvementWorkId: improvementWorkId,\n name: name,\n deadlineDate: deadlineDate,\n startDate: startDate,\n stage: stage,\n content: content,\n members: []\n });\n case 4:\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, improvementWorkId); // Atomically add task to the tasks array field.\n _context3.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(improvementWorkRef, {\n tasks: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(taskId)\n });\n case 7:\n _context3.next = 13;\n break;\n case 9:\n _context3.prev = 9;\n _context3.t0 = _context3[\"catch\"](0);\n console.log(\"Error creating task: \", _context3.t0);\n throw _context3.t0;\n case 13:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, null, [[0, 9]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction createdDocumentInKnowledgeBank(documentUrl, name) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n _context4.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(knowledgeDocumentCollection);\n _context4.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n name: name\n });\n case 4:\n _context4.next = 10;\n break;\n case 6:\n _context4.prev = 6;\n _context4.t0 = _context4[\"catch\"](0);\n console.log(\"Error adding document: \", _context4.t0);\n throw _context4.t0;\n case 10:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4, null, [[0, 6]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction addDocumentToImprovementWork(documentUrl, name, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var improvementWorkRef, docRef;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n _context5.prev = 0;\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, improvementWorkId);\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkRef, \"documents\");\n _context5.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n timestamp: new Date(),\n name: name\n });\n case 5:\n _context5.next = 11;\n break;\n case 7:\n _context5.prev = 7;\n _context5.t0 = _context5[\"catch\"](0);\n console.log(\"Error adding document: \", _context5.t0);\n throw _context5.t0;\n case 11:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5, null, [[0, 7]]);\n }));\n}\n//add a member to a improvementWork\n// takes in id, users HSAid, improvementWorks id as string and if is owner, is responsible as boolean\n// throws error if transaction failed\nfunction addMemberToImprovementWork(userHsaId, improvementWorkId, isOwner, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var improvementWorkRef, userRef;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n _context6.prev = 0;\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, improvementWorkId); // return;\n // Atomically update the members array in the improvementWork document\n _context6.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(improvementWorkRef, {\n members: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)({\n userHsaId: userHsaId,\n isOwner: isOwner,\n isResponsibleFor: isResponsibleFor\n })\n });\n case 4:\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, userHsaId); // Atomically add improvementWork to user\n _context6.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(userRef, {\n improvementWorks: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)({\n improvementWorkId: improvementWorkId,\n isOwner: isOwner,\n isResponsibleFor: isResponsibleFor\n })\n });\n case 7:\n _context6.next = 13;\n break;\n case 9:\n _context6.prev = 9;\n _context6.t0 = _context6[\"catch\"](0);\n console.log(\"Error adding member: \", _context6.t0);\n throw _context6.t0;\n case 13:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6, null, [[0, 9]]);\n }));\n}\n//create a hospital\n// takes in ID, name as string\n// throws error if transaction failed\nfunction createHospital(hospitalId,\n// should be auto?\nname) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var ref;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.prev = 0;\n ref = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection, hospitalId);\n _context7.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(ref, {\n id: ref.id,\n name: name,\n units: []\n });\n case 4:\n _context7.next = 10;\n break;\n case 6:\n _context7.prev = 6;\n _context7.t0 = _context7[\"catch\"](0);\n console.log(\"Error creating hospital: \", _context7.t0);\n throw _context7.t0;\n case 10:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7, null, [[0, 6]]);\n }));\n}\n//create a unit\n// takes in id, hospitals id and name as string\n// throws error if transaction failed\nfunction createUnit(unitId,\n//should be auto?\nhospitalId, name) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var unitRef, hospitalRef;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n _context8.prev = 0;\n unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection, unitId);\n _context8.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(unitRef, {\n id: unitRef.id,\n hospitalId: hospitalId,\n name: name,\n members: []\n });\n case 4:\n // Atomically add unit to hospital.\n hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection, hospitalId);\n _context8.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(hospitalRef, {\n units: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(unitRef.id)\n });\n case 7:\n _context8.next = 13;\n break;\n case 9:\n _context8.prev = 9;\n _context8.t0 = _context8[\"catch\"](0);\n console.log(\"Error creating unit: \", _context8.t0);\n throw _context8.t0;\n case 13:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8, null, [[0, 9]]);\n }));\n}\n//adds a member to task\n// takes in ID, the added members hsaId, task id as string and if person is responsible as boolean\n// throws error if transaction failed\nfunction addMemberToTask(userHsaId, taskId, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var taskRef, userRef;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n _context9.prev = 0;\n // Atomically add a member to task.\n taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection, taskId);\n _context9.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(taskRef, {\n members: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)({\n userHsaId: userHsaId,\n isResponsibleFor: isResponsibleFor\n })\n });\n case 4:\n // Atomically add a task to user.\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, userHsaId);\n _context9.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(userRef, {\n tasks: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)({\n taskId: taskId,\n isResponsibleFor: isResponsibleFor\n })\n });\n case 7:\n _context9.next = 13;\n break;\n case 9:\n _context9.prev = 9;\n _context9.t0 = _context9[\"catch\"](0);\n console.log(\"Error adding member: \", _context9.t0);\n throw _context9.t0;\n case 13:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9, null, [[0, 9]]);\n }));\n}\n//creates a suggestion\n// takes in ID, the creators hsaId, name, content and the responding unitId as string\n// throws error if transaction failed\nfunction createSuggestion(id, creatorHsaId, name, area, content, purpose, measure, ideas,\n//need: boolean,\nunitId, departmentId, isPublic) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var suggestionRef, commentCollection;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n _context10.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, id);\n _context10.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(suggestionRef, {\n id: suggestionRef.id,\n creatorHsaId: creatorHsaId,\n name: name,\n area: area,\n content: content,\n purpose: purpose,\n measure: measure,\n ideas: ideas,\n //need: need,\n unitId: unitId,\n departmentId: departmentId,\n \"public\": isPublic,\n upvotes: [],\n comments: [],\n dateCreated: new Date()\n });\n case 4:\n _context10.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\");\n case 6:\n commentCollection = _context10.sent;\n _context10.next = 9;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(commentCollection);\n case 9:\n _context10.next = 15;\n break;\n case 11:\n _context10.prev = 11;\n _context10.t0 = _context10[\"catch\"](0);\n console.log(\"Error creating suggestion: \", _context10.t0);\n throw _context10.t0;\n case 15:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10, null, [[0, 11]]);\n }));\n}\n// Upvote a suggestion for a user\n// takes in suggestion id, user HSAid\n// returns error if transaction failed\nfunction upvoteSuggestion(suggestionId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var suggestionRef;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n _context11.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId); // Atomically add a update to the upvote array field.\n _context11.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(suggestionRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 4:\n _context11.next = 10;\n break;\n case 6:\n _context11.prev = 6;\n _context11.t0 = _context11[\"catch\"](0);\n console.log(\"Error upvoting suggestion: \", _context11.t0);\n throw _context11.t0;\n case 10:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11, null, [[0, 6]]);\n }));\n}\n//creates a comment\n// takes in commenters id, suggestion id and content as string\n// throws error if transaction failed\nfunction createComment(\n// change to subcollection\ncommenterHsaId, suggestionId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var suggestionRef, commentCollection, commentRef;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n _context12.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context12.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\");\n case 4:\n commentCollection = _context12.sent;\n _context12.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(commentCollection);\n case 7:\n commentRef = _context12.sent;\n _context12.next = 10;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(commentRef, {\n id: commentRef.id,\n commenterHsaId: commenterHsaId,\n content: content,\n dateCreated: new Date(),\n upvotes: []\n });\n case 10:\n _context12.next = 16;\n break;\n case 12:\n _context12.prev = 12;\n _context12.t0 = _context12[\"catch\"](0);\n console.log(\"Error creating comment: \", _context12.t0);\n throw _context12.t0;\n case 16:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12, null, [[0, 12]]);\n }));\n}\n// Upvote a comment for a user\n// takes in suggestionId, commentId and userId as strings\n// return error if transaction failed\nfunction upvoteComment(suggestionId, commentId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var suggestionRef, commentRef;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n _context13.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n commentRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionRef, \"comment\", commentId); // Atomically add a update to the upvote array field.\n _context13.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(commentRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 5:\n _context13.next = 11;\n break;\n case 7:\n _context13.prev = 7;\n _context13.t0 = _context13[\"catch\"](0);\n console.log(\"Error upvoting comment: \", _context13.t0);\n throw _context13.t0;\n case 11:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13, null, [[0, 7]]);\n }));\n}\n//add a note to a user\n// takes in userHsaId and content as string\n// throws error if transaction failed\nfunction addNoteToUser(userHsaId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var userRef, docRef;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n _context14.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, userHsaId);\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userRef, \"notes\");\n _context14.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n content: content,\n dateCreated: new Date()\n });\n case 5:\n _context14.next = 11;\n break;\n case 7:\n _context14.prev = 7;\n _context14.t0 = _context14[\"catch\"](0);\n console.log(\"Error adding document: \", _context14.t0);\n throw _context14.t0;\n case 11:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14, null, [[0, 7]]);\n }));\n}\n// export to setters to be able to use in other files\n\n//////////////////////////////////////////////GETTERS/////////////////////////////////////////////////////////////////////\n// Get any object\n// input is the database type as a string.\n// output is the whole collection of that type.\nfunction getObject(collectionPath) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n var collectionRef, querySnapshot, result;\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n _context15.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionPath);\n _context15.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n querySnapshot = _context15.sent;\n result = [];\n querySnapshot.forEach(function (doc) {\n result.push(doc.data());\n });\n return _context15.abrupt(\"return\", result);\n case 10:\n _context15.prev = 10;\n _context15.t0 = _context15[\"catch\"](0);\n console.error(\"Error getting collection data\", _context15.t0);\n throw _context15.t0;\n case 14:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15, null, [[0, 10]]);\n }));\n}\n/**\n * Asynchronously retrieves a single document object from the specified collection path and document ID.\n * If the document does not exist, logs a warning and returns null.\n *\n * @param {string} collectionPath - The path to the collection in the database (\"improvementWork\", \"hospital\", \"suggestion\", \"task\", \"unit\", \"users\")\n * @param {string} documentId - The ID of the document to retrieve.\n * @returns {Promise<any|null>} A promise that resolves to the document object if found, or null if not.\n *\n * @throws Will throw an error if there is an issue during retrieval from the database.\n */\nfunction getObjectById(collectionPath, documentId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {\n var docRef, docSnapshot;\n return _regeneratorRuntime().wrap(function _callee16$(_context16) {\n while (1) switch (_context16.prev = _context16.next) {\n case 0:\n _context16.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, collectionPath, documentId);\n _context16.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDoc)(docRef);\n case 4:\n docSnapshot = _context16.sent;\n if (!docSnapshot.exists()) {\n _context16.next = 9;\n break;\n }\n return _context16.abrupt(\"return\", docSnapshot.data());\n case 9:\n console.warn(\"No such document! \".concat(collectionPath, \"/\").concat(documentId));\n return _context16.abrupt(\"return\", null);\n case 11:\n _context16.next = 17;\n break;\n case 13:\n _context16.prev = 13;\n _context16.t0 = _context16[\"catch\"](0);\n console.error(\"Error getting object\", _context16.t0);\n throw _context16.t0;\n case 17:\n case \"end\":\n return _context16.stop();\n }\n }, _callee16, null, [[0, 13]]);\n }));\n}\n/**\n * Asynchronously retrieves comments for a given suggestion.\n *\n * @param {Object} params - The parameters for fetching comments.\n * @param {string} params.suggestionId - The ID of the suggestion to fetch comments for.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - The criterion to sort the comments by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Determines if the sorting should be in ascending order. Defaults to false (descending).\n * @returns {Promise<any[]>} A promise that resolves to an array of comment objects.\n *\n * @throws Will throw an error if the comments cannot be retrieved.\n */\nfunction getComments(_ref) {\n var suggestionId = _ref.suggestionId,\n _ref$sortBy = _ref.sortBy,\n sortBy = _ref$sortBy === void 0 ? \"dateCreated\" : _ref$sortBy,\n _ref$ascending = _ref.ascending,\n ascending = _ref$ascending === void 0 ? false : _ref$ascending;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {\n var suggestionRef, commentsQuery, commentsSnapshot, comments;\n return _regeneratorRuntime().wrap(function _callee17$(_context17) {\n while (1) switch (_context17.prev = _context17.next) {\n case 0:\n _context17.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, \"suggestionCollection\", suggestionId);\n commentsQuery = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\"), (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n _context17.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(commentsQuery);\n case 5:\n commentsSnapshot = _context17.sent;\n comments = [];\n commentsSnapshot.forEach(function (doc) {\n comments.push(doc.data());\n });\n return _context17.abrupt(\"return\", comments);\n case 11:\n _context17.prev = 11;\n _context17.t0 = _context17[\"catch\"](0);\n console.error(\"Error getting comments for suggestion: \", _context17.t0);\n throw _context17.t0;\n case 15:\n case \"end\":\n return _context17.stop();\n }\n }, _callee17, null, [[0, 11]]);\n }));\n}\n//Filtering suggestions on unitId AND creatorHsaId\n//Sort suggestions on dateCreated OR upvotes\n/**\n * Asynchronously retrieves an array of suggestions from the database, with various filters and sorting options.\n *\n * @param {Object} params - The parameters for filtering and sorting suggestions.\n * @param {string} [params.id] - Optional ID to filter suggestions by a specific identifier.\n * @param {string} [params.creatorHsaId] - Optional HSA ID to filter suggestions by the creator's HSA ID.\n * @param {string} [params.unitId] - Optional unit ID to filter suggestions by a specific unit.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - Criterion to sort the suggestions by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Flag indicating if sorting should be ascending. Defaults to false (descending order).\n * @param {boolean} [params.isPublic=true] - Flag indicating whether to filter for public suggestions. Defaults to true.\n * @returns {Promise<any[]>} A promise that resolves to an array of suggestion objects.\n *\n * @throws Will throw an error if there is an issue retrieving suggestions.\n */\nfunction getSuggestions(_ref2) {\n var id = _ref2.id,\n creatorHsaId = _ref2.creatorHsaId,\n unitId = _ref2.unitId,\n _ref2$sortBy = _ref2.sortBy,\n sortBy = _ref2$sortBy === void 0 ? \"dateCreated\" : _ref2$sortBy,\n _ref2$ascending = _ref2.ascending,\n ascending = _ref2$ascending === void 0 ? false : _ref2$ascending,\n _ref2$isPublic = _ref2.isPublic,\n isPublic = _ref2$isPublic === void 0 ? true : _ref2$isPublic;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {\n var collectionRef, constraints, q, querySnapshot, suggestions;\n return _regeneratorRuntime().wrap(function _callee18$(_context18) {\n while (1) switch (_context18.prev = _context18.next) {\n case 0:\n _context18.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (creatorHsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"creatorHsaId\", \"==\", creatorHsaId));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"public\", \"==\", isPublic));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context18.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 11:\n querySnapshot = _context18.sent;\n suggestions = [];\n querySnapshot.forEach(function (doc) {\n suggestions.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context18.abrupt(\"return\", suggestions);\n case 17:\n _context18.prev = 17;\n _context18.t0 = _context18[\"catch\"](0);\n console.log(\"Error retrieving suggestions by department: \", _context18.t0);\n throw _context18.t0;\n case 21:\n case \"end\":\n return _context18.stop();\n }\n }, _callee18, null, [[0, 17]]);\n }));\n}\n/**\n * Asynchronously searches for hospital documents in the database.\n * It can filter the results by the hospital's name, ID, or both.\n * If no parameters are provided, it retrieves all hospitals.\n *\n * @param {Object} params - An object containing the search parameters.\n * @param {string} [params.hospitalName] - Optional name of the hospital to filter the search.\n * @param {string} [params.hospitalId] - Optional unique identifier of the hospital to filter the search.\n * @returns {Promise<any[]>} A promise that resolves to an array of hospital objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getHospitals(_ref3) {\n var hospitalName = _ref3.hospitalName,\n hospitalId = _ref3.hospitalId;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {\n var collectionRef, constraints, q, querySnapshot, hospitals;\n return _regeneratorRuntime().wrap(function _callee19$(_context19) {\n while (1) switch (_context19.prev = _context19.next) {\n case 0:\n _context19.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\n constraints = [];\n if (hospitalName) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", hospitalName));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hospitalId));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context19.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context19.sent;\n hospitals = [];\n querySnapshot.forEach(function (doc) {\n hospitals.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context19.abrupt(\"return\", hospitals);\n case 14:\n _context19.prev = 14;\n _context19.t0 = _context19[\"catch\"](0);\n console.log(\"Error retrieving Hospitals\", _context19.t0);\n throw _context19.t0;\n case 18:\n case \"end\":\n return _context19.stop();\n }\n }, _callee19, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of improvement work documents based on various filter criteria.\n * It supports filtering by ID, Nolan stage, unit ID, completion status, ongoing status, and patient risk level.\n * It also supports sorting by the start date of the improvement work in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.id] - Optional identifier to filter the improvement works.\n * @param {string} [params.nolanStage] - Optional Nolan stage to filter the improvement works.\n * @param {string} [params.unitId] - Optional unit ID to filter the improvement works.\n * @param {boolean} [params.completed] - Optional flag to filter the improvement works by their completion status.\n * @param {boolean} [params.ongoing] - Optional flag to filter the improvement works by their ongoing status.\n * @param {string} [params.patientRiskLevel] - Optional patient risk level to filter the improvement works.\n * @param {boolean} [params.ascendingDates=false] - Optional flag for sorting by date in ascending order. Defaults to false.\n * @returns {Promise<any[]>} A promise that resolves to an array of improvement work objects that match the criteria.\n *\n * @throws Will throw an error if there is a problem retrieving the improvement works.\n */\nfunction getImprovementWorks(_ref4) {\n var id = _ref4.id,\n nolanStage = _ref4.nolanStage,\n unitId = _ref4.unitId,\n completed = _ref4.completed,\n ongoing = _ref4.ongoing,\n patientRiskLevel = _ref4.patientRiskLevel,\n _ref4$ascendingDates = _ref4.ascendingDates,\n ascendingDates = _ref4$ascendingDates === void 0 ? false : _ref4$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {\n var collectionRef, constraints, q, querySnapshot, improvementWorks;\n return _regeneratorRuntime().wrap(function _callee20$(_context20) {\n while (1) switch (_context20.prev = _context20.next) {\n case 0:\n _context20.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (nolanStage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"currentStage\", \"==\", nolanStage));\n }\n if (completed != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"completed\", \"==\", completed));\n }\n if (ongoing !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"ongoing\", \"==\", ongoing));\n }\n if (patientRiskLevel) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"patientRiskLevel\", \"==\", patientRiskLevel));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"dateStarted\", ascendingDates ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context20.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 13:\n querySnapshot = _context20.sent;\n improvementWorks = [];\n querySnapshot.forEach(function (doc) {\n improvementWorks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context20.abrupt(\"return\", improvementWorks);\n case 19:\n _context20.prev = 19;\n _context20.t0 = _context20[\"catch\"](0);\n console.log(\"Error retrieving improvementWorks: \", _context20.t0);\n throw _context20.t0;\n case 23:\n case \"end\":\n return _context20.stop();\n }\n }, _callee20, null, [[0, 19]]);\n }));\n}\n/**\n * Asynchronously retrieves user documents from the database based on various filter criteria.\n * It can filter by the Health Savings Account ID (hsaId), unit ID, and unique identifier (uid).\n * Additionally, it can sort the results by first name in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.hsaId] - Optional HSA ID to filter the users.\n * @param {string} [params.unitId] - Optional unit ID to filter the users.\n * @param {boolean} [params.ascendingFirstNames=false] - Optional flag to sort by first names in ascending order. Defaults to false (descending order).\n * @param {string} [params.uid] - Optional unique identifier to filter the users.\n * @returns {Promise<any[]>} A promise that resolves to an array of user objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUsers(_ref5) {\n var hsaId = _ref5.hsaId,\n unitId = _ref5.unitId,\n _ref5$ascendingFirstN = _ref5.ascendingFirstNames,\n ascendingFirstNames = _ref5$ascendingFirstN === void 0 ? false : _ref5$ascendingFirstN,\n uid = _ref5.uid;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {\n var collectionRef, constraints, q, querySnapshot, users;\n return _regeneratorRuntime().wrap(function _callee21$(_context21) {\n while (1) switch (_context21.prev = _context21.next) {\n case 0:\n _context21.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\n constraints = [];\n if (hsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hsaId));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (uid) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"uid\", \"==\", uid));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"firstName\", ascendingFirstNames ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context21.next = 10;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 10:\n querySnapshot = _context21.sent;\n users = [];\n querySnapshot.forEach(function (doc) {\n users.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context21.abrupt(\"return\", users);\n case 16:\n _context21.prev = 16;\n _context21.t0 = _context21[\"catch\"](0);\n console.log(\"Error retrieving users by department: \", _context21.t0);\n throw _context21.t0;\n case 20:\n case \"end\":\n return _context21.stop();\n }\n }, _callee21, null, [[0, 16]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of task documents from the database based on several filter and sorting criteria.\n * Filters include task ID, user ID and their responsibility status, and related improvement work ID.\n * Results can be sorted by date either in ascending or descending order.\n *\n * @param {Object} params - Parameters to filter and sort the task results.\n * @param {string} [params.taskId] - Optional task ID to filter the tasks.\n * @param {string} [params.userId] - Optional user ID to identify tasks related to a user.\n * @param {boolean} [params.isResponsibleFor] - Optional flag to filter tasks where the user is marked as responsible.\n * @param {string} [params.improvementWorkId] - Optional improvement work ID to filter tasks related to a specific improvement work.\n * @param {boolean} [params.ascendingDates=false] - Optional flag to sort tasks by date in ascending order; defaults to descending order.\n * @returns {Promise<any[]>} A promise that resolves to an array of task objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getTasks(_ref6) {\n var taskId = _ref6.taskId,\n userId = _ref6.userId,\n isResponsibleFor = _ref6.isResponsibleFor,\n improvementWorkId = _ref6.improvementWorkId,\n _ref6$ascendingDates = _ref6.ascendingDates,\n ascendingDates = _ref6$ascendingDates === void 0 ? false : _ref6$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {\n var collectionRef, constraints, q, querySnapshot, tasks;\n return _regeneratorRuntime().wrap(function _callee22$(_context22) {\n while (1) switch (_context22.prev = _context22.next) {\n case 0:\n _context22.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\n constraints = [];\n if (taskId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", taskId));\n }\n if (userId && isResponsibleFor !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"members\", \"array-contains\", {\n userHsaId: userId,\n isResponsibleFor: isResponsibleFor\n }));\n }\n if (improvementWorkId != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"startDate\", ascendingDates ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context22.next = 9;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 9:\n querySnapshot = _context22.sent;\n tasks = [];\n querySnapshot.forEach(function (doc) {\n tasks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context22.abrupt(\"return\", tasks);\n case 15:\n _context22.prev = 15;\n _context22.t0 = _context22[\"catch\"](0);\n console.log(\"Error retrieving task by department: \", _context22.t0);\n throw _context22.t0;\n case 19:\n case \"end\":\n return _context22.stop();\n }\n }, _callee22, null, [[0, 15]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of unit documents from the database based on various filter criteria.\n * Filters can be applied based on unit ID, hospital ID, and unit name.\n * Additionally, results can be sorted by unit names in ascending or descending order.\n *\n * @param {Object} params - The parameters object containing filter and sorting options.\n * @param {string} [params.unitId] - Optional unit ID to filter the units.\n * @param {string} [params.hospitalId] - Optional hospital ID to filter units within a specific hospital.\n * @param {string} [params.name] - Optional name to filter units by a specific name.\n * @param {boolean} [params.ascendingUnitNames=false] - Optional flag to sort units by name in ascending order, defaults to descending.\n * @returns {Promise<any[]>} A promise that resolves to an array of unit objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUnits(_ref7) {\n var unitId = _ref7.unitId,\n hospitalId = _ref7.hospitalId,\n name = _ref7.name,\n _ref7$ascendingUnitNa = _ref7.ascendingUnitNames,\n ascendingUnitNames = _ref7$ascendingUnitNa === void 0 ? false : _ref7$ascendingUnitNa;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {\n var collectionRef, constraints, q, querySnapshot, units;\n return _regeneratorRuntime().wrap(function _callee23$(_context23) {\n while (1) switch (_context23.prev = _context23.next) {\n case 0:\n _context23.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\n constraints = [];\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", unitId));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"hospitalId\", \"==\", hospitalId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"name\", ascendingUnitNames ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context23.next = 9;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 9:\n querySnapshot = _context23.sent;\n units = [];\n querySnapshot.forEach(function (doc) {\n units.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context23.abrupt(\"return\", units);\n case 15:\n _context23.prev = 15;\n _context23.t0 = _context23[\"catch\"](0);\n console.log(\"Error retrieving units by hospitalId: \", _context23.t0);\n throw _context23.t0;\n case 19:\n case \"end\":\n return _context23.stop();\n }\n }, _callee23, null, [[0, 15]]);\n }));\n}\n//getMembersFilteredAndSorted() -> Get all members of a project (sorted by firstName?)\n// export getters to be able to use in other files\n\n////////////////////////////////////DELETING/////////////////////////////////////////////\n// delete an instance of a type\nfunction deleteInstance(docType, docId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee24$(_context24) {\n while (1) switch (_context24.prev = _context24.next) {\n case 0:\n _context24.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context24.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(docRef);\n case 4:\n console.log(\"\".concat(docType, \" deleted successfully.\"));\n _context24.next = 11;\n break;\n case 7:\n _context24.prev = 7;\n _context24.t0 = _context24[\"catch\"](0);\n console.error(\"Error deleting \".concat(docType, \":\"), _context24.t0);\n throw _context24.t0;\n case 11:\n case \"end\":\n return _context24.stop();\n }\n }, _callee24, null, [[0, 7]]);\n }));\n}\n// delete all instances of a type\nfunction deleteAllDocumentsInCollection(collectionName) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {\n var _this = this;\n var collectionRef, snapshot, deletePromises;\n return _regeneratorRuntime().wrap(function _callee26$(_context26) {\n while (1) switch (_context26.prev = _context26.next) {\n case 0:\n _context26.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionName);\n _context26.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n snapshot = _context26.sent;\n // Delete all documents in the collection\n deletePromises = snapshot.docs.map(function (doc) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {\n return _regeneratorRuntime().wrap(function _callee25$(_context25) {\n while (1) switch (_context25.prev = _context25.next) {\n case 0:\n _context25.next = 2;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(doc.ref);\n case 2:\n case \"end\":\n return _context25.stop();\n }\n }, _callee25);\n }));\n });\n _context26.next = 8;\n return Promise.all(deletePromises);\n case 8:\n console.log(\"All documents in the \".concat(collectionName, \" collection deleted successfully.\"));\n _context26.next = 15;\n break;\n case 11:\n _context26.prev = 11;\n _context26.t0 = _context26[\"catch\"](0);\n console.error(\"Error deleting all documents in \".concat(collectionName, \":\"), _context26.t0);\n throw _context26.t0;\n case 15:\n case \"end\":\n return _context26.stop();\n }\n }, _callee26, null, [[0, 11]]);\n }));\n}\n////////////////////////////////////UPDATING/////////////////////////////////////////////\n// update a field in an instance\nfunction updateInstance(docType, docId, updates) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee27$(_context27) {\n while (1) switch (_context27.prev = _context27.next) {\n case 0:\n _context27.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context27.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(docRef, updates);\n case 4:\n console.log(\"\".concat(docType, \" updated successfully.\"));\n _context27.next = 11;\n break;\n case 7:\n _context27.prev = 7;\n _context27.t0 = _context27[\"catch\"](0);\n console.error(\"Error updating \".concat(docType, \":\"), _context27.t0);\n throw _context27.t0;\n case 11:\n case \"end\":\n return _context27.stop();\n }\n }, _callee27, null, [[0, 7]]);\n }));\n}\n// changes the ongoing status of an improvement work. if ongoing it is paused, if if paused onging.\n// user must be a manager\nfunction startOrPauseImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee28$(_context28) {\n while (1) switch (_context28.prev = _context28.next) {\n case 0:\n _context28.prev = 0;\n _context28.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context28.sent;\n _context28.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context28.sent;\n if (!(!user || !user.manager)) {\n _context28.next = 11;\n break;\n }\n throw new Error(\"User can't change improvementWork status\");\n case 11:\n if (!improvementWork) {\n _context28.next = 18;\n break;\n }\n update = {\n ongoing: !improvementWork.ongoing\n };\n _context28.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n _context28.next = 19;\n break;\n case 18:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n case 19:\n _context28.next = 25;\n break;\n case 21:\n _context28.prev = 21;\n _context28.t0 = _context28[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context28.t0);\n throw _context28.t0;\n case 25:\n case \"end\":\n return _context28.stop();\n }\n }, _callee28, null, [[0, 21]]);\n }));\n}\nfunction changePatientRiskLevel(userId, improvementWorkId, patientRiskLevel) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee29$(_context29) {\n while (1) switch (_context29.prev = _context29.next) {\n case 0:\n _context29.prev = 0;\n _context29.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context29.sent;\n _context29.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context29.sent;\n if (!(!user || !user.manager)) {\n _context29.next = 11;\n break;\n }\n throw new Error(\"User can't change patientRiskLevel in improvement work\");\n case 11:\n if (!improvementWork) {\n _context29.next = 18;\n break;\n }\n update = {\n patientRiskLevel: patientRiskLevel\n };\n _context29.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n _context29.next = 19;\n break;\n case 18:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n case 19:\n _context29.next = 25;\n break;\n case 21:\n _context29.prev = 21;\n _context29.t0 = _context29[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context29.t0);\n throw _context29.t0;\n case 25:\n case \"end\":\n return _context29.stop();\n }\n }, _callee29, null, [[0, 21]]);\n }));\n}\n// finalizes the improvement work. ongoing is set to false.\n// user must be a manager\nfunction finalizeImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {\n var user, update;\n return _regeneratorRuntime().wrap(function _callee30$(_context30) {\n while (1) switch (_context30.prev = _context30.next) {\n case 0:\n _context30.prev = 0;\n _context30.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context30.sent;\n if (!(!user || !user.manager)) {\n _context30.next = 8;\n break;\n }\n throw new Error(\"User can't finalize improvementWork status\");\n case 8:\n update = {\n completed: true,\n ongoing: false\n };\n _context30.next = 11;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 11:\n _context30.next = 16;\n break;\n case 13:\n _context30.prev = 13;\n _context30.t0 = _context30[\"catch\"](0);\n console.log(_context30.t0);\n case 16:\n case \"end\":\n return _context30.stop();\n }\n }, _callee30, null, [[0, 13]]);\n }));\n}\n\n//////////////////////////////// for later sprint\n//function add_upvotes\n//function add_notes\n//function add_intrested_users\n\n//# sourceURL=webpack://c3/./client/Database/database.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addDocumentToImprovementWork: () => (/* binding */ addDocumentToImprovementWork),\n/* harmony export */ addMemberToImprovementWork: () => (/* binding */ addMemberToImprovementWork),\n/* harmony export */ addMemberToTask: () => (/* binding */ addMemberToTask),\n/* harmony export */ addNoteToUser: () => (/* binding */ addNoteToUser),\n/* harmony export */ auth: () => (/* binding */ auth),\n/* harmony export */ changePatientRiskLevel: () => (/* binding */ changePatientRiskLevel),\n/* harmony export */ createComment: () => (/* binding */ createComment),\n/* harmony export */ createHospital: () => (/* binding */ createHospital),\n/* harmony export */ createImprovementWork: () => (/* binding */ createImprovementWork),\n/* harmony export */ createSuggestion: () => (/* binding */ createSuggestion),\n/* harmony export */ createTaskOnImprovementWork: () => (/* binding */ createTaskOnImprovementWork),\n/* harmony export */ createUnit: () => (/* binding */ createUnit),\n/* harmony export */ createUser: () => (/* binding */ createUser),\n/* harmony export */ createdDocumentInKnowledgeBank: () => (/* binding */ createdDocumentInKnowledgeBank),\n/* harmony export */ db: () => (/* binding */ db),\n/* harmony export */ deleteAllDocumentsInCollection: () => (/* binding */ deleteAllDocumentsInCollection),\n/* harmony export */ deleteInstance: () => (/* binding */ deleteInstance),\n/* harmony export */ finalizeImprovementWork: () => (/* binding */ finalizeImprovementWork),\n/* harmony export */ getComments: () => (/* binding */ getComments),\n/* harmony export */ getHospitals: () => (/* binding */ getHospitals),\n/* harmony export */ getImprovementWorkOwner: () => (/* binding */ getImprovementWorkOwner),\n/* harmony export */ getImprovementWorkResponsible: () => (/* binding */ getImprovementWorkResponsible),\n/* harmony export */ getImprovementWorks: () => (/* binding */ getImprovementWorks),\n/* harmony export */ getImprovementWorksForUser: () => (/* binding */ getImprovementWorksForUser),\n/* harmony export */ getObject: () => (/* binding */ getObject),\n/* harmony export */ getObjectById: () => (/* binding */ getObjectById),\n/* harmony export */ getSuggestions: () => (/* binding */ getSuggestions),\n/* harmony export */ getTasks: () => (/* binding */ getTasks),\n/* harmony export */ getUnits: () => (/* binding */ getUnits),\n/* harmony export */ getUsers: () => (/* binding */ getUsers),\n/* harmony export */ getUsersForImprovementWork: () => (/* binding */ getUsersForImprovementWork),\n/* harmony export */ startOrPauseImprovementWork: () => (/* binding */ startOrPauseImprovementWork),\n/* harmony export */ updateInstance: () => (/* binding */ updateInstance),\n/* harmony export */ upvoteComment: () => (/* binding */ upvoteComment),\n/* harmony export */ upvoteSuggestion: () => (/* binding */ upvoteSuggestion)\n/* harmony export */ });\n/* harmony import */ var firebase_app__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! firebase/app */ \"./node_modules/firebase/app/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_firestore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! firebase/firestore */ \"./node_modules/firebase/firestore/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_auth__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! firebase/auth */ \"./node_modules/firebase/auth/dist/esm/index.esm.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nvar firebaseConfig = {\n apiKey: \"AIzaSyDqkaVZMr11J4mfnR0auqoQilZyPfyD-x4\",\n authDomain: \"c3solutions-dc109.firebaseapp.com\",\n projectId: \"c3solutions-dc109\",\n storageBucket: \"c3solutions-dc109.appspot.com\",\n messagingSenderId: \"902143402555\",\n appId: \"1:902143402555:web:29213e81de0a0cba38b21e\"\n};\n/*const firebaseConfig = {\n apiKey: \"AIzaSyBIsZq_yOsJljp1woIxndJO1GkW6soh-g4\",\n authDomain: \"company3-456bb.firebaseapp.com\",\n projectId: \"company3-456bb\",\n storageBucket: \"company3-456bb.appspot.com\",\n messagingSenderId: \"310033686522\",\n appId: \"1:310033686522:web:63198bb0db679c98ee4e43\",\n measurementId: \"G-PFLDQY00DB\"\n};*/\n// const firebaseConfig = {\n// apiKey: \"AIzaSyBIsZq_yOsJljp1woIxndJO1GkW6soh-g4\",\n// authDomain: \"company3-456bb.firebaseapp.com\",\n// projectId: \"company3-456bb\",\n// storageBucket: \"company3-456bb.appspot.com\",\n// messagingSenderId: \"310033686522\",\n// appId: \"1:310033686522:web:63198bb0db679c98ee4e43\",\n// measurementId: \"G-PFLDQY00DB\"\n// };\nvar app = (0,firebase_app__WEBPACK_IMPORTED_MODULE_0__.initializeApp)(firebaseConfig);\nvar auth = (0,firebase_auth__WEBPACK_IMPORTED_MODULE_2__.getAuth)();\nvar db = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getFirestore)(app);\nvar userCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\nvar unitCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\nvar improvementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\nvar taskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\nvar hospitalCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\nvar suggestionCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\nvar knowledgeDocumentCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"knowledgeDocument\");\nvar userImprovementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"userImprovementWork\");\nvar userTaskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"userTask\");\n////////////////////////////////////////Setters///////////////////////////////////////////////////////////////////\n// Function to create user a new user in database\n// takes in userId, unitId, firstname, lastname, email and password as string\n// throws error if transaction failed\nfunction createUser(hsaId, unitId, firstName, lastName, email, manager, uid) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var userRef, unitRef;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, hsaId);\n _context.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(userRef, {\n id: userRef.id,\n uid: uid,\n unitId: unitId,\n firstName: firstName,\n lastName: lastName,\n email: email,\n // TODO Replace with userImprovementWork collection\n improvementWorks: [],\n tasks: [],\n manager: manager\n });\n case 4:\n // Atomically add user to unit.\n unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection, unitId);\n _context.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(unitRef, {\n members: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userRef.id)\n });\n case 7:\n _context.next = 12;\n break;\n case 9:\n _context.prev = 9;\n _context.t0 = _context[\"catch\"](0);\n console.log(_context.t0);\n case 12:\n case \"end\":\n return _context.stop();\n }\n }, _callee, null, [[0, 9]]);\n }));\n}\nfunction createImprovementWork(id, name, currentStage, content,\n// Är detta description bör detta förtydligas. \nunitId, purpose,\n//Bör tas bort motsvaras av p2- mål med projektet\npatientRiskLevel, area,\n//Questions in planning stage\np1, p2, p3, p4, p5, p6, p7,\n//Questions in Doing (G) stage\ng1, g2, g3, g4, g5,\n//Questions in stydy stage\ns1, s2, s3,\n//Questions in acting stage\na1, a2, a3, a4) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var improvementWorkData, improvementWorkRef, _improvementWorkRef;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.prev = 0;\n improvementWorkData = {\n name: name,\n currentStage: currentStage,\n content: content,\n purpose: purpose,\n dateStarted: new Date(),\n unitId: unitId,\n completed: false,\n ongoing: false,\n tasks: [],\n // TODO Remove members array\n members: [],\n patientRiskLevel: patientRiskLevel,\n area: area,\n p1: p1,\n p2: p2,\n p3: p3,\n p4: p4,\n p5: p5,\n p6: p6,\n p7: p7,\n g1: g1,\n g2: g2,\n g3: g3,\n g4: g4,\n g5: g5,\n s1: s1,\n s2: s2,\n s3: s3,\n a1: a1,\n a2: a2,\n a3: a3,\n a4: a4\n };\n if (!id) {\n _context2.next = 8;\n break;\n }\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, id);\n _context2.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(improvementWorkRef, Object.assign({\n id: improvementWorkRef.id\n }, improvementWorkData));\n case 6:\n _context2.next = 11;\n break;\n case 8:\n _improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection);\n _context2.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_improvementWorkRef, improvementWorkData);\n case 11:\n _context2.next = 17;\n break;\n case 13:\n _context2.prev = 13;\n _context2.t0 = _context2[\"catch\"](0);\n console.log(\"Error creating improvementWork: \", _context2.t0);\n throw _context2.t0;\n case 17:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, null, [[0, 13]]);\n }));\n}\nfunction addMemberToTask(userHsaId, taskId, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var relationRef;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.prev = 0;\n relationRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userTaskCollection);\n _context3.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(relationRef, {\n id: relationRef.id,\n userHsaId: userHsaId,\n taskId: taskId,\n isResponsibleFor: isResponsibleFor\n });\n case 4:\n _context3.next = 10;\n break;\n case 6:\n _context3.prev = 6;\n _context3.t0 = _context3[\"catch\"](0);\n console.log(\"Error adding member to task: \", _context3.t0);\n throw _context3.t0;\n case 10:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, null, [[0, 6]]);\n }));\n}\nfunction addMemberToImprovementWork(userHsaId, improvementWorkId, isOwner, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var relationRef;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n _context4.prev = 0;\n relationRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userImprovementWorkCollection);\n _context4.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(relationRef, {\n id: relationRef.id,\n userHsaId: userHsaId,\n improvementWorkId: improvementWorkId,\n isOwner: isOwner,\n isResponsibleFor: isResponsibleFor\n });\n case 4:\n _context4.next = 10;\n break;\n case 6:\n _context4.prev = 6;\n _context4.t0 = _context4[\"catch\"](0);\n console.log(\"Error adding member to improvementWork: \", _context4.t0);\n throw _context4.t0;\n case 10:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4, null, [[0, 6]]);\n }));\n}\nfunction createTaskOnImprovementWork(taskId, improvementWorkId, name, deadlineDate, startDate, stage, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var taskData, taskRef, _taskRef;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n _context5.prev = 0;\n taskData = {\n improvementWorkId: improvementWorkId,\n name: name,\n deadlineDate: deadlineDate,\n startDate: startDate,\n stage: stage,\n content: content,\n members: [] // Initialize with an empty array\n };\n if (!taskId) {\n _context5.next = 8;\n break;\n }\n taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection, taskId);\n _context5.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(taskRef, Object.assign({\n id: taskRef.id\n }, taskData));\n case 6:\n _context5.next = 11;\n break;\n case 8:\n _taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection);\n _context5.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_taskRef, taskData);\n case 11:\n _context5.next = 17;\n break;\n case 13:\n _context5.prev = 13;\n _context5.t0 = _context5[\"catch\"](0);\n console.log(\"Error creating task: \", _context5.t0);\n throw _context5.t0;\n case 17:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5, null, [[0, 13]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction createdDocumentInKnowledgeBank(documentUrl, name) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n _context6.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(knowledgeDocumentCollection);\n _context6.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n name: name\n });\n case 4:\n _context6.next = 10;\n break;\n case 6:\n _context6.prev = 6;\n _context6.t0 = _context6[\"catch\"](0);\n console.log(\"Error adding document: \", _context6.t0);\n throw _context6.t0;\n case 10:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6, null, [[0, 6]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction addDocumentToImprovementWork(documentUrl, name, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var improvementWorkRef, docRef;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.prev = 0;\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, improvementWorkId);\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkRef, \"documents\");\n _context7.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n timestamp: new Date(),\n name: name\n });\n case 5:\n _context7.next = 11;\n break;\n case 7:\n _context7.prev = 7;\n _context7.t0 = _context7[\"catch\"](0);\n console.log(\"Error adding document: \", _context7.t0);\n throw _context7.t0;\n case 11:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7, null, [[0, 7]]);\n }));\n}\nfunction createHospital(hospitalId,\n// should be auto?\nname) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var hospitalData, hospitalRef, _hospitalRef;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n _context8.prev = 0;\n hospitalData = {\n name: name,\n units: []\n };\n if (!hospitalId) {\n _context8.next = 8;\n break;\n }\n hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection, hospitalId);\n _context8.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(hospitalRef, Object.assign({\n id: hospitalRef.id\n }, hospitalData));\n case 6:\n _context8.next = 11;\n break;\n case 8:\n _hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection);\n _context8.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_hospitalRef, hospitalData);\n case 11:\n _context8.next = 17;\n break;\n case 13:\n _context8.prev = 13;\n _context8.t0 = _context8[\"catch\"](0);\n console.log(\"Error creating hospital: \", _context8.t0);\n throw _context8.t0;\n case 17:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8, null, [[0, 13]]);\n }));\n}\nfunction createUnit(unitId,\n//should be auto?\nhospitalId, name) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var unitData, unitRef, _unitRef;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n _context9.prev = 0;\n unitData = {\n hospitalId: hospitalId,\n name: name,\n members: []\n };\n if (!unitId) {\n _context9.next = 8;\n break;\n }\n unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection, unitId);\n _context9.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(unitRef, Object.assign({\n id: unitRef.id\n }, unitData));\n case 6:\n _context9.next = 11;\n break;\n case 8:\n _unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection);\n _context9.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_unitRef, unitData);\n case 11:\n _context9.next = 17;\n break;\n case 13:\n _context9.prev = 13;\n _context9.t0 = _context9[\"catch\"](0);\n console.log(\"Error creating unit: \", _context9.t0);\n throw _context9.t0;\n case 17:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9, null, [[0, 13]]);\n }));\n}\nfunction createSuggestion(id, creatorHsaId, name, area, content, purpose, measure, ideas,\n//need: boolean,\nunitId, departmentId, isPublic) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var suggestionData, suggestionRef, _suggestionRef;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n _context10.prev = 0;\n suggestionData = {\n creatorHsaId: creatorHsaId,\n name: name,\n area: area,\n content: content,\n purpose: purpose,\n measure: measure,\n ideas: ideas,\n //need,\n unitId: unitId,\n departmentId: departmentId,\n \"public\": isPublic,\n upvotes: [],\n comments: [],\n dateCreated: new Date()\n };\n if (!id) {\n _context10.next = 8;\n break;\n }\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, id);\n _context10.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(suggestionRef, Object.assign({\n id: suggestionRef.id\n }, suggestionData));\n case 6:\n _context10.next = 11;\n break;\n case 8:\n _suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection);\n _context10.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_suggestionRef, suggestionData);\n case 11:\n _context10.next = 17;\n break;\n case 13:\n _context10.prev = 13;\n _context10.t0 = _context10[\"catch\"](0);\n console.log(\"Error creating suggestion: \", _context10.t0);\n throw _context10.t0;\n case 17:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10, null, [[0, 13]]);\n }));\n}\n// Upvote a suggestion for a user\n// takes in suggestion id, user HSAid\n// returns error if transaction failed\nfunction upvoteSuggestion(suggestionId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var suggestionRef;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n _context11.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId); // Atomically add a update to the upvote array field.\n _context11.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(suggestionRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 4:\n _context11.next = 10;\n break;\n case 6:\n _context11.prev = 6;\n _context11.t0 = _context11[\"catch\"](0);\n console.log(\"Error upvoting suggestion: \", _context11.t0);\n throw _context11.t0;\n case 10:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11, null, [[0, 6]]);\n }));\n}\n//creates a comment\n// takes in commenters id, suggestion id and content as string\n// throws error if transaction failed\nfunction createComment(\n// change to subcollection\ncommenterHsaId, suggestionId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var suggestionRef, commentCollection, commentRef;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n _context12.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context12.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\");\n case 4:\n commentCollection = _context12.sent;\n _context12.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(commentCollection);\n case 7:\n commentRef = _context12.sent;\n _context12.next = 10;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(commentRef, {\n id: commentRef.id,\n commenterHsaId: commenterHsaId,\n content: content,\n dateCreated: new Date(),\n upvotes: []\n });\n case 10:\n _context12.next = 16;\n break;\n case 12:\n _context12.prev = 12;\n _context12.t0 = _context12[\"catch\"](0);\n console.log(\"Error creating comment: \", _context12.t0);\n throw _context12.t0;\n case 16:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12, null, [[0, 12]]);\n }));\n}\n// Upvote a comment for a user\n// takes in suggestionId, commentId and userId as strings\n// return error if transaction failed\nfunction upvoteComment(suggestionId, commentId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var suggestionRef, commentRef;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n _context13.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n commentRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionRef, \"comment\", commentId); // Atomically add a update to the upvote array field.\n _context13.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(commentRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 5:\n _context13.next = 11;\n break;\n case 7:\n _context13.prev = 7;\n _context13.t0 = _context13[\"catch\"](0);\n console.log(\"Error upvoting comment: \", _context13.t0);\n throw _context13.t0;\n case 11:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13, null, [[0, 7]]);\n }));\n}\n//add a note to a user\n// takes in userHsaId and content as string\n// throws error if transaction failed\nfunction addNoteToUser(userHsaId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var userRef, docRef;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n _context14.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, userHsaId);\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userRef, \"notes\");\n _context14.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n content: content,\n dateCreated: new Date()\n });\n case 5:\n _context14.next = 11;\n break;\n case 7:\n _context14.prev = 7;\n _context14.t0 = _context14[\"catch\"](0);\n console.log(\"Error adding document: \", _context14.t0);\n throw _context14.t0;\n case 11:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14, null, [[0, 7]]);\n }));\n}\n// export to setters to be able to use in other files\n\n//////////////////////////////////////////////GETTERS/////////////////////////////////////////////////////////////////////\n// Get any object\n// input is the database type as a string.\n// output is the whole collection of that type.\nfunction getObject(collectionPath) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n var collectionRef, querySnapshot, result;\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n _context15.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionPath);\n _context15.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n querySnapshot = _context15.sent;\n result = [];\n querySnapshot.forEach(function (doc) {\n result.push(doc.data());\n });\n return _context15.abrupt(\"return\", result);\n case 10:\n _context15.prev = 10;\n _context15.t0 = _context15[\"catch\"](0);\n console.error(\"Error getting collection data\", _context15.t0);\n throw _context15.t0;\n case 14:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15, null, [[0, 10]]);\n }));\n}\n/**\n * Asynchronously retrieves a single document object from the specified collection path and document ID.\n * If the document does not exist, logs a warning and returns null.\n *\n * @param {string} collectionPath - The path to the collection in the database (\"improvementWork\", \"hospital\", \"suggestion\", \"task\", \"unit\", \"users\")\n * @param {string} documentId - The ID of the document to retrieve.\n * @returns {Promise<any|null>} A promise that resolves to the document object if found, or null if not.\n *\n * @throws Will throw an error if there is an issue during retrieval from the database.\n */\nfunction getObjectById(collectionPath, documentId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {\n var docRef, docSnapshot;\n return _regeneratorRuntime().wrap(function _callee16$(_context16) {\n while (1) switch (_context16.prev = _context16.next) {\n case 0:\n _context16.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, collectionPath, documentId);\n _context16.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDoc)(docRef);\n case 4:\n docSnapshot = _context16.sent;\n if (!docSnapshot.exists()) {\n _context16.next = 9;\n break;\n }\n return _context16.abrupt(\"return\", Object.assign({\n id: docSnapshot.id\n }, docSnapshot.data()));\n case 9:\n console.warn(\"No such document! \".concat(collectionPath, \"/\").concat(documentId));\n return _context16.abrupt(\"return\", null);\n case 11:\n _context16.next = 17;\n break;\n case 13:\n _context16.prev = 13;\n _context16.t0 = _context16[\"catch\"](0);\n console.error(\"Error getting object\", _context16.t0);\n throw _context16.t0;\n case 17:\n case \"end\":\n return _context16.stop();\n }\n }, _callee16, null, [[0, 13]]);\n }));\n}\n/**\n * Asynchronously retrieves comments for a given suggestion.\n *\n * @param {Object} params - The parameters for fetching comments.\n * @param {string} params.suggestionId - The ID of the suggestion to fetch comments for.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - The criterion to sort the comments by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Determines if the sorting should be in ascending order. Defaults to false (descending).\n * @returns {Promise<any[]>} A promise that resolves to an array of comment objects.\n *\n * @throws Will throw an error if the comments cannot be retrieved.\n */\nfunction getComments(_ref) {\n var suggestionId = _ref.suggestionId,\n _ref$sortBy = _ref.sortBy,\n sortBy = _ref$sortBy === void 0 ? \"dateCreated\" : _ref$sortBy,\n _ref$ascending = _ref.ascending,\n ascending = _ref$ascending === void 0 ? false : _ref$ascending;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {\n var suggestionRef, commentsQuery, commentsSnapshot, comments;\n return _regeneratorRuntime().wrap(function _callee17$(_context17) {\n while (1) switch (_context17.prev = _context17.next) {\n case 0:\n _context17.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, \"suggestionCollection\", suggestionId);\n commentsQuery = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\"), (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n _context17.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(commentsQuery);\n case 5:\n commentsSnapshot = _context17.sent;\n comments = [];\n commentsSnapshot.forEach(function (doc) {\n comments.push(doc.data());\n });\n return _context17.abrupt(\"return\", comments);\n case 11:\n _context17.prev = 11;\n _context17.t0 = _context17[\"catch\"](0);\n console.error(\"Error getting comments for suggestion: \", _context17.t0);\n throw _context17.t0;\n case 15:\n case \"end\":\n return _context17.stop();\n }\n }, _callee17, null, [[0, 11]]);\n }));\n}\n//Filtering suggestions on unitId AND creatorHsaId\n//Sort suggestions on dateCreated OR upvotes\n/**\n * Asynchronously retrieves an array of suggestions from the database, with various filters and sorting options.\n *\n * @param {Object} params - The parameters for filtering and sorting suggestions.\n * @param {string} [params.id] - Optional ID to filter suggestions by a specific identifier.\n * @param {string} [params.creatorHsaId] - Optional HSA ID to filter suggestions by the creator's HSA ID.\n * @param {string} [params.unitId] - Optional unit ID to filter suggestions by a specific unit.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - Criterion to sort the suggestions by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Flag indicating if sorting should be ascending. Defaults to false (descending order).\n * @param {boolean} [params.isPublic=true] - Flag indicating whether to filter for public suggestions. Defaults to true.\n * @returns {Promise<any[]>} A promise that resolves to an array of suggestion objects.\n *\n * @throws Will throw an error if there is an issue retrieving suggestions.\n */\nfunction getSuggestions(_ref2) {\n var id = _ref2.id,\n creatorHsaId = _ref2.creatorHsaId,\n unitId = _ref2.unitId,\n _ref2$sortBy = _ref2.sortBy,\n sortBy = _ref2$sortBy === void 0 ? \"dateCreated\" : _ref2$sortBy,\n _ref2$ascending = _ref2.ascending,\n ascending = _ref2$ascending === void 0 ? false : _ref2$ascending,\n _ref2$isPublic = _ref2.isPublic,\n isPublic = _ref2$isPublic === void 0 ? true : _ref2$isPublic;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {\n var collectionRef, constraints, q, querySnapshot, suggestions;\n return _regeneratorRuntime().wrap(function _callee18$(_context18) {\n while (1) switch (_context18.prev = _context18.next) {\n case 0:\n _context18.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (creatorHsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"creatorHsaId\", \"==\", creatorHsaId));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"public\", \"==\", isPublic));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context18.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 11:\n querySnapshot = _context18.sent;\n suggestions = [];\n querySnapshot.forEach(function (doc) {\n suggestions.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context18.abrupt(\"return\", suggestions);\n case 17:\n _context18.prev = 17;\n _context18.t0 = _context18[\"catch\"](0);\n console.log(\"Error retrieving suggestions by department: \", _context18.t0);\n throw _context18.t0;\n case 21:\n case \"end\":\n return _context18.stop();\n }\n }, _callee18, null, [[0, 17]]);\n }));\n}\n/**\n * Asynchronously searches for hospital documents in the database.\n * It can filter the results by the hospital's name, ID, or both.\n * If no parameters are provided, it retrieves all hospitals.\n *\n * @param {Object} params - An object containing the search parameters.\n * @param {string} [params.hospitalName] - Optional name of the hospital to filter the search.\n * @param {string} [params.hospitalId] - Optional unique identifier of the hospital to filter the search.\n * @returns {Promise<any[]>} A promise that resolves to an array of hospital objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getHospitals(_ref3) {\n var hospitalName = _ref3.hospitalName,\n hospitalId = _ref3.hospitalId;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {\n var collectionRef, constraints, q, querySnapshot, hospitals;\n return _regeneratorRuntime().wrap(function _callee19$(_context19) {\n while (1) switch (_context19.prev = _context19.next) {\n case 0:\n _context19.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\n constraints = [];\n if (hospitalName) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", hospitalName));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hospitalId));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context19.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context19.sent;\n hospitals = [];\n querySnapshot.forEach(function (doc) {\n hospitals.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context19.abrupt(\"return\", hospitals);\n case 14:\n _context19.prev = 14;\n _context19.t0 = _context19[\"catch\"](0);\n console.log(\"Error retrieving Hospitals\", _context19.t0);\n throw _context19.t0;\n case 18:\n case \"end\":\n return _context19.stop();\n }\n }, _callee19, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of improvement work documents based on various filter criteria.\n * It supports filtering by ID, Nolan stage, unit ID, completion status, ongoing status, and patient risk level.\n * It also supports sorting by the start date of the improvement work in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.id] - Optional identifier to filter the improvement works.\n * @param {string} [params.nolanStage] - Optional Nolan stage to filter the improvement works.\n * @param {string} [params.unitId] - Optional unit ID to filter the improvement works.\n * @param {boolean} [params.completed] - Optional flag to filter the improvement works by their completion status.\n * @param {boolean} [params.ongoing] - Optional flag to filter the improvement works by their ongoing status.\n * @param {string} [params.patientRiskLevel] - Optional patient risk level to filter the improvement works.\n * @param {boolean} [params.ascendingDates=false] - Optional flag for sorting by date in ascending order. Defaults to false.\n * @returns {Promise<any[]>} A promise that resolves to an array of improvement work objects that match the criteria.\n *\n * @throws Will throw an error if there is a problem retrieving the improvement works.\n */\nfunction getImprovementWorks(_ref4) {\n var id = _ref4.id,\n nolanStage = _ref4.nolanStage,\n unitId = _ref4.unitId,\n completed = _ref4.completed,\n ongoing = _ref4.ongoing,\n patientRiskLevel = _ref4.patientRiskLevel,\n _ref4$ascendingDates = _ref4.ascendingDates,\n ascendingDates = _ref4$ascendingDates === void 0 ? false : _ref4$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {\n var collectionRef, constraints, q, querySnapshot, improvementWorks;\n return _regeneratorRuntime().wrap(function _callee20$(_context20) {\n while (1) switch (_context20.prev = _context20.next) {\n case 0:\n _context20.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (nolanStage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"currentStage\", \"==\", nolanStage));\n }\n if (completed != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"completed\", \"==\", completed));\n }\n if (ongoing !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"ongoing\", \"==\", ongoing));\n }\n if (patientRiskLevel) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"patientRiskLevel\", \"==\", patientRiskLevel));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"dateStarted\", ascendingDates ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context20.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 13:\n querySnapshot = _context20.sent;\n improvementWorks = [];\n querySnapshot.forEach(function (doc) {\n improvementWorks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context20.abrupt(\"return\", improvementWorks);\n case 19:\n _context20.prev = 19;\n _context20.t0 = _context20[\"catch\"](0);\n console.log(\"Error retrieving improvementWorks: \", _context20.t0);\n throw _context20.t0;\n case 23:\n case \"end\":\n return _context20.stop();\n }\n }, _callee20, null, [[0, 19]]);\n }));\n}\nfunction getImprovementWorkOwner(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {\n var constraints, q, querySnapshot, owner;\n return _regeneratorRuntime().wrap(function _callee21$(_context21) {\n while (1) switch (_context21.prev = _context21.next) {\n case 0:\n _context21.prev = 0;\n constraints = [];\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"isOwner\", \"==\", true));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context21.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 7:\n querySnapshot = _context21.sent;\n if (!querySnapshot.empty) {\n _context21.next = 13;\n break;\n }\n console.log(\"Improvement work \", improvementWorkId, \" has no owner\");\n return _context21.abrupt(\"return\", null);\n case 13:\n owner = querySnapshot.docs[0].data().userHsaId;\n return _context21.abrupt(\"return\", owner);\n case 15:\n _context21.next = 20;\n break;\n case 17:\n _context21.prev = 17;\n _context21.t0 = _context21[\"catch\"](0);\n console.log(_context21.t0);\n case 20:\n case \"end\":\n return _context21.stop();\n }\n }, _callee21, null, [[0, 17]]);\n }));\n}\nfunction getImprovementWorkResponsible(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {\n var constraints, q, querySnapshot, responsible;\n return _regeneratorRuntime().wrap(function _callee22$(_context22) {\n while (1) switch (_context22.prev = _context22.next) {\n case 0:\n _context22.prev = 0;\n constraints = [];\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"isResponsibleFor\", \"==\", true));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context22.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 7:\n querySnapshot = _context22.sent;\n if (!querySnapshot.empty) {\n _context22.next = 13;\n break;\n }\n console.log(\"Improvement work \", improvementWorkId, \" has no responsible\");\n return _context22.abrupt(\"return\", null);\n case 13:\n responsible = querySnapshot.docs[0].data().userHsaId;\n return _context22.abrupt(\"return\", responsible);\n case 15:\n _context22.next = 20;\n break;\n case 17:\n _context22.prev = 17;\n _context22.t0 = _context22[\"catch\"](0);\n console.log(_context22.t0);\n case 20:\n case \"end\":\n return _context22.stop();\n }\n }, _callee22, null, [[0, 17]]);\n }));\n}\n// TODO getUsersForTask!\n/**\n * Asynchronously retrieves user documents from the database based on various filter criteria.\n * It can filter by the Health Savings Account ID (hsaId), unit ID, and unique identifier (uid).\n * Additionally, it can sort the results by first name in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.hsaId] - Optional HSA ID to filter the users.\n * @param {string} [params.unitId] - Optional unit ID to filter the users.\n * @param {boolean} [params.ascendingFirstNames=false] - Optional flag to sort by first names in ascending order. Defaults to false (descending order).\n * @param {string} [params.uid] - Optional unique identifier to filter the users.\n * @returns {Promise<any[]>} A promise that resolves to an array of user objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUsers(_ref5) {\n var hsaId = _ref5.hsaId,\n unitId = _ref5.unitId,\n _ref5$ascendingFirstN = _ref5.ascendingFirstNames,\n ascendingFirstNames = _ref5$ascendingFirstN === void 0 ? false : _ref5$ascendingFirstN,\n uid = _ref5.uid;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {\n var collectionRef, constraints, q, querySnapshot, users;\n return _regeneratorRuntime().wrap(function _callee23$(_context23) {\n while (1) switch (_context23.prev = _context23.next) {\n case 0:\n _context23.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\n constraints = [];\n if (hsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hsaId));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (uid) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"uid\", \"==\", uid));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"firstName\", ascendingFirstNames ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context23.next = 10;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 10:\n querySnapshot = _context23.sent;\n users = [];\n querySnapshot.forEach(function (doc) {\n users.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context23.abrupt(\"return\", users);\n case 16:\n _context23.prev = 16;\n _context23.t0 = _context23[\"catch\"](0);\n console.log(\"Error retrieving users by department: \", _context23.t0);\n throw _context23.t0;\n case 20:\n case \"end\":\n return _context23.stop();\n }\n }, _callee23, null, [[0, 16]]);\n }));\n}\n// TODO getTasksForUser!\n/**\n * Asynchronously retrieves an array of task documents from the database based on several filter and sorting criteria.\n * Filters include task ID, user ID and their responsibility status, and related improvement work ID.\n * Results can be sorted by date either in ascending or descending order.\n *\n * @param {Object} params - Parameters to filter and sort the task results.\n * @param {string} [params.taskId] - Optional task ID to filter the tasks.\n * @param {string} [params.userId] - Optional user ID to identify tasks related to a user.\n * @param {boolean} [params.isResponsibleFor] - Optional flag to filter tasks where the user is marked as responsible.\n * @param {string} [params.improvementWorkId] - Optional improvement work ID to filter tasks related to a specific improvement work.\n * @param {boolean} [params.ascendingDates=false] - Optional flag to sort tasks by date in ascending order; defaults to descending order.\n * @returns {Promise<any[]>} A promise that resolves to an array of task objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getTasks(_ref6) {\n var improvementWorkId = _ref6.improvementWorkId,\n stage = _ref6.stage,\n _ref6$ascendingDates = _ref6.ascendingDates,\n ascendingDates = _ref6$ascendingDates === void 0 ? false : _ref6$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {\n var collectionRef, constraints, q, querySnapshot, tasks;\n return _regeneratorRuntime().wrap(function _callee24$(_context24) {\n while (1) switch (_context24.prev = _context24.next) {\n case 0:\n _context24.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\n constraints = []; // FUTURE FEATURE: Filter on userHsaId AND improvementWork\n // if (userHsaId && isResponsibleFor !== undefined) {\n // constraints.push(\n // where(\"members\", \"array-contains\", {\n // userHsaId: userHsaId,\n // isResponsibleFor: isResponsibleFor,\n // })\n // );\n // }\n if (stage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"stage\", \"==\", stage));\n }\n if (improvementWorkId != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"startDate\", ascendingDates ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context24.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context24.sent;\n tasks = [];\n querySnapshot.forEach(function (doc) {\n tasks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context24.abrupt(\"return\", tasks);\n case 14:\n _context24.prev = 14;\n _context24.t0 = _context24[\"catch\"](0);\n console.log(\"Error retrieving task by department: \", _context24.t0);\n throw _context24.t0;\n case 18:\n case \"end\":\n return _context24.stop();\n }\n }, _callee24, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of unit documents from the database based on various filter criteria.\n * Filters can be applied based on unit ID, hospital ID, and unit name.\n * Additionally, results can be sorted by unit names in ascending or descending order.\n *\n * @param {Object} params - The parameters object containing filter and sorting options.\n * @param {string} [params.unitId] - Optional unit ID to filter the units.\n * @param {string} [params.hospitalId] - Optional hospital ID to filter units within a specific hospital.\n * @param {string} [params.name] - Optional name to filter units by a specific name.\n * @param {boolean} [params.ascendingUnitNames=false] - Optional flag to sort units by name in ascending order, defaults to descending.\n * @returns {Promise<any[]>} A promise that resolves to an array of unit objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUnits(_ref7) {\n var unitId = _ref7.unitId,\n hospitalId = _ref7.hospitalId,\n name = _ref7.name,\n _ref7$ascendingUnitNa = _ref7.ascendingUnitNames,\n ascendingUnitNames = _ref7$ascendingUnitNa === void 0 ? false : _ref7$ascendingUnitNa;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {\n var collectionRef, constraints, q, querySnapshot, units;\n return _regeneratorRuntime().wrap(function _callee25$(_context25) {\n while (1) switch (_context25.prev = _context25.next) {\n case 0:\n _context25.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\n constraints = [];\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", unitId));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"hospitalId\", \"==\", hospitalId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"name\", ascendingUnitNames ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context25.next = 9;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 9:\n querySnapshot = _context25.sent;\n units = [];\n querySnapshot.forEach(function (doc) {\n units.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context25.abrupt(\"return\", units);\n case 15:\n _context25.prev = 15;\n _context25.t0 = _context25[\"catch\"](0);\n console.log(\"Error retrieving units by hospitalId: \", _context25.t0);\n throw _context25.t0;\n case 19:\n case \"end\":\n return _context25.stop();\n }\n }, _callee25, null, [[0, 15]]);\n }));\n}\nfunction getImprovementWorksForUser(userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {\n var q, querySnapshot, improvementWorks, _iterator, _step, _doc, improvementWorkId, improvementWorkDoc;\n return _regeneratorRuntime().wrap(function _callee26$(_context26) {\n while (1) switch (_context26.prev = _context26.next) {\n case 0:\n _context26.prev = 0;\n console.log(\"Getting improvementworks for user: \", userHsaId);\n // Query the userImprovementWork collection for relations involving this user\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(userImprovementWorkCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)('userHsaId', '==', userHsaId));\n _context26.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 5:\n querySnapshot = _context26.sent;\n // Fetch each related improvementWork document\n improvementWorks = [];\n _iterator = _createForOfIteratorHelper(querySnapshot.docs);\n _context26.prev = 8;\n _iterator.s();\n case 10:\n if ((_step = _iterator.n()).done) {\n _context26.next = 19;\n break;\n }\n _doc = _step.value;\n improvementWorkId = _doc.data().improvementWorkId;\n _context26.next = 15;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 15:\n improvementWorkDoc = _context26.sent;\n improvementWorks.push(improvementWorkDoc);\n case 17:\n _context26.next = 10;\n break;\n case 19:\n _context26.next = 24;\n break;\n case 21:\n _context26.prev = 21;\n _context26.t0 = _context26[\"catch\"](8);\n _iterator.e(_context26.t0);\n case 24:\n _context26.prev = 24;\n _iterator.f();\n return _context26.finish(24);\n case 27:\n return _context26.abrupt(\"return\", improvementWorks);\n case 30:\n _context26.prev = 30;\n _context26.t1 = _context26[\"catch\"](0);\n console.error(\"Error getting improvement works for user: \", _context26.t1);\n throw _context26.t1;\n case 34:\n case \"end\":\n return _context26.stop();\n }\n }, _callee26, null, [[0, 30], [8, 21, 24, 27]]);\n }));\n}\nfunction getUsersForImprovementWork(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {\n var q, querySnapshot, users, _iterator2, _step2, _doc2, userHsaId, userDoc;\n return _regeneratorRuntime().wrap(function _callee27$(_context27) {\n while (1) switch (_context27.prev = _context27.next) {\n case 0:\n _context27.prev = 0;\n console.log(\"Getting users for improvementwork: \", improvementWorkId);\n // Query the userImprovementWork collection for relations involving this improvementWork\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(userImprovementWorkCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)('improvementWorkId', '==', improvementWorkId));\n _context27.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 5:\n querySnapshot = _context27.sent;\n // Fetch each related user document\n users = [];\n _iterator2 = _createForOfIteratorHelper(querySnapshot.docs);\n _context27.prev = 8;\n _iterator2.s();\n case 10:\n if ((_step2 = _iterator2.n()).done) {\n _context27.next = 19;\n break;\n }\n _doc2 = _step2.value;\n userHsaId = _doc2.data().userHsaId;\n _context27.next = 15;\n return getObjectById(\"users\", userHsaId);\n case 15:\n userDoc = _context27.sent;\n users.push(userDoc);\n case 17:\n _context27.next = 10;\n break;\n case 19:\n _context27.next = 24;\n break;\n case 21:\n _context27.prev = 21;\n _context27.t0 = _context27[\"catch\"](8);\n _iterator2.e(_context27.t0);\n case 24:\n _context27.prev = 24;\n _iterator2.f();\n return _context27.finish(24);\n case 27:\n return _context27.abrupt(\"return\", users);\n case 30:\n _context27.prev = 30;\n _context27.t1 = _context27[\"catch\"](0);\n console.error(\"Error getting users for improvementWork: \", _context27.t1);\n throw _context27.t1;\n case 34:\n case \"end\":\n return _context27.stop();\n }\n }, _callee27, null, [[0, 30], [8, 21, 24, 27]]);\n }));\n}\n// export getters to be able to use in other files\n\n////////////////////////////////////DELETING/////////////////////////////////////////////\n// delete an instance of a type\nfunction deleteInstance(docType, docId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee28$(_context28) {\n while (1) switch (_context28.prev = _context28.next) {\n case 0:\n _context28.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context28.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(docRef);\n case 4:\n console.log(\"\".concat(docType, \" deleted successfully.\"));\n _context28.next = 11;\n break;\n case 7:\n _context28.prev = 7;\n _context28.t0 = _context28[\"catch\"](0);\n console.error(\"Error deleting \".concat(docType, \":\"), _context28.t0);\n throw _context28.t0;\n case 11:\n case \"end\":\n return _context28.stop();\n }\n }, _callee28, null, [[0, 7]]);\n }));\n}\n// delete all instances of a type\nfunction deleteAllDocumentsInCollection(collectionName) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {\n var _this = this;\n var collectionRef, snapshot, deletePromises;\n return _regeneratorRuntime().wrap(function _callee30$(_context30) {\n while (1) switch (_context30.prev = _context30.next) {\n case 0:\n _context30.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionName);\n _context30.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n snapshot = _context30.sent;\n // Delete all documents in the collection\n deletePromises = snapshot.docs.map(function (doc) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {\n return _regeneratorRuntime().wrap(function _callee29$(_context29) {\n while (1) switch (_context29.prev = _context29.next) {\n case 0:\n _context29.next = 2;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(doc.ref);\n case 2:\n case \"end\":\n return _context29.stop();\n }\n }, _callee29);\n }));\n });\n _context30.next = 8;\n return Promise.all(deletePromises);\n case 8:\n console.log(\"All documents in the \".concat(collectionName, \" collection deleted successfully.\"));\n _context30.next = 15;\n break;\n case 11:\n _context30.prev = 11;\n _context30.t0 = _context30[\"catch\"](0);\n console.error(\"Error deleting all documents in \".concat(collectionName, \":\"), _context30.t0);\n throw _context30.t0;\n case 15:\n case \"end\":\n return _context30.stop();\n }\n }, _callee30, null, [[0, 11]]);\n }));\n}\n////////////////////////////////////UPDATING/////////////////////////////////////////////\n// update a field in an instance\nfunction updateInstance(docType, docId, updates) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee31$(_context31) {\n while (1) switch (_context31.prev = _context31.next) {\n case 0:\n _context31.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context31.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(docRef, updates);\n case 4:\n console.log(\"\".concat(docType, \" updated successfully.\"));\n _context31.next = 11;\n break;\n case 7:\n _context31.prev = 7;\n _context31.t0 = _context31[\"catch\"](0);\n console.error(\"Error updating \".concat(docType, \":\"), _context31.t0);\n throw _context31.t0;\n case 11:\n case \"end\":\n return _context31.stop();\n }\n }, _callee31, null, [[0, 7]]);\n }));\n}\n// changes the ongoing status of an improvement work. if ongoing it is paused, if if paused onging.\n// user must be a manager\nfunction startOrPauseImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee32$(_context32) {\n while (1) switch (_context32.prev = _context32.next) {\n case 0:\n _context32.prev = 0;\n _context32.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context32.sent;\n _context32.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context32.sent;\n if (!(!user || !user.manager)) {\n _context32.next = 11;\n break;\n }\n throw new Error(\"User can't change improvementWork status\");\n case 11:\n if (!improvementWork) {\n _context32.next = 18;\n break;\n }\n update = {\n ongoing: !improvementWork.ongoing\n };\n _context32.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n _context32.next = 19;\n break;\n case 18:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n case 19:\n _context32.next = 25;\n break;\n case 21:\n _context32.prev = 21;\n _context32.t0 = _context32[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context32.t0);\n throw _context32.t0;\n case 25:\n case \"end\":\n return _context32.stop();\n }\n }, _callee32, null, [[0, 21]]);\n }));\n}\nfunction changePatientRiskLevel(userId, improvementWorkId, patientRiskLevel) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee33$(_context33) {\n while (1) switch (_context33.prev = _context33.next) {\n case 0:\n _context33.prev = 0;\n _context33.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context33.sent;\n _context33.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context33.sent;\n if (!(!user || !user.manager)) {\n _context33.next = 11;\n break;\n }\n throw new Error(\"User can't change patientRiskLevel in improvement work\");\n case 11:\n if (!improvementWork) {\n _context33.next = 18;\n break;\n }\n update = {\n patientRiskLevel: patientRiskLevel\n };\n _context33.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n _context33.next = 19;\n break;\n case 18:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n case 19:\n _context33.next = 25;\n break;\n case 21:\n _context33.prev = 21;\n _context33.t0 = _context33[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context33.t0);\n throw _context33.t0;\n case 25:\n case \"end\":\n return _context33.stop();\n }\n }, _callee33, null, [[0, 21]]);\n }));\n}\n// finalizes the improvement work. ongoing is set to false.\n// user must be a manager\nfunction finalizeImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {\n var user, update;\n return _regeneratorRuntime().wrap(function _callee34$(_context34) {\n while (1) switch (_context34.prev = _context34.next) {\n case 0:\n _context34.prev = 0;\n _context34.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context34.sent;\n if (!(!user || !user.manager)) {\n _context34.next = 8;\n break;\n }\n throw new Error(\"User can't finalize improvementWork status\");\n case 8:\n update = {\n completed: true,\n ongoing: false\n };\n _context34.next = 11;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 11:\n _context34.next = 16;\n break;\n case 13:\n _context34.prev = 13;\n _context34.t0 = _context34[\"catch\"](0);\n console.log(_context34.t0);\n case 16:\n case \"end\":\n return _context34.stop();\n }\n }, _callee34, null, [[0, 13]]);\n }));\n}\n\n//////////////////////////////// for later sprint\n//function add_upvotes\n//function add_notes\n//function add_intrested_users\n\n//# sourceURL=webpack://c3/./client/Database/database.js?"); /***/ }), @@ -106,7 +106,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \*************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ testFunc: () => (/* binding */ testFunc)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n//import {loadInitiatePage} from \"../SidebarAndHeader/pageHandler.js\";\nvar myIdeaCards = {};\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n }\n _createClass(IdeaCard, [{\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImage\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFaded\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n </div>\\n <div class=\\\"ideaCardUpvotes\\\">\\n <img src=\\\"images/upvoteIcon.png\\\" class =\\\"upvoteIcon\\\" alt=\\\"upvoteIcon\\\">\\n <p id =\\\"upvoteNumber\\\" class=\\\"ideaCardFont\\\">\").concat(this.upvoteCount, \"</p>\\n </div>\\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <p class=\\\"ideaCardFont\\\">Kommentarer</p>\\n <p class=\\\"ideaCardFont\\\">Komment 7</p>\\n <p class=\\\"ideaCardFont\\\">K0mment 2</p>\\n </div>\\n\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.id, \"\\\">Initiera Project</button>\\n </div>\\n </div>\\n </div>\\n </div>\");\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n window.location.href = '../client/projectPage/projectPageP.html';\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var suggestions, counter;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 2:\n suggestions = _context2.sent;\n //If there exist filter use those instead to get matching suggestions rest should not need to be changed\n counter = 1;\n suggestions.forEach(function (suggestion) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context.sent;\n _context.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context.sent;\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter);\n counter = counter + 1;\n case 8:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n case 5:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount);\n cardHTML = card.generateHTML();\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n container.appendChild(div);\n case 7:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction testFunc() {\n console.log(\"Test func works\");\n}\nfunction loadPage() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var container, scriptElement;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context4.next = 3;\n break;\n }\n return _context4.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n scriptElement = document.createElement(\"script\");\n scriptElement.src = \"../dist/ideaBank.bundle.js\";\n container.appendChild(scriptElement);\n fetch(\"ideaBank/ideaBank.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBar\");\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n myIdeaCards = {};\n _context4.next = 10;\n return createNewCards(\"IdeaCardDiv\", container);\n case 10:\n addListner(myIdeaCards, container);\n case 11:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n}\nfunction addListner(cardArray, element) {\n element.addEventListener(\"click\", function (event) {\n var target = event.target;\n //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n var cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n var card = cardArray[cardId];\n var expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n //adds an event listener for the initiate page \n // if (target && target.className === \"initiateProjectButton\") {\n // const cardId = parseInt(target.id.replace(\"initiateProjectFromCard\", \"\"), 10);\n // if (cardArray[cardId]) {\n // $(\"#container-fluid\").empty();\n // loadInitiatePage(cardId);\n // }\n //}\n });\n}\n\n//# sourceURL=webpack://c3/./client/ideaBank/ideaBank.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ testFunc: () => (/* binding */ testFunc)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n//import {loadInitiatePage} from \"../SidebarAndHeader/pageHandler.js\";\nvar myIdeaCards = {};\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount, suggestionID) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n this.suggestionID = suggestionID;\n }\n _createClass(IdeaCard, [{\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImage\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFaded\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n </div>\\n <div class=\\\"ideaCardUpvotes\\\">\\n <img src=\\\"images/upvoteIcon.png\\\" class =\\\"upvoteIcon\\\" alt=\\\"upvoteIcon\\\">\\n <p id =\\\"upvoteNumber\\\" class=\\\"ideaCardFont\\\">\").concat(this.upvoteCount, \"</p>\\n </div>\\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <p class=\\\"ideaCardFont\\\">Kommentarer</p>\\n <p class=\\\"ideaCardFont\\\">Komment 7</p>\\n <p class=\\\"ideaCardFont\\\">K0mment 2</p>\\n </div>\\n\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.suggestionID, \"\\\">Initiera Project</button>\\n </div>\\n </div>\\n </div>\\n </div>\");\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n window.location.href = '../client/projectPage/projectPageP.html';\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var suggestions, counter;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 2:\n suggestions = _context2.sent;\n //If there exist filter use those instead to get matching suggestions rest should not need to be changed\n counter = 1;\n suggestions.forEach(function (suggestion) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context.sent;\n _context.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context.sent;\n console.log(suggestion);\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter, suggestion.id);\n counter = counter + 1;\n case 9:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n case 5:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID, suggestionID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount, suggestionID);\n cardHTML = card.generateHTML();\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n container.appendChild(div);\n case 7:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction testFunc() {\n console.log(\"Test func works\");\n}\nfunction loadPage() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var container, scriptElement;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context4.next = 3;\n break;\n }\n return _context4.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n scriptElement = document.createElement(\"script\");\n scriptElement.src = \"../dist/ideaBank.bundle.js\";\n container.appendChild(scriptElement);\n fetch(\"ideaBank/ideaBank.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBar\");\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n myIdeaCards = {};\n _context4.next = 10;\n return createNewCards(\"IdeaCardDiv\", container);\n case 10:\n addListner(myIdeaCards, container);\n case 11:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n}\nfunction addListner(cardArray, element) {\n element.addEventListener(\"click\", function (event) {\n var target = event.target;\n //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n var cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n var card = cardArray[cardId];\n var expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n //adds an event listener for the initiate page \n // if (target && target.className === \"initiateProjectButton\") {\n // const cardId = parseInt(target.id.replace(\"initiateProjectFromCard\", \"\"), 10);\n // if (cardArray[cardId]) {\n // $(\"#container-fluid\").empty();\n // loadInitiatePage(cardId);\n // }\n //}\n });\n}\n\n//# sourceURL=webpack://c3/./client/ideaBank/ideaBank.js?"); /***/ }), diff --git a/client/dist/initiateIdea.bundle.js b/client/dist/initiateIdea.bundle.js index 46fd71f91dcd9749a8cdd64a0c09f1b6de1aee61..6def26ac41aa143a3c92ca7604367cb6c4a03615 100644 --- a/client/dist/initiateIdea.bundle.js +++ b/client/dist/initiateIdea.bundle.js @@ -96,7 +96,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \*************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addDocumentToImprovementWork: () => (/* binding */ addDocumentToImprovementWork),\n/* harmony export */ addMemberToImprovementWork: () => (/* binding */ addMemberToImprovementWork),\n/* harmony export */ addMemberToTask: () => (/* binding */ addMemberToTask),\n/* harmony export */ addNoteToUser: () => (/* binding */ addNoteToUser),\n/* harmony export */ auth: () => (/* binding */ auth),\n/* harmony export */ changePatientRiskLevel: () => (/* binding */ changePatientRiskLevel),\n/* harmony export */ createComment: () => (/* binding */ createComment),\n/* harmony export */ createHospital: () => (/* binding */ createHospital),\n/* harmony export */ createImprovementWork: () => (/* binding */ createImprovementWork),\n/* harmony export */ createSuggestion: () => (/* binding */ createSuggestion),\n/* harmony export */ createTaskOnImprovementWork: () => (/* binding */ createTaskOnImprovementWork),\n/* harmony export */ createUnit: () => (/* binding */ createUnit),\n/* harmony export */ createUser: () => (/* binding */ createUser),\n/* harmony export */ createdDocumentInKnowledgeBank: () => (/* binding */ createdDocumentInKnowledgeBank),\n/* harmony export */ db: () => (/* binding */ db),\n/* harmony export */ deleteAllDocumentsInCollection: () => (/* binding */ deleteAllDocumentsInCollection),\n/* harmony export */ deleteInstance: () => (/* binding */ deleteInstance),\n/* harmony export */ finalizeImprovementWork: () => (/* binding */ finalizeImprovementWork),\n/* harmony export */ getComments: () => (/* binding */ getComments),\n/* harmony export */ getHospitals: () => (/* binding */ getHospitals),\n/* harmony export */ getImprovementWorks: () => (/* binding */ getImprovementWorks),\n/* harmony export */ getObject: () => (/* binding */ getObject),\n/* harmony export */ getObjectById: () => (/* binding */ getObjectById),\n/* harmony export */ getSuggestions: () => (/* binding */ getSuggestions),\n/* harmony export */ getTasks: () => (/* binding */ getTasks),\n/* harmony export */ getUnits: () => (/* binding */ getUnits),\n/* harmony export */ getUsers: () => (/* binding */ getUsers),\n/* harmony export */ startOrPauseImprovementWork: () => (/* binding */ startOrPauseImprovementWork),\n/* harmony export */ updateInstance: () => (/* binding */ updateInstance),\n/* harmony export */ upvoteComment: () => (/* binding */ upvoteComment),\n/* harmony export */ upvoteSuggestion: () => (/* binding */ upvoteSuggestion)\n/* harmony export */ });\n/* harmony import */ var firebase_app__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! firebase/app */ \"./node_modules/firebase/app/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_firestore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! firebase/firestore */ \"./node_modules/firebase/firestore/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_auth__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! firebase/auth */ \"./node_modules/firebase/auth/dist/esm/index.esm.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nvar firebaseConfig = {\n apiKey: \"AIzaSyDqkaVZMr11J4mfnR0auqoQilZyPfyD-x4\",\n authDomain: \"c3solutions-dc109.firebaseapp.com\",\n projectId: \"c3solutions-dc109\",\n storageBucket: \"c3solutions-dc109.appspot.com\",\n messagingSenderId: \"902143402555\",\n appId: \"1:902143402555:web:29213e81de0a0cba38b21e\"\n};\nvar app = (0,firebase_app__WEBPACK_IMPORTED_MODULE_0__.initializeApp)(firebaseConfig);\nvar auth = (0,firebase_auth__WEBPACK_IMPORTED_MODULE_2__.getAuth)();\nvar db = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getFirestore)(app);\nvar userCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\nvar unitCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\nvar improvementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\nvar taskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\nvar hospitalCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\nvar suggestionCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\nvar knowledgeDocumentCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"knowledgeDocument\");\n////////////////////////////////////////Setters///////////////////////////////////////////////////////////////////\n// Function to create user a new user in database\n// takes in userId, unitId, firstname, lastname, email and password as string\n// throws error if transaction failed\nfunction createUser(hsaId, unitId, firstName, lastName, email, manager, uid) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var userRef, unitRef;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, hsaId);\n _context.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(userRef, {\n id: userRef.id,\n uid: uid,\n unitId: unitId,\n firstName: firstName,\n lastName: lastName,\n email: email,\n improvementWorks: [],\n tasks: [],\n manager: manager\n });\n case 4:\n // Atomically add user to unit.\n unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection, unitId);\n _context.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(unitRef, {\n members: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userRef.id)\n });\n case 7:\n _context.next = 12;\n break;\n case 9:\n _context.prev = 9;\n _context.t0 = _context[\"catch\"](0);\n console.log(_context.t0);\n case 12:\n case \"end\":\n return _context.stop();\n }\n }, _callee, null, [[0, 9]]);\n }));\n}\n//Adds a new improvementWork to the database\n// takes in Id, name, currentStage in PDSA, content, unitId refers to as string and if completed as boolean\n// throws error if transaction failed\nfunction createImprovementWork(id, name, currentStage, content,\n// Är detta description bör detta förtydligas. \nunitId, purpose,\n//Bör tas bort motsvaras av p2- mål med projektet\npatientRiskLevel, area,\n// patientRiskLevel: \"Green\" | \"Blue\" | \"Orange\" | \"Red\"\n//Questions in planning stage\np1, p2, p3, p4, p5, p6, p7,\n//Questions in Doing (G) stage\ng1, g2, g3, g4, g5,\n//Questions in stydy stage\ns1, s2, s3,\n//Questions in acting stage\na1, a2, a3, a4) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var improvementWorkRef;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.prev = 0;\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, id);\n _context2.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(improvementWorkRef, {\n id: improvementWorkRef.id,\n currentStage: currentStage,\n name: name,\n content: content,\n purpose: purpose,\n dateStarted: new Date(),\n unitId: unitId,\n completed: false,\n ongoing: false,\n tasks: [],\n members: [],\n patientRiskLevel: patientRiskLevel,\n area: area,\n p1: p1,\n p2: p2,\n p3: p3,\n p4: p4,\n p5: p5,\n p6: p6,\n p7: p7,\n g1: g1,\n g2: g2,\n g3: g3,\n g4: g4,\n g5: g5,\n s1: s1,\n s2: s2,\n s3: s3,\n a1: a1,\n a2: a2,\n a3: a3,\n a4: a4\n });\n case 4:\n _context2.next = 10;\n break;\n case 6:\n _context2.prev = 6;\n _context2.t0 = _context2[\"catch\"](0);\n console.log(\"Error creating improvementWork: \", _context2.t0);\n throw _context2.t0;\n case 10:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, null, [[0, 6]]);\n }));\n}\n//create task to improvementWork\n// takes in improvementWorkId, name, deadline date, start date, stage in PDSA and content as string\n// throws error if transaction failed\nfunction createTaskOnImprovementWork(taskId, improvementWorkId, name, deadlineDate, startDate, stage, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var ref, improvementWorkRef;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.prev = 0;\n ref = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection, taskId);\n _context3.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(ref, {\n id: ref.id,\n improvementWorkId: improvementWorkId,\n name: name,\n deadlineDate: deadlineDate,\n startDate: startDate,\n stage: stage,\n content: content,\n members: []\n });\n case 4:\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, improvementWorkId); // Atomically add task to the tasks array field.\n _context3.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(improvementWorkRef, {\n tasks: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(taskId)\n });\n case 7:\n _context3.next = 13;\n break;\n case 9:\n _context3.prev = 9;\n _context3.t0 = _context3[\"catch\"](0);\n console.log(\"Error creating task: \", _context3.t0);\n throw _context3.t0;\n case 13:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, null, [[0, 9]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction createdDocumentInKnowledgeBank(documentUrl, name) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n _context4.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(knowledgeDocumentCollection);\n _context4.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n name: name\n });\n case 4:\n _context4.next = 10;\n break;\n case 6:\n _context4.prev = 6;\n _context4.t0 = _context4[\"catch\"](0);\n console.log(\"Error adding document: \", _context4.t0);\n throw _context4.t0;\n case 10:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4, null, [[0, 6]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction addDocumentToImprovementWork(documentUrl, name, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var improvementWorkRef, docRef;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n _context5.prev = 0;\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, improvementWorkId);\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkRef, \"documents\");\n _context5.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n timestamp: new Date(),\n name: name\n });\n case 5:\n _context5.next = 11;\n break;\n case 7:\n _context5.prev = 7;\n _context5.t0 = _context5[\"catch\"](0);\n console.log(\"Error adding document: \", _context5.t0);\n throw _context5.t0;\n case 11:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5, null, [[0, 7]]);\n }));\n}\n//add a member to a improvementWork\n// takes in id, users HSAid, improvementWorks id as string and if is owner, is responsible as boolean\n// throws error if transaction failed\nfunction addMemberToImprovementWork(userHsaId, improvementWorkId, isOwner, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var improvementWorkRef, userRef;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n _context6.prev = 0;\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, improvementWorkId); // return;\n // Atomically update the members array in the improvementWork document\n _context6.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(improvementWorkRef, {\n members: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)({\n userHsaId: userHsaId,\n isOwner: isOwner,\n isResponsibleFor: isResponsibleFor\n })\n });\n case 4:\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, userHsaId); // Atomically add improvementWork to user\n _context6.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(userRef, {\n improvementWorks: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)({\n improvementWorkId: improvementWorkId,\n isOwner: isOwner,\n isResponsibleFor: isResponsibleFor\n })\n });\n case 7:\n _context6.next = 13;\n break;\n case 9:\n _context6.prev = 9;\n _context6.t0 = _context6[\"catch\"](0);\n console.log(\"Error adding member: \", _context6.t0);\n throw _context6.t0;\n case 13:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6, null, [[0, 9]]);\n }));\n}\n//create a hospital\n// takes in ID, name as string\n// throws error if transaction failed\nfunction createHospital(hospitalId,\n// should be auto?\nname) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var ref;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.prev = 0;\n ref = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection, hospitalId);\n _context7.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(ref, {\n id: ref.id,\n name: name,\n units: []\n });\n case 4:\n _context7.next = 10;\n break;\n case 6:\n _context7.prev = 6;\n _context7.t0 = _context7[\"catch\"](0);\n console.log(\"Error creating hospital: \", _context7.t0);\n throw _context7.t0;\n case 10:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7, null, [[0, 6]]);\n }));\n}\n//create a unit\n// takes in id, hospitals id and name as string\n// throws error if transaction failed\nfunction createUnit(unitId,\n//should be auto?\nhospitalId, name) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var unitRef, hospitalRef;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n _context8.prev = 0;\n unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection, unitId);\n _context8.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(unitRef, {\n id: unitRef.id,\n hospitalId: hospitalId,\n name: name,\n members: []\n });\n case 4:\n // Atomically add unit to hospital.\n hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection, hospitalId);\n _context8.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(hospitalRef, {\n units: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(unitRef.id)\n });\n case 7:\n _context8.next = 13;\n break;\n case 9:\n _context8.prev = 9;\n _context8.t0 = _context8[\"catch\"](0);\n console.log(\"Error creating unit: \", _context8.t0);\n throw _context8.t0;\n case 13:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8, null, [[0, 9]]);\n }));\n}\n//adds a member to task\n// takes in ID, the added members hsaId, task id as string and if person is responsible as boolean\n// throws error if transaction failed\nfunction addMemberToTask(userHsaId, taskId, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var taskRef, userRef;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n _context9.prev = 0;\n // Atomically add a member to task.\n taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection, taskId);\n _context9.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(taskRef, {\n members: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)({\n userHsaId: userHsaId,\n isResponsibleFor: isResponsibleFor\n })\n });\n case 4:\n // Atomically add a task to user.\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, userHsaId);\n _context9.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(userRef, {\n tasks: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)({\n taskId: taskId,\n isResponsibleFor: isResponsibleFor\n })\n });\n case 7:\n _context9.next = 13;\n break;\n case 9:\n _context9.prev = 9;\n _context9.t0 = _context9[\"catch\"](0);\n console.log(\"Error adding member: \", _context9.t0);\n throw _context9.t0;\n case 13:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9, null, [[0, 9]]);\n }));\n}\n//creates a suggestion\n// takes in ID, the creators hsaId, name, content and the responding unitId as string\n// throws error if transaction failed\nfunction createSuggestion(id, creatorHsaId, name, area, content, purpose, measure, ideas,\n//need: boolean,\nunitId, departmentId, isPublic) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var suggestionRef, commentCollection;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n _context10.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, id);\n _context10.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(suggestionRef, {\n id: suggestionRef.id,\n creatorHsaId: creatorHsaId,\n name: name,\n area: area,\n content: content,\n purpose: purpose,\n measure: measure,\n ideas: ideas,\n //need: need,\n unitId: unitId,\n departmentId: departmentId,\n \"public\": isPublic,\n upvotes: [],\n comments: [],\n dateCreated: new Date()\n });\n case 4:\n _context10.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\");\n case 6:\n commentCollection = _context10.sent;\n _context10.next = 9;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(commentCollection);\n case 9:\n _context10.next = 15;\n break;\n case 11:\n _context10.prev = 11;\n _context10.t0 = _context10[\"catch\"](0);\n console.log(\"Error creating suggestion: \", _context10.t0);\n throw _context10.t0;\n case 15:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10, null, [[0, 11]]);\n }));\n}\n// Upvote a suggestion for a user\n// takes in suggestion id, user HSAid\n// returns error if transaction failed\nfunction upvoteSuggestion(suggestionId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var suggestionRef;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n _context11.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId); // Atomically add a update to the upvote array field.\n _context11.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(suggestionRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 4:\n _context11.next = 10;\n break;\n case 6:\n _context11.prev = 6;\n _context11.t0 = _context11[\"catch\"](0);\n console.log(\"Error upvoting suggestion: \", _context11.t0);\n throw _context11.t0;\n case 10:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11, null, [[0, 6]]);\n }));\n}\n//creates a comment\n// takes in commenters id, suggestion id and content as string\n// throws error if transaction failed\nfunction createComment(\n// change to subcollection\ncommenterHsaId, suggestionId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var suggestionRef, commentCollection, commentRef;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n _context12.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context12.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\");\n case 4:\n commentCollection = _context12.sent;\n _context12.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(commentCollection);\n case 7:\n commentRef = _context12.sent;\n _context12.next = 10;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(commentRef, {\n id: commentRef.id,\n commenterHsaId: commenterHsaId,\n content: content,\n dateCreated: new Date(),\n upvotes: []\n });\n case 10:\n _context12.next = 16;\n break;\n case 12:\n _context12.prev = 12;\n _context12.t0 = _context12[\"catch\"](0);\n console.log(\"Error creating comment: \", _context12.t0);\n throw _context12.t0;\n case 16:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12, null, [[0, 12]]);\n }));\n}\n// Upvote a comment for a user\n// takes in suggestionId, commentId and userId as strings\n// return error if transaction failed\nfunction upvoteComment(suggestionId, commentId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var suggestionRef, commentRef;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n _context13.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n commentRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionRef, \"comment\", commentId); // Atomically add a update to the upvote array field.\n _context13.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(commentRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 5:\n _context13.next = 11;\n break;\n case 7:\n _context13.prev = 7;\n _context13.t0 = _context13[\"catch\"](0);\n console.log(\"Error upvoting comment: \", _context13.t0);\n throw _context13.t0;\n case 11:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13, null, [[0, 7]]);\n }));\n}\n//add a note to a user\n// takes in userHsaId and content as string\n// throws error if transaction failed\nfunction addNoteToUser(userHsaId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var userRef, docRef;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n _context14.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, userHsaId);\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userRef, \"notes\");\n _context14.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n content: content,\n dateCreated: new Date()\n });\n case 5:\n _context14.next = 11;\n break;\n case 7:\n _context14.prev = 7;\n _context14.t0 = _context14[\"catch\"](0);\n console.log(\"Error adding document: \", _context14.t0);\n throw _context14.t0;\n case 11:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14, null, [[0, 7]]);\n }));\n}\n// export to setters to be able to use in other files\n\n//////////////////////////////////////////////GETTERS/////////////////////////////////////////////////////////////////////\n// Get any object\n// input is the database type as a string.\n// output is the whole collection of that type.\nfunction getObject(collectionPath) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n var collectionRef, querySnapshot, result;\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n _context15.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionPath);\n _context15.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n querySnapshot = _context15.sent;\n result = [];\n querySnapshot.forEach(function (doc) {\n result.push(doc.data());\n });\n return _context15.abrupt(\"return\", result);\n case 10:\n _context15.prev = 10;\n _context15.t0 = _context15[\"catch\"](0);\n console.error(\"Error getting collection data\", _context15.t0);\n throw _context15.t0;\n case 14:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15, null, [[0, 10]]);\n }));\n}\n/**\n * Asynchronously retrieves a single document object from the specified collection path and document ID.\n * If the document does not exist, logs a warning and returns null.\n *\n * @param {string} collectionPath - The path to the collection in the database (\"improvementWork\", \"hospital\", \"suggestion\", \"task\", \"unit\", \"users\")\n * @param {string} documentId - The ID of the document to retrieve.\n * @returns {Promise<any|null>} A promise that resolves to the document object if found, or null if not.\n *\n * @throws Will throw an error if there is an issue during retrieval from the database.\n */\nfunction getObjectById(collectionPath, documentId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {\n var docRef, docSnapshot;\n return _regeneratorRuntime().wrap(function _callee16$(_context16) {\n while (1) switch (_context16.prev = _context16.next) {\n case 0:\n _context16.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, collectionPath, documentId);\n _context16.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDoc)(docRef);\n case 4:\n docSnapshot = _context16.sent;\n if (!docSnapshot.exists()) {\n _context16.next = 9;\n break;\n }\n return _context16.abrupt(\"return\", docSnapshot.data());\n case 9:\n console.warn(\"No such document! \".concat(collectionPath, \"/\").concat(documentId));\n return _context16.abrupt(\"return\", null);\n case 11:\n _context16.next = 17;\n break;\n case 13:\n _context16.prev = 13;\n _context16.t0 = _context16[\"catch\"](0);\n console.error(\"Error getting object\", _context16.t0);\n throw _context16.t0;\n case 17:\n case \"end\":\n return _context16.stop();\n }\n }, _callee16, null, [[0, 13]]);\n }));\n}\n/**\n * Asynchronously retrieves comments for a given suggestion.\n *\n * @param {Object} params - The parameters for fetching comments.\n * @param {string} params.suggestionId - The ID of the suggestion to fetch comments for.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - The criterion to sort the comments by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Determines if the sorting should be in ascending order. Defaults to false (descending).\n * @returns {Promise<any[]>} A promise that resolves to an array of comment objects.\n *\n * @throws Will throw an error if the comments cannot be retrieved.\n */\nfunction getComments(_ref) {\n var suggestionId = _ref.suggestionId,\n _ref$sortBy = _ref.sortBy,\n sortBy = _ref$sortBy === void 0 ? \"dateCreated\" : _ref$sortBy,\n _ref$ascending = _ref.ascending,\n ascending = _ref$ascending === void 0 ? false : _ref$ascending;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {\n var suggestionRef, commentsQuery, commentsSnapshot, comments;\n return _regeneratorRuntime().wrap(function _callee17$(_context17) {\n while (1) switch (_context17.prev = _context17.next) {\n case 0:\n _context17.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, \"suggestionCollection\", suggestionId);\n commentsQuery = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\"), (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n _context17.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(commentsQuery);\n case 5:\n commentsSnapshot = _context17.sent;\n comments = [];\n commentsSnapshot.forEach(function (doc) {\n comments.push(doc.data());\n });\n return _context17.abrupt(\"return\", comments);\n case 11:\n _context17.prev = 11;\n _context17.t0 = _context17[\"catch\"](0);\n console.error(\"Error getting comments for suggestion: \", _context17.t0);\n throw _context17.t0;\n case 15:\n case \"end\":\n return _context17.stop();\n }\n }, _callee17, null, [[0, 11]]);\n }));\n}\n//Filtering suggestions on unitId AND creatorHsaId\n//Sort suggestions on dateCreated OR upvotes\n/**\n * Asynchronously retrieves an array of suggestions from the database, with various filters and sorting options.\n *\n * @param {Object} params - The parameters for filtering and sorting suggestions.\n * @param {string} [params.id] - Optional ID to filter suggestions by a specific identifier.\n * @param {string} [params.creatorHsaId] - Optional HSA ID to filter suggestions by the creator's HSA ID.\n * @param {string} [params.unitId] - Optional unit ID to filter suggestions by a specific unit.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - Criterion to sort the suggestions by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Flag indicating if sorting should be ascending. Defaults to false (descending order).\n * @param {boolean} [params.isPublic=true] - Flag indicating whether to filter for public suggestions. Defaults to true.\n * @returns {Promise<any[]>} A promise that resolves to an array of suggestion objects.\n *\n * @throws Will throw an error if there is an issue retrieving suggestions.\n */\nfunction getSuggestions(_ref2) {\n var id = _ref2.id,\n creatorHsaId = _ref2.creatorHsaId,\n unitId = _ref2.unitId,\n _ref2$sortBy = _ref2.sortBy,\n sortBy = _ref2$sortBy === void 0 ? \"dateCreated\" : _ref2$sortBy,\n _ref2$ascending = _ref2.ascending,\n ascending = _ref2$ascending === void 0 ? false : _ref2$ascending,\n _ref2$isPublic = _ref2.isPublic,\n isPublic = _ref2$isPublic === void 0 ? true : _ref2$isPublic;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {\n var collectionRef, constraints, q, querySnapshot, suggestions;\n return _regeneratorRuntime().wrap(function _callee18$(_context18) {\n while (1) switch (_context18.prev = _context18.next) {\n case 0:\n _context18.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (creatorHsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"creatorHsaId\", \"==\", creatorHsaId));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"public\", \"==\", isPublic));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context18.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 11:\n querySnapshot = _context18.sent;\n suggestions = [];\n querySnapshot.forEach(function (doc) {\n suggestions.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context18.abrupt(\"return\", suggestions);\n case 17:\n _context18.prev = 17;\n _context18.t0 = _context18[\"catch\"](0);\n console.log(\"Error retrieving suggestions by department: \", _context18.t0);\n throw _context18.t0;\n case 21:\n case \"end\":\n return _context18.stop();\n }\n }, _callee18, null, [[0, 17]]);\n }));\n}\n/**\n * Asynchronously searches for hospital documents in the database.\n * It can filter the results by the hospital's name, ID, or both.\n * If no parameters are provided, it retrieves all hospitals.\n *\n * @param {Object} params - An object containing the search parameters.\n * @param {string} [params.hospitalName] - Optional name of the hospital to filter the search.\n * @param {string} [params.hospitalId] - Optional unique identifier of the hospital to filter the search.\n * @returns {Promise<any[]>} A promise that resolves to an array of hospital objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getHospitals(_ref3) {\n var hospitalName = _ref3.hospitalName,\n hospitalId = _ref3.hospitalId;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {\n var collectionRef, constraints, q, querySnapshot, hospitals;\n return _regeneratorRuntime().wrap(function _callee19$(_context19) {\n while (1) switch (_context19.prev = _context19.next) {\n case 0:\n _context19.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\n constraints = [];\n if (hospitalName) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", hospitalName));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hospitalId));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context19.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context19.sent;\n hospitals = [];\n querySnapshot.forEach(function (doc) {\n hospitals.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context19.abrupt(\"return\", hospitals);\n case 14:\n _context19.prev = 14;\n _context19.t0 = _context19[\"catch\"](0);\n console.log(\"Error retrieving Hospitals\", _context19.t0);\n throw _context19.t0;\n case 18:\n case \"end\":\n return _context19.stop();\n }\n }, _callee19, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of improvement work documents based on various filter criteria.\n * It supports filtering by ID, Nolan stage, unit ID, completion status, ongoing status, and patient risk level.\n * It also supports sorting by the start date of the improvement work in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.id] - Optional identifier to filter the improvement works.\n * @param {string} [params.nolanStage] - Optional Nolan stage to filter the improvement works.\n * @param {string} [params.unitId] - Optional unit ID to filter the improvement works.\n * @param {boolean} [params.completed] - Optional flag to filter the improvement works by their completion status.\n * @param {boolean} [params.ongoing] - Optional flag to filter the improvement works by their ongoing status.\n * @param {string} [params.patientRiskLevel] - Optional patient risk level to filter the improvement works.\n * @param {boolean} [params.ascendingDates=false] - Optional flag for sorting by date in ascending order. Defaults to false.\n * @returns {Promise<any[]>} A promise that resolves to an array of improvement work objects that match the criteria.\n *\n * @throws Will throw an error if there is a problem retrieving the improvement works.\n */\nfunction getImprovementWorks(_ref4) {\n var id = _ref4.id,\n nolanStage = _ref4.nolanStage,\n unitId = _ref4.unitId,\n completed = _ref4.completed,\n ongoing = _ref4.ongoing,\n patientRiskLevel = _ref4.patientRiskLevel,\n _ref4$ascendingDates = _ref4.ascendingDates,\n ascendingDates = _ref4$ascendingDates === void 0 ? false : _ref4$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {\n var collectionRef, constraints, q, querySnapshot, improvementWorks;\n return _regeneratorRuntime().wrap(function _callee20$(_context20) {\n while (1) switch (_context20.prev = _context20.next) {\n case 0:\n _context20.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (nolanStage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"currentStage\", \"==\", nolanStage));\n }\n if (completed != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"completed\", \"==\", completed));\n }\n if (ongoing !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"ongoing\", \"==\", ongoing));\n }\n if (patientRiskLevel) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"patientRiskLevel\", \"==\", patientRiskLevel));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"dateStarted\", ascendingDates ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context20.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 13:\n querySnapshot = _context20.sent;\n improvementWorks = [];\n querySnapshot.forEach(function (doc) {\n improvementWorks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context20.abrupt(\"return\", improvementWorks);\n case 19:\n _context20.prev = 19;\n _context20.t0 = _context20[\"catch\"](0);\n console.log(\"Error retrieving improvementWorks: \", _context20.t0);\n throw _context20.t0;\n case 23:\n case \"end\":\n return _context20.stop();\n }\n }, _callee20, null, [[0, 19]]);\n }));\n}\n/**\n * Asynchronously retrieves user documents from the database based on various filter criteria.\n * It can filter by the Health Savings Account ID (hsaId), unit ID, and unique identifier (uid).\n * Additionally, it can sort the results by first name in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.hsaId] - Optional HSA ID to filter the users.\n * @param {string} [params.unitId] - Optional unit ID to filter the users.\n * @param {boolean} [params.ascendingFirstNames=false] - Optional flag to sort by first names in ascending order. Defaults to false (descending order).\n * @param {string} [params.uid] - Optional unique identifier to filter the users.\n * @returns {Promise<any[]>} A promise that resolves to an array of user objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUsers(_ref5) {\n var hsaId = _ref5.hsaId,\n unitId = _ref5.unitId,\n _ref5$ascendingFirstN = _ref5.ascendingFirstNames,\n ascendingFirstNames = _ref5$ascendingFirstN === void 0 ? false : _ref5$ascendingFirstN,\n uid = _ref5.uid;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {\n var collectionRef, constraints, q, querySnapshot, users;\n return _regeneratorRuntime().wrap(function _callee21$(_context21) {\n while (1) switch (_context21.prev = _context21.next) {\n case 0:\n _context21.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\n constraints = [];\n if (hsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hsaId));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (uid) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"uid\", \"==\", uid));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"firstName\", ascendingFirstNames ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context21.next = 10;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 10:\n querySnapshot = _context21.sent;\n users = [];\n querySnapshot.forEach(function (doc) {\n users.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context21.abrupt(\"return\", users);\n case 16:\n _context21.prev = 16;\n _context21.t0 = _context21[\"catch\"](0);\n console.log(\"Error retrieving users by department: \", _context21.t0);\n throw _context21.t0;\n case 20:\n case \"end\":\n return _context21.stop();\n }\n }, _callee21, null, [[0, 16]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of task documents from the database based on several filter and sorting criteria.\n * Filters include task ID, user ID and their responsibility status, and related improvement work ID.\n * Results can be sorted by date either in ascending or descending order.\n *\n * @param {Object} params - Parameters to filter and sort the task results.\n * @param {string} [params.taskId] - Optional task ID to filter the tasks.\n * @param {string} [params.userId] - Optional user ID to identify tasks related to a user.\n * @param {boolean} [params.isResponsibleFor] - Optional flag to filter tasks where the user is marked as responsible.\n * @param {string} [params.improvementWorkId] - Optional improvement work ID to filter tasks related to a specific improvement work.\n * @param {boolean} [params.ascendingDates=false] - Optional flag to sort tasks by date in ascending order; defaults to descending order.\n * @returns {Promise<any[]>} A promise that resolves to an array of task objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getTasks(_ref6) {\n var taskId = _ref6.taskId,\n userId = _ref6.userId,\n isResponsibleFor = _ref6.isResponsibleFor,\n improvementWorkId = _ref6.improvementWorkId,\n _ref6$ascendingDates = _ref6.ascendingDates,\n ascendingDates = _ref6$ascendingDates === void 0 ? false : _ref6$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {\n var collectionRef, constraints, q, querySnapshot, tasks;\n return _regeneratorRuntime().wrap(function _callee22$(_context22) {\n while (1) switch (_context22.prev = _context22.next) {\n case 0:\n _context22.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\n constraints = [];\n if (taskId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", taskId));\n }\n if (userId && isResponsibleFor !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"members\", \"array-contains\", {\n userHsaId: userId,\n isResponsibleFor: isResponsibleFor\n }));\n }\n if (improvementWorkId != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"startDate\", ascendingDates ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context22.next = 9;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 9:\n querySnapshot = _context22.sent;\n tasks = [];\n querySnapshot.forEach(function (doc) {\n tasks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context22.abrupt(\"return\", tasks);\n case 15:\n _context22.prev = 15;\n _context22.t0 = _context22[\"catch\"](0);\n console.log(\"Error retrieving task by department: \", _context22.t0);\n throw _context22.t0;\n case 19:\n case \"end\":\n return _context22.stop();\n }\n }, _callee22, null, [[0, 15]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of unit documents from the database based on various filter criteria.\n * Filters can be applied based on unit ID, hospital ID, and unit name.\n * Additionally, results can be sorted by unit names in ascending or descending order.\n *\n * @param {Object} params - The parameters object containing filter and sorting options.\n * @param {string} [params.unitId] - Optional unit ID to filter the units.\n * @param {string} [params.hospitalId] - Optional hospital ID to filter units within a specific hospital.\n * @param {string} [params.name] - Optional name to filter units by a specific name.\n * @param {boolean} [params.ascendingUnitNames=false] - Optional flag to sort units by name in ascending order, defaults to descending.\n * @returns {Promise<any[]>} A promise that resolves to an array of unit objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUnits(_ref7) {\n var unitId = _ref7.unitId,\n hospitalId = _ref7.hospitalId,\n name = _ref7.name,\n _ref7$ascendingUnitNa = _ref7.ascendingUnitNames,\n ascendingUnitNames = _ref7$ascendingUnitNa === void 0 ? false : _ref7$ascendingUnitNa;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {\n var collectionRef, constraints, q, querySnapshot, units;\n return _regeneratorRuntime().wrap(function _callee23$(_context23) {\n while (1) switch (_context23.prev = _context23.next) {\n case 0:\n _context23.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\n constraints = [];\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", unitId));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"hospitalId\", \"==\", hospitalId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"name\", ascendingUnitNames ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context23.next = 9;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 9:\n querySnapshot = _context23.sent;\n units = [];\n querySnapshot.forEach(function (doc) {\n units.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context23.abrupt(\"return\", units);\n case 15:\n _context23.prev = 15;\n _context23.t0 = _context23[\"catch\"](0);\n console.log(\"Error retrieving units by hospitalId: \", _context23.t0);\n throw _context23.t0;\n case 19:\n case \"end\":\n return _context23.stop();\n }\n }, _callee23, null, [[0, 15]]);\n }));\n}\n//getMembersFilteredAndSorted() -> Get all members of a project (sorted by firstName?)\n// export getters to be able to use in other files\n\n////////////////////////////////////DELETING/////////////////////////////////////////////\n// delete an instance of a type\nfunction deleteInstance(docType, docId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee24$(_context24) {\n while (1) switch (_context24.prev = _context24.next) {\n case 0:\n _context24.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context24.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(docRef);\n case 4:\n console.log(\"\".concat(docType, \" deleted successfully.\"));\n _context24.next = 11;\n break;\n case 7:\n _context24.prev = 7;\n _context24.t0 = _context24[\"catch\"](0);\n console.error(\"Error deleting \".concat(docType, \":\"), _context24.t0);\n throw _context24.t0;\n case 11:\n case \"end\":\n return _context24.stop();\n }\n }, _callee24, null, [[0, 7]]);\n }));\n}\n// delete all instances of a type\nfunction deleteAllDocumentsInCollection(collectionName) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {\n var _this = this;\n var collectionRef, snapshot, deletePromises;\n return _regeneratorRuntime().wrap(function _callee26$(_context26) {\n while (1) switch (_context26.prev = _context26.next) {\n case 0:\n _context26.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionName);\n _context26.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n snapshot = _context26.sent;\n // Delete all documents in the collection\n deletePromises = snapshot.docs.map(function (doc) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {\n return _regeneratorRuntime().wrap(function _callee25$(_context25) {\n while (1) switch (_context25.prev = _context25.next) {\n case 0:\n _context25.next = 2;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(doc.ref);\n case 2:\n case \"end\":\n return _context25.stop();\n }\n }, _callee25);\n }));\n });\n _context26.next = 8;\n return Promise.all(deletePromises);\n case 8:\n console.log(\"All documents in the \".concat(collectionName, \" collection deleted successfully.\"));\n _context26.next = 15;\n break;\n case 11:\n _context26.prev = 11;\n _context26.t0 = _context26[\"catch\"](0);\n console.error(\"Error deleting all documents in \".concat(collectionName, \":\"), _context26.t0);\n throw _context26.t0;\n case 15:\n case \"end\":\n return _context26.stop();\n }\n }, _callee26, null, [[0, 11]]);\n }));\n}\n////////////////////////////////////UPDATING/////////////////////////////////////////////\n// update a field in an instance\nfunction updateInstance(docType, docId, updates) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee27$(_context27) {\n while (1) switch (_context27.prev = _context27.next) {\n case 0:\n _context27.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context27.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(docRef, updates);\n case 4:\n console.log(\"\".concat(docType, \" updated successfully.\"));\n _context27.next = 11;\n break;\n case 7:\n _context27.prev = 7;\n _context27.t0 = _context27[\"catch\"](0);\n console.error(\"Error updating \".concat(docType, \":\"), _context27.t0);\n throw _context27.t0;\n case 11:\n case \"end\":\n return _context27.stop();\n }\n }, _callee27, null, [[0, 7]]);\n }));\n}\n// changes the ongoing status of an improvement work. if ongoing it is paused, if if paused onging.\n// user must be a manager\nfunction startOrPauseImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee28$(_context28) {\n while (1) switch (_context28.prev = _context28.next) {\n case 0:\n _context28.prev = 0;\n _context28.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context28.sent;\n _context28.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context28.sent;\n if (!(!user || !user.manager)) {\n _context28.next = 11;\n break;\n }\n throw new Error(\"User can't change improvementWork status\");\n case 11:\n if (!improvementWork) {\n _context28.next = 18;\n break;\n }\n update = {\n ongoing: !improvementWork.ongoing\n };\n _context28.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n _context28.next = 19;\n break;\n case 18:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n case 19:\n _context28.next = 25;\n break;\n case 21:\n _context28.prev = 21;\n _context28.t0 = _context28[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context28.t0);\n throw _context28.t0;\n case 25:\n case \"end\":\n return _context28.stop();\n }\n }, _callee28, null, [[0, 21]]);\n }));\n}\nfunction changePatientRiskLevel(userId, improvementWorkId, patientRiskLevel) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee29$(_context29) {\n while (1) switch (_context29.prev = _context29.next) {\n case 0:\n _context29.prev = 0;\n _context29.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context29.sent;\n _context29.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context29.sent;\n if (!(!user || !user.manager)) {\n _context29.next = 11;\n break;\n }\n throw new Error(\"User can't change patientRiskLevel in improvement work\");\n case 11:\n if (!improvementWork) {\n _context29.next = 18;\n break;\n }\n update = {\n patientRiskLevel: patientRiskLevel\n };\n _context29.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n _context29.next = 19;\n break;\n case 18:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n case 19:\n _context29.next = 25;\n break;\n case 21:\n _context29.prev = 21;\n _context29.t0 = _context29[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context29.t0);\n throw _context29.t0;\n case 25:\n case \"end\":\n return _context29.stop();\n }\n }, _callee29, null, [[0, 21]]);\n }));\n}\n// finalizes the improvement work. ongoing is set to false.\n// user must be a manager\nfunction finalizeImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {\n var user, update;\n return _regeneratorRuntime().wrap(function _callee30$(_context30) {\n while (1) switch (_context30.prev = _context30.next) {\n case 0:\n _context30.prev = 0;\n _context30.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context30.sent;\n if (!(!user || !user.manager)) {\n _context30.next = 8;\n break;\n }\n throw new Error(\"User can't finalize improvementWork status\");\n case 8:\n update = {\n completed: true,\n ongoing: false\n };\n _context30.next = 11;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 11:\n _context30.next = 16;\n break;\n case 13:\n _context30.prev = 13;\n _context30.t0 = _context30[\"catch\"](0);\n console.log(_context30.t0);\n case 16:\n case \"end\":\n return _context30.stop();\n }\n }, _callee30, null, [[0, 13]]);\n }));\n}\n\n//////////////////////////////// for later sprint\n//function add_upvotes\n//function add_notes\n//function add_intrested_users\n\n//# sourceURL=webpack://c3/./client/Database/database.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addDocumentToImprovementWork: () => (/* binding */ addDocumentToImprovementWork),\n/* harmony export */ addMemberToImprovementWork: () => (/* binding */ addMemberToImprovementWork),\n/* harmony export */ addMemberToTask: () => (/* binding */ addMemberToTask),\n/* harmony export */ addNoteToUser: () => (/* binding */ addNoteToUser),\n/* harmony export */ auth: () => (/* binding */ auth),\n/* harmony export */ changePatientRiskLevel: () => (/* binding */ changePatientRiskLevel),\n/* harmony export */ createComment: () => (/* binding */ createComment),\n/* harmony export */ createHospital: () => (/* binding */ createHospital),\n/* harmony export */ createImprovementWork: () => (/* binding */ createImprovementWork),\n/* harmony export */ createSuggestion: () => (/* binding */ createSuggestion),\n/* harmony export */ createTaskOnImprovementWork: () => (/* binding */ createTaskOnImprovementWork),\n/* harmony export */ createUnit: () => (/* binding */ createUnit),\n/* harmony export */ createUser: () => (/* binding */ createUser),\n/* harmony export */ createdDocumentInKnowledgeBank: () => (/* binding */ createdDocumentInKnowledgeBank),\n/* harmony export */ db: () => (/* binding */ db),\n/* harmony export */ deleteAllDocumentsInCollection: () => (/* binding */ deleteAllDocumentsInCollection),\n/* harmony export */ deleteInstance: () => (/* binding */ deleteInstance),\n/* harmony export */ finalizeImprovementWork: () => (/* binding */ finalizeImprovementWork),\n/* harmony export */ getComments: () => (/* binding */ getComments),\n/* harmony export */ getHospitals: () => (/* binding */ getHospitals),\n/* harmony export */ getImprovementWorkOwner: () => (/* binding */ getImprovementWorkOwner),\n/* harmony export */ getImprovementWorkResponsible: () => (/* binding */ getImprovementWorkResponsible),\n/* harmony export */ getImprovementWorks: () => (/* binding */ getImprovementWorks),\n/* harmony export */ getImprovementWorksForUser: () => (/* binding */ getImprovementWorksForUser),\n/* harmony export */ getObject: () => (/* binding */ getObject),\n/* harmony export */ getObjectById: () => (/* binding */ getObjectById),\n/* harmony export */ getSuggestions: () => (/* binding */ getSuggestions),\n/* harmony export */ getTasks: () => (/* binding */ getTasks),\n/* harmony export */ getUnits: () => (/* binding */ getUnits),\n/* harmony export */ getUsers: () => (/* binding */ getUsers),\n/* harmony export */ getUsersForImprovementWork: () => (/* binding */ getUsersForImprovementWork),\n/* harmony export */ startOrPauseImprovementWork: () => (/* binding */ startOrPauseImprovementWork),\n/* harmony export */ updateInstance: () => (/* binding */ updateInstance),\n/* harmony export */ upvoteComment: () => (/* binding */ upvoteComment),\n/* harmony export */ upvoteSuggestion: () => (/* binding */ upvoteSuggestion)\n/* harmony export */ });\n/* harmony import */ var firebase_app__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! firebase/app */ \"./node_modules/firebase/app/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_firestore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! firebase/firestore */ \"./node_modules/firebase/firestore/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_auth__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! firebase/auth */ \"./node_modules/firebase/auth/dist/esm/index.esm.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nvar firebaseConfig = {\n apiKey: \"AIzaSyDqkaVZMr11J4mfnR0auqoQilZyPfyD-x4\",\n authDomain: \"c3solutions-dc109.firebaseapp.com\",\n projectId: \"c3solutions-dc109\",\n storageBucket: \"c3solutions-dc109.appspot.com\",\n messagingSenderId: \"902143402555\",\n appId: \"1:902143402555:web:29213e81de0a0cba38b21e\"\n};\n/*const firebaseConfig = {\n apiKey: \"AIzaSyBIsZq_yOsJljp1woIxndJO1GkW6soh-g4\",\n authDomain: \"company3-456bb.firebaseapp.com\",\n projectId: \"company3-456bb\",\n storageBucket: \"company3-456bb.appspot.com\",\n messagingSenderId: \"310033686522\",\n appId: \"1:310033686522:web:63198bb0db679c98ee4e43\",\n measurementId: \"G-PFLDQY00DB\"\n};*/\n// const firebaseConfig = {\n// apiKey: \"AIzaSyBIsZq_yOsJljp1woIxndJO1GkW6soh-g4\",\n// authDomain: \"company3-456bb.firebaseapp.com\",\n// projectId: \"company3-456bb\",\n// storageBucket: \"company3-456bb.appspot.com\",\n// messagingSenderId: \"310033686522\",\n// appId: \"1:310033686522:web:63198bb0db679c98ee4e43\",\n// measurementId: \"G-PFLDQY00DB\"\n// };\nvar app = (0,firebase_app__WEBPACK_IMPORTED_MODULE_0__.initializeApp)(firebaseConfig);\nvar auth = (0,firebase_auth__WEBPACK_IMPORTED_MODULE_2__.getAuth)();\nvar db = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getFirestore)(app);\nvar userCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\nvar unitCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\nvar improvementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\nvar taskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\nvar hospitalCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\nvar suggestionCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\nvar knowledgeDocumentCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"knowledgeDocument\");\nvar userImprovementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"userImprovementWork\");\nvar userTaskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"userTask\");\n////////////////////////////////////////Setters///////////////////////////////////////////////////////////////////\n// Function to create user a new user in database\n// takes in userId, unitId, firstname, lastname, email and password as string\n// throws error if transaction failed\nfunction createUser(hsaId, unitId, firstName, lastName, email, manager, uid) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var userRef, unitRef;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, hsaId);\n _context.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(userRef, {\n id: userRef.id,\n uid: uid,\n unitId: unitId,\n firstName: firstName,\n lastName: lastName,\n email: email,\n // TODO Replace with userImprovementWork collection\n improvementWorks: [],\n tasks: [],\n manager: manager\n });\n case 4:\n // Atomically add user to unit.\n unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection, unitId);\n _context.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(unitRef, {\n members: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userRef.id)\n });\n case 7:\n _context.next = 12;\n break;\n case 9:\n _context.prev = 9;\n _context.t0 = _context[\"catch\"](0);\n console.log(_context.t0);\n case 12:\n case \"end\":\n return _context.stop();\n }\n }, _callee, null, [[0, 9]]);\n }));\n}\nfunction createImprovementWork(id, name, currentStage, content,\n// Är detta description bör detta förtydligas. \nunitId, purpose,\n//Bör tas bort motsvaras av p2- mål med projektet\npatientRiskLevel, area,\n//Questions in planning stage\np1, p2, p3, p4, p5, p6, p7,\n//Questions in Doing (G) stage\ng1, g2, g3, g4, g5,\n//Questions in stydy stage\ns1, s2, s3,\n//Questions in acting stage\na1, a2, a3, a4) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var improvementWorkData, improvementWorkRef, _improvementWorkRef;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.prev = 0;\n improvementWorkData = {\n name: name,\n currentStage: currentStage,\n content: content,\n purpose: purpose,\n dateStarted: new Date(),\n unitId: unitId,\n completed: false,\n ongoing: false,\n tasks: [],\n // TODO Remove members array\n members: [],\n patientRiskLevel: patientRiskLevel,\n area: area,\n p1: p1,\n p2: p2,\n p3: p3,\n p4: p4,\n p5: p5,\n p6: p6,\n p7: p7,\n g1: g1,\n g2: g2,\n g3: g3,\n g4: g4,\n g5: g5,\n s1: s1,\n s2: s2,\n s3: s3,\n a1: a1,\n a2: a2,\n a3: a3,\n a4: a4\n };\n if (!id) {\n _context2.next = 8;\n break;\n }\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, id);\n _context2.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(improvementWorkRef, Object.assign({\n id: improvementWorkRef.id\n }, improvementWorkData));\n case 6:\n _context2.next = 11;\n break;\n case 8:\n _improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection);\n _context2.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_improvementWorkRef, improvementWorkData);\n case 11:\n _context2.next = 17;\n break;\n case 13:\n _context2.prev = 13;\n _context2.t0 = _context2[\"catch\"](0);\n console.log(\"Error creating improvementWork: \", _context2.t0);\n throw _context2.t0;\n case 17:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, null, [[0, 13]]);\n }));\n}\nfunction addMemberToTask(userHsaId, taskId, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var relationRef;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.prev = 0;\n relationRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userTaskCollection);\n _context3.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(relationRef, {\n id: relationRef.id,\n userHsaId: userHsaId,\n taskId: taskId,\n isResponsibleFor: isResponsibleFor\n });\n case 4:\n _context3.next = 10;\n break;\n case 6:\n _context3.prev = 6;\n _context3.t0 = _context3[\"catch\"](0);\n console.log(\"Error adding member to task: \", _context3.t0);\n throw _context3.t0;\n case 10:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, null, [[0, 6]]);\n }));\n}\nfunction addMemberToImprovementWork(userHsaId, improvementWorkId, isOwner, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var relationRef;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n _context4.prev = 0;\n relationRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userImprovementWorkCollection);\n _context4.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(relationRef, {\n id: relationRef.id,\n userHsaId: userHsaId,\n improvementWorkId: improvementWorkId,\n isOwner: isOwner,\n isResponsibleFor: isResponsibleFor\n });\n case 4:\n _context4.next = 10;\n break;\n case 6:\n _context4.prev = 6;\n _context4.t0 = _context4[\"catch\"](0);\n console.log(\"Error adding member to improvementWork: \", _context4.t0);\n throw _context4.t0;\n case 10:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4, null, [[0, 6]]);\n }));\n}\nfunction createTaskOnImprovementWork(taskId, improvementWorkId, name, deadlineDate, startDate, stage, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var taskData, taskRef, _taskRef;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n _context5.prev = 0;\n taskData = {\n improvementWorkId: improvementWorkId,\n name: name,\n deadlineDate: deadlineDate,\n startDate: startDate,\n stage: stage,\n content: content,\n members: [] // Initialize with an empty array\n };\n if (!taskId) {\n _context5.next = 8;\n break;\n }\n taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection, taskId);\n _context5.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(taskRef, Object.assign({\n id: taskRef.id\n }, taskData));\n case 6:\n _context5.next = 11;\n break;\n case 8:\n _taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection);\n _context5.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_taskRef, taskData);\n case 11:\n _context5.next = 17;\n break;\n case 13:\n _context5.prev = 13;\n _context5.t0 = _context5[\"catch\"](0);\n console.log(\"Error creating task: \", _context5.t0);\n throw _context5.t0;\n case 17:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5, null, [[0, 13]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction createdDocumentInKnowledgeBank(documentUrl, name) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n _context6.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(knowledgeDocumentCollection);\n _context6.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n name: name\n });\n case 4:\n _context6.next = 10;\n break;\n case 6:\n _context6.prev = 6;\n _context6.t0 = _context6[\"catch\"](0);\n console.log(\"Error adding document: \", _context6.t0);\n throw _context6.t0;\n case 10:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6, null, [[0, 6]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction addDocumentToImprovementWork(documentUrl, name, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var improvementWorkRef, docRef;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.prev = 0;\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, improvementWorkId);\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkRef, \"documents\");\n _context7.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n timestamp: new Date(),\n name: name\n });\n case 5:\n _context7.next = 11;\n break;\n case 7:\n _context7.prev = 7;\n _context7.t0 = _context7[\"catch\"](0);\n console.log(\"Error adding document: \", _context7.t0);\n throw _context7.t0;\n case 11:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7, null, [[0, 7]]);\n }));\n}\nfunction createHospital(hospitalId,\n// should be auto?\nname) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var hospitalData, hospitalRef, _hospitalRef;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n _context8.prev = 0;\n hospitalData = {\n name: name,\n units: []\n };\n if (!hospitalId) {\n _context8.next = 8;\n break;\n }\n hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection, hospitalId);\n _context8.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(hospitalRef, Object.assign({\n id: hospitalRef.id\n }, hospitalData));\n case 6:\n _context8.next = 11;\n break;\n case 8:\n _hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection);\n _context8.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_hospitalRef, hospitalData);\n case 11:\n _context8.next = 17;\n break;\n case 13:\n _context8.prev = 13;\n _context8.t0 = _context8[\"catch\"](0);\n console.log(\"Error creating hospital: \", _context8.t0);\n throw _context8.t0;\n case 17:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8, null, [[0, 13]]);\n }));\n}\nfunction createUnit(unitId,\n//should be auto?\nhospitalId, name) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var unitData, unitRef, _unitRef;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n _context9.prev = 0;\n unitData = {\n hospitalId: hospitalId,\n name: name,\n members: []\n };\n if (!unitId) {\n _context9.next = 8;\n break;\n }\n unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection, unitId);\n _context9.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(unitRef, Object.assign({\n id: unitRef.id\n }, unitData));\n case 6:\n _context9.next = 11;\n break;\n case 8:\n _unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection);\n _context9.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_unitRef, unitData);\n case 11:\n _context9.next = 17;\n break;\n case 13:\n _context9.prev = 13;\n _context9.t0 = _context9[\"catch\"](0);\n console.log(\"Error creating unit: \", _context9.t0);\n throw _context9.t0;\n case 17:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9, null, [[0, 13]]);\n }));\n}\nfunction createSuggestion(id, creatorHsaId, name, area, content, purpose, measure, ideas,\n//need: boolean,\nunitId, departmentId, isPublic) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var suggestionData, suggestionRef, _suggestionRef;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n _context10.prev = 0;\n suggestionData = {\n creatorHsaId: creatorHsaId,\n name: name,\n area: area,\n content: content,\n purpose: purpose,\n measure: measure,\n ideas: ideas,\n //need,\n unitId: unitId,\n departmentId: departmentId,\n \"public\": isPublic,\n upvotes: [],\n comments: [],\n dateCreated: new Date()\n };\n if (!id) {\n _context10.next = 8;\n break;\n }\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, id);\n _context10.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(suggestionRef, Object.assign({\n id: suggestionRef.id\n }, suggestionData));\n case 6:\n _context10.next = 11;\n break;\n case 8:\n _suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection);\n _context10.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_suggestionRef, suggestionData);\n case 11:\n _context10.next = 17;\n break;\n case 13:\n _context10.prev = 13;\n _context10.t0 = _context10[\"catch\"](0);\n console.log(\"Error creating suggestion: \", _context10.t0);\n throw _context10.t0;\n case 17:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10, null, [[0, 13]]);\n }));\n}\n// Upvote a suggestion for a user\n// takes in suggestion id, user HSAid\n// returns error if transaction failed\nfunction upvoteSuggestion(suggestionId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var suggestionRef;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n _context11.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId); // Atomically add a update to the upvote array field.\n _context11.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(suggestionRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 4:\n _context11.next = 10;\n break;\n case 6:\n _context11.prev = 6;\n _context11.t0 = _context11[\"catch\"](0);\n console.log(\"Error upvoting suggestion: \", _context11.t0);\n throw _context11.t0;\n case 10:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11, null, [[0, 6]]);\n }));\n}\n//creates a comment\n// takes in commenters id, suggestion id and content as string\n// throws error if transaction failed\nfunction createComment(\n// change to subcollection\ncommenterHsaId, suggestionId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var suggestionRef, commentCollection, commentRef;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n _context12.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context12.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\");\n case 4:\n commentCollection = _context12.sent;\n _context12.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(commentCollection);\n case 7:\n commentRef = _context12.sent;\n _context12.next = 10;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(commentRef, {\n id: commentRef.id,\n commenterHsaId: commenterHsaId,\n content: content,\n dateCreated: new Date(),\n upvotes: []\n });\n case 10:\n _context12.next = 16;\n break;\n case 12:\n _context12.prev = 12;\n _context12.t0 = _context12[\"catch\"](0);\n console.log(\"Error creating comment: \", _context12.t0);\n throw _context12.t0;\n case 16:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12, null, [[0, 12]]);\n }));\n}\n// Upvote a comment for a user\n// takes in suggestionId, commentId and userId as strings\n// return error if transaction failed\nfunction upvoteComment(suggestionId, commentId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var suggestionRef, commentRef;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n _context13.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n commentRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionRef, \"comment\", commentId); // Atomically add a update to the upvote array field.\n _context13.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(commentRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 5:\n _context13.next = 11;\n break;\n case 7:\n _context13.prev = 7;\n _context13.t0 = _context13[\"catch\"](0);\n console.log(\"Error upvoting comment: \", _context13.t0);\n throw _context13.t0;\n case 11:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13, null, [[0, 7]]);\n }));\n}\n//add a note to a user\n// takes in userHsaId and content as string\n// throws error if transaction failed\nfunction addNoteToUser(userHsaId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var userRef, docRef;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n _context14.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, userHsaId);\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userRef, \"notes\");\n _context14.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n content: content,\n dateCreated: new Date()\n });\n case 5:\n _context14.next = 11;\n break;\n case 7:\n _context14.prev = 7;\n _context14.t0 = _context14[\"catch\"](0);\n console.log(\"Error adding document: \", _context14.t0);\n throw _context14.t0;\n case 11:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14, null, [[0, 7]]);\n }));\n}\n// export to setters to be able to use in other files\n\n//////////////////////////////////////////////GETTERS/////////////////////////////////////////////////////////////////////\n// Get any object\n// input is the database type as a string.\n// output is the whole collection of that type.\nfunction getObject(collectionPath) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n var collectionRef, querySnapshot, result;\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n _context15.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionPath);\n _context15.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n querySnapshot = _context15.sent;\n result = [];\n querySnapshot.forEach(function (doc) {\n result.push(doc.data());\n });\n return _context15.abrupt(\"return\", result);\n case 10:\n _context15.prev = 10;\n _context15.t0 = _context15[\"catch\"](0);\n console.error(\"Error getting collection data\", _context15.t0);\n throw _context15.t0;\n case 14:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15, null, [[0, 10]]);\n }));\n}\n/**\n * Asynchronously retrieves a single document object from the specified collection path and document ID.\n * If the document does not exist, logs a warning and returns null.\n *\n * @param {string} collectionPath - The path to the collection in the database (\"improvementWork\", \"hospital\", \"suggestion\", \"task\", \"unit\", \"users\")\n * @param {string} documentId - The ID of the document to retrieve.\n * @returns {Promise<any|null>} A promise that resolves to the document object if found, or null if not.\n *\n * @throws Will throw an error if there is an issue during retrieval from the database.\n */\nfunction getObjectById(collectionPath, documentId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {\n var docRef, docSnapshot;\n return _regeneratorRuntime().wrap(function _callee16$(_context16) {\n while (1) switch (_context16.prev = _context16.next) {\n case 0:\n _context16.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, collectionPath, documentId);\n _context16.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDoc)(docRef);\n case 4:\n docSnapshot = _context16.sent;\n if (!docSnapshot.exists()) {\n _context16.next = 9;\n break;\n }\n return _context16.abrupt(\"return\", Object.assign({\n id: docSnapshot.id\n }, docSnapshot.data()));\n case 9:\n console.warn(\"No such document! \".concat(collectionPath, \"/\").concat(documentId));\n return _context16.abrupt(\"return\", null);\n case 11:\n _context16.next = 17;\n break;\n case 13:\n _context16.prev = 13;\n _context16.t0 = _context16[\"catch\"](0);\n console.error(\"Error getting object\", _context16.t0);\n throw _context16.t0;\n case 17:\n case \"end\":\n return _context16.stop();\n }\n }, _callee16, null, [[0, 13]]);\n }));\n}\n/**\n * Asynchronously retrieves comments for a given suggestion.\n *\n * @param {Object} params - The parameters for fetching comments.\n * @param {string} params.suggestionId - The ID of the suggestion to fetch comments for.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - The criterion to sort the comments by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Determines if the sorting should be in ascending order. Defaults to false (descending).\n * @returns {Promise<any[]>} A promise that resolves to an array of comment objects.\n *\n * @throws Will throw an error if the comments cannot be retrieved.\n */\nfunction getComments(_ref) {\n var suggestionId = _ref.suggestionId,\n _ref$sortBy = _ref.sortBy,\n sortBy = _ref$sortBy === void 0 ? \"dateCreated\" : _ref$sortBy,\n _ref$ascending = _ref.ascending,\n ascending = _ref$ascending === void 0 ? false : _ref$ascending;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {\n var suggestionRef, commentsQuery, commentsSnapshot, comments;\n return _regeneratorRuntime().wrap(function _callee17$(_context17) {\n while (1) switch (_context17.prev = _context17.next) {\n case 0:\n _context17.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, \"suggestionCollection\", suggestionId);\n commentsQuery = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\"), (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n _context17.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(commentsQuery);\n case 5:\n commentsSnapshot = _context17.sent;\n comments = [];\n commentsSnapshot.forEach(function (doc) {\n comments.push(doc.data());\n });\n return _context17.abrupt(\"return\", comments);\n case 11:\n _context17.prev = 11;\n _context17.t0 = _context17[\"catch\"](0);\n console.error(\"Error getting comments for suggestion: \", _context17.t0);\n throw _context17.t0;\n case 15:\n case \"end\":\n return _context17.stop();\n }\n }, _callee17, null, [[0, 11]]);\n }));\n}\n//Filtering suggestions on unitId AND creatorHsaId\n//Sort suggestions on dateCreated OR upvotes\n/**\n * Asynchronously retrieves an array of suggestions from the database, with various filters and sorting options.\n *\n * @param {Object} params - The parameters for filtering and sorting suggestions.\n * @param {string} [params.id] - Optional ID to filter suggestions by a specific identifier.\n * @param {string} [params.creatorHsaId] - Optional HSA ID to filter suggestions by the creator's HSA ID.\n * @param {string} [params.unitId] - Optional unit ID to filter suggestions by a specific unit.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - Criterion to sort the suggestions by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Flag indicating if sorting should be ascending. Defaults to false (descending order).\n * @param {boolean} [params.isPublic=true] - Flag indicating whether to filter for public suggestions. Defaults to true.\n * @returns {Promise<any[]>} A promise that resolves to an array of suggestion objects.\n *\n * @throws Will throw an error if there is an issue retrieving suggestions.\n */\nfunction getSuggestions(_ref2) {\n var id = _ref2.id,\n creatorHsaId = _ref2.creatorHsaId,\n unitId = _ref2.unitId,\n _ref2$sortBy = _ref2.sortBy,\n sortBy = _ref2$sortBy === void 0 ? \"dateCreated\" : _ref2$sortBy,\n _ref2$ascending = _ref2.ascending,\n ascending = _ref2$ascending === void 0 ? false : _ref2$ascending,\n _ref2$isPublic = _ref2.isPublic,\n isPublic = _ref2$isPublic === void 0 ? true : _ref2$isPublic;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {\n var collectionRef, constraints, q, querySnapshot, suggestions;\n return _regeneratorRuntime().wrap(function _callee18$(_context18) {\n while (1) switch (_context18.prev = _context18.next) {\n case 0:\n _context18.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (creatorHsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"creatorHsaId\", \"==\", creatorHsaId));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"public\", \"==\", isPublic));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context18.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 11:\n querySnapshot = _context18.sent;\n suggestions = [];\n querySnapshot.forEach(function (doc) {\n suggestions.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context18.abrupt(\"return\", suggestions);\n case 17:\n _context18.prev = 17;\n _context18.t0 = _context18[\"catch\"](0);\n console.log(\"Error retrieving suggestions by department: \", _context18.t0);\n throw _context18.t0;\n case 21:\n case \"end\":\n return _context18.stop();\n }\n }, _callee18, null, [[0, 17]]);\n }));\n}\n/**\n * Asynchronously searches for hospital documents in the database.\n * It can filter the results by the hospital's name, ID, or both.\n * If no parameters are provided, it retrieves all hospitals.\n *\n * @param {Object} params - An object containing the search parameters.\n * @param {string} [params.hospitalName] - Optional name of the hospital to filter the search.\n * @param {string} [params.hospitalId] - Optional unique identifier of the hospital to filter the search.\n * @returns {Promise<any[]>} A promise that resolves to an array of hospital objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getHospitals(_ref3) {\n var hospitalName = _ref3.hospitalName,\n hospitalId = _ref3.hospitalId;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {\n var collectionRef, constraints, q, querySnapshot, hospitals;\n return _regeneratorRuntime().wrap(function _callee19$(_context19) {\n while (1) switch (_context19.prev = _context19.next) {\n case 0:\n _context19.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\n constraints = [];\n if (hospitalName) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", hospitalName));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hospitalId));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context19.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context19.sent;\n hospitals = [];\n querySnapshot.forEach(function (doc) {\n hospitals.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context19.abrupt(\"return\", hospitals);\n case 14:\n _context19.prev = 14;\n _context19.t0 = _context19[\"catch\"](0);\n console.log(\"Error retrieving Hospitals\", _context19.t0);\n throw _context19.t0;\n case 18:\n case \"end\":\n return _context19.stop();\n }\n }, _callee19, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of improvement work documents based on various filter criteria.\n * It supports filtering by ID, Nolan stage, unit ID, completion status, ongoing status, and patient risk level.\n * It also supports sorting by the start date of the improvement work in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.id] - Optional identifier to filter the improvement works.\n * @param {string} [params.nolanStage] - Optional Nolan stage to filter the improvement works.\n * @param {string} [params.unitId] - Optional unit ID to filter the improvement works.\n * @param {boolean} [params.completed] - Optional flag to filter the improvement works by their completion status.\n * @param {boolean} [params.ongoing] - Optional flag to filter the improvement works by their ongoing status.\n * @param {string} [params.patientRiskLevel] - Optional patient risk level to filter the improvement works.\n * @param {boolean} [params.ascendingDates=false] - Optional flag for sorting by date in ascending order. Defaults to false.\n * @returns {Promise<any[]>} A promise that resolves to an array of improvement work objects that match the criteria.\n *\n * @throws Will throw an error if there is a problem retrieving the improvement works.\n */\nfunction getImprovementWorks(_ref4) {\n var id = _ref4.id,\n nolanStage = _ref4.nolanStage,\n unitId = _ref4.unitId,\n completed = _ref4.completed,\n ongoing = _ref4.ongoing,\n patientRiskLevel = _ref4.patientRiskLevel,\n _ref4$ascendingDates = _ref4.ascendingDates,\n ascendingDates = _ref4$ascendingDates === void 0 ? false : _ref4$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {\n var collectionRef, constraints, q, querySnapshot, improvementWorks;\n return _regeneratorRuntime().wrap(function _callee20$(_context20) {\n while (1) switch (_context20.prev = _context20.next) {\n case 0:\n _context20.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (nolanStage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"currentStage\", \"==\", nolanStage));\n }\n if (completed != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"completed\", \"==\", completed));\n }\n if (ongoing !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"ongoing\", \"==\", ongoing));\n }\n if (patientRiskLevel) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"patientRiskLevel\", \"==\", patientRiskLevel));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"dateStarted\", ascendingDates ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context20.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 13:\n querySnapshot = _context20.sent;\n improvementWorks = [];\n querySnapshot.forEach(function (doc) {\n improvementWorks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context20.abrupt(\"return\", improvementWorks);\n case 19:\n _context20.prev = 19;\n _context20.t0 = _context20[\"catch\"](0);\n console.log(\"Error retrieving improvementWorks: \", _context20.t0);\n throw _context20.t0;\n case 23:\n case \"end\":\n return _context20.stop();\n }\n }, _callee20, null, [[0, 19]]);\n }));\n}\nfunction getImprovementWorkOwner(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {\n var constraints, q, querySnapshot, owner;\n return _regeneratorRuntime().wrap(function _callee21$(_context21) {\n while (1) switch (_context21.prev = _context21.next) {\n case 0:\n _context21.prev = 0;\n constraints = [];\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"isOwner\", \"==\", true));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context21.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 7:\n querySnapshot = _context21.sent;\n if (!querySnapshot.empty) {\n _context21.next = 13;\n break;\n }\n console.log(\"Improvement work \", improvementWorkId, \" has no owner\");\n return _context21.abrupt(\"return\", null);\n case 13:\n owner = querySnapshot.docs[0].data().userHsaId;\n return _context21.abrupt(\"return\", owner);\n case 15:\n _context21.next = 20;\n break;\n case 17:\n _context21.prev = 17;\n _context21.t0 = _context21[\"catch\"](0);\n console.log(_context21.t0);\n case 20:\n case \"end\":\n return _context21.stop();\n }\n }, _callee21, null, [[0, 17]]);\n }));\n}\nfunction getImprovementWorkResponsible(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {\n var constraints, q, querySnapshot, responsible;\n return _regeneratorRuntime().wrap(function _callee22$(_context22) {\n while (1) switch (_context22.prev = _context22.next) {\n case 0:\n _context22.prev = 0;\n constraints = [];\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"isResponsibleFor\", \"==\", true));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context22.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 7:\n querySnapshot = _context22.sent;\n if (!querySnapshot.empty) {\n _context22.next = 13;\n break;\n }\n console.log(\"Improvement work \", improvementWorkId, \" has no responsible\");\n return _context22.abrupt(\"return\", null);\n case 13:\n responsible = querySnapshot.docs[0].data().userHsaId;\n return _context22.abrupt(\"return\", responsible);\n case 15:\n _context22.next = 20;\n break;\n case 17:\n _context22.prev = 17;\n _context22.t0 = _context22[\"catch\"](0);\n console.log(_context22.t0);\n case 20:\n case \"end\":\n return _context22.stop();\n }\n }, _callee22, null, [[0, 17]]);\n }));\n}\n// TODO getUsersForTask!\n/**\n * Asynchronously retrieves user documents from the database based on various filter criteria.\n * It can filter by the Health Savings Account ID (hsaId), unit ID, and unique identifier (uid).\n * Additionally, it can sort the results by first name in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.hsaId] - Optional HSA ID to filter the users.\n * @param {string} [params.unitId] - Optional unit ID to filter the users.\n * @param {boolean} [params.ascendingFirstNames=false] - Optional flag to sort by first names in ascending order. Defaults to false (descending order).\n * @param {string} [params.uid] - Optional unique identifier to filter the users.\n * @returns {Promise<any[]>} A promise that resolves to an array of user objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUsers(_ref5) {\n var hsaId = _ref5.hsaId,\n unitId = _ref5.unitId,\n _ref5$ascendingFirstN = _ref5.ascendingFirstNames,\n ascendingFirstNames = _ref5$ascendingFirstN === void 0 ? false : _ref5$ascendingFirstN,\n uid = _ref5.uid;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {\n var collectionRef, constraints, q, querySnapshot, users;\n return _regeneratorRuntime().wrap(function _callee23$(_context23) {\n while (1) switch (_context23.prev = _context23.next) {\n case 0:\n _context23.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\n constraints = [];\n if (hsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hsaId));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (uid) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"uid\", \"==\", uid));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"firstName\", ascendingFirstNames ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context23.next = 10;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 10:\n querySnapshot = _context23.sent;\n users = [];\n querySnapshot.forEach(function (doc) {\n users.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context23.abrupt(\"return\", users);\n case 16:\n _context23.prev = 16;\n _context23.t0 = _context23[\"catch\"](0);\n console.log(\"Error retrieving users by department: \", _context23.t0);\n throw _context23.t0;\n case 20:\n case \"end\":\n return _context23.stop();\n }\n }, _callee23, null, [[0, 16]]);\n }));\n}\n// TODO getTasksForUser!\n/**\n * Asynchronously retrieves an array of task documents from the database based on several filter and sorting criteria.\n * Filters include task ID, user ID and their responsibility status, and related improvement work ID.\n * Results can be sorted by date either in ascending or descending order.\n *\n * @param {Object} params - Parameters to filter and sort the task results.\n * @param {string} [params.taskId] - Optional task ID to filter the tasks.\n * @param {string} [params.userId] - Optional user ID to identify tasks related to a user.\n * @param {boolean} [params.isResponsibleFor] - Optional flag to filter tasks where the user is marked as responsible.\n * @param {string} [params.improvementWorkId] - Optional improvement work ID to filter tasks related to a specific improvement work.\n * @param {boolean} [params.ascendingDates=false] - Optional flag to sort tasks by date in ascending order; defaults to descending order.\n * @returns {Promise<any[]>} A promise that resolves to an array of task objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getTasks(_ref6) {\n var improvementWorkId = _ref6.improvementWorkId,\n stage = _ref6.stage,\n _ref6$ascendingDates = _ref6.ascendingDates,\n ascendingDates = _ref6$ascendingDates === void 0 ? false : _ref6$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {\n var collectionRef, constraints, q, querySnapshot, tasks;\n return _regeneratorRuntime().wrap(function _callee24$(_context24) {\n while (1) switch (_context24.prev = _context24.next) {\n case 0:\n _context24.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\n constraints = []; // FUTURE FEATURE: Filter on userHsaId AND improvementWork\n // if (userHsaId && isResponsibleFor !== undefined) {\n // constraints.push(\n // where(\"members\", \"array-contains\", {\n // userHsaId: userHsaId,\n // isResponsibleFor: isResponsibleFor,\n // })\n // );\n // }\n if (stage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"stage\", \"==\", stage));\n }\n if (improvementWorkId != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"startDate\", ascendingDates ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context24.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context24.sent;\n tasks = [];\n querySnapshot.forEach(function (doc) {\n tasks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context24.abrupt(\"return\", tasks);\n case 14:\n _context24.prev = 14;\n _context24.t0 = _context24[\"catch\"](0);\n console.log(\"Error retrieving task by department: \", _context24.t0);\n throw _context24.t0;\n case 18:\n case \"end\":\n return _context24.stop();\n }\n }, _callee24, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of unit documents from the database based on various filter criteria.\n * Filters can be applied based on unit ID, hospital ID, and unit name.\n * Additionally, results can be sorted by unit names in ascending or descending order.\n *\n * @param {Object} params - The parameters object containing filter and sorting options.\n * @param {string} [params.unitId] - Optional unit ID to filter the units.\n * @param {string} [params.hospitalId] - Optional hospital ID to filter units within a specific hospital.\n * @param {string} [params.name] - Optional name to filter units by a specific name.\n * @param {boolean} [params.ascendingUnitNames=false] - Optional flag to sort units by name in ascending order, defaults to descending.\n * @returns {Promise<any[]>} A promise that resolves to an array of unit objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUnits(_ref7) {\n var unitId = _ref7.unitId,\n hospitalId = _ref7.hospitalId,\n name = _ref7.name,\n _ref7$ascendingUnitNa = _ref7.ascendingUnitNames,\n ascendingUnitNames = _ref7$ascendingUnitNa === void 0 ? false : _ref7$ascendingUnitNa;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {\n var collectionRef, constraints, q, querySnapshot, units;\n return _regeneratorRuntime().wrap(function _callee25$(_context25) {\n while (1) switch (_context25.prev = _context25.next) {\n case 0:\n _context25.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\n constraints = [];\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", unitId));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"hospitalId\", \"==\", hospitalId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"name\", ascendingUnitNames ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context25.next = 9;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 9:\n querySnapshot = _context25.sent;\n units = [];\n querySnapshot.forEach(function (doc) {\n units.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context25.abrupt(\"return\", units);\n case 15:\n _context25.prev = 15;\n _context25.t0 = _context25[\"catch\"](0);\n console.log(\"Error retrieving units by hospitalId: \", _context25.t0);\n throw _context25.t0;\n case 19:\n case \"end\":\n return _context25.stop();\n }\n }, _callee25, null, [[0, 15]]);\n }));\n}\nfunction getImprovementWorksForUser(userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {\n var q, querySnapshot, improvementWorks, _iterator, _step, _doc, improvementWorkId, improvementWorkDoc;\n return _regeneratorRuntime().wrap(function _callee26$(_context26) {\n while (1) switch (_context26.prev = _context26.next) {\n case 0:\n _context26.prev = 0;\n console.log(\"Getting improvementworks for user: \", userHsaId);\n // Query the userImprovementWork collection for relations involving this user\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(userImprovementWorkCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)('userHsaId', '==', userHsaId));\n _context26.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 5:\n querySnapshot = _context26.sent;\n // Fetch each related improvementWork document\n improvementWorks = [];\n _iterator = _createForOfIteratorHelper(querySnapshot.docs);\n _context26.prev = 8;\n _iterator.s();\n case 10:\n if ((_step = _iterator.n()).done) {\n _context26.next = 19;\n break;\n }\n _doc = _step.value;\n improvementWorkId = _doc.data().improvementWorkId;\n _context26.next = 15;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 15:\n improvementWorkDoc = _context26.sent;\n improvementWorks.push(improvementWorkDoc);\n case 17:\n _context26.next = 10;\n break;\n case 19:\n _context26.next = 24;\n break;\n case 21:\n _context26.prev = 21;\n _context26.t0 = _context26[\"catch\"](8);\n _iterator.e(_context26.t0);\n case 24:\n _context26.prev = 24;\n _iterator.f();\n return _context26.finish(24);\n case 27:\n return _context26.abrupt(\"return\", improvementWorks);\n case 30:\n _context26.prev = 30;\n _context26.t1 = _context26[\"catch\"](0);\n console.error(\"Error getting improvement works for user: \", _context26.t1);\n throw _context26.t1;\n case 34:\n case \"end\":\n return _context26.stop();\n }\n }, _callee26, null, [[0, 30], [8, 21, 24, 27]]);\n }));\n}\nfunction getUsersForImprovementWork(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {\n var q, querySnapshot, users, _iterator2, _step2, _doc2, userHsaId, userDoc;\n return _regeneratorRuntime().wrap(function _callee27$(_context27) {\n while (1) switch (_context27.prev = _context27.next) {\n case 0:\n _context27.prev = 0;\n console.log(\"Getting users for improvementwork: \", improvementWorkId);\n // Query the userImprovementWork collection for relations involving this improvementWork\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(userImprovementWorkCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)('improvementWorkId', '==', improvementWorkId));\n _context27.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 5:\n querySnapshot = _context27.sent;\n // Fetch each related user document\n users = [];\n _iterator2 = _createForOfIteratorHelper(querySnapshot.docs);\n _context27.prev = 8;\n _iterator2.s();\n case 10:\n if ((_step2 = _iterator2.n()).done) {\n _context27.next = 19;\n break;\n }\n _doc2 = _step2.value;\n userHsaId = _doc2.data().userHsaId;\n _context27.next = 15;\n return getObjectById(\"users\", userHsaId);\n case 15:\n userDoc = _context27.sent;\n users.push(userDoc);\n case 17:\n _context27.next = 10;\n break;\n case 19:\n _context27.next = 24;\n break;\n case 21:\n _context27.prev = 21;\n _context27.t0 = _context27[\"catch\"](8);\n _iterator2.e(_context27.t0);\n case 24:\n _context27.prev = 24;\n _iterator2.f();\n return _context27.finish(24);\n case 27:\n return _context27.abrupt(\"return\", users);\n case 30:\n _context27.prev = 30;\n _context27.t1 = _context27[\"catch\"](0);\n console.error(\"Error getting users for improvementWork: \", _context27.t1);\n throw _context27.t1;\n case 34:\n case \"end\":\n return _context27.stop();\n }\n }, _callee27, null, [[0, 30], [8, 21, 24, 27]]);\n }));\n}\n// export getters to be able to use in other files\n\n////////////////////////////////////DELETING/////////////////////////////////////////////\n// delete an instance of a type\nfunction deleteInstance(docType, docId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee28$(_context28) {\n while (1) switch (_context28.prev = _context28.next) {\n case 0:\n _context28.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context28.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(docRef);\n case 4:\n console.log(\"\".concat(docType, \" deleted successfully.\"));\n _context28.next = 11;\n break;\n case 7:\n _context28.prev = 7;\n _context28.t0 = _context28[\"catch\"](0);\n console.error(\"Error deleting \".concat(docType, \":\"), _context28.t0);\n throw _context28.t0;\n case 11:\n case \"end\":\n return _context28.stop();\n }\n }, _callee28, null, [[0, 7]]);\n }));\n}\n// delete all instances of a type\nfunction deleteAllDocumentsInCollection(collectionName) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {\n var _this = this;\n var collectionRef, snapshot, deletePromises;\n return _regeneratorRuntime().wrap(function _callee30$(_context30) {\n while (1) switch (_context30.prev = _context30.next) {\n case 0:\n _context30.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionName);\n _context30.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n snapshot = _context30.sent;\n // Delete all documents in the collection\n deletePromises = snapshot.docs.map(function (doc) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {\n return _regeneratorRuntime().wrap(function _callee29$(_context29) {\n while (1) switch (_context29.prev = _context29.next) {\n case 0:\n _context29.next = 2;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(doc.ref);\n case 2:\n case \"end\":\n return _context29.stop();\n }\n }, _callee29);\n }));\n });\n _context30.next = 8;\n return Promise.all(deletePromises);\n case 8:\n console.log(\"All documents in the \".concat(collectionName, \" collection deleted successfully.\"));\n _context30.next = 15;\n break;\n case 11:\n _context30.prev = 11;\n _context30.t0 = _context30[\"catch\"](0);\n console.error(\"Error deleting all documents in \".concat(collectionName, \":\"), _context30.t0);\n throw _context30.t0;\n case 15:\n case \"end\":\n return _context30.stop();\n }\n }, _callee30, null, [[0, 11]]);\n }));\n}\n////////////////////////////////////UPDATING/////////////////////////////////////////////\n// update a field in an instance\nfunction updateInstance(docType, docId, updates) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee31$(_context31) {\n while (1) switch (_context31.prev = _context31.next) {\n case 0:\n _context31.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context31.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(docRef, updates);\n case 4:\n console.log(\"\".concat(docType, \" updated successfully.\"));\n _context31.next = 11;\n break;\n case 7:\n _context31.prev = 7;\n _context31.t0 = _context31[\"catch\"](0);\n console.error(\"Error updating \".concat(docType, \":\"), _context31.t0);\n throw _context31.t0;\n case 11:\n case \"end\":\n return _context31.stop();\n }\n }, _callee31, null, [[0, 7]]);\n }));\n}\n// changes the ongoing status of an improvement work. if ongoing it is paused, if if paused onging.\n// user must be a manager\nfunction startOrPauseImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee32$(_context32) {\n while (1) switch (_context32.prev = _context32.next) {\n case 0:\n _context32.prev = 0;\n _context32.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context32.sent;\n _context32.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context32.sent;\n if (!(!user || !user.manager)) {\n _context32.next = 11;\n break;\n }\n throw new Error(\"User can't change improvementWork status\");\n case 11:\n if (!improvementWork) {\n _context32.next = 18;\n break;\n }\n update = {\n ongoing: !improvementWork.ongoing\n };\n _context32.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n _context32.next = 19;\n break;\n case 18:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n case 19:\n _context32.next = 25;\n break;\n case 21:\n _context32.prev = 21;\n _context32.t0 = _context32[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context32.t0);\n throw _context32.t0;\n case 25:\n case \"end\":\n return _context32.stop();\n }\n }, _callee32, null, [[0, 21]]);\n }));\n}\nfunction changePatientRiskLevel(userId, improvementWorkId, patientRiskLevel) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee33$(_context33) {\n while (1) switch (_context33.prev = _context33.next) {\n case 0:\n _context33.prev = 0;\n _context33.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context33.sent;\n _context33.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context33.sent;\n if (!(!user || !user.manager)) {\n _context33.next = 11;\n break;\n }\n throw new Error(\"User can't change patientRiskLevel in improvement work\");\n case 11:\n if (!improvementWork) {\n _context33.next = 18;\n break;\n }\n update = {\n patientRiskLevel: patientRiskLevel\n };\n _context33.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n _context33.next = 19;\n break;\n case 18:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n case 19:\n _context33.next = 25;\n break;\n case 21:\n _context33.prev = 21;\n _context33.t0 = _context33[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context33.t0);\n throw _context33.t0;\n case 25:\n case \"end\":\n return _context33.stop();\n }\n }, _callee33, null, [[0, 21]]);\n }));\n}\n// finalizes the improvement work. ongoing is set to false.\n// user must be a manager\nfunction finalizeImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {\n var user, update;\n return _regeneratorRuntime().wrap(function _callee34$(_context34) {\n while (1) switch (_context34.prev = _context34.next) {\n case 0:\n _context34.prev = 0;\n _context34.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context34.sent;\n if (!(!user || !user.manager)) {\n _context34.next = 8;\n break;\n }\n throw new Error(\"User can't finalize improvementWork status\");\n case 8:\n update = {\n completed: true,\n ongoing: false\n };\n _context34.next = 11;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 11:\n _context34.next = 16;\n break;\n case 13:\n _context34.prev = 13;\n _context34.t0 = _context34[\"catch\"](0);\n console.log(_context34.t0);\n case 16:\n case \"end\":\n return _context34.stop();\n }\n }, _callee34, null, [[0, 13]]);\n }));\n}\n\n//////////////////////////////// for later sprint\n//function add_upvotes\n//function add_notes\n//function add_intrested_users\n\n//# sourceURL=webpack://c3/./client/Database/database.js?"); /***/ }), @@ -106,7 +106,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \***********************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n//Globala varibler för projekledare & Users\nvar selectedEmployees = [];\nfunction loadEmployees() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var selectProjectLeaderHTML, selectEmployeeHTML, allUsers, allProjectLeaders, selectHospitalHTML, selectUnitHTML, allHospitals, allUnits;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n selectProjectLeaderHTML = $('#projectLeader'); // loads the select type from html\n selectEmployeeHTML = $('#selectEmployee'); // loads the select type from html\n _context.next = 4;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 4:\n allUsers = _context.sent;\n _context.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 7:\n allProjectLeaders = _context.sent;\n //here you can put constraints\n allUsers.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(\"\".concat(user.firstName) + \" \" + \"\".concat(user.lastName));\n selectEmployeeHTML.append(optionElement);\n });\n allProjectLeaders.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(\"\".concat(user.firstName) + \" \" + \"\".concat(user.lastName));\n selectProjectLeaderHTML.append(optionElement);\n });\n selectHospitalHTML = $('#selectHospital'); // loads the select type from html\n selectUnitHTML = $('#selectDepartment'); // loads the select type from html\n _context.next = 14;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({});\n case 14:\n allHospitals = _context.sent;\n _context.next = 17;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({});\n case 17:\n allUnits = _context.sent;\n //here you can put constraints\n console.log(allHospitals);\n console.log(allUnits);\n allHospitals.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(user.name);\n selectHospitalHTML.append(optionElement);\n });\n allUnits.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(user.name);\n selectUnitHTML.append(optionElement);\n });\n case 22:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction assignedEmployer() {\n var employeeList = $('#selectEmployee');\n var selectedBox = $('#selectedEmployees');\n var selectedOption = employeeList.find('option:selected');\n var selectedText = selectedOption.text();\n selectedBox.append(createAssignedEmployeeDesign(selectedText, selectedOption, employeeList));\n selectedEmployees.push(String(selectedOption.val()));\n employeeList.find('option:selected').remove();\n employeeList.prop('selectedIndex', 0);\n}\nfunction createAssignedEmployeeDesign(s, x, employeeList) {\n var container = $('<div>').addClass('selectedEmployeeBubble'); // Create a div element and add a class\n var textSpan = $('<span>').addClass('ideaCardFont').text(s); // Create a span element, set text, and add a class\n var deleteButton = $('<button>').addClass('employeeDeleteButton').text('X'); // Create a button element, set text, and add a class\n deleteButton.on('click', function () {\n container.remove();\n employeeList.append(x);\n employeeList.prop('selectedIndex', 0);\n //removes from global list\n var index = selectedEmployees.indexOf(String(x.val()));\n if (index !== -1) {\n selectedEmployees.splice(index, 1);\n }\n });\n container.append(textSpan, deleteButton); // Append the span and button to the div container\n return container;\n}\n//Functions to load the page\nfunction loadPage(id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var container, linkelementCSS, linkQuestionCSS, linkActivitycardCSS, scriptElement, generatedHTML, generatedElement;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n container = document.querySelector('#container-fluid');\n if (container) {\n _context2.next = 3;\n break;\n }\n return _context2.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n linkelementCSS = document.createElement('link');\n linkelementCSS.rel = 'styleSheet';\n linkelementCSS.href = 'initiateForbattringsarbete/initiateIdea.css';\n document.head.appendChild(linkelementCSS);\n linkQuestionCSS = document.createElement('link');\n linkQuestionCSS.rel = 'styleSheet';\n linkQuestionCSS.href = 'Make_Suggestion_Code/makeSuggestion.css';\n document.head.appendChild(linkQuestionCSS);\n linkActivitycardCSS = document.createElement(\"link\");\n linkActivitycardCSS.rel = \"stylesheet\";\n linkActivitycardCSS.href = 'Activity_card_code/activitity_card.css';\n document.head.appendChild(linkActivitycardCSS);\n scriptElement = document.createElement(\"script\");\n scriptElement.src = \"../dist/initiateIdea.bundle.js\";\n container.appendChild(scriptElement);\n _context2.next = 20;\n return generateQuestionHTML(id);\n case 20:\n generatedHTML = _context2.sent;\n generatedElement = document.createRange().createContextualFragment(generatedHTML);\n fetch('initiateForbattringsarbete/initiateIdea.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.initiateIdeaWholePage');\n //Eventlistenerbuttons:\n var createButton = document.getElementById('createProjectFromSuggestionButton');\n var selectEmployeeButton = document.getElementById('selectEmployee');\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n //adds an event listener for the initiate page \n if (target.id === \"createProjectFromSuggestionButton\") {\n createProject();\n }\n });\n document.addEventListener(\"change\", function (event) {\n var target = event.target;\n //adds an event listener for the initiate page \n if (target.id === \"selectEmployee\") {\n assignedEmployer();\n }\n });\n if (specificElement) {\n // Insert the generated element before the specific element\n container.insertBefore(generatedElement, container.firstChild);\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n selectedEmployees = []; //clears the global employee list\n loadEmployees();\n }\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n case 23:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction createProject() {\n var inputSelectProjectleaderInput = document.getElementById(\"projectLeader\");\n var selectDepartment = document.getElementById(\"selectHospital\");\n var selectUnit = document.getElementById(\"selectDepartment\");\n var inputBoxFormNameInput = document.getElementById(\"inputBoxFormNameInput\");\n var inputBoxFormAreaInput = document.getElementById(\"inputBoxFormAreaInput\");\n var inputBoxFormContentInput = document.getElementById(\"inputBoxFormContentInput\");\n var inputBoxFormPurposeInput = document.getElementById(\"inputBoxFormPurposeInput\");\n var inputBoxFormMeasureInput = document.getElementById(\"inputBoxFormMeasureInput\");\n var inputBoxFormIdeasInput = document.getElementById(\"inputBoxFormIdeasInput\");\n alert(\"Kul att du försöker! Detta är inte klart ännu... \\n Däremot är värdena följande: \\n\" + inputSelectProjectleaderInput.options[inputSelectProjectleaderInput.selectedIndex].value + \"\\n\" + selectDepartment.options[selectDepartment.selectedIndex].value + \"\\n\" + selectUnit.options[selectUnit.selectedIndex].value + \"\\n\" + selectedEmployees + \"\\n\" + inputBoxFormNameInput.value + \"\\n\" + inputBoxFormAreaInput.value + \"\\n\" + inputBoxFormContentInput.value + \"\\n\" + inputBoxFormPurposeInput.value + \"\\n\" + inputBoxFormMeasureInput.value + \"\\n\" + inputBoxFormIdeasInput.value + \"\\n\");\n console.log(selectedEmployees);\n}\nfunction generateQuestionHTML(suggestionID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var suggestionData;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"suggestion\", suggestionID);\n case 2:\n suggestionData = _context3.sent;\n return _context3.abrupt(\"return\", \"\\n <div class=\\\"filter-section\\\">\\n <div class=\\\"makeSuggestionFilterButtons\\\">\\n <select name=\\\"department\\\" id=\\\"selectHospital\\\" class=\\\"filterButtons\\\"> </select>\\n\\n <select name=\\\"section\\\" id=\\\"selectDepartment\\\" class=\\\"filterButtons\\\">\\n </select>\\n\\n </div>\\n</div>\\n\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">Rubrik *</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormName\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormNameInput\\\"\\n placeholder=\\\"Vad vill du kalla ditt f\\xF6rslag?\\\"\\n value = \\\"\" + suggestionData.name + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Vilket \\xE4r omr\\xE5det f\\xF6r f\\xF6rb\\xE4ttringen? *\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormArea\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormAreaInput\\\"\\n placeholder=\\\"Ber\\xE4tta om omr\\xE5de ditt f\\xF6rslag hade f\\xF6rb\\xE4ttrat.\\\"\\n value = \\\"\" + suggestionData.area + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\" id=\\\"middleShadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">Bakgrund *</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormContent\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormContentInput\\\"\\n placeholder=\\\"Beskriv problemet\\\"\\n value = \\\"\" + suggestionData.content + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Vilket syfte har f\\xF6rb\\xE4ttringen? *\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormPurpose\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormPurposeInput\\\"\\n placeholder=\\\"Vad ska \\xE5stadkommas och varf\\xF6r? Kom ih\\xE5g att f\\xE5 med patientperspektivet\\\"\\n value = \\\"\" + suggestionData.purpose + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Hur ska det m\\xE4tas?\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormMeasure\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormMeasureInput\\\"\\n placeholder=\\\"Hur vet vi att en f\\xF6r\\xE4ndring \\xE4r en f\\xF6rb\\xE4ttring?\\\"\\n value = \\\"\" + suggestionData.measure + \"\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">Id\\xE9er</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeas\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeasInput\\\"\\n placeholder=\\\"Vilka f\\xF6r\\xE4ndringar kan pr\\xF6vas f\\xF6r att uppn\\xE5 en f\\xF6rb\\xE4ttring?\\\"\\n value = \\\"\" + suggestionData.ideas + \"\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n<button id=\\\"createProjectFromSuggestionButton\\\">Skapa f\\xF6rb\\xE4ttringsarbete!</button>\");\n case 4:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/initiateForbattringsarbete/initiateIdea.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n//Globala varibler för projekledare & Users\nvar selectedEmployees = [];\nfunction loadEmployees() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var selectProjectLeaderHTML, selectEmployeeHTML, allUsers, allProjectLeaders, selectHospitalHTML, selectUnitHTML, allHospitals, allUnits;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n selectProjectLeaderHTML = $('#projectLeader'); // loads the select type from html\n selectEmployeeHTML = $('#selectEmployee'); // loads the select type from html\n _context.next = 4;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 4:\n allUsers = _context.sent;\n _context.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 7:\n allProjectLeaders = _context.sent;\n //here you can put constraints\n allUsers.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(\"\".concat(user.firstName) + \" \" + \"\".concat(user.lastName));\n selectEmployeeHTML.append(optionElement);\n });\n allProjectLeaders.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(\"\".concat(user.firstName) + \" \" + \"\".concat(user.lastName));\n selectProjectLeaderHTML.append(optionElement);\n });\n selectHospitalHTML = $('#selectHospital'); // loads the select type from html\n selectUnitHTML = $('#selectDepartment'); // loads the select type from html\n _context.next = 14;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({});\n case 14:\n allHospitals = _context.sent;\n _context.next = 17;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({});\n case 17:\n allUnits = _context.sent;\n //here you can put constraints\n console.log(allHospitals);\n console.log(allUnits);\n allHospitals.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(user.name);\n selectHospitalHTML.append(optionElement);\n });\n allUnits.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(user.name);\n selectUnitHTML.append(optionElement);\n });\n case 22:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction assignedEmployer() {\n var employeeList = $('#selectEmployee');\n var selectedBox = $('#selectedEmployees');\n var selectedOption = employeeList.find('option:selected');\n var selectedText = selectedOption.text();\n selectedBox.append(createAssignedEmployeeDesign(selectedText, selectedOption, employeeList));\n selectedEmployees.push(String(selectedOption.val()));\n employeeList.find('option:selected').remove();\n employeeList.prop('selectedIndex', 0);\n}\nfunction createAssignedEmployeeDesign(s, x, employeeList) {\n var container = $('<div>').addClass('selectedEmployeeBubble'); // Create a div element and add a class\n var textSpan = $('<span>').addClass('ideaCardFont').text(s); // Create a span element, set text, and add a class\n var deleteButton = $('<button>').addClass('employeeDeleteButton').text('X'); // Create a button element, set text, and add a class\n deleteButton.on('click', function () {\n container.remove();\n employeeList.append(x);\n employeeList.prop('selectedIndex', 0);\n //removes from global list\n var index = selectedEmployees.indexOf(String(x.val()));\n if (index !== -1) {\n selectedEmployees.splice(index, 1);\n }\n });\n container.append(textSpan, deleteButton); // Append the span and button to the div container\n return container;\n}\n//Functions to load the page\nfunction clearFromEventListeners(container) {\n var clonedContainer = container.cloneNode(true);\n container.replaceWith(clonedContainer);\n console.log(\"cleared\");\n}\nfunction loadPage(id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var container, linkelementCSS, linkQuestionCSS, linkActivitycardCSS, scriptElement, generatedHTML, generatedElement;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n console.log(id);\n container = document.querySelector('#container-fluid');\n if (container) {\n _context2.next = 4;\n break;\n }\n return _context2.abrupt(\"return\");\n case 4:\n // Stop if the container isn't found\n linkelementCSS = document.createElement('link');\n linkelementCSS.rel = 'styleSheet';\n linkelementCSS.href = 'initiateForbattringsarbete/initiateIdea.css';\n document.head.appendChild(linkelementCSS);\n linkQuestionCSS = document.createElement('link');\n linkQuestionCSS.rel = 'styleSheet';\n linkQuestionCSS.href = 'Make_Suggestion_Code/makeSuggestion.css';\n document.head.appendChild(linkQuestionCSS);\n linkActivitycardCSS = document.createElement(\"link\");\n linkActivitycardCSS.rel = \"stylesheet\";\n linkActivitycardCSS.href = 'Activity_card_code/activitity_card.css';\n document.head.appendChild(linkActivitycardCSS);\n scriptElement = document.createElement(\"script\");\n scriptElement.src = \"../dist/initiateIdea.bundle.js\";\n container.appendChild(scriptElement);\n _context2.next = 21;\n return generateQuestionHTML(id);\n case 21:\n generatedHTML = _context2.sent;\n generatedElement = document.createRange().createContextualFragment(generatedHTML);\n fetch('initiateForbattringsarbete/initiateIdea.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.initiateIdeaWholePage');\n //Eventlistenerbuttons:\n var createButton = document.getElementById('createProjectFromSuggestionButton');\n var selectEmployeeButton = document.getElementById('selectEmployee');\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n //adds an event listener for the initiate page \n if (target.id === \"createProjectFromSuggestionButton\") {\n createProject();\n }\n });\n document.addEventListener(\"change\", function (event) {\n var target = event.target;\n //adds an event listener for the initiate page \n if (target.id === \"selectEmployee\") {\n assignedEmployer();\n }\n });\n if (specificElement) {\n // Insert the generated element before the specific element\n container.insertBefore(generatedElement, container.firstChild);\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n selectedEmployees = []; //clears the global employee list\n loadEmployees();\n }\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n case 24:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction createProject() {\n var inputSelectProjectleaderInput = document.getElementById(\"projectLeader\");\n var selectDepartment = document.getElementById(\"selectHospital\");\n var selectUnit = document.getElementById(\"selectDepartment\");\n var inputBoxFormNameInput = document.getElementById(\"inputBoxFormNameInput\");\n var inputBoxFormAreaInput = document.getElementById(\"inputBoxFormAreaInput\");\n var inputBoxFormContentInput = document.getElementById(\"inputBoxFormContentInput\");\n var inputBoxFormPurposeInput = document.getElementById(\"inputBoxFormPurposeInput\");\n var inputBoxFormMeasureInput = document.getElementById(\"inputBoxFormMeasureInput\");\n var inputBoxFormIdeasInput = document.getElementById(\"inputBoxFormIdeasInput\");\n alert(\"Kul att du försöker! Detta är inte klart ännu... \\n Däremot är värdena följande: \\n\" + inputSelectProjectleaderInput.options[inputSelectProjectleaderInput.selectedIndex].value + \"\\n\" + selectDepartment.options[selectDepartment.selectedIndex].value + \"\\n\" + selectUnit.options[selectUnit.selectedIndex].value + \"\\n\" + selectedEmployees + \"\\n\" + inputBoxFormNameInput.value + \"\\n\" + inputBoxFormAreaInput.value + \"\\n\" + inputBoxFormContentInput.value + \"\\n\" + inputBoxFormPurposeInput.value + \"\\n\" + inputBoxFormMeasureInput.value + \"\\n\" + inputBoxFormIdeasInput.value + \"\\n\");\n console.log(selectedEmployees);\n}\nfunction generateQuestionHTML(suggestionID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var suggestionData;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"suggestion\", suggestionID);\n case 2:\n suggestionData = _context3.sent;\n return _context3.abrupt(\"return\", \"\\n <div class=\\\"filter-section\\\">\\n <div class=\\\"makeSuggestionFilterButtons\\\">\\n <select name=\\\"department\\\" id=\\\"selectHospital\\\" class=\\\"filterButtons\\\"> </select>\\n\\n <select name=\\\"section\\\" id=\\\"selectDepartment\\\" class=\\\"filterButtons\\\">\\n </select>\\n\\n </div>\\n</div>\\n\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">Rubrik *</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormName\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormNameInput\\\"\\n placeholder=\\\"Vad vill du kalla ditt f\\xF6rslag?\\\"\\n value = \\\"\" + suggestionData.name + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Vilket \\xE4r omr\\xE5det f\\xF6r f\\xF6rb\\xE4ttringen? *\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormArea\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormAreaInput\\\"\\n placeholder=\\\"Ber\\xE4tta om omr\\xE5de ditt f\\xF6rslag hade f\\xF6rb\\xE4ttrat.\\\"\\n value = \\\"\" + suggestionData.area + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\" id=\\\"middleShadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">Bakgrund *</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormContent\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormContentInput\\\"\\n placeholder=\\\"Beskriv problemet\\\"\\n value = \\\"\" + suggestionData.content + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Vilket syfte har f\\xF6rb\\xE4ttringen? *\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormPurpose\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormPurposeInput\\\"\\n placeholder=\\\"Vad ska \\xE5stadkommas och varf\\xF6r? Kom ih\\xE5g att f\\xE5 med patientperspektivet\\\"\\n value = \\\"\" + suggestionData.purpose + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Hur ska det m\\xE4tas?\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormMeasure\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormMeasureInput\\\"\\n placeholder=\\\"Hur vet vi att en f\\xF6r\\xE4ndring \\xE4r en f\\xF6rb\\xE4ttring?\\\"\\n value = \\\"\" + suggestionData.measure + \"\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">Id\\xE9er</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeas\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeasInput\\\"\\n placeholder=\\\"Vilka f\\xF6r\\xE4ndringar kan pr\\xF6vas f\\xF6r att uppn\\xE5 en f\\xF6rb\\xE4ttring?\\\"\\n value = \\\"\" + suggestionData.ideas + \"\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n<button id=\\\"createProjectFromSuggestionButton\\\">Skapa f\\xF6rb\\xE4ttringsarbete!</button>\");\n case 4:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/initiateForbattringsarbete/initiateIdea.js?"); /***/ }), diff --git a/client/dist/login.bundle.js b/client/dist/login.bundle.js index f2ae46fdfcf16cf798afdbb143fed94f6ca424c2..60f87f9ad392ff8a64400df30dffa6ddb362827a 100644 --- a/client/dist/login.bundle.js +++ b/client/dist/login.bundle.js @@ -106,7 +106,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \*************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addDocumentToImprovementWork: () => (/* binding */ addDocumentToImprovementWork),\n/* harmony export */ addMemberToImprovementWork: () => (/* binding */ addMemberToImprovementWork),\n/* harmony export */ addMemberToTask: () => (/* binding */ addMemberToTask),\n/* harmony export */ addNoteToUser: () => (/* binding */ addNoteToUser),\n/* harmony export */ auth: () => (/* binding */ auth),\n/* harmony export */ changePatientRiskLevel: () => (/* binding */ changePatientRiskLevel),\n/* harmony export */ createComment: () => (/* binding */ createComment),\n/* harmony export */ createHospital: () => (/* binding */ createHospital),\n/* harmony export */ createImprovementWork: () => (/* binding */ createImprovementWork),\n/* harmony export */ createSuggestion: () => (/* binding */ createSuggestion),\n/* harmony export */ createTaskOnImprovementWork: () => (/* binding */ createTaskOnImprovementWork),\n/* harmony export */ createUnit: () => (/* binding */ createUnit),\n/* harmony export */ createUser: () => (/* binding */ createUser),\n/* harmony export */ createdDocumentInKnowledgeBank: () => (/* binding */ createdDocumentInKnowledgeBank),\n/* harmony export */ db: () => (/* binding */ db),\n/* harmony export */ deleteAllDocumentsInCollection: () => (/* binding */ deleteAllDocumentsInCollection),\n/* harmony export */ deleteInstance: () => (/* binding */ deleteInstance),\n/* harmony export */ finalizeImprovementWork: () => (/* binding */ finalizeImprovementWork),\n/* harmony export */ getComments: () => (/* binding */ getComments),\n/* harmony export */ getHospitals: () => (/* binding */ getHospitals),\n/* harmony export */ getImprovementWorks: () => (/* binding */ getImprovementWorks),\n/* harmony export */ getObject: () => (/* binding */ getObject),\n/* harmony export */ getObjectById: () => (/* binding */ getObjectById),\n/* harmony export */ getSuggestions: () => (/* binding */ getSuggestions),\n/* harmony export */ getTasks: () => (/* binding */ getTasks),\n/* harmony export */ getUnits: () => (/* binding */ getUnits),\n/* harmony export */ getUsers: () => (/* binding */ getUsers),\n/* harmony export */ startOrPauseImprovementWork: () => (/* binding */ startOrPauseImprovementWork),\n/* harmony export */ updateInstance: () => (/* binding */ updateInstance),\n/* harmony export */ upvoteComment: () => (/* binding */ upvoteComment),\n/* harmony export */ upvoteSuggestion: () => (/* binding */ upvoteSuggestion)\n/* harmony export */ });\n/* harmony import */ var firebase_app__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! firebase/app */ \"./node_modules/firebase/app/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_firestore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! firebase/firestore */ \"./node_modules/firebase/firestore/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_auth__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! firebase/auth */ \"./node_modules/firebase/auth/dist/esm/index.esm.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nvar firebaseConfig = {\n apiKey: \"AIzaSyDqkaVZMr11J4mfnR0auqoQilZyPfyD-x4\",\n authDomain: \"c3solutions-dc109.firebaseapp.com\",\n projectId: \"c3solutions-dc109\",\n storageBucket: \"c3solutions-dc109.appspot.com\",\n messagingSenderId: \"902143402555\",\n appId: \"1:902143402555:web:29213e81de0a0cba38b21e\"\n};\nvar app = (0,firebase_app__WEBPACK_IMPORTED_MODULE_0__.initializeApp)(firebaseConfig);\nvar auth = (0,firebase_auth__WEBPACK_IMPORTED_MODULE_2__.getAuth)();\nvar db = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getFirestore)(app);\nvar userCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\nvar unitCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\nvar improvementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\nvar taskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\nvar hospitalCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\nvar suggestionCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\nvar knowledgeDocumentCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"knowledgeDocument\");\n////////////////////////////////////////Setters///////////////////////////////////////////////////////////////////\n// Function to create user a new user in database\n// takes in userId, unitId, firstname, lastname, email and password as string\n// throws error if transaction failed\nfunction createUser(hsaId, unitId, firstName, lastName, email, manager, uid) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var userRef, unitRef;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, hsaId);\n _context.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(userRef, {\n id: userRef.id,\n uid: uid,\n unitId: unitId,\n firstName: firstName,\n lastName: lastName,\n email: email,\n improvementWorks: [],\n tasks: [],\n manager: manager\n });\n case 4:\n // Atomically add user to unit.\n unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection, unitId);\n _context.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(unitRef, {\n members: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userRef.id)\n });\n case 7:\n _context.next = 12;\n break;\n case 9:\n _context.prev = 9;\n _context.t0 = _context[\"catch\"](0);\n console.log(_context.t0);\n case 12:\n case \"end\":\n return _context.stop();\n }\n }, _callee, null, [[0, 9]]);\n }));\n}\n//Adds a new improvementWork to the database\n// takes in Id, name, currentStage in PDSA, content, unitId refers to as string and if completed as boolean\n// throws error if transaction failed\nfunction createImprovementWork(id, name, currentStage, content,\n// Är detta description bör detta förtydligas. \nunitId, purpose,\n//Bör tas bort motsvaras av p2- mål med projektet\npatientRiskLevel, area,\n// patientRiskLevel: \"Green\" | \"Blue\" | \"Orange\" | \"Red\"\n//Questions in planning stage\np1, p2, p3, p4, p5, p6, p7,\n//Questions in Doing (G) stage\ng1, g2, g3, g4, g5,\n//Questions in stydy stage\ns1, s2, s3,\n//Questions in acting stage\na1, a2, a3, a4) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var improvementWorkRef;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.prev = 0;\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, id);\n _context2.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(improvementWorkRef, {\n id: improvementWorkRef.id,\n currentStage: currentStage,\n name: name,\n content: content,\n purpose: purpose,\n dateStarted: new Date(),\n unitId: unitId,\n completed: false,\n ongoing: false,\n tasks: [],\n members: [],\n patientRiskLevel: patientRiskLevel,\n area: area,\n p1: p1,\n p2: p2,\n p3: p3,\n p4: p4,\n p5: p5,\n p6: p6,\n p7: p7,\n g1: g1,\n g2: g2,\n g3: g3,\n g4: g4,\n g5: g5,\n s1: s1,\n s2: s2,\n s3: s3,\n a1: a1,\n a2: a2,\n a3: a3,\n a4: a4\n });\n case 4:\n _context2.next = 10;\n break;\n case 6:\n _context2.prev = 6;\n _context2.t0 = _context2[\"catch\"](0);\n console.log(\"Error creating improvementWork: \", _context2.t0);\n throw _context2.t0;\n case 10:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, null, [[0, 6]]);\n }));\n}\n//create task to improvementWork\n// takes in improvementWorkId, name, deadline date, start date, stage in PDSA and content as string\n// throws error if transaction failed\nfunction createTaskOnImprovementWork(taskId, improvementWorkId, name, deadlineDate, startDate, stage, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var ref, improvementWorkRef;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.prev = 0;\n ref = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection, taskId);\n _context3.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(ref, {\n id: ref.id,\n improvementWorkId: improvementWorkId,\n name: name,\n deadlineDate: deadlineDate,\n startDate: startDate,\n stage: stage,\n content: content,\n members: []\n });\n case 4:\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, improvementWorkId); // Atomically add task to the tasks array field.\n _context3.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(improvementWorkRef, {\n tasks: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(taskId)\n });\n case 7:\n _context3.next = 13;\n break;\n case 9:\n _context3.prev = 9;\n _context3.t0 = _context3[\"catch\"](0);\n console.log(\"Error creating task: \", _context3.t0);\n throw _context3.t0;\n case 13:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, null, [[0, 9]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction createdDocumentInKnowledgeBank(documentUrl, name) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n _context4.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(knowledgeDocumentCollection);\n _context4.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n name: name\n });\n case 4:\n _context4.next = 10;\n break;\n case 6:\n _context4.prev = 6;\n _context4.t0 = _context4[\"catch\"](0);\n console.log(\"Error adding document: \", _context4.t0);\n throw _context4.t0;\n case 10:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4, null, [[0, 6]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction addDocumentToImprovementWork(documentUrl, name, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var improvementWorkRef, docRef;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n _context5.prev = 0;\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, improvementWorkId);\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkRef, \"documents\");\n _context5.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n timestamp: new Date(),\n name: name\n });\n case 5:\n _context5.next = 11;\n break;\n case 7:\n _context5.prev = 7;\n _context5.t0 = _context5[\"catch\"](0);\n console.log(\"Error adding document: \", _context5.t0);\n throw _context5.t0;\n case 11:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5, null, [[0, 7]]);\n }));\n}\n//add a member to a improvementWork\n// takes in id, users HSAid, improvementWorks id as string and if is owner, is responsible as boolean\n// throws error if transaction failed\nfunction addMemberToImprovementWork(userHsaId, improvementWorkId, isOwner, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var improvementWorkRef, userRef;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n _context6.prev = 0;\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, improvementWorkId); // return;\n // Atomically update the members array in the improvementWork document\n _context6.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(improvementWorkRef, {\n members: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)({\n userHsaId: userHsaId,\n isOwner: isOwner,\n isResponsibleFor: isResponsibleFor\n })\n });\n case 4:\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, userHsaId); // Atomically add improvementWork to user\n _context6.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(userRef, {\n improvementWorks: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)({\n improvementWorkId: improvementWorkId,\n isOwner: isOwner,\n isResponsibleFor: isResponsibleFor\n })\n });\n case 7:\n _context6.next = 13;\n break;\n case 9:\n _context6.prev = 9;\n _context6.t0 = _context6[\"catch\"](0);\n console.log(\"Error adding member: \", _context6.t0);\n throw _context6.t0;\n case 13:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6, null, [[0, 9]]);\n }));\n}\n//create a hospital\n// takes in ID, name as string\n// throws error if transaction failed\nfunction createHospital(hospitalId,\n// should be auto?\nname) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var ref;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.prev = 0;\n ref = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection, hospitalId);\n _context7.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(ref, {\n id: ref.id,\n name: name,\n units: []\n });\n case 4:\n _context7.next = 10;\n break;\n case 6:\n _context7.prev = 6;\n _context7.t0 = _context7[\"catch\"](0);\n console.log(\"Error creating hospital: \", _context7.t0);\n throw _context7.t0;\n case 10:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7, null, [[0, 6]]);\n }));\n}\n//create a unit\n// takes in id, hospitals id and name as string\n// throws error if transaction failed\nfunction createUnit(unitId,\n//should be auto?\nhospitalId, name) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var unitRef, hospitalRef;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n _context8.prev = 0;\n unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection, unitId);\n _context8.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(unitRef, {\n id: unitRef.id,\n hospitalId: hospitalId,\n name: name,\n members: []\n });\n case 4:\n // Atomically add unit to hospital.\n hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection, hospitalId);\n _context8.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(hospitalRef, {\n units: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(unitRef.id)\n });\n case 7:\n _context8.next = 13;\n break;\n case 9:\n _context8.prev = 9;\n _context8.t0 = _context8[\"catch\"](0);\n console.log(\"Error creating unit: \", _context8.t0);\n throw _context8.t0;\n case 13:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8, null, [[0, 9]]);\n }));\n}\n//adds a member to task\n// takes in ID, the added members hsaId, task id as string and if person is responsible as boolean\n// throws error if transaction failed\nfunction addMemberToTask(userHsaId, taskId, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var taskRef, userRef;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n _context9.prev = 0;\n // Atomically add a member to task.\n taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection, taskId);\n _context9.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(taskRef, {\n members: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)({\n userHsaId: userHsaId,\n isResponsibleFor: isResponsibleFor\n })\n });\n case 4:\n // Atomically add a task to user.\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, userHsaId);\n _context9.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(userRef, {\n tasks: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)({\n taskId: taskId,\n isResponsibleFor: isResponsibleFor\n })\n });\n case 7:\n _context9.next = 13;\n break;\n case 9:\n _context9.prev = 9;\n _context9.t0 = _context9[\"catch\"](0);\n console.log(\"Error adding member: \", _context9.t0);\n throw _context9.t0;\n case 13:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9, null, [[0, 9]]);\n }));\n}\n//creates a suggestion\n// takes in ID, the creators hsaId, name, content and the responding unitId as string\n// throws error if transaction failed\nfunction createSuggestion(id, creatorHsaId, name, area, content, purpose, measure, ideas,\n//need: boolean,\nunitId, departmentId, isPublic) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var suggestionRef, commentCollection;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n _context10.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, id);\n _context10.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(suggestionRef, {\n id: suggestionRef.id,\n creatorHsaId: creatorHsaId,\n name: name,\n area: area,\n content: content,\n purpose: purpose,\n measure: measure,\n ideas: ideas,\n //need: need,\n unitId: unitId,\n departmentId: departmentId,\n \"public\": isPublic,\n upvotes: [],\n comments: [],\n dateCreated: new Date()\n });\n case 4:\n _context10.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\");\n case 6:\n commentCollection = _context10.sent;\n _context10.next = 9;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(commentCollection);\n case 9:\n _context10.next = 15;\n break;\n case 11:\n _context10.prev = 11;\n _context10.t0 = _context10[\"catch\"](0);\n console.log(\"Error creating suggestion: \", _context10.t0);\n throw _context10.t0;\n case 15:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10, null, [[0, 11]]);\n }));\n}\n// Upvote a suggestion for a user\n// takes in suggestion id, user HSAid\n// returns error if transaction failed\nfunction upvoteSuggestion(suggestionId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var suggestionRef;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n _context11.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId); // Atomically add a update to the upvote array field.\n _context11.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(suggestionRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 4:\n _context11.next = 10;\n break;\n case 6:\n _context11.prev = 6;\n _context11.t0 = _context11[\"catch\"](0);\n console.log(\"Error upvoting suggestion: \", _context11.t0);\n throw _context11.t0;\n case 10:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11, null, [[0, 6]]);\n }));\n}\n//creates a comment\n// takes in commenters id, suggestion id and content as string\n// throws error if transaction failed\nfunction createComment(\n// change to subcollection\ncommenterHsaId, suggestionId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var suggestionRef, commentCollection, commentRef;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n _context12.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context12.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\");\n case 4:\n commentCollection = _context12.sent;\n _context12.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(commentCollection);\n case 7:\n commentRef = _context12.sent;\n _context12.next = 10;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(commentRef, {\n id: commentRef.id,\n commenterHsaId: commenterHsaId,\n content: content,\n dateCreated: new Date(),\n upvotes: []\n });\n case 10:\n _context12.next = 16;\n break;\n case 12:\n _context12.prev = 12;\n _context12.t0 = _context12[\"catch\"](0);\n console.log(\"Error creating comment: \", _context12.t0);\n throw _context12.t0;\n case 16:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12, null, [[0, 12]]);\n }));\n}\n// Upvote a comment for a user\n// takes in suggestionId, commentId and userId as strings\n// return error if transaction failed\nfunction upvoteComment(suggestionId, commentId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var suggestionRef, commentRef;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n _context13.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n commentRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionRef, \"comment\", commentId); // Atomically add a update to the upvote array field.\n _context13.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(commentRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 5:\n _context13.next = 11;\n break;\n case 7:\n _context13.prev = 7;\n _context13.t0 = _context13[\"catch\"](0);\n console.log(\"Error upvoting comment: \", _context13.t0);\n throw _context13.t0;\n case 11:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13, null, [[0, 7]]);\n }));\n}\n//add a note to a user\n// takes in userHsaId and content as string\n// throws error if transaction failed\nfunction addNoteToUser(userHsaId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var userRef, docRef;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n _context14.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, userHsaId);\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userRef, \"notes\");\n _context14.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n content: content,\n dateCreated: new Date()\n });\n case 5:\n _context14.next = 11;\n break;\n case 7:\n _context14.prev = 7;\n _context14.t0 = _context14[\"catch\"](0);\n console.log(\"Error adding document: \", _context14.t0);\n throw _context14.t0;\n case 11:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14, null, [[0, 7]]);\n }));\n}\n// export to setters to be able to use in other files\n\n//////////////////////////////////////////////GETTERS/////////////////////////////////////////////////////////////////////\n// Get any object\n// input is the database type as a string.\n// output is the whole collection of that type.\nfunction getObject(collectionPath) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n var collectionRef, querySnapshot, result;\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n _context15.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionPath);\n _context15.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n querySnapshot = _context15.sent;\n result = [];\n querySnapshot.forEach(function (doc) {\n result.push(doc.data());\n });\n return _context15.abrupt(\"return\", result);\n case 10:\n _context15.prev = 10;\n _context15.t0 = _context15[\"catch\"](0);\n console.error(\"Error getting collection data\", _context15.t0);\n throw _context15.t0;\n case 14:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15, null, [[0, 10]]);\n }));\n}\n/**\n * Asynchronously retrieves a single document object from the specified collection path and document ID.\n * If the document does not exist, logs a warning and returns null.\n *\n * @param {string} collectionPath - The path to the collection in the database (\"improvementWork\", \"hospital\", \"suggestion\", \"task\", \"unit\", \"users\")\n * @param {string} documentId - The ID of the document to retrieve.\n * @returns {Promise<any|null>} A promise that resolves to the document object if found, or null if not.\n *\n * @throws Will throw an error if there is an issue during retrieval from the database.\n */\nfunction getObjectById(collectionPath, documentId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {\n var docRef, docSnapshot;\n return _regeneratorRuntime().wrap(function _callee16$(_context16) {\n while (1) switch (_context16.prev = _context16.next) {\n case 0:\n _context16.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, collectionPath, documentId);\n _context16.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDoc)(docRef);\n case 4:\n docSnapshot = _context16.sent;\n if (!docSnapshot.exists()) {\n _context16.next = 9;\n break;\n }\n return _context16.abrupt(\"return\", docSnapshot.data());\n case 9:\n console.warn(\"No such document! \".concat(collectionPath, \"/\").concat(documentId));\n return _context16.abrupt(\"return\", null);\n case 11:\n _context16.next = 17;\n break;\n case 13:\n _context16.prev = 13;\n _context16.t0 = _context16[\"catch\"](0);\n console.error(\"Error getting object\", _context16.t0);\n throw _context16.t0;\n case 17:\n case \"end\":\n return _context16.stop();\n }\n }, _callee16, null, [[0, 13]]);\n }));\n}\n/**\n * Asynchronously retrieves comments for a given suggestion.\n *\n * @param {Object} params - The parameters for fetching comments.\n * @param {string} params.suggestionId - The ID of the suggestion to fetch comments for.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - The criterion to sort the comments by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Determines if the sorting should be in ascending order. Defaults to false (descending).\n * @returns {Promise<any[]>} A promise that resolves to an array of comment objects.\n *\n * @throws Will throw an error if the comments cannot be retrieved.\n */\nfunction getComments(_ref) {\n var suggestionId = _ref.suggestionId,\n _ref$sortBy = _ref.sortBy,\n sortBy = _ref$sortBy === void 0 ? \"dateCreated\" : _ref$sortBy,\n _ref$ascending = _ref.ascending,\n ascending = _ref$ascending === void 0 ? false : _ref$ascending;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {\n var suggestionRef, commentsQuery, commentsSnapshot, comments;\n return _regeneratorRuntime().wrap(function _callee17$(_context17) {\n while (1) switch (_context17.prev = _context17.next) {\n case 0:\n _context17.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, \"suggestionCollection\", suggestionId);\n commentsQuery = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\"), (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n _context17.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(commentsQuery);\n case 5:\n commentsSnapshot = _context17.sent;\n comments = [];\n commentsSnapshot.forEach(function (doc) {\n comments.push(doc.data());\n });\n return _context17.abrupt(\"return\", comments);\n case 11:\n _context17.prev = 11;\n _context17.t0 = _context17[\"catch\"](0);\n console.error(\"Error getting comments for suggestion: \", _context17.t0);\n throw _context17.t0;\n case 15:\n case \"end\":\n return _context17.stop();\n }\n }, _callee17, null, [[0, 11]]);\n }));\n}\n//Filtering suggestions on unitId AND creatorHsaId\n//Sort suggestions on dateCreated OR upvotes\n/**\n * Asynchronously retrieves an array of suggestions from the database, with various filters and sorting options.\n *\n * @param {Object} params - The parameters for filtering and sorting suggestions.\n * @param {string} [params.id] - Optional ID to filter suggestions by a specific identifier.\n * @param {string} [params.creatorHsaId] - Optional HSA ID to filter suggestions by the creator's HSA ID.\n * @param {string} [params.unitId] - Optional unit ID to filter suggestions by a specific unit.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - Criterion to sort the suggestions by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Flag indicating if sorting should be ascending. Defaults to false (descending order).\n * @param {boolean} [params.isPublic=true] - Flag indicating whether to filter for public suggestions. Defaults to true.\n * @returns {Promise<any[]>} A promise that resolves to an array of suggestion objects.\n *\n * @throws Will throw an error if there is an issue retrieving suggestions.\n */\nfunction getSuggestions(_ref2) {\n var id = _ref2.id,\n creatorHsaId = _ref2.creatorHsaId,\n unitId = _ref2.unitId,\n _ref2$sortBy = _ref2.sortBy,\n sortBy = _ref2$sortBy === void 0 ? \"dateCreated\" : _ref2$sortBy,\n _ref2$ascending = _ref2.ascending,\n ascending = _ref2$ascending === void 0 ? false : _ref2$ascending,\n _ref2$isPublic = _ref2.isPublic,\n isPublic = _ref2$isPublic === void 0 ? true : _ref2$isPublic;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {\n var collectionRef, constraints, q, querySnapshot, suggestions;\n return _regeneratorRuntime().wrap(function _callee18$(_context18) {\n while (1) switch (_context18.prev = _context18.next) {\n case 0:\n _context18.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (creatorHsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"creatorHsaId\", \"==\", creatorHsaId));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"public\", \"==\", isPublic));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context18.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 11:\n querySnapshot = _context18.sent;\n suggestions = [];\n querySnapshot.forEach(function (doc) {\n suggestions.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context18.abrupt(\"return\", suggestions);\n case 17:\n _context18.prev = 17;\n _context18.t0 = _context18[\"catch\"](0);\n console.log(\"Error retrieving suggestions by department: \", _context18.t0);\n throw _context18.t0;\n case 21:\n case \"end\":\n return _context18.stop();\n }\n }, _callee18, null, [[0, 17]]);\n }));\n}\n/**\n * Asynchronously searches for hospital documents in the database.\n * It can filter the results by the hospital's name, ID, or both.\n * If no parameters are provided, it retrieves all hospitals.\n *\n * @param {Object} params - An object containing the search parameters.\n * @param {string} [params.hospitalName] - Optional name of the hospital to filter the search.\n * @param {string} [params.hospitalId] - Optional unique identifier of the hospital to filter the search.\n * @returns {Promise<any[]>} A promise that resolves to an array of hospital objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getHospitals(_ref3) {\n var hospitalName = _ref3.hospitalName,\n hospitalId = _ref3.hospitalId;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {\n var collectionRef, constraints, q, querySnapshot, hospitals;\n return _regeneratorRuntime().wrap(function _callee19$(_context19) {\n while (1) switch (_context19.prev = _context19.next) {\n case 0:\n _context19.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\n constraints = [];\n if (hospitalName) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", hospitalName));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hospitalId));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context19.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context19.sent;\n hospitals = [];\n querySnapshot.forEach(function (doc) {\n hospitals.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context19.abrupt(\"return\", hospitals);\n case 14:\n _context19.prev = 14;\n _context19.t0 = _context19[\"catch\"](0);\n console.log(\"Error retrieving Hospitals\", _context19.t0);\n throw _context19.t0;\n case 18:\n case \"end\":\n return _context19.stop();\n }\n }, _callee19, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of improvement work documents based on various filter criteria.\n * It supports filtering by ID, Nolan stage, unit ID, completion status, ongoing status, and patient risk level.\n * It also supports sorting by the start date of the improvement work in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.id] - Optional identifier to filter the improvement works.\n * @param {string} [params.nolanStage] - Optional Nolan stage to filter the improvement works.\n * @param {string} [params.unitId] - Optional unit ID to filter the improvement works.\n * @param {boolean} [params.completed] - Optional flag to filter the improvement works by their completion status.\n * @param {boolean} [params.ongoing] - Optional flag to filter the improvement works by their ongoing status.\n * @param {string} [params.patientRiskLevel] - Optional patient risk level to filter the improvement works.\n * @param {boolean} [params.ascendingDates=false] - Optional flag for sorting by date in ascending order. Defaults to false.\n * @returns {Promise<any[]>} A promise that resolves to an array of improvement work objects that match the criteria.\n *\n * @throws Will throw an error if there is a problem retrieving the improvement works.\n */\nfunction getImprovementWorks(_ref4) {\n var id = _ref4.id,\n nolanStage = _ref4.nolanStage,\n unitId = _ref4.unitId,\n completed = _ref4.completed,\n ongoing = _ref4.ongoing,\n patientRiskLevel = _ref4.patientRiskLevel,\n _ref4$ascendingDates = _ref4.ascendingDates,\n ascendingDates = _ref4$ascendingDates === void 0 ? false : _ref4$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {\n var collectionRef, constraints, q, querySnapshot, improvementWorks;\n return _regeneratorRuntime().wrap(function _callee20$(_context20) {\n while (1) switch (_context20.prev = _context20.next) {\n case 0:\n _context20.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (nolanStage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"currentStage\", \"==\", nolanStage));\n }\n if (completed != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"completed\", \"==\", completed));\n }\n if (ongoing !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"ongoing\", \"==\", ongoing));\n }\n if (patientRiskLevel) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"patientRiskLevel\", \"==\", patientRiskLevel));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"dateStarted\", ascendingDates ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context20.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 13:\n querySnapshot = _context20.sent;\n improvementWorks = [];\n querySnapshot.forEach(function (doc) {\n improvementWorks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context20.abrupt(\"return\", improvementWorks);\n case 19:\n _context20.prev = 19;\n _context20.t0 = _context20[\"catch\"](0);\n console.log(\"Error retrieving improvementWorks: \", _context20.t0);\n throw _context20.t0;\n case 23:\n case \"end\":\n return _context20.stop();\n }\n }, _callee20, null, [[0, 19]]);\n }));\n}\n/**\n * Asynchronously retrieves user documents from the database based on various filter criteria.\n * It can filter by the Health Savings Account ID (hsaId), unit ID, and unique identifier (uid).\n * Additionally, it can sort the results by first name in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.hsaId] - Optional HSA ID to filter the users.\n * @param {string} [params.unitId] - Optional unit ID to filter the users.\n * @param {boolean} [params.ascendingFirstNames=false] - Optional flag to sort by first names in ascending order. Defaults to false (descending order).\n * @param {string} [params.uid] - Optional unique identifier to filter the users.\n * @returns {Promise<any[]>} A promise that resolves to an array of user objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUsers(_ref5) {\n var hsaId = _ref5.hsaId,\n unitId = _ref5.unitId,\n _ref5$ascendingFirstN = _ref5.ascendingFirstNames,\n ascendingFirstNames = _ref5$ascendingFirstN === void 0 ? false : _ref5$ascendingFirstN,\n uid = _ref5.uid;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {\n var collectionRef, constraints, q, querySnapshot, users;\n return _regeneratorRuntime().wrap(function _callee21$(_context21) {\n while (1) switch (_context21.prev = _context21.next) {\n case 0:\n _context21.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\n constraints = [];\n if (hsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hsaId));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (uid) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"uid\", \"==\", uid));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"firstName\", ascendingFirstNames ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context21.next = 10;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 10:\n querySnapshot = _context21.sent;\n users = [];\n querySnapshot.forEach(function (doc) {\n users.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context21.abrupt(\"return\", users);\n case 16:\n _context21.prev = 16;\n _context21.t0 = _context21[\"catch\"](0);\n console.log(\"Error retrieving users by department: \", _context21.t0);\n throw _context21.t0;\n case 20:\n case \"end\":\n return _context21.stop();\n }\n }, _callee21, null, [[0, 16]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of task documents from the database based on several filter and sorting criteria.\n * Filters include task ID, user ID and their responsibility status, and related improvement work ID.\n * Results can be sorted by date either in ascending or descending order.\n *\n * @param {Object} params - Parameters to filter and sort the task results.\n * @param {string} [params.taskId] - Optional task ID to filter the tasks.\n * @param {string} [params.userId] - Optional user ID to identify tasks related to a user.\n * @param {boolean} [params.isResponsibleFor] - Optional flag to filter tasks where the user is marked as responsible.\n * @param {string} [params.improvementWorkId] - Optional improvement work ID to filter tasks related to a specific improvement work.\n * @param {boolean} [params.ascendingDates=false] - Optional flag to sort tasks by date in ascending order; defaults to descending order.\n * @returns {Promise<any[]>} A promise that resolves to an array of task objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getTasks(_ref6) {\n var taskId = _ref6.taskId,\n userId = _ref6.userId,\n isResponsibleFor = _ref6.isResponsibleFor,\n improvementWorkId = _ref6.improvementWorkId,\n _ref6$ascendingDates = _ref6.ascendingDates,\n ascendingDates = _ref6$ascendingDates === void 0 ? false : _ref6$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {\n var collectionRef, constraints, q, querySnapshot, tasks;\n return _regeneratorRuntime().wrap(function _callee22$(_context22) {\n while (1) switch (_context22.prev = _context22.next) {\n case 0:\n _context22.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\n constraints = [];\n if (taskId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", taskId));\n }\n if (userId && isResponsibleFor !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"members\", \"array-contains\", {\n userHsaId: userId,\n isResponsibleFor: isResponsibleFor\n }));\n }\n if (improvementWorkId != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"startDate\", ascendingDates ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context22.next = 9;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 9:\n querySnapshot = _context22.sent;\n tasks = [];\n querySnapshot.forEach(function (doc) {\n tasks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context22.abrupt(\"return\", tasks);\n case 15:\n _context22.prev = 15;\n _context22.t0 = _context22[\"catch\"](0);\n console.log(\"Error retrieving task by department: \", _context22.t0);\n throw _context22.t0;\n case 19:\n case \"end\":\n return _context22.stop();\n }\n }, _callee22, null, [[0, 15]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of unit documents from the database based on various filter criteria.\n * Filters can be applied based on unit ID, hospital ID, and unit name.\n * Additionally, results can be sorted by unit names in ascending or descending order.\n *\n * @param {Object} params - The parameters object containing filter and sorting options.\n * @param {string} [params.unitId] - Optional unit ID to filter the units.\n * @param {string} [params.hospitalId] - Optional hospital ID to filter units within a specific hospital.\n * @param {string} [params.name] - Optional name to filter units by a specific name.\n * @param {boolean} [params.ascendingUnitNames=false] - Optional flag to sort units by name in ascending order, defaults to descending.\n * @returns {Promise<any[]>} A promise that resolves to an array of unit objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUnits(_ref7) {\n var unitId = _ref7.unitId,\n hospitalId = _ref7.hospitalId,\n name = _ref7.name,\n _ref7$ascendingUnitNa = _ref7.ascendingUnitNames,\n ascendingUnitNames = _ref7$ascendingUnitNa === void 0 ? false : _ref7$ascendingUnitNa;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {\n var collectionRef, constraints, q, querySnapshot, units;\n return _regeneratorRuntime().wrap(function _callee23$(_context23) {\n while (1) switch (_context23.prev = _context23.next) {\n case 0:\n _context23.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\n constraints = [];\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", unitId));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"hospitalId\", \"==\", hospitalId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"name\", ascendingUnitNames ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context23.next = 9;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 9:\n querySnapshot = _context23.sent;\n units = [];\n querySnapshot.forEach(function (doc) {\n units.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context23.abrupt(\"return\", units);\n case 15:\n _context23.prev = 15;\n _context23.t0 = _context23[\"catch\"](0);\n console.log(\"Error retrieving units by hospitalId: \", _context23.t0);\n throw _context23.t0;\n case 19:\n case \"end\":\n return _context23.stop();\n }\n }, _callee23, null, [[0, 15]]);\n }));\n}\n//getMembersFilteredAndSorted() -> Get all members of a project (sorted by firstName?)\n// export getters to be able to use in other files\n\n////////////////////////////////////DELETING/////////////////////////////////////////////\n// delete an instance of a type\nfunction deleteInstance(docType, docId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee24$(_context24) {\n while (1) switch (_context24.prev = _context24.next) {\n case 0:\n _context24.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context24.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(docRef);\n case 4:\n console.log(\"\".concat(docType, \" deleted successfully.\"));\n _context24.next = 11;\n break;\n case 7:\n _context24.prev = 7;\n _context24.t0 = _context24[\"catch\"](0);\n console.error(\"Error deleting \".concat(docType, \":\"), _context24.t0);\n throw _context24.t0;\n case 11:\n case \"end\":\n return _context24.stop();\n }\n }, _callee24, null, [[0, 7]]);\n }));\n}\n// delete all instances of a type\nfunction deleteAllDocumentsInCollection(collectionName) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {\n var _this = this;\n var collectionRef, snapshot, deletePromises;\n return _regeneratorRuntime().wrap(function _callee26$(_context26) {\n while (1) switch (_context26.prev = _context26.next) {\n case 0:\n _context26.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionName);\n _context26.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n snapshot = _context26.sent;\n // Delete all documents in the collection\n deletePromises = snapshot.docs.map(function (doc) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {\n return _regeneratorRuntime().wrap(function _callee25$(_context25) {\n while (1) switch (_context25.prev = _context25.next) {\n case 0:\n _context25.next = 2;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(doc.ref);\n case 2:\n case \"end\":\n return _context25.stop();\n }\n }, _callee25);\n }));\n });\n _context26.next = 8;\n return Promise.all(deletePromises);\n case 8:\n console.log(\"All documents in the \".concat(collectionName, \" collection deleted successfully.\"));\n _context26.next = 15;\n break;\n case 11:\n _context26.prev = 11;\n _context26.t0 = _context26[\"catch\"](0);\n console.error(\"Error deleting all documents in \".concat(collectionName, \":\"), _context26.t0);\n throw _context26.t0;\n case 15:\n case \"end\":\n return _context26.stop();\n }\n }, _callee26, null, [[0, 11]]);\n }));\n}\n////////////////////////////////////UPDATING/////////////////////////////////////////////\n// update a field in an instance\nfunction updateInstance(docType, docId, updates) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee27$(_context27) {\n while (1) switch (_context27.prev = _context27.next) {\n case 0:\n _context27.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context27.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(docRef, updates);\n case 4:\n console.log(\"\".concat(docType, \" updated successfully.\"));\n _context27.next = 11;\n break;\n case 7:\n _context27.prev = 7;\n _context27.t0 = _context27[\"catch\"](0);\n console.error(\"Error updating \".concat(docType, \":\"), _context27.t0);\n throw _context27.t0;\n case 11:\n case \"end\":\n return _context27.stop();\n }\n }, _callee27, null, [[0, 7]]);\n }));\n}\n// changes the ongoing status of an improvement work. if ongoing it is paused, if if paused onging.\n// user must be a manager\nfunction startOrPauseImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee28$(_context28) {\n while (1) switch (_context28.prev = _context28.next) {\n case 0:\n _context28.prev = 0;\n _context28.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context28.sent;\n _context28.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context28.sent;\n if (!(!user || !user.manager)) {\n _context28.next = 11;\n break;\n }\n throw new Error(\"User can't change improvementWork status\");\n case 11:\n if (!improvementWork) {\n _context28.next = 18;\n break;\n }\n update = {\n ongoing: !improvementWork.ongoing\n };\n _context28.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n _context28.next = 19;\n break;\n case 18:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n case 19:\n _context28.next = 25;\n break;\n case 21:\n _context28.prev = 21;\n _context28.t0 = _context28[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context28.t0);\n throw _context28.t0;\n case 25:\n case \"end\":\n return _context28.stop();\n }\n }, _callee28, null, [[0, 21]]);\n }));\n}\nfunction changePatientRiskLevel(userId, improvementWorkId, patientRiskLevel) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee29$(_context29) {\n while (1) switch (_context29.prev = _context29.next) {\n case 0:\n _context29.prev = 0;\n _context29.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context29.sent;\n _context29.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context29.sent;\n if (!(!user || !user.manager)) {\n _context29.next = 11;\n break;\n }\n throw new Error(\"User can't change patientRiskLevel in improvement work\");\n case 11:\n if (!improvementWork) {\n _context29.next = 18;\n break;\n }\n update = {\n patientRiskLevel: patientRiskLevel\n };\n _context29.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n _context29.next = 19;\n break;\n case 18:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n case 19:\n _context29.next = 25;\n break;\n case 21:\n _context29.prev = 21;\n _context29.t0 = _context29[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context29.t0);\n throw _context29.t0;\n case 25:\n case \"end\":\n return _context29.stop();\n }\n }, _callee29, null, [[0, 21]]);\n }));\n}\n// finalizes the improvement work. ongoing is set to false.\n// user must be a manager\nfunction finalizeImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {\n var user, update;\n return _regeneratorRuntime().wrap(function _callee30$(_context30) {\n while (1) switch (_context30.prev = _context30.next) {\n case 0:\n _context30.prev = 0;\n _context30.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context30.sent;\n if (!(!user || !user.manager)) {\n _context30.next = 8;\n break;\n }\n throw new Error(\"User can't finalize improvementWork status\");\n case 8:\n update = {\n completed: true,\n ongoing: false\n };\n _context30.next = 11;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 11:\n _context30.next = 16;\n break;\n case 13:\n _context30.prev = 13;\n _context30.t0 = _context30[\"catch\"](0);\n console.log(_context30.t0);\n case 16:\n case \"end\":\n return _context30.stop();\n }\n }, _callee30, null, [[0, 13]]);\n }));\n}\n\n//////////////////////////////// for later sprint\n//function add_upvotes\n//function add_notes\n//function add_intrested_users\n\n//# sourceURL=webpack://c3/./client/Database/database.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addDocumentToImprovementWork: () => (/* binding */ addDocumentToImprovementWork),\n/* harmony export */ addMemberToImprovementWork: () => (/* binding */ addMemberToImprovementWork),\n/* harmony export */ addMemberToTask: () => (/* binding */ addMemberToTask),\n/* harmony export */ addNoteToUser: () => (/* binding */ addNoteToUser),\n/* harmony export */ auth: () => (/* binding */ auth),\n/* harmony export */ changePatientRiskLevel: () => (/* binding */ changePatientRiskLevel),\n/* harmony export */ createComment: () => (/* binding */ createComment),\n/* harmony export */ createHospital: () => (/* binding */ createHospital),\n/* harmony export */ createImprovementWork: () => (/* binding */ createImprovementWork),\n/* harmony export */ createSuggestion: () => (/* binding */ createSuggestion),\n/* harmony export */ createTaskOnImprovementWork: () => (/* binding */ createTaskOnImprovementWork),\n/* harmony export */ createUnit: () => (/* binding */ createUnit),\n/* harmony export */ createUser: () => (/* binding */ createUser),\n/* harmony export */ createdDocumentInKnowledgeBank: () => (/* binding */ createdDocumentInKnowledgeBank),\n/* harmony export */ db: () => (/* binding */ db),\n/* harmony export */ deleteAllDocumentsInCollection: () => (/* binding */ deleteAllDocumentsInCollection),\n/* harmony export */ deleteInstance: () => (/* binding */ deleteInstance),\n/* harmony export */ finalizeImprovementWork: () => (/* binding */ finalizeImprovementWork),\n/* harmony export */ getComments: () => (/* binding */ getComments),\n/* harmony export */ getHospitals: () => (/* binding */ getHospitals),\n/* harmony export */ getImprovementWorkOwner: () => (/* binding */ getImprovementWorkOwner),\n/* harmony export */ getImprovementWorkResponsible: () => (/* binding */ getImprovementWorkResponsible),\n/* harmony export */ getImprovementWorks: () => (/* binding */ getImprovementWorks),\n/* harmony export */ getImprovementWorksForUser: () => (/* binding */ getImprovementWorksForUser),\n/* harmony export */ getObject: () => (/* binding */ getObject),\n/* harmony export */ getObjectById: () => (/* binding */ getObjectById),\n/* harmony export */ getSuggestions: () => (/* binding */ getSuggestions),\n/* harmony export */ getTasks: () => (/* binding */ getTasks),\n/* harmony export */ getUnits: () => (/* binding */ getUnits),\n/* harmony export */ getUsers: () => (/* binding */ getUsers),\n/* harmony export */ getUsersForImprovementWork: () => (/* binding */ getUsersForImprovementWork),\n/* harmony export */ startOrPauseImprovementWork: () => (/* binding */ startOrPauseImprovementWork),\n/* harmony export */ updateInstance: () => (/* binding */ updateInstance),\n/* harmony export */ upvoteComment: () => (/* binding */ upvoteComment),\n/* harmony export */ upvoteSuggestion: () => (/* binding */ upvoteSuggestion)\n/* harmony export */ });\n/* harmony import */ var firebase_app__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! firebase/app */ \"./node_modules/firebase/app/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_firestore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! firebase/firestore */ \"./node_modules/firebase/firestore/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_auth__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! firebase/auth */ \"./node_modules/firebase/auth/dist/esm/index.esm.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nvar firebaseConfig = {\n apiKey: \"AIzaSyDqkaVZMr11J4mfnR0auqoQilZyPfyD-x4\",\n authDomain: \"c3solutions-dc109.firebaseapp.com\",\n projectId: \"c3solutions-dc109\",\n storageBucket: \"c3solutions-dc109.appspot.com\",\n messagingSenderId: \"902143402555\",\n appId: \"1:902143402555:web:29213e81de0a0cba38b21e\"\n};\n/*const firebaseConfig = {\n apiKey: \"AIzaSyBIsZq_yOsJljp1woIxndJO1GkW6soh-g4\",\n authDomain: \"company3-456bb.firebaseapp.com\",\n projectId: \"company3-456bb\",\n storageBucket: \"company3-456bb.appspot.com\",\n messagingSenderId: \"310033686522\",\n appId: \"1:310033686522:web:63198bb0db679c98ee4e43\",\n measurementId: \"G-PFLDQY00DB\"\n};*/\n// const firebaseConfig = {\n// apiKey: \"AIzaSyBIsZq_yOsJljp1woIxndJO1GkW6soh-g4\",\n// authDomain: \"company3-456bb.firebaseapp.com\",\n// projectId: \"company3-456bb\",\n// storageBucket: \"company3-456bb.appspot.com\",\n// messagingSenderId: \"310033686522\",\n// appId: \"1:310033686522:web:63198bb0db679c98ee4e43\",\n// measurementId: \"G-PFLDQY00DB\"\n// };\nvar app = (0,firebase_app__WEBPACK_IMPORTED_MODULE_0__.initializeApp)(firebaseConfig);\nvar auth = (0,firebase_auth__WEBPACK_IMPORTED_MODULE_2__.getAuth)();\nvar db = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getFirestore)(app);\nvar userCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\nvar unitCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\nvar improvementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\nvar taskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\nvar hospitalCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\nvar suggestionCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\nvar knowledgeDocumentCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"knowledgeDocument\");\nvar userImprovementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"userImprovementWork\");\nvar userTaskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"userTask\");\n////////////////////////////////////////Setters///////////////////////////////////////////////////////////////////\n// Function to create user a new user in database\n// takes in userId, unitId, firstname, lastname, email and password as string\n// throws error if transaction failed\nfunction createUser(hsaId, unitId, firstName, lastName, email, manager, uid) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var userRef, unitRef;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, hsaId);\n _context.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(userRef, {\n id: userRef.id,\n uid: uid,\n unitId: unitId,\n firstName: firstName,\n lastName: lastName,\n email: email,\n // TODO Replace with userImprovementWork collection\n improvementWorks: [],\n tasks: [],\n manager: manager\n });\n case 4:\n // Atomically add user to unit.\n unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection, unitId);\n _context.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(unitRef, {\n members: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userRef.id)\n });\n case 7:\n _context.next = 12;\n break;\n case 9:\n _context.prev = 9;\n _context.t0 = _context[\"catch\"](0);\n console.log(_context.t0);\n case 12:\n case \"end\":\n return _context.stop();\n }\n }, _callee, null, [[0, 9]]);\n }));\n}\nfunction createImprovementWork(id, name, currentStage, content,\n// Är detta description bör detta förtydligas. \nunitId, purpose,\n//Bör tas bort motsvaras av p2- mål med projektet\npatientRiskLevel, area,\n//Questions in planning stage\np1, p2, p3, p4, p5, p6, p7,\n//Questions in Doing (G) stage\ng1, g2, g3, g4, g5,\n//Questions in stydy stage\ns1, s2, s3,\n//Questions in acting stage\na1, a2, a3, a4) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var improvementWorkData, improvementWorkRef, _improvementWorkRef;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.prev = 0;\n improvementWorkData = {\n name: name,\n currentStage: currentStage,\n content: content,\n purpose: purpose,\n dateStarted: new Date(),\n unitId: unitId,\n completed: false,\n ongoing: false,\n tasks: [],\n // TODO Remove members array\n members: [],\n patientRiskLevel: patientRiskLevel,\n area: area,\n p1: p1,\n p2: p2,\n p3: p3,\n p4: p4,\n p5: p5,\n p6: p6,\n p7: p7,\n g1: g1,\n g2: g2,\n g3: g3,\n g4: g4,\n g5: g5,\n s1: s1,\n s2: s2,\n s3: s3,\n a1: a1,\n a2: a2,\n a3: a3,\n a4: a4\n };\n if (!id) {\n _context2.next = 8;\n break;\n }\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, id);\n _context2.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(improvementWorkRef, Object.assign({\n id: improvementWorkRef.id\n }, improvementWorkData));\n case 6:\n _context2.next = 11;\n break;\n case 8:\n _improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection);\n _context2.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_improvementWorkRef, improvementWorkData);\n case 11:\n _context2.next = 17;\n break;\n case 13:\n _context2.prev = 13;\n _context2.t0 = _context2[\"catch\"](0);\n console.log(\"Error creating improvementWork: \", _context2.t0);\n throw _context2.t0;\n case 17:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, null, [[0, 13]]);\n }));\n}\nfunction addMemberToTask(userHsaId, taskId, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var relationRef;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.prev = 0;\n relationRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userTaskCollection);\n _context3.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(relationRef, {\n id: relationRef.id,\n userHsaId: userHsaId,\n taskId: taskId,\n isResponsibleFor: isResponsibleFor\n });\n case 4:\n _context3.next = 10;\n break;\n case 6:\n _context3.prev = 6;\n _context3.t0 = _context3[\"catch\"](0);\n console.log(\"Error adding member to task: \", _context3.t0);\n throw _context3.t0;\n case 10:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, null, [[0, 6]]);\n }));\n}\nfunction addMemberToImprovementWork(userHsaId, improvementWorkId, isOwner, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var relationRef;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n _context4.prev = 0;\n relationRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userImprovementWorkCollection);\n _context4.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(relationRef, {\n id: relationRef.id,\n userHsaId: userHsaId,\n improvementWorkId: improvementWorkId,\n isOwner: isOwner,\n isResponsibleFor: isResponsibleFor\n });\n case 4:\n _context4.next = 10;\n break;\n case 6:\n _context4.prev = 6;\n _context4.t0 = _context4[\"catch\"](0);\n console.log(\"Error adding member to improvementWork: \", _context4.t0);\n throw _context4.t0;\n case 10:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4, null, [[0, 6]]);\n }));\n}\nfunction createTaskOnImprovementWork(taskId, improvementWorkId, name, deadlineDate, startDate, stage, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var taskData, taskRef, _taskRef;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n _context5.prev = 0;\n taskData = {\n improvementWorkId: improvementWorkId,\n name: name,\n deadlineDate: deadlineDate,\n startDate: startDate,\n stage: stage,\n content: content,\n members: [] // Initialize with an empty array\n };\n if (!taskId) {\n _context5.next = 8;\n break;\n }\n taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection, taskId);\n _context5.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(taskRef, Object.assign({\n id: taskRef.id\n }, taskData));\n case 6:\n _context5.next = 11;\n break;\n case 8:\n _taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection);\n _context5.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_taskRef, taskData);\n case 11:\n _context5.next = 17;\n break;\n case 13:\n _context5.prev = 13;\n _context5.t0 = _context5[\"catch\"](0);\n console.log(\"Error creating task: \", _context5.t0);\n throw _context5.t0;\n case 17:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5, null, [[0, 13]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction createdDocumentInKnowledgeBank(documentUrl, name) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n _context6.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(knowledgeDocumentCollection);\n _context6.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n name: name\n });\n case 4:\n _context6.next = 10;\n break;\n case 6:\n _context6.prev = 6;\n _context6.t0 = _context6[\"catch\"](0);\n console.log(\"Error adding document: \", _context6.t0);\n throw _context6.t0;\n case 10:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6, null, [[0, 6]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction addDocumentToImprovementWork(documentUrl, name, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var improvementWorkRef, docRef;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.prev = 0;\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, improvementWorkId);\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkRef, \"documents\");\n _context7.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n timestamp: new Date(),\n name: name\n });\n case 5:\n _context7.next = 11;\n break;\n case 7:\n _context7.prev = 7;\n _context7.t0 = _context7[\"catch\"](0);\n console.log(\"Error adding document: \", _context7.t0);\n throw _context7.t0;\n case 11:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7, null, [[0, 7]]);\n }));\n}\nfunction createHospital(hospitalId,\n// should be auto?\nname) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var hospitalData, hospitalRef, _hospitalRef;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n _context8.prev = 0;\n hospitalData = {\n name: name,\n units: []\n };\n if (!hospitalId) {\n _context8.next = 8;\n break;\n }\n hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection, hospitalId);\n _context8.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(hospitalRef, Object.assign({\n id: hospitalRef.id\n }, hospitalData));\n case 6:\n _context8.next = 11;\n break;\n case 8:\n _hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection);\n _context8.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_hospitalRef, hospitalData);\n case 11:\n _context8.next = 17;\n break;\n case 13:\n _context8.prev = 13;\n _context8.t0 = _context8[\"catch\"](0);\n console.log(\"Error creating hospital: \", _context8.t0);\n throw _context8.t0;\n case 17:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8, null, [[0, 13]]);\n }));\n}\nfunction createUnit(unitId,\n//should be auto?\nhospitalId, name) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var unitData, unitRef, _unitRef;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n _context9.prev = 0;\n unitData = {\n hospitalId: hospitalId,\n name: name,\n members: []\n };\n if (!unitId) {\n _context9.next = 8;\n break;\n }\n unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection, unitId);\n _context9.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(unitRef, Object.assign({\n id: unitRef.id\n }, unitData));\n case 6:\n _context9.next = 11;\n break;\n case 8:\n _unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection);\n _context9.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_unitRef, unitData);\n case 11:\n _context9.next = 17;\n break;\n case 13:\n _context9.prev = 13;\n _context9.t0 = _context9[\"catch\"](0);\n console.log(\"Error creating unit: \", _context9.t0);\n throw _context9.t0;\n case 17:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9, null, [[0, 13]]);\n }));\n}\nfunction createSuggestion(id, creatorHsaId, name, area, content, purpose, measure, ideas,\n//need: boolean,\nunitId, departmentId, isPublic) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var suggestionData, suggestionRef, _suggestionRef;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n _context10.prev = 0;\n suggestionData = {\n creatorHsaId: creatorHsaId,\n name: name,\n area: area,\n content: content,\n purpose: purpose,\n measure: measure,\n ideas: ideas,\n //need,\n unitId: unitId,\n departmentId: departmentId,\n \"public\": isPublic,\n upvotes: [],\n comments: [],\n dateCreated: new Date()\n };\n if (!id) {\n _context10.next = 8;\n break;\n }\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, id);\n _context10.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(suggestionRef, Object.assign({\n id: suggestionRef.id\n }, suggestionData));\n case 6:\n _context10.next = 11;\n break;\n case 8:\n _suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection);\n _context10.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_suggestionRef, suggestionData);\n case 11:\n _context10.next = 17;\n break;\n case 13:\n _context10.prev = 13;\n _context10.t0 = _context10[\"catch\"](0);\n console.log(\"Error creating suggestion: \", _context10.t0);\n throw _context10.t0;\n case 17:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10, null, [[0, 13]]);\n }));\n}\n// Upvote a suggestion for a user\n// takes in suggestion id, user HSAid\n// returns error if transaction failed\nfunction upvoteSuggestion(suggestionId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var suggestionRef;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n _context11.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId); // Atomically add a update to the upvote array field.\n _context11.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(suggestionRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 4:\n _context11.next = 10;\n break;\n case 6:\n _context11.prev = 6;\n _context11.t0 = _context11[\"catch\"](0);\n console.log(\"Error upvoting suggestion: \", _context11.t0);\n throw _context11.t0;\n case 10:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11, null, [[0, 6]]);\n }));\n}\n//creates a comment\n// takes in commenters id, suggestion id and content as string\n// throws error if transaction failed\nfunction createComment(\n// change to subcollection\ncommenterHsaId, suggestionId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var suggestionRef, commentCollection, commentRef;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n _context12.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context12.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\");\n case 4:\n commentCollection = _context12.sent;\n _context12.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(commentCollection);\n case 7:\n commentRef = _context12.sent;\n _context12.next = 10;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(commentRef, {\n id: commentRef.id,\n commenterHsaId: commenterHsaId,\n content: content,\n dateCreated: new Date(),\n upvotes: []\n });\n case 10:\n _context12.next = 16;\n break;\n case 12:\n _context12.prev = 12;\n _context12.t0 = _context12[\"catch\"](0);\n console.log(\"Error creating comment: \", _context12.t0);\n throw _context12.t0;\n case 16:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12, null, [[0, 12]]);\n }));\n}\n// Upvote a comment for a user\n// takes in suggestionId, commentId and userId as strings\n// return error if transaction failed\nfunction upvoteComment(suggestionId, commentId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var suggestionRef, commentRef;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n _context13.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n commentRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionRef, \"comment\", commentId); // Atomically add a update to the upvote array field.\n _context13.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(commentRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 5:\n _context13.next = 11;\n break;\n case 7:\n _context13.prev = 7;\n _context13.t0 = _context13[\"catch\"](0);\n console.log(\"Error upvoting comment: \", _context13.t0);\n throw _context13.t0;\n case 11:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13, null, [[0, 7]]);\n }));\n}\n//add a note to a user\n// takes in userHsaId and content as string\n// throws error if transaction failed\nfunction addNoteToUser(userHsaId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var userRef, docRef;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n _context14.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, userHsaId);\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userRef, \"notes\");\n _context14.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n content: content,\n dateCreated: new Date()\n });\n case 5:\n _context14.next = 11;\n break;\n case 7:\n _context14.prev = 7;\n _context14.t0 = _context14[\"catch\"](0);\n console.log(\"Error adding document: \", _context14.t0);\n throw _context14.t0;\n case 11:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14, null, [[0, 7]]);\n }));\n}\n// export to setters to be able to use in other files\n\n//////////////////////////////////////////////GETTERS/////////////////////////////////////////////////////////////////////\n// Get any object\n// input is the database type as a string.\n// output is the whole collection of that type.\nfunction getObject(collectionPath) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n var collectionRef, querySnapshot, result;\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n _context15.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionPath);\n _context15.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n querySnapshot = _context15.sent;\n result = [];\n querySnapshot.forEach(function (doc) {\n result.push(doc.data());\n });\n return _context15.abrupt(\"return\", result);\n case 10:\n _context15.prev = 10;\n _context15.t0 = _context15[\"catch\"](0);\n console.error(\"Error getting collection data\", _context15.t0);\n throw _context15.t0;\n case 14:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15, null, [[0, 10]]);\n }));\n}\n/**\n * Asynchronously retrieves a single document object from the specified collection path and document ID.\n * If the document does not exist, logs a warning and returns null.\n *\n * @param {string} collectionPath - The path to the collection in the database (\"improvementWork\", \"hospital\", \"suggestion\", \"task\", \"unit\", \"users\")\n * @param {string} documentId - The ID of the document to retrieve.\n * @returns {Promise<any|null>} A promise that resolves to the document object if found, or null if not.\n *\n * @throws Will throw an error if there is an issue during retrieval from the database.\n */\nfunction getObjectById(collectionPath, documentId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {\n var docRef, docSnapshot;\n return _regeneratorRuntime().wrap(function _callee16$(_context16) {\n while (1) switch (_context16.prev = _context16.next) {\n case 0:\n _context16.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, collectionPath, documentId);\n _context16.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDoc)(docRef);\n case 4:\n docSnapshot = _context16.sent;\n if (!docSnapshot.exists()) {\n _context16.next = 9;\n break;\n }\n return _context16.abrupt(\"return\", Object.assign({\n id: docSnapshot.id\n }, docSnapshot.data()));\n case 9:\n console.warn(\"No such document! \".concat(collectionPath, \"/\").concat(documentId));\n return _context16.abrupt(\"return\", null);\n case 11:\n _context16.next = 17;\n break;\n case 13:\n _context16.prev = 13;\n _context16.t0 = _context16[\"catch\"](0);\n console.error(\"Error getting object\", _context16.t0);\n throw _context16.t0;\n case 17:\n case \"end\":\n return _context16.stop();\n }\n }, _callee16, null, [[0, 13]]);\n }));\n}\n/**\n * Asynchronously retrieves comments for a given suggestion.\n *\n * @param {Object} params - The parameters for fetching comments.\n * @param {string} params.suggestionId - The ID of the suggestion to fetch comments for.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - The criterion to sort the comments by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Determines if the sorting should be in ascending order. Defaults to false (descending).\n * @returns {Promise<any[]>} A promise that resolves to an array of comment objects.\n *\n * @throws Will throw an error if the comments cannot be retrieved.\n */\nfunction getComments(_ref) {\n var suggestionId = _ref.suggestionId,\n _ref$sortBy = _ref.sortBy,\n sortBy = _ref$sortBy === void 0 ? \"dateCreated\" : _ref$sortBy,\n _ref$ascending = _ref.ascending,\n ascending = _ref$ascending === void 0 ? false : _ref$ascending;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {\n var suggestionRef, commentsQuery, commentsSnapshot, comments;\n return _regeneratorRuntime().wrap(function _callee17$(_context17) {\n while (1) switch (_context17.prev = _context17.next) {\n case 0:\n _context17.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, \"suggestionCollection\", suggestionId);\n commentsQuery = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\"), (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n _context17.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(commentsQuery);\n case 5:\n commentsSnapshot = _context17.sent;\n comments = [];\n commentsSnapshot.forEach(function (doc) {\n comments.push(doc.data());\n });\n return _context17.abrupt(\"return\", comments);\n case 11:\n _context17.prev = 11;\n _context17.t0 = _context17[\"catch\"](0);\n console.error(\"Error getting comments for suggestion: \", _context17.t0);\n throw _context17.t0;\n case 15:\n case \"end\":\n return _context17.stop();\n }\n }, _callee17, null, [[0, 11]]);\n }));\n}\n//Filtering suggestions on unitId AND creatorHsaId\n//Sort suggestions on dateCreated OR upvotes\n/**\n * Asynchronously retrieves an array of suggestions from the database, with various filters and sorting options.\n *\n * @param {Object} params - The parameters for filtering and sorting suggestions.\n * @param {string} [params.id] - Optional ID to filter suggestions by a specific identifier.\n * @param {string} [params.creatorHsaId] - Optional HSA ID to filter suggestions by the creator's HSA ID.\n * @param {string} [params.unitId] - Optional unit ID to filter suggestions by a specific unit.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - Criterion to sort the suggestions by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Flag indicating if sorting should be ascending. Defaults to false (descending order).\n * @param {boolean} [params.isPublic=true] - Flag indicating whether to filter for public suggestions. Defaults to true.\n * @returns {Promise<any[]>} A promise that resolves to an array of suggestion objects.\n *\n * @throws Will throw an error if there is an issue retrieving suggestions.\n */\nfunction getSuggestions(_ref2) {\n var id = _ref2.id,\n creatorHsaId = _ref2.creatorHsaId,\n unitId = _ref2.unitId,\n _ref2$sortBy = _ref2.sortBy,\n sortBy = _ref2$sortBy === void 0 ? \"dateCreated\" : _ref2$sortBy,\n _ref2$ascending = _ref2.ascending,\n ascending = _ref2$ascending === void 0 ? false : _ref2$ascending,\n _ref2$isPublic = _ref2.isPublic,\n isPublic = _ref2$isPublic === void 0 ? true : _ref2$isPublic;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {\n var collectionRef, constraints, q, querySnapshot, suggestions;\n return _regeneratorRuntime().wrap(function _callee18$(_context18) {\n while (1) switch (_context18.prev = _context18.next) {\n case 0:\n _context18.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (creatorHsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"creatorHsaId\", \"==\", creatorHsaId));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"public\", \"==\", isPublic));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context18.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 11:\n querySnapshot = _context18.sent;\n suggestions = [];\n querySnapshot.forEach(function (doc) {\n suggestions.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context18.abrupt(\"return\", suggestions);\n case 17:\n _context18.prev = 17;\n _context18.t0 = _context18[\"catch\"](0);\n console.log(\"Error retrieving suggestions by department: \", _context18.t0);\n throw _context18.t0;\n case 21:\n case \"end\":\n return _context18.stop();\n }\n }, _callee18, null, [[0, 17]]);\n }));\n}\n/**\n * Asynchronously searches for hospital documents in the database.\n * It can filter the results by the hospital's name, ID, or both.\n * If no parameters are provided, it retrieves all hospitals.\n *\n * @param {Object} params - An object containing the search parameters.\n * @param {string} [params.hospitalName] - Optional name of the hospital to filter the search.\n * @param {string} [params.hospitalId] - Optional unique identifier of the hospital to filter the search.\n * @returns {Promise<any[]>} A promise that resolves to an array of hospital objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getHospitals(_ref3) {\n var hospitalName = _ref3.hospitalName,\n hospitalId = _ref3.hospitalId;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {\n var collectionRef, constraints, q, querySnapshot, hospitals;\n return _regeneratorRuntime().wrap(function _callee19$(_context19) {\n while (1) switch (_context19.prev = _context19.next) {\n case 0:\n _context19.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\n constraints = [];\n if (hospitalName) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", hospitalName));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hospitalId));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context19.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context19.sent;\n hospitals = [];\n querySnapshot.forEach(function (doc) {\n hospitals.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context19.abrupt(\"return\", hospitals);\n case 14:\n _context19.prev = 14;\n _context19.t0 = _context19[\"catch\"](0);\n console.log(\"Error retrieving Hospitals\", _context19.t0);\n throw _context19.t0;\n case 18:\n case \"end\":\n return _context19.stop();\n }\n }, _callee19, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of improvement work documents based on various filter criteria.\n * It supports filtering by ID, Nolan stage, unit ID, completion status, ongoing status, and patient risk level.\n * It also supports sorting by the start date of the improvement work in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.id] - Optional identifier to filter the improvement works.\n * @param {string} [params.nolanStage] - Optional Nolan stage to filter the improvement works.\n * @param {string} [params.unitId] - Optional unit ID to filter the improvement works.\n * @param {boolean} [params.completed] - Optional flag to filter the improvement works by their completion status.\n * @param {boolean} [params.ongoing] - Optional flag to filter the improvement works by their ongoing status.\n * @param {string} [params.patientRiskLevel] - Optional patient risk level to filter the improvement works.\n * @param {boolean} [params.ascendingDates=false] - Optional flag for sorting by date in ascending order. Defaults to false.\n * @returns {Promise<any[]>} A promise that resolves to an array of improvement work objects that match the criteria.\n *\n * @throws Will throw an error if there is a problem retrieving the improvement works.\n */\nfunction getImprovementWorks(_ref4) {\n var id = _ref4.id,\n nolanStage = _ref4.nolanStage,\n unitId = _ref4.unitId,\n completed = _ref4.completed,\n ongoing = _ref4.ongoing,\n patientRiskLevel = _ref4.patientRiskLevel,\n _ref4$ascendingDates = _ref4.ascendingDates,\n ascendingDates = _ref4$ascendingDates === void 0 ? false : _ref4$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {\n var collectionRef, constraints, q, querySnapshot, improvementWorks;\n return _regeneratorRuntime().wrap(function _callee20$(_context20) {\n while (1) switch (_context20.prev = _context20.next) {\n case 0:\n _context20.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (nolanStage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"currentStage\", \"==\", nolanStage));\n }\n if (completed != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"completed\", \"==\", completed));\n }\n if (ongoing !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"ongoing\", \"==\", ongoing));\n }\n if (patientRiskLevel) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"patientRiskLevel\", \"==\", patientRiskLevel));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"dateStarted\", ascendingDates ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context20.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 13:\n querySnapshot = _context20.sent;\n improvementWorks = [];\n querySnapshot.forEach(function (doc) {\n improvementWorks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context20.abrupt(\"return\", improvementWorks);\n case 19:\n _context20.prev = 19;\n _context20.t0 = _context20[\"catch\"](0);\n console.log(\"Error retrieving improvementWorks: \", _context20.t0);\n throw _context20.t0;\n case 23:\n case \"end\":\n return _context20.stop();\n }\n }, _callee20, null, [[0, 19]]);\n }));\n}\nfunction getImprovementWorkOwner(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {\n var constraints, q, querySnapshot, owner;\n return _regeneratorRuntime().wrap(function _callee21$(_context21) {\n while (1) switch (_context21.prev = _context21.next) {\n case 0:\n _context21.prev = 0;\n constraints = [];\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"isOwner\", \"==\", true));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context21.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 7:\n querySnapshot = _context21.sent;\n if (!querySnapshot.empty) {\n _context21.next = 13;\n break;\n }\n console.log(\"Improvement work \", improvementWorkId, \" has no owner\");\n return _context21.abrupt(\"return\", null);\n case 13:\n owner = querySnapshot.docs[0].data().userHsaId;\n return _context21.abrupt(\"return\", owner);\n case 15:\n _context21.next = 20;\n break;\n case 17:\n _context21.prev = 17;\n _context21.t0 = _context21[\"catch\"](0);\n console.log(_context21.t0);\n case 20:\n case \"end\":\n return _context21.stop();\n }\n }, _callee21, null, [[0, 17]]);\n }));\n}\nfunction getImprovementWorkResponsible(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {\n var constraints, q, querySnapshot, responsible;\n return _regeneratorRuntime().wrap(function _callee22$(_context22) {\n while (1) switch (_context22.prev = _context22.next) {\n case 0:\n _context22.prev = 0;\n constraints = [];\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"isResponsibleFor\", \"==\", true));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context22.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 7:\n querySnapshot = _context22.sent;\n if (!querySnapshot.empty) {\n _context22.next = 13;\n break;\n }\n console.log(\"Improvement work \", improvementWorkId, \" has no responsible\");\n return _context22.abrupt(\"return\", null);\n case 13:\n responsible = querySnapshot.docs[0].data().userHsaId;\n return _context22.abrupt(\"return\", responsible);\n case 15:\n _context22.next = 20;\n break;\n case 17:\n _context22.prev = 17;\n _context22.t0 = _context22[\"catch\"](0);\n console.log(_context22.t0);\n case 20:\n case \"end\":\n return _context22.stop();\n }\n }, _callee22, null, [[0, 17]]);\n }));\n}\n// TODO getUsersForTask!\n/**\n * Asynchronously retrieves user documents from the database based on various filter criteria.\n * It can filter by the Health Savings Account ID (hsaId), unit ID, and unique identifier (uid).\n * Additionally, it can sort the results by first name in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.hsaId] - Optional HSA ID to filter the users.\n * @param {string} [params.unitId] - Optional unit ID to filter the users.\n * @param {boolean} [params.ascendingFirstNames=false] - Optional flag to sort by first names in ascending order. Defaults to false (descending order).\n * @param {string} [params.uid] - Optional unique identifier to filter the users.\n * @returns {Promise<any[]>} A promise that resolves to an array of user objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUsers(_ref5) {\n var hsaId = _ref5.hsaId,\n unitId = _ref5.unitId,\n _ref5$ascendingFirstN = _ref5.ascendingFirstNames,\n ascendingFirstNames = _ref5$ascendingFirstN === void 0 ? false : _ref5$ascendingFirstN,\n uid = _ref5.uid;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {\n var collectionRef, constraints, q, querySnapshot, users;\n return _regeneratorRuntime().wrap(function _callee23$(_context23) {\n while (1) switch (_context23.prev = _context23.next) {\n case 0:\n _context23.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\n constraints = [];\n if (hsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hsaId));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (uid) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"uid\", \"==\", uid));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"firstName\", ascendingFirstNames ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context23.next = 10;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 10:\n querySnapshot = _context23.sent;\n users = [];\n querySnapshot.forEach(function (doc) {\n users.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context23.abrupt(\"return\", users);\n case 16:\n _context23.prev = 16;\n _context23.t0 = _context23[\"catch\"](0);\n console.log(\"Error retrieving users by department: \", _context23.t0);\n throw _context23.t0;\n case 20:\n case \"end\":\n return _context23.stop();\n }\n }, _callee23, null, [[0, 16]]);\n }));\n}\n// TODO getTasksForUser!\n/**\n * Asynchronously retrieves an array of task documents from the database based on several filter and sorting criteria.\n * Filters include task ID, user ID and their responsibility status, and related improvement work ID.\n * Results can be sorted by date either in ascending or descending order.\n *\n * @param {Object} params - Parameters to filter and sort the task results.\n * @param {string} [params.taskId] - Optional task ID to filter the tasks.\n * @param {string} [params.userId] - Optional user ID to identify tasks related to a user.\n * @param {boolean} [params.isResponsibleFor] - Optional flag to filter tasks where the user is marked as responsible.\n * @param {string} [params.improvementWorkId] - Optional improvement work ID to filter tasks related to a specific improvement work.\n * @param {boolean} [params.ascendingDates=false] - Optional flag to sort tasks by date in ascending order; defaults to descending order.\n * @returns {Promise<any[]>} A promise that resolves to an array of task objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getTasks(_ref6) {\n var improvementWorkId = _ref6.improvementWorkId,\n stage = _ref6.stage,\n _ref6$ascendingDates = _ref6.ascendingDates,\n ascendingDates = _ref6$ascendingDates === void 0 ? false : _ref6$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {\n var collectionRef, constraints, q, querySnapshot, tasks;\n return _regeneratorRuntime().wrap(function _callee24$(_context24) {\n while (1) switch (_context24.prev = _context24.next) {\n case 0:\n _context24.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\n constraints = []; // FUTURE FEATURE: Filter on userHsaId AND improvementWork\n // if (userHsaId && isResponsibleFor !== undefined) {\n // constraints.push(\n // where(\"members\", \"array-contains\", {\n // userHsaId: userHsaId,\n // isResponsibleFor: isResponsibleFor,\n // })\n // );\n // }\n if (stage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"stage\", \"==\", stage));\n }\n if (improvementWorkId != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"startDate\", ascendingDates ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context24.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context24.sent;\n tasks = [];\n querySnapshot.forEach(function (doc) {\n tasks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context24.abrupt(\"return\", tasks);\n case 14:\n _context24.prev = 14;\n _context24.t0 = _context24[\"catch\"](0);\n console.log(\"Error retrieving task by department: \", _context24.t0);\n throw _context24.t0;\n case 18:\n case \"end\":\n return _context24.stop();\n }\n }, _callee24, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of unit documents from the database based on various filter criteria.\n * Filters can be applied based on unit ID, hospital ID, and unit name.\n * Additionally, results can be sorted by unit names in ascending or descending order.\n *\n * @param {Object} params - The parameters object containing filter and sorting options.\n * @param {string} [params.unitId] - Optional unit ID to filter the units.\n * @param {string} [params.hospitalId] - Optional hospital ID to filter units within a specific hospital.\n * @param {string} [params.name] - Optional name to filter units by a specific name.\n * @param {boolean} [params.ascendingUnitNames=false] - Optional flag to sort units by name in ascending order, defaults to descending.\n * @returns {Promise<any[]>} A promise that resolves to an array of unit objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUnits(_ref7) {\n var unitId = _ref7.unitId,\n hospitalId = _ref7.hospitalId,\n name = _ref7.name,\n _ref7$ascendingUnitNa = _ref7.ascendingUnitNames,\n ascendingUnitNames = _ref7$ascendingUnitNa === void 0 ? false : _ref7$ascendingUnitNa;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {\n var collectionRef, constraints, q, querySnapshot, units;\n return _regeneratorRuntime().wrap(function _callee25$(_context25) {\n while (1) switch (_context25.prev = _context25.next) {\n case 0:\n _context25.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\n constraints = [];\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", unitId));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"hospitalId\", \"==\", hospitalId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"name\", ascendingUnitNames ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context25.next = 9;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 9:\n querySnapshot = _context25.sent;\n units = [];\n querySnapshot.forEach(function (doc) {\n units.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context25.abrupt(\"return\", units);\n case 15:\n _context25.prev = 15;\n _context25.t0 = _context25[\"catch\"](0);\n console.log(\"Error retrieving units by hospitalId: \", _context25.t0);\n throw _context25.t0;\n case 19:\n case \"end\":\n return _context25.stop();\n }\n }, _callee25, null, [[0, 15]]);\n }));\n}\nfunction getImprovementWorksForUser(userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {\n var q, querySnapshot, improvementWorks, _iterator, _step, _doc, improvementWorkId, improvementWorkDoc;\n return _regeneratorRuntime().wrap(function _callee26$(_context26) {\n while (1) switch (_context26.prev = _context26.next) {\n case 0:\n _context26.prev = 0;\n console.log(\"Getting improvementworks for user: \", userHsaId);\n // Query the userImprovementWork collection for relations involving this user\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(userImprovementWorkCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)('userHsaId', '==', userHsaId));\n _context26.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 5:\n querySnapshot = _context26.sent;\n // Fetch each related improvementWork document\n improvementWorks = [];\n _iterator = _createForOfIteratorHelper(querySnapshot.docs);\n _context26.prev = 8;\n _iterator.s();\n case 10:\n if ((_step = _iterator.n()).done) {\n _context26.next = 19;\n break;\n }\n _doc = _step.value;\n improvementWorkId = _doc.data().improvementWorkId;\n _context26.next = 15;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 15:\n improvementWorkDoc = _context26.sent;\n improvementWorks.push(improvementWorkDoc);\n case 17:\n _context26.next = 10;\n break;\n case 19:\n _context26.next = 24;\n break;\n case 21:\n _context26.prev = 21;\n _context26.t0 = _context26[\"catch\"](8);\n _iterator.e(_context26.t0);\n case 24:\n _context26.prev = 24;\n _iterator.f();\n return _context26.finish(24);\n case 27:\n return _context26.abrupt(\"return\", improvementWorks);\n case 30:\n _context26.prev = 30;\n _context26.t1 = _context26[\"catch\"](0);\n console.error(\"Error getting improvement works for user: \", _context26.t1);\n throw _context26.t1;\n case 34:\n case \"end\":\n return _context26.stop();\n }\n }, _callee26, null, [[0, 30], [8, 21, 24, 27]]);\n }));\n}\nfunction getUsersForImprovementWork(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {\n var q, querySnapshot, users, _iterator2, _step2, _doc2, userHsaId, userDoc;\n return _regeneratorRuntime().wrap(function _callee27$(_context27) {\n while (1) switch (_context27.prev = _context27.next) {\n case 0:\n _context27.prev = 0;\n console.log(\"Getting users for improvementwork: \", improvementWorkId);\n // Query the userImprovementWork collection for relations involving this improvementWork\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(userImprovementWorkCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)('improvementWorkId', '==', improvementWorkId));\n _context27.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 5:\n querySnapshot = _context27.sent;\n // Fetch each related user document\n users = [];\n _iterator2 = _createForOfIteratorHelper(querySnapshot.docs);\n _context27.prev = 8;\n _iterator2.s();\n case 10:\n if ((_step2 = _iterator2.n()).done) {\n _context27.next = 19;\n break;\n }\n _doc2 = _step2.value;\n userHsaId = _doc2.data().userHsaId;\n _context27.next = 15;\n return getObjectById(\"users\", userHsaId);\n case 15:\n userDoc = _context27.sent;\n users.push(userDoc);\n case 17:\n _context27.next = 10;\n break;\n case 19:\n _context27.next = 24;\n break;\n case 21:\n _context27.prev = 21;\n _context27.t0 = _context27[\"catch\"](8);\n _iterator2.e(_context27.t0);\n case 24:\n _context27.prev = 24;\n _iterator2.f();\n return _context27.finish(24);\n case 27:\n return _context27.abrupt(\"return\", users);\n case 30:\n _context27.prev = 30;\n _context27.t1 = _context27[\"catch\"](0);\n console.error(\"Error getting users for improvementWork: \", _context27.t1);\n throw _context27.t1;\n case 34:\n case \"end\":\n return _context27.stop();\n }\n }, _callee27, null, [[0, 30], [8, 21, 24, 27]]);\n }));\n}\n// export getters to be able to use in other files\n\n////////////////////////////////////DELETING/////////////////////////////////////////////\n// delete an instance of a type\nfunction deleteInstance(docType, docId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee28$(_context28) {\n while (1) switch (_context28.prev = _context28.next) {\n case 0:\n _context28.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context28.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(docRef);\n case 4:\n console.log(\"\".concat(docType, \" deleted successfully.\"));\n _context28.next = 11;\n break;\n case 7:\n _context28.prev = 7;\n _context28.t0 = _context28[\"catch\"](0);\n console.error(\"Error deleting \".concat(docType, \":\"), _context28.t0);\n throw _context28.t0;\n case 11:\n case \"end\":\n return _context28.stop();\n }\n }, _callee28, null, [[0, 7]]);\n }));\n}\n// delete all instances of a type\nfunction deleteAllDocumentsInCollection(collectionName) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {\n var _this = this;\n var collectionRef, snapshot, deletePromises;\n return _regeneratorRuntime().wrap(function _callee30$(_context30) {\n while (1) switch (_context30.prev = _context30.next) {\n case 0:\n _context30.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionName);\n _context30.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n snapshot = _context30.sent;\n // Delete all documents in the collection\n deletePromises = snapshot.docs.map(function (doc) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {\n return _regeneratorRuntime().wrap(function _callee29$(_context29) {\n while (1) switch (_context29.prev = _context29.next) {\n case 0:\n _context29.next = 2;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(doc.ref);\n case 2:\n case \"end\":\n return _context29.stop();\n }\n }, _callee29);\n }));\n });\n _context30.next = 8;\n return Promise.all(deletePromises);\n case 8:\n console.log(\"All documents in the \".concat(collectionName, \" collection deleted successfully.\"));\n _context30.next = 15;\n break;\n case 11:\n _context30.prev = 11;\n _context30.t0 = _context30[\"catch\"](0);\n console.error(\"Error deleting all documents in \".concat(collectionName, \":\"), _context30.t0);\n throw _context30.t0;\n case 15:\n case \"end\":\n return _context30.stop();\n }\n }, _callee30, null, [[0, 11]]);\n }));\n}\n////////////////////////////////////UPDATING/////////////////////////////////////////////\n// update a field in an instance\nfunction updateInstance(docType, docId, updates) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee31$(_context31) {\n while (1) switch (_context31.prev = _context31.next) {\n case 0:\n _context31.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context31.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(docRef, updates);\n case 4:\n console.log(\"\".concat(docType, \" updated successfully.\"));\n _context31.next = 11;\n break;\n case 7:\n _context31.prev = 7;\n _context31.t0 = _context31[\"catch\"](0);\n console.error(\"Error updating \".concat(docType, \":\"), _context31.t0);\n throw _context31.t0;\n case 11:\n case \"end\":\n return _context31.stop();\n }\n }, _callee31, null, [[0, 7]]);\n }));\n}\n// changes the ongoing status of an improvement work. if ongoing it is paused, if if paused onging.\n// user must be a manager\nfunction startOrPauseImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee32$(_context32) {\n while (1) switch (_context32.prev = _context32.next) {\n case 0:\n _context32.prev = 0;\n _context32.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context32.sent;\n _context32.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context32.sent;\n if (!(!user || !user.manager)) {\n _context32.next = 11;\n break;\n }\n throw new Error(\"User can't change improvementWork status\");\n case 11:\n if (!improvementWork) {\n _context32.next = 18;\n break;\n }\n update = {\n ongoing: !improvementWork.ongoing\n };\n _context32.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n _context32.next = 19;\n break;\n case 18:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n case 19:\n _context32.next = 25;\n break;\n case 21:\n _context32.prev = 21;\n _context32.t0 = _context32[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context32.t0);\n throw _context32.t0;\n case 25:\n case \"end\":\n return _context32.stop();\n }\n }, _callee32, null, [[0, 21]]);\n }));\n}\nfunction changePatientRiskLevel(userId, improvementWorkId, patientRiskLevel) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee33$(_context33) {\n while (1) switch (_context33.prev = _context33.next) {\n case 0:\n _context33.prev = 0;\n _context33.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context33.sent;\n _context33.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context33.sent;\n if (!(!user || !user.manager)) {\n _context33.next = 11;\n break;\n }\n throw new Error(\"User can't change patientRiskLevel in improvement work\");\n case 11:\n if (!improvementWork) {\n _context33.next = 18;\n break;\n }\n update = {\n patientRiskLevel: patientRiskLevel\n };\n _context33.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n _context33.next = 19;\n break;\n case 18:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n case 19:\n _context33.next = 25;\n break;\n case 21:\n _context33.prev = 21;\n _context33.t0 = _context33[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context33.t0);\n throw _context33.t0;\n case 25:\n case \"end\":\n return _context33.stop();\n }\n }, _callee33, null, [[0, 21]]);\n }));\n}\n// finalizes the improvement work. ongoing is set to false.\n// user must be a manager\nfunction finalizeImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {\n var user, update;\n return _regeneratorRuntime().wrap(function _callee34$(_context34) {\n while (1) switch (_context34.prev = _context34.next) {\n case 0:\n _context34.prev = 0;\n _context34.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context34.sent;\n if (!(!user || !user.manager)) {\n _context34.next = 8;\n break;\n }\n throw new Error(\"User can't finalize improvementWork status\");\n case 8:\n update = {\n completed: true,\n ongoing: false\n };\n _context34.next = 11;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 11:\n _context34.next = 16;\n break;\n case 13:\n _context34.prev = 13;\n _context34.t0 = _context34[\"catch\"](0);\n console.log(_context34.t0);\n case 16:\n case \"end\":\n return _context34.stop();\n }\n }, _callee34, null, [[0, 13]]);\n }));\n}\n\n//////////////////////////////// for later sprint\n//function add_upvotes\n//function add_notes\n//function add_intrested_users\n\n//# sourceURL=webpack://c3/./client/Database/database.js?"); /***/ }), diff --git a/client/dist/makeSuggestion.bundle.js b/client/dist/makeSuggestion.bundle.js index 36f3be6a228c428f2a4284e2198bb8659674ec5f..6c8ac8b258267b29b3fec477562c5332408649d9 100644 --- a/client/dist/makeSuggestion.bundle.js +++ b/client/dist/makeSuggestion.bundle.js @@ -96,7 +96,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \*************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addDocumentToImprovementWork: () => (/* binding */ addDocumentToImprovementWork),\n/* harmony export */ addMemberToImprovementWork: () => (/* binding */ addMemberToImprovementWork),\n/* harmony export */ addMemberToTask: () => (/* binding */ addMemberToTask),\n/* harmony export */ addNoteToUser: () => (/* binding */ addNoteToUser),\n/* harmony export */ auth: () => (/* binding */ auth),\n/* harmony export */ changePatientRiskLevel: () => (/* binding */ changePatientRiskLevel),\n/* harmony export */ createComment: () => (/* binding */ createComment),\n/* harmony export */ createHospital: () => (/* binding */ createHospital),\n/* harmony export */ createImprovementWork: () => (/* binding */ createImprovementWork),\n/* harmony export */ createSuggestion: () => (/* binding */ createSuggestion),\n/* harmony export */ createTaskOnImprovementWork: () => (/* binding */ createTaskOnImprovementWork),\n/* harmony export */ createUnit: () => (/* binding */ createUnit),\n/* harmony export */ createUser: () => (/* binding */ createUser),\n/* harmony export */ createdDocumentInKnowledgeBank: () => (/* binding */ createdDocumentInKnowledgeBank),\n/* harmony export */ db: () => (/* binding */ db),\n/* harmony export */ deleteAllDocumentsInCollection: () => (/* binding */ deleteAllDocumentsInCollection),\n/* harmony export */ deleteInstance: () => (/* binding */ deleteInstance),\n/* harmony export */ finalizeImprovementWork: () => (/* binding */ finalizeImprovementWork),\n/* harmony export */ getComments: () => (/* binding */ getComments),\n/* harmony export */ getHospitals: () => (/* binding */ getHospitals),\n/* harmony export */ getImprovementWorks: () => (/* binding */ getImprovementWorks),\n/* harmony export */ getObject: () => (/* binding */ getObject),\n/* harmony export */ getObjectById: () => (/* binding */ getObjectById),\n/* harmony export */ getSuggestions: () => (/* binding */ getSuggestions),\n/* harmony export */ getTasks: () => (/* binding */ getTasks),\n/* harmony export */ getUnits: () => (/* binding */ getUnits),\n/* harmony export */ getUsers: () => (/* binding */ getUsers),\n/* harmony export */ startOrPauseImprovementWork: () => (/* binding */ startOrPauseImprovementWork),\n/* harmony export */ updateInstance: () => (/* binding */ updateInstance),\n/* harmony export */ upvoteComment: () => (/* binding */ upvoteComment),\n/* harmony export */ upvoteSuggestion: () => (/* binding */ upvoteSuggestion)\n/* harmony export */ });\n/* harmony import */ var firebase_app__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! firebase/app */ \"./node_modules/firebase/app/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_firestore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! firebase/firestore */ \"./node_modules/firebase/firestore/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_auth__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! firebase/auth */ \"./node_modules/firebase/auth/dist/esm/index.esm.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nvar firebaseConfig = {\n apiKey: \"AIzaSyDqkaVZMr11J4mfnR0auqoQilZyPfyD-x4\",\n authDomain: \"c3solutions-dc109.firebaseapp.com\",\n projectId: \"c3solutions-dc109\",\n storageBucket: \"c3solutions-dc109.appspot.com\",\n messagingSenderId: \"902143402555\",\n appId: \"1:902143402555:web:29213e81de0a0cba38b21e\"\n};\nvar app = (0,firebase_app__WEBPACK_IMPORTED_MODULE_0__.initializeApp)(firebaseConfig);\nvar auth = (0,firebase_auth__WEBPACK_IMPORTED_MODULE_2__.getAuth)();\nvar db = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getFirestore)(app);\nvar userCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\nvar unitCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\nvar improvementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\nvar taskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\nvar hospitalCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\nvar suggestionCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\nvar knowledgeDocumentCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"knowledgeDocument\");\n////////////////////////////////////////Setters///////////////////////////////////////////////////////////////////\n// Function to create user a new user in database\n// takes in userId, unitId, firstname, lastname, email and password as string\n// throws error if transaction failed\nfunction createUser(hsaId, unitId, firstName, lastName, email, manager, uid) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var userRef, unitRef;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, hsaId);\n _context.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(userRef, {\n id: userRef.id,\n uid: uid,\n unitId: unitId,\n firstName: firstName,\n lastName: lastName,\n email: email,\n improvementWorks: [],\n tasks: [],\n manager: manager\n });\n case 4:\n // Atomically add user to unit.\n unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection, unitId);\n _context.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(unitRef, {\n members: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userRef.id)\n });\n case 7:\n _context.next = 12;\n break;\n case 9:\n _context.prev = 9;\n _context.t0 = _context[\"catch\"](0);\n console.log(_context.t0);\n case 12:\n case \"end\":\n return _context.stop();\n }\n }, _callee, null, [[0, 9]]);\n }));\n}\n//Adds a new improvementWork to the database\n// takes in Id, name, currentStage in PDSA, content, unitId refers to as string and if completed as boolean\n// throws error if transaction failed\nfunction createImprovementWork(id, name, currentStage, content,\n// Är detta description bör detta förtydligas. \nunitId, purpose,\n//Bör tas bort motsvaras av p2- mål med projektet\npatientRiskLevel, area,\n// patientRiskLevel: \"Green\" | \"Blue\" | \"Orange\" | \"Red\"\n//Questions in planning stage\np1, p2, p3, p4, p5, p6, p7,\n//Questions in Doing (G) stage\ng1, g2, g3, g4, g5,\n//Questions in stydy stage\ns1, s2, s3,\n//Questions in acting stage\na1, a2, a3, a4) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var improvementWorkRef;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.prev = 0;\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, id);\n _context2.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(improvementWorkRef, {\n id: improvementWorkRef.id,\n currentStage: currentStage,\n name: name,\n content: content,\n purpose: purpose,\n dateStarted: new Date(),\n unitId: unitId,\n completed: false,\n ongoing: false,\n tasks: [],\n members: [],\n patientRiskLevel: patientRiskLevel,\n area: area,\n p1: p1,\n p2: p2,\n p3: p3,\n p4: p4,\n p5: p5,\n p6: p6,\n p7: p7,\n g1: g1,\n g2: g2,\n g3: g3,\n g4: g4,\n g5: g5,\n s1: s1,\n s2: s2,\n s3: s3,\n a1: a1,\n a2: a2,\n a3: a3,\n a4: a4\n });\n case 4:\n _context2.next = 10;\n break;\n case 6:\n _context2.prev = 6;\n _context2.t0 = _context2[\"catch\"](0);\n console.log(\"Error creating improvementWork: \", _context2.t0);\n throw _context2.t0;\n case 10:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, null, [[0, 6]]);\n }));\n}\n//create task to improvementWork\n// takes in improvementWorkId, name, deadline date, start date, stage in PDSA and content as string\n// throws error if transaction failed\nfunction createTaskOnImprovementWork(taskId, improvementWorkId, name, deadlineDate, startDate, stage, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var ref, improvementWorkRef;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.prev = 0;\n ref = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection, taskId);\n _context3.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(ref, {\n id: ref.id,\n improvementWorkId: improvementWorkId,\n name: name,\n deadlineDate: deadlineDate,\n startDate: startDate,\n stage: stage,\n content: content,\n members: []\n });\n case 4:\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, improvementWorkId); // Atomically add task to the tasks array field.\n _context3.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(improvementWorkRef, {\n tasks: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(taskId)\n });\n case 7:\n _context3.next = 13;\n break;\n case 9:\n _context3.prev = 9;\n _context3.t0 = _context3[\"catch\"](0);\n console.log(\"Error creating task: \", _context3.t0);\n throw _context3.t0;\n case 13:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, null, [[0, 9]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction createdDocumentInKnowledgeBank(documentUrl, name) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n _context4.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(knowledgeDocumentCollection);\n _context4.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n name: name\n });\n case 4:\n _context4.next = 10;\n break;\n case 6:\n _context4.prev = 6;\n _context4.t0 = _context4[\"catch\"](0);\n console.log(\"Error adding document: \", _context4.t0);\n throw _context4.t0;\n case 10:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4, null, [[0, 6]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction addDocumentToImprovementWork(documentUrl, name, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var improvementWorkRef, docRef;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n _context5.prev = 0;\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, improvementWorkId);\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkRef, \"documents\");\n _context5.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n timestamp: new Date(),\n name: name\n });\n case 5:\n _context5.next = 11;\n break;\n case 7:\n _context5.prev = 7;\n _context5.t0 = _context5[\"catch\"](0);\n console.log(\"Error adding document: \", _context5.t0);\n throw _context5.t0;\n case 11:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5, null, [[0, 7]]);\n }));\n}\n//add a member to a improvementWork\n// takes in id, users HSAid, improvementWorks id as string and if is owner, is responsible as boolean\n// throws error if transaction failed\nfunction addMemberToImprovementWork(userHsaId, improvementWorkId, isOwner, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var improvementWorkRef, userRef;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n _context6.prev = 0;\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, improvementWorkId); // return;\n // Atomically update the members array in the improvementWork document\n _context6.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(improvementWorkRef, {\n members: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)({\n userHsaId: userHsaId,\n isOwner: isOwner,\n isResponsibleFor: isResponsibleFor\n })\n });\n case 4:\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, userHsaId); // Atomically add improvementWork to user\n _context6.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(userRef, {\n improvementWorks: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)({\n improvementWorkId: improvementWorkId,\n isOwner: isOwner,\n isResponsibleFor: isResponsibleFor\n })\n });\n case 7:\n _context6.next = 13;\n break;\n case 9:\n _context6.prev = 9;\n _context6.t0 = _context6[\"catch\"](0);\n console.log(\"Error adding member: \", _context6.t0);\n throw _context6.t0;\n case 13:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6, null, [[0, 9]]);\n }));\n}\n//create a hospital\n// takes in ID, name as string\n// throws error if transaction failed\nfunction createHospital(hospitalId,\n// should be auto?\nname) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var ref;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.prev = 0;\n ref = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection, hospitalId);\n _context7.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(ref, {\n id: ref.id,\n name: name,\n units: []\n });\n case 4:\n _context7.next = 10;\n break;\n case 6:\n _context7.prev = 6;\n _context7.t0 = _context7[\"catch\"](0);\n console.log(\"Error creating hospital: \", _context7.t0);\n throw _context7.t0;\n case 10:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7, null, [[0, 6]]);\n }));\n}\n//create a unit\n// takes in id, hospitals id and name as string\n// throws error if transaction failed\nfunction createUnit(unitId,\n//should be auto?\nhospitalId, name) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var unitRef, hospitalRef;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n _context8.prev = 0;\n unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection, unitId);\n _context8.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(unitRef, {\n id: unitRef.id,\n hospitalId: hospitalId,\n name: name,\n members: []\n });\n case 4:\n // Atomically add unit to hospital.\n hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection, hospitalId);\n _context8.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(hospitalRef, {\n units: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(unitRef.id)\n });\n case 7:\n _context8.next = 13;\n break;\n case 9:\n _context8.prev = 9;\n _context8.t0 = _context8[\"catch\"](0);\n console.log(\"Error creating unit: \", _context8.t0);\n throw _context8.t0;\n case 13:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8, null, [[0, 9]]);\n }));\n}\n//adds a member to task\n// takes in ID, the added members hsaId, task id as string and if person is responsible as boolean\n// throws error if transaction failed\nfunction addMemberToTask(userHsaId, taskId, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var taskRef, userRef;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n _context9.prev = 0;\n // Atomically add a member to task.\n taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection, taskId);\n _context9.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(taskRef, {\n members: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)({\n userHsaId: userHsaId,\n isResponsibleFor: isResponsibleFor\n })\n });\n case 4:\n // Atomically add a task to user.\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, userHsaId);\n _context9.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(userRef, {\n tasks: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)({\n taskId: taskId,\n isResponsibleFor: isResponsibleFor\n })\n });\n case 7:\n _context9.next = 13;\n break;\n case 9:\n _context9.prev = 9;\n _context9.t0 = _context9[\"catch\"](0);\n console.log(\"Error adding member: \", _context9.t0);\n throw _context9.t0;\n case 13:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9, null, [[0, 9]]);\n }));\n}\n//creates a suggestion\n// takes in ID, the creators hsaId, name, content and the responding unitId as string\n// throws error if transaction failed\nfunction createSuggestion(id, creatorHsaId, name, area, content, purpose, measure, ideas,\n//need: boolean,\nunitId, departmentId, isPublic) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var suggestionRef, commentCollection;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n _context10.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, id);\n _context10.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(suggestionRef, {\n id: suggestionRef.id,\n creatorHsaId: creatorHsaId,\n name: name,\n area: area,\n content: content,\n purpose: purpose,\n measure: measure,\n ideas: ideas,\n //need: need,\n unitId: unitId,\n departmentId: departmentId,\n \"public\": isPublic,\n upvotes: [],\n comments: [],\n dateCreated: new Date()\n });\n case 4:\n _context10.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\");\n case 6:\n commentCollection = _context10.sent;\n _context10.next = 9;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(commentCollection);\n case 9:\n _context10.next = 15;\n break;\n case 11:\n _context10.prev = 11;\n _context10.t0 = _context10[\"catch\"](0);\n console.log(\"Error creating suggestion: \", _context10.t0);\n throw _context10.t0;\n case 15:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10, null, [[0, 11]]);\n }));\n}\n// Upvote a suggestion for a user\n// takes in suggestion id, user HSAid\n// returns error if transaction failed\nfunction upvoteSuggestion(suggestionId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var suggestionRef;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n _context11.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId); // Atomically add a update to the upvote array field.\n _context11.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(suggestionRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 4:\n _context11.next = 10;\n break;\n case 6:\n _context11.prev = 6;\n _context11.t0 = _context11[\"catch\"](0);\n console.log(\"Error upvoting suggestion: \", _context11.t0);\n throw _context11.t0;\n case 10:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11, null, [[0, 6]]);\n }));\n}\n//creates a comment\n// takes in commenters id, suggestion id and content as string\n// throws error if transaction failed\nfunction createComment(\n// change to subcollection\ncommenterHsaId, suggestionId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var suggestionRef, commentCollection, commentRef;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n _context12.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context12.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\");\n case 4:\n commentCollection = _context12.sent;\n _context12.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(commentCollection);\n case 7:\n commentRef = _context12.sent;\n _context12.next = 10;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(commentRef, {\n id: commentRef.id,\n commenterHsaId: commenterHsaId,\n content: content,\n dateCreated: new Date(),\n upvotes: []\n });\n case 10:\n _context12.next = 16;\n break;\n case 12:\n _context12.prev = 12;\n _context12.t0 = _context12[\"catch\"](0);\n console.log(\"Error creating comment: \", _context12.t0);\n throw _context12.t0;\n case 16:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12, null, [[0, 12]]);\n }));\n}\n// Upvote a comment for a user\n// takes in suggestionId, commentId and userId as strings\n// return error if transaction failed\nfunction upvoteComment(suggestionId, commentId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var suggestionRef, commentRef;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n _context13.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n commentRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionRef, \"comment\", commentId); // Atomically add a update to the upvote array field.\n _context13.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(commentRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 5:\n _context13.next = 11;\n break;\n case 7:\n _context13.prev = 7;\n _context13.t0 = _context13[\"catch\"](0);\n console.log(\"Error upvoting comment: \", _context13.t0);\n throw _context13.t0;\n case 11:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13, null, [[0, 7]]);\n }));\n}\n//add a note to a user\n// takes in userHsaId and content as string\n// throws error if transaction failed\nfunction addNoteToUser(userHsaId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var userRef, docRef;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n _context14.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, userHsaId);\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userRef, \"notes\");\n _context14.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n content: content,\n dateCreated: new Date()\n });\n case 5:\n _context14.next = 11;\n break;\n case 7:\n _context14.prev = 7;\n _context14.t0 = _context14[\"catch\"](0);\n console.log(\"Error adding document: \", _context14.t0);\n throw _context14.t0;\n case 11:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14, null, [[0, 7]]);\n }));\n}\n// export to setters to be able to use in other files\n\n//////////////////////////////////////////////GETTERS/////////////////////////////////////////////////////////////////////\n// Get any object\n// input is the database type as a string.\n// output is the whole collection of that type.\nfunction getObject(collectionPath) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n var collectionRef, querySnapshot, result;\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n _context15.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionPath);\n _context15.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n querySnapshot = _context15.sent;\n result = [];\n querySnapshot.forEach(function (doc) {\n result.push(doc.data());\n });\n return _context15.abrupt(\"return\", result);\n case 10:\n _context15.prev = 10;\n _context15.t0 = _context15[\"catch\"](0);\n console.error(\"Error getting collection data\", _context15.t0);\n throw _context15.t0;\n case 14:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15, null, [[0, 10]]);\n }));\n}\n/**\n * Asynchronously retrieves a single document object from the specified collection path and document ID.\n * If the document does not exist, logs a warning and returns null.\n *\n * @param {string} collectionPath - The path to the collection in the database (\"improvementWork\", \"hospital\", \"suggestion\", \"task\", \"unit\", \"users\")\n * @param {string} documentId - The ID of the document to retrieve.\n * @returns {Promise<any|null>} A promise that resolves to the document object if found, or null if not.\n *\n * @throws Will throw an error if there is an issue during retrieval from the database.\n */\nfunction getObjectById(collectionPath, documentId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {\n var docRef, docSnapshot;\n return _regeneratorRuntime().wrap(function _callee16$(_context16) {\n while (1) switch (_context16.prev = _context16.next) {\n case 0:\n _context16.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, collectionPath, documentId);\n _context16.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDoc)(docRef);\n case 4:\n docSnapshot = _context16.sent;\n if (!docSnapshot.exists()) {\n _context16.next = 9;\n break;\n }\n return _context16.abrupt(\"return\", docSnapshot.data());\n case 9:\n console.warn(\"No such document! \".concat(collectionPath, \"/\").concat(documentId));\n return _context16.abrupt(\"return\", null);\n case 11:\n _context16.next = 17;\n break;\n case 13:\n _context16.prev = 13;\n _context16.t0 = _context16[\"catch\"](0);\n console.error(\"Error getting object\", _context16.t0);\n throw _context16.t0;\n case 17:\n case \"end\":\n return _context16.stop();\n }\n }, _callee16, null, [[0, 13]]);\n }));\n}\n/**\n * Asynchronously retrieves comments for a given suggestion.\n *\n * @param {Object} params - The parameters for fetching comments.\n * @param {string} params.suggestionId - The ID of the suggestion to fetch comments for.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - The criterion to sort the comments by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Determines if the sorting should be in ascending order. Defaults to false (descending).\n * @returns {Promise<any[]>} A promise that resolves to an array of comment objects.\n *\n * @throws Will throw an error if the comments cannot be retrieved.\n */\nfunction getComments(_ref) {\n var suggestionId = _ref.suggestionId,\n _ref$sortBy = _ref.sortBy,\n sortBy = _ref$sortBy === void 0 ? \"dateCreated\" : _ref$sortBy,\n _ref$ascending = _ref.ascending,\n ascending = _ref$ascending === void 0 ? false : _ref$ascending;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {\n var suggestionRef, commentsQuery, commentsSnapshot, comments;\n return _regeneratorRuntime().wrap(function _callee17$(_context17) {\n while (1) switch (_context17.prev = _context17.next) {\n case 0:\n _context17.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, \"suggestionCollection\", suggestionId);\n commentsQuery = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\"), (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n _context17.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(commentsQuery);\n case 5:\n commentsSnapshot = _context17.sent;\n comments = [];\n commentsSnapshot.forEach(function (doc) {\n comments.push(doc.data());\n });\n return _context17.abrupt(\"return\", comments);\n case 11:\n _context17.prev = 11;\n _context17.t0 = _context17[\"catch\"](0);\n console.error(\"Error getting comments for suggestion: \", _context17.t0);\n throw _context17.t0;\n case 15:\n case \"end\":\n return _context17.stop();\n }\n }, _callee17, null, [[0, 11]]);\n }));\n}\n//Filtering suggestions on unitId AND creatorHsaId\n//Sort suggestions on dateCreated OR upvotes\n/**\n * Asynchronously retrieves an array of suggestions from the database, with various filters and sorting options.\n *\n * @param {Object} params - The parameters for filtering and sorting suggestions.\n * @param {string} [params.id] - Optional ID to filter suggestions by a specific identifier.\n * @param {string} [params.creatorHsaId] - Optional HSA ID to filter suggestions by the creator's HSA ID.\n * @param {string} [params.unitId] - Optional unit ID to filter suggestions by a specific unit.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - Criterion to sort the suggestions by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Flag indicating if sorting should be ascending. Defaults to false (descending order).\n * @param {boolean} [params.isPublic=true] - Flag indicating whether to filter for public suggestions. Defaults to true.\n * @returns {Promise<any[]>} A promise that resolves to an array of suggestion objects.\n *\n * @throws Will throw an error if there is an issue retrieving suggestions.\n */\nfunction getSuggestions(_ref2) {\n var id = _ref2.id,\n creatorHsaId = _ref2.creatorHsaId,\n unitId = _ref2.unitId,\n _ref2$sortBy = _ref2.sortBy,\n sortBy = _ref2$sortBy === void 0 ? \"dateCreated\" : _ref2$sortBy,\n _ref2$ascending = _ref2.ascending,\n ascending = _ref2$ascending === void 0 ? false : _ref2$ascending,\n _ref2$isPublic = _ref2.isPublic,\n isPublic = _ref2$isPublic === void 0 ? true : _ref2$isPublic;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {\n var collectionRef, constraints, q, querySnapshot, suggestions;\n return _regeneratorRuntime().wrap(function _callee18$(_context18) {\n while (1) switch (_context18.prev = _context18.next) {\n case 0:\n _context18.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (creatorHsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"creatorHsaId\", \"==\", creatorHsaId));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"public\", \"==\", isPublic));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context18.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 11:\n querySnapshot = _context18.sent;\n suggestions = [];\n querySnapshot.forEach(function (doc) {\n suggestions.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context18.abrupt(\"return\", suggestions);\n case 17:\n _context18.prev = 17;\n _context18.t0 = _context18[\"catch\"](0);\n console.log(\"Error retrieving suggestions by department: \", _context18.t0);\n throw _context18.t0;\n case 21:\n case \"end\":\n return _context18.stop();\n }\n }, _callee18, null, [[0, 17]]);\n }));\n}\n/**\n * Asynchronously searches for hospital documents in the database.\n * It can filter the results by the hospital's name, ID, or both.\n * If no parameters are provided, it retrieves all hospitals.\n *\n * @param {Object} params - An object containing the search parameters.\n * @param {string} [params.hospitalName] - Optional name of the hospital to filter the search.\n * @param {string} [params.hospitalId] - Optional unique identifier of the hospital to filter the search.\n * @returns {Promise<any[]>} A promise that resolves to an array of hospital objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getHospitals(_ref3) {\n var hospitalName = _ref3.hospitalName,\n hospitalId = _ref3.hospitalId;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {\n var collectionRef, constraints, q, querySnapshot, hospitals;\n return _regeneratorRuntime().wrap(function _callee19$(_context19) {\n while (1) switch (_context19.prev = _context19.next) {\n case 0:\n _context19.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\n constraints = [];\n if (hospitalName) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", hospitalName));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hospitalId));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context19.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context19.sent;\n hospitals = [];\n querySnapshot.forEach(function (doc) {\n hospitals.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context19.abrupt(\"return\", hospitals);\n case 14:\n _context19.prev = 14;\n _context19.t0 = _context19[\"catch\"](0);\n console.log(\"Error retrieving Hospitals\", _context19.t0);\n throw _context19.t0;\n case 18:\n case \"end\":\n return _context19.stop();\n }\n }, _callee19, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of improvement work documents based on various filter criteria.\n * It supports filtering by ID, Nolan stage, unit ID, completion status, ongoing status, and patient risk level.\n * It also supports sorting by the start date of the improvement work in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.id] - Optional identifier to filter the improvement works.\n * @param {string} [params.nolanStage] - Optional Nolan stage to filter the improvement works.\n * @param {string} [params.unitId] - Optional unit ID to filter the improvement works.\n * @param {boolean} [params.completed] - Optional flag to filter the improvement works by their completion status.\n * @param {boolean} [params.ongoing] - Optional flag to filter the improvement works by their ongoing status.\n * @param {string} [params.patientRiskLevel] - Optional patient risk level to filter the improvement works.\n * @param {boolean} [params.ascendingDates=false] - Optional flag for sorting by date in ascending order. Defaults to false.\n * @returns {Promise<any[]>} A promise that resolves to an array of improvement work objects that match the criteria.\n *\n * @throws Will throw an error if there is a problem retrieving the improvement works.\n */\nfunction getImprovementWorks(_ref4) {\n var id = _ref4.id,\n nolanStage = _ref4.nolanStage,\n unitId = _ref4.unitId,\n completed = _ref4.completed,\n ongoing = _ref4.ongoing,\n patientRiskLevel = _ref4.patientRiskLevel,\n _ref4$ascendingDates = _ref4.ascendingDates,\n ascendingDates = _ref4$ascendingDates === void 0 ? false : _ref4$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {\n var collectionRef, constraints, q, querySnapshot, improvementWorks;\n return _regeneratorRuntime().wrap(function _callee20$(_context20) {\n while (1) switch (_context20.prev = _context20.next) {\n case 0:\n _context20.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (nolanStage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"currentStage\", \"==\", nolanStage));\n }\n if (completed != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"completed\", \"==\", completed));\n }\n if (ongoing !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"ongoing\", \"==\", ongoing));\n }\n if (patientRiskLevel) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"patientRiskLevel\", \"==\", patientRiskLevel));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"dateStarted\", ascendingDates ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context20.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 13:\n querySnapshot = _context20.sent;\n improvementWorks = [];\n querySnapshot.forEach(function (doc) {\n improvementWorks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context20.abrupt(\"return\", improvementWorks);\n case 19:\n _context20.prev = 19;\n _context20.t0 = _context20[\"catch\"](0);\n console.log(\"Error retrieving improvementWorks: \", _context20.t0);\n throw _context20.t0;\n case 23:\n case \"end\":\n return _context20.stop();\n }\n }, _callee20, null, [[0, 19]]);\n }));\n}\n/**\n * Asynchronously retrieves user documents from the database based on various filter criteria.\n * It can filter by the Health Savings Account ID (hsaId), unit ID, and unique identifier (uid).\n * Additionally, it can sort the results by first name in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.hsaId] - Optional HSA ID to filter the users.\n * @param {string} [params.unitId] - Optional unit ID to filter the users.\n * @param {boolean} [params.ascendingFirstNames=false] - Optional flag to sort by first names in ascending order. Defaults to false (descending order).\n * @param {string} [params.uid] - Optional unique identifier to filter the users.\n * @returns {Promise<any[]>} A promise that resolves to an array of user objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUsers(_ref5) {\n var hsaId = _ref5.hsaId,\n unitId = _ref5.unitId,\n _ref5$ascendingFirstN = _ref5.ascendingFirstNames,\n ascendingFirstNames = _ref5$ascendingFirstN === void 0 ? false : _ref5$ascendingFirstN,\n uid = _ref5.uid;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {\n var collectionRef, constraints, q, querySnapshot, users;\n return _regeneratorRuntime().wrap(function _callee21$(_context21) {\n while (1) switch (_context21.prev = _context21.next) {\n case 0:\n _context21.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\n constraints = [];\n if (hsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hsaId));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (uid) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"uid\", \"==\", uid));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"firstName\", ascendingFirstNames ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context21.next = 10;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 10:\n querySnapshot = _context21.sent;\n users = [];\n querySnapshot.forEach(function (doc) {\n users.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context21.abrupt(\"return\", users);\n case 16:\n _context21.prev = 16;\n _context21.t0 = _context21[\"catch\"](0);\n console.log(\"Error retrieving users by department: \", _context21.t0);\n throw _context21.t0;\n case 20:\n case \"end\":\n return _context21.stop();\n }\n }, _callee21, null, [[0, 16]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of task documents from the database based on several filter and sorting criteria.\n * Filters include task ID, user ID and their responsibility status, and related improvement work ID.\n * Results can be sorted by date either in ascending or descending order.\n *\n * @param {Object} params - Parameters to filter and sort the task results.\n * @param {string} [params.taskId] - Optional task ID to filter the tasks.\n * @param {string} [params.userId] - Optional user ID to identify tasks related to a user.\n * @param {boolean} [params.isResponsibleFor] - Optional flag to filter tasks where the user is marked as responsible.\n * @param {string} [params.improvementWorkId] - Optional improvement work ID to filter tasks related to a specific improvement work.\n * @param {boolean} [params.ascendingDates=false] - Optional flag to sort tasks by date in ascending order; defaults to descending order.\n * @returns {Promise<any[]>} A promise that resolves to an array of task objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getTasks(_ref6) {\n var taskId = _ref6.taskId,\n userId = _ref6.userId,\n isResponsibleFor = _ref6.isResponsibleFor,\n improvementWorkId = _ref6.improvementWorkId,\n _ref6$ascendingDates = _ref6.ascendingDates,\n ascendingDates = _ref6$ascendingDates === void 0 ? false : _ref6$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {\n var collectionRef, constraints, q, querySnapshot, tasks;\n return _regeneratorRuntime().wrap(function _callee22$(_context22) {\n while (1) switch (_context22.prev = _context22.next) {\n case 0:\n _context22.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\n constraints = [];\n if (taskId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", taskId));\n }\n if (userId && isResponsibleFor !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"members\", \"array-contains\", {\n userHsaId: userId,\n isResponsibleFor: isResponsibleFor\n }));\n }\n if (improvementWorkId != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"startDate\", ascendingDates ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context22.next = 9;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 9:\n querySnapshot = _context22.sent;\n tasks = [];\n querySnapshot.forEach(function (doc) {\n tasks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context22.abrupt(\"return\", tasks);\n case 15:\n _context22.prev = 15;\n _context22.t0 = _context22[\"catch\"](0);\n console.log(\"Error retrieving task by department: \", _context22.t0);\n throw _context22.t0;\n case 19:\n case \"end\":\n return _context22.stop();\n }\n }, _callee22, null, [[0, 15]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of unit documents from the database based on various filter criteria.\n * Filters can be applied based on unit ID, hospital ID, and unit name.\n * Additionally, results can be sorted by unit names in ascending or descending order.\n *\n * @param {Object} params - The parameters object containing filter and sorting options.\n * @param {string} [params.unitId] - Optional unit ID to filter the units.\n * @param {string} [params.hospitalId] - Optional hospital ID to filter units within a specific hospital.\n * @param {string} [params.name] - Optional name to filter units by a specific name.\n * @param {boolean} [params.ascendingUnitNames=false] - Optional flag to sort units by name in ascending order, defaults to descending.\n * @returns {Promise<any[]>} A promise that resolves to an array of unit objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUnits(_ref7) {\n var unitId = _ref7.unitId,\n hospitalId = _ref7.hospitalId,\n name = _ref7.name,\n _ref7$ascendingUnitNa = _ref7.ascendingUnitNames,\n ascendingUnitNames = _ref7$ascendingUnitNa === void 0 ? false : _ref7$ascendingUnitNa;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {\n var collectionRef, constraints, q, querySnapshot, units;\n return _regeneratorRuntime().wrap(function _callee23$(_context23) {\n while (1) switch (_context23.prev = _context23.next) {\n case 0:\n _context23.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\n constraints = [];\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", unitId));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"hospitalId\", \"==\", hospitalId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"name\", ascendingUnitNames ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context23.next = 9;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 9:\n querySnapshot = _context23.sent;\n units = [];\n querySnapshot.forEach(function (doc) {\n units.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context23.abrupt(\"return\", units);\n case 15:\n _context23.prev = 15;\n _context23.t0 = _context23[\"catch\"](0);\n console.log(\"Error retrieving units by hospitalId: \", _context23.t0);\n throw _context23.t0;\n case 19:\n case \"end\":\n return _context23.stop();\n }\n }, _callee23, null, [[0, 15]]);\n }));\n}\n//getMembersFilteredAndSorted() -> Get all members of a project (sorted by firstName?)\n// export getters to be able to use in other files\n\n////////////////////////////////////DELETING/////////////////////////////////////////////\n// delete an instance of a type\nfunction deleteInstance(docType, docId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee24$(_context24) {\n while (1) switch (_context24.prev = _context24.next) {\n case 0:\n _context24.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context24.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(docRef);\n case 4:\n console.log(\"\".concat(docType, \" deleted successfully.\"));\n _context24.next = 11;\n break;\n case 7:\n _context24.prev = 7;\n _context24.t0 = _context24[\"catch\"](0);\n console.error(\"Error deleting \".concat(docType, \":\"), _context24.t0);\n throw _context24.t0;\n case 11:\n case \"end\":\n return _context24.stop();\n }\n }, _callee24, null, [[0, 7]]);\n }));\n}\n// delete all instances of a type\nfunction deleteAllDocumentsInCollection(collectionName) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {\n var _this = this;\n var collectionRef, snapshot, deletePromises;\n return _regeneratorRuntime().wrap(function _callee26$(_context26) {\n while (1) switch (_context26.prev = _context26.next) {\n case 0:\n _context26.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionName);\n _context26.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n snapshot = _context26.sent;\n // Delete all documents in the collection\n deletePromises = snapshot.docs.map(function (doc) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {\n return _regeneratorRuntime().wrap(function _callee25$(_context25) {\n while (1) switch (_context25.prev = _context25.next) {\n case 0:\n _context25.next = 2;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(doc.ref);\n case 2:\n case \"end\":\n return _context25.stop();\n }\n }, _callee25);\n }));\n });\n _context26.next = 8;\n return Promise.all(deletePromises);\n case 8:\n console.log(\"All documents in the \".concat(collectionName, \" collection deleted successfully.\"));\n _context26.next = 15;\n break;\n case 11:\n _context26.prev = 11;\n _context26.t0 = _context26[\"catch\"](0);\n console.error(\"Error deleting all documents in \".concat(collectionName, \":\"), _context26.t0);\n throw _context26.t0;\n case 15:\n case \"end\":\n return _context26.stop();\n }\n }, _callee26, null, [[0, 11]]);\n }));\n}\n////////////////////////////////////UPDATING/////////////////////////////////////////////\n// update a field in an instance\nfunction updateInstance(docType, docId, updates) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee27$(_context27) {\n while (1) switch (_context27.prev = _context27.next) {\n case 0:\n _context27.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context27.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(docRef, updates);\n case 4:\n console.log(\"\".concat(docType, \" updated successfully.\"));\n _context27.next = 11;\n break;\n case 7:\n _context27.prev = 7;\n _context27.t0 = _context27[\"catch\"](0);\n console.error(\"Error updating \".concat(docType, \":\"), _context27.t0);\n throw _context27.t0;\n case 11:\n case \"end\":\n return _context27.stop();\n }\n }, _callee27, null, [[0, 7]]);\n }));\n}\n// changes the ongoing status of an improvement work. if ongoing it is paused, if if paused onging.\n// user must be a manager\nfunction startOrPauseImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee28$(_context28) {\n while (1) switch (_context28.prev = _context28.next) {\n case 0:\n _context28.prev = 0;\n _context28.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context28.sent;\n _context28.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context28.sent;\n if (!(!user || !user.manager)) {\n _context28.next = 11;\n break;\n }\n throw new Error(\"User can't change improvementWork status\");\n case 11:\n if (!improvementWork) {\n _context28.next = 18;\n break;\n }\n update = {\n ongoing: !improvementWork.ongoing\n };\n _context28.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n _context28.next = 19;\n break;\n case 18:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n case 19:\n _context28.next = 25;\n break;\n case 21:\n _context28.prev = 21;\n _context28.t0 = _context28[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context28.t0);\n throw _context28.t0;\n case 25:\n case \"end\":\n return _context28.stop();\n }\n }, _callee28, null, [[0, 21]]);\n }));\n}\nfunction changePatientRiskLevel(userId, improvementWorkId, patientRiskLevel) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee29$(_context29) {\n while (1) switch (_context29.prev = _context29.next) {\n case 0:\n _context29.prev = 0;\n _context29.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context29.sent;\n _context29.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context29.sent;\n if (!(!user || !user.manager)) {\n _context29.next = 11;\n break;\n }\n throw new Error(\"User can't change patientRiskLevel in improvement work\");\n case 11:\n if (!improvementWork) {\n _context29.next = 18;\n break;\n }\n update = {\n patientRiskLevel: patientRiskLevel\n };\n _context29.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n _context29.next = 19;\n break;\n case 18:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n case 19:\n _context29.next = 25;\n break;\n case 21:\n _context29.prev = 21;\n _context29.t0 = _context29[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context29.t0);\n throw _context29.t0;\n case 25:\n case \"end\":\n return _context29.stop();\n }\n }, _callee29, null, [[0, 21]]);\n }));\n}\n// finalizes the improvement work. ongoing is set to false.\n// user must be a manager\nfunction finalizeImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {\n var user, update;\n return _regeneratorRuntime().wrap(function _callee30$(_context30) {\n while (1) switch (_context30.prev = _context30.next) {\n case 0:\n _context30.prev = 0;\n _context30.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context30.sent;\n if (!(!user || !user.manager)) {\n _context30.next = 8;\n break;\n }\n throw new Error(\"User can't finalize improvementWork status\");\n case 8:\n update = {\n completed: true,\n ongoing: false\n };\n _context30.next = 11;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 11:\n _context30.next = 16;\n break;\n case 13:\n _context30.prev = 13;\n _context30.t0 = _context30[\"catch\"](0);\n console.log(_context30.t0);\n case 16:\n case \"end\":\n return _context30.stop();\n }\n }, _callee30, null, [[0, 13]]);\n }));\n}\n\n//////////////////////////////// for later sprint\n//function add_upvotes\n//function add_notes\n//function add_intrested_users\n\n//# sourceURL=webpack://c3/./client/Database/database.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addDocumentToImprovementWork: () => (/* binding */ addDocumentToImprovementWork),\n/* harmony export */ addMemberToImprovementWork: () => (/* binding */ addMemberToImprovementWork),\n/* harmony export */ addMemberToTask: () => (/* binding */ addMemberToTask),\n/* harmony export */ addNoteToUser: () => (/* binding */ addNoteToUser),\n/* harmony export */ auth: () => (/* binding */ auth),\n/* harmony export */ changePatientRiskLevel: () => (/* binding */ changePatientRiskLevel),\n/* harmony export */ createComment: () => (/* binding */ createComment),\n/* harmony export */ createHospital: () => (/* binding */ createHospital),\n/* harmony export */ createImprovementWork: () => (/* binding */ createImprovementWork),\n/* harmony export */ createSuggestion: () => (/* binding */ createSuggestion),\n/* harmony export */ createTaskOnImprovementWork: () => (/* binding */ createTaskOnImprovementWork),\n/* harmony export */ createUnit: () => (/* binding */ createUnit),\n/* harmony export */ createUser: () => (/* binding */ createUser),\n/* harmony export */ createdDocumentInKnowledgeBank: () => (/* binding */ createdDocumentInKnowledgeBank),\n/* harmony export */ db: () => (/* binding */ db),\n/* harmony export */ deleteAllDocumentsInCollection: () => (/* binding */ deleteAllDocumentsInCollection),\n/* harmony export */ deleteInstance: () => (/* binding */ deleteInstance),\n/* harmony export */ finalizeImprovementWork: () => (/* binding */ finalizeImprovementWork),\n/* harmony export */ getComments: () => (/* binding */ getComments),\n/* harmony export */ getHospitals: () => (/* binding */ getHospitals),\n/* harmony export */ getImprovementWorkOwner: () => (/* binding */ getImprovementWorkOwner),\n/* harmony export */ getImprovementWorkResponsible: () => (/* binding */ getImprovementWorkResponsible),\n/* harmony export */ getImprovementWorks: () => (/* binding */ getImprovementWorks),\n/* harmony export */ getImprovementWorksForUser: () => (/* binding */ getImprovementWorksForUser),\n/* harmony export */ getObject: () => (/* binding */ getObject),\n/* harmony export */ getObjectById: () => (/* binding */ getObjectById),\n/* harmony export */ getSuggestions: () => (/* binding */ getSuggestions),\n/* harmony export */ getTasks: () => (/* binding */ getTasks),\n/* harmony export */ getUnits: () => (/* binding */ getUnits),\n/* harmony export */ getUsers: () => (/* binding */ getUsers),\n/* harmony export */ getUsersForImprovementWork: () => (/* binding */ getUsersForImprovementWork),\n/* harmony export */ startOrPauseImprovementWork: () => (/* binding */ startOrPauseImprovementWork),\n/* harmony export */ updateInstance: () => (/* binding */ updateInstance),\n/* harmony export */ upvoteComment: () => (/* binding */ upvoteComment),\n/* harmony export */ upvoteSuggestion: () => (/* binding */ upvoteSuggestion)\n/* harmony export */ });\n/* harmony import */ var firebase_app__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! firebase/app */ \"./node_modules/firebase/app/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_firestore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! firebase/firestore */ \"./node_modules/firebase/firestore/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_auth__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! firebase/auth */ \"./node_modules/firebase/auth/dist/esm/index.esm.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nvar firebaseConfig = {\n apiKey: \"AIzaSyDqkaVZMr11J4mfnR0auqoQilZyPfyD-x4\",\n authDomain: \"c3solutions-dc109.firebaseapp.com\",\n projectId: \"c3solutions-dc109\",\n storageBucket: \"c3solutions-dc109.appspot.com\",\n messagingSenderId: \"902143402555\",\n appId: \"1:902143402555:web:29213e81de0a0cba38b21e\"\n};\n/*const firebaseConfig = {\n apiKey: \"AIzaSyBIsZq_yOsJljp1woIxndJO1GkW6soh-g4\",\n authDomain: \"company3-456bb.firebaseapp.com\",\n projectId: \"company3-456bb\",\n storageBucket: \"company3-456bb.appspot.com\",\n messagingSenderId: \"310033686522\",\n appId: \"1:310033686522:web:63198bb0db679c98ee4e43\",\n measurementId: \"G-PFLDQY00DB\"\n};*/\n// const firebaseConfig = {\n// apiKey: \"AIzaSyBIsZq_yOsJljp1woIxndJO1GkW6soh-g4\",\n// authDomain: \"company3-456bb.firebaseapp.com\",\n// projectId: \"company3-456bb\",\n// storageBucket: \"company3-456bb.appspot.com\",\n// messagingSenderId: \"310033686522\",\n// appId: \"1:310033686522:web:63198bb0db679c98ee4e43\",\n// measurementId: \"G-PFLDQY00DB\"\n// };\nvar app = (0,firebase_app__WEBPACK_IMPORTED_MODULE_0__.initializeApp)(firebaseConfig);\nvar auth = (0,firebase_auth__WEBPACK_IMPORTED_MODULE_2__.getAuth)();\nvar db = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getFirestore)(app);\nvar userCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\nvar unitCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\nvar improvementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\nvar taskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\nvar hospitalCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\nvar suggestionCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\nvar knowledgeDocumentCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"knowledgeDocument\");\nvar userImprovementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"userImprovementWork\");\nvar userTaskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"userTask\");\n////////////////////////////////////////Setters///////////////////////////////////////////////////////////////////\n// Function to create user a new user in database\n// takes in userId, unitId, firstname, lastname, email and password as string\n// throws error if transaction failed\nfunction createUser(hsaId, unitId, firstName, lastName, email, manager, uid) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var userRef, unitRef;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, hsaId);\n _context.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(userRef, {\n id: userRef.id,\n uid: uid,\n unitId: unitId,\n firstName: firstName,\n lastName: lastName,\n email: email,\n // TODO Replace with userImprovementWork collection\n improvementWorks: [],\n tasks: [],\n manager: manager\n });\n case 4:\n // Atomically add user to unit.\n unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection, unitId);\n _context.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(unitRef, {\n members: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userRef.id)\n });\n case 7:\n _context.next = 12;\n break;\n case 9:\n _context.prev = 9;\n _context.t0 = _context[\"catch\"](0);\n console.log(_context.t0);\n case 12:\n case \"end\":\n return _context.stop();\n }\n }, _callee, null, [[0, 9]]);\n }));\n}\nfunction createImprovementWork(id, name, currentStage, content,\n// Är detta description bör detta förtydligas. \nunitId, purpose,\n//Bör tas bort motsvaras av p2- mål med projektet\npatientRiskLevel, area,\n//Questions in planning stage\np1, p2, p3, p4, p5, p6, p7,\n//Questions in Doing (G) stage\ng1, g2, g3, g4, g5,\n//Questions in stydy stage\ns1, s2, s3,\n//Questions in acting stage\na1, a2, a3, a4) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var improvementWorkData, improvementWorkRef, _improvementWorkRef;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.prev = 0;\n improvementWorkData = {\n name: name,\n currentStage: currentStage,\n content: content,\n purpose: purpose,\n dateStarted: new Date(),\n unitId: unitId,\n completed: false,\n ongoing: false,\n tasks: [],\n // TODO Remove members array\n members: [],\n patientRiskLevel: patientRiskLevel,\n area: area,\n p1: p1,\n p2: p2,\n p3: p3,\n p4: p4,\n p5: p5,\n p6: p6,\n p7: p7,\n g1: g1,\n g2: g2,\n g3: g3,\n g4: g4,\n g5: g5,\n s1: s1,\n s2: s2,\n s3: s3,\n a1: a1,\n a2: a2,\n a3: a3,\n a4: a4\n };\n if (!id) {\n _context2.next = 8;\n break;\n }\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, id);\n _context2.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(improvementWorkRef, Object.assign({\n id: improvementWorkRef.id\n }, improvementWorkData));\n case 6:\n _context2.next = 11;\n break;\n case 8:\n _improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection);\n _context2.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_improvementWorkRef, improvementWorkData);\n case 11:\n _context2.next = 17;\n break;\n case 13:\n _context2.prev = 13;\n _context2.t0 = _context2[\"catch\"](0);\n console.log(\"Error creating improvementWork: \", _context2.t0);\n throw _context2.t0;\n case 17:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, null, [[0, 13]]);\n }));\n}\nfunction addMemberToTask(userHsaId, taskId, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var relationRef;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.prev = 0;\n relationRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userTaskCollection);\n _context3.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(relationRef, {\n id: relationRef.id,\n userHsaId: userHsaId,\n taskId: taskId,\n isResponsibleFor: isResponsibleFor\n });\n case 4:\n _context3.next = 10;\n break;\n case 6:\n _context3.prev = 6;\n _context3.t0 = _context3[\"catch\"](0);\n console.log(\"Error adding member to task: \", _context3.t0);\n throw _context3.t0;\n case 10:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, null, [[0, 6]]);\n }));\n}\nfunction addMemberToImprovementWork(userHsaId, improvementWorkId, isOwner, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var relationRef;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n _context4.prev = 0;\n relationRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userImprovementWorkCollection);\n _context4.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(relationRef, {\n id: relationRef.id,\n userHsaId: userHsaId,\n improvementWorkId: improvementWorkId,\n isOwner: isOwner,\n isResponsibleFor: isResponsibleFor\n });\n case 4:\n _context4.next = 10;\n break;\n case 6:\n _context4.prev = 6;\n _context4.t0 = _context4[\"catch\"](0);\n console.log(\"Error adding member to improvementWork: \", _context4.t0);\n throw _context4.t0;\n case 10:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4, null, [[0, 6]]);\n }));\n}\nfunction createTaskOnImprovementWork(taskId, improvementWorkId, name, deadlineDate, startDate, stage, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var taskData, taskRef, _taskRef;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n _context5.prev = 0;\n taskData = {\n improvementWorkId: improvementWorkId,\n name: name,\n deadlineDate: deadlineDate,\n startDate: startDate,\n stage: stage,\n content: content,\n members: [] // Initialize with an empty array\n };\n if (!taskId) {\n _context5.next = 8;\n break;\n }\n taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection, taskId);\n _context5.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(taskRef, Object.assign({\n id: taskRef.id\n }, taskData));\n case 6:\n _context5.next = 11;\n break;\n case 8:\n _taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection);\n _context5.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_taskRef, taskData);\n case 11:\n _context5.next = 17;\n break;\n case 13:\n _context5.prev = 13;\n _context5.t0 = _context5[\"catch\"](0);\n console.log(\"Error creating task: \", _context5.t0);\n throw _context5.t0;\n case 17:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5, null, [[0, 13]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction createdDocumentInKnowledgeBank(documentUrl, name) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n _context6.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(knowledgeDocumentCollection);\n _context6.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n name: name\n });\n case 4:\n _context6.next = 10;\n break;\n case 6:\n _context6.prev = 6;\n _context6.t0 = _context6[\"catch\"](0);\n console.log(\"Error adding document: \", _context6.t0);\n throw _context6.t0;\n case 10:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6, null, [[0, 6]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction addDocumentToImprovementWork(documentUrl, name, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var improvementWorkRef, docRef;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.prev = 0;\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, improvementWorkId);\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkRef, \"documents\");\n _context7.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n timestamp: new Date(),\n name: name\n });\n case 5:\n _context7.next = 11;\n break;\n case 7:\n _context7.prev = 7;\n _context7.t0 = _context7[\"catch\"](0);\n console.log(\"Error adding document: \", _context7.t0);\n throw _context7.t0;\n case 11:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7, null, [[0, 7]]);\n }));\n}\nfunction createHospital(hospitalId,\n// should be auto?\nname) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var hospitalData, hospitalRef, _hospitalRef;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n _context8.prev = 0;\n hospitalData = {\n name: name,\n units: []\n };\n if (!hospitalId) {\n _context8.next = 8;\n break;\n }\n hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection, hospitalId);\n _context8.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(hospitalRef, Object.assign({\n id: hospitalRef.id\n }, hospitalData));\n case 6:\n _context8.next = 11;\n break;\n case 8:\n _hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection);\n _context8.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_hospitalRef, hospitalData);\n case 11:\n _context8.next = 17;\n break;\n case 13:\n _context8.prev = 13;\n _context8.t0 = _context8[\"catch\"](0);\n console.log(\"Error creating hospital: \", _context8.t0);\n throw _context8.t0;\n case 17:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8, null, [[0, 13]]);\n }));\n}\nfunction createUnit(unitId,\n//should be auto?\nhospitalId, name) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var unitData, unitRef, _unitRef;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n _context9.prev = 0;\n unitData = {\n hospitalId: hospitalId,\n name: name,\n members: []\n };\n if (!unitId) {\n _context9.next = 8;\n break;\n }\n unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection, unitId);\n _context9.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(unitRef, Object.assign({\n id: unitRef.id\n }, unitData));\n case 6:\n _context9.next = 11;\n break;\n case 8:\n _unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection);\n _context9.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_unitRef, unitData);\n case 11:\n _context9.next = 17;\n break;\n case 13:\n _context9.prev = 13;\n _context9.t0 = _context9[\"catch\"](0);\n console.log(\"Error creating unit: \", _context9.t0);\n throw _context9.t0;\n case 17:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9, null, [[0, 13]]);\n }));\n}\nfunction createSuggestion(id, creatorHsaId, name, area, content, purpose, measure, ideas,\n//need: boolean,\nunitId, departmentId, isPublic) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var suggestionData, suggestionRef, _suggestionRef;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n _context10.prev = 0;\n suggestionData = {\n creatorHsaId: creatorHsaId,\n name: name,\n area: area,\n content: content,\n purpose: purpose,\n measure: measure,\n ideas: ideas,\n //need,\n unitId: unitId,\n departmentId: departmentId,\n \"public\": isPublic,\n upvotes: [],\n comments: [],\n dateCreated: new Date()\n };\n if (!id) {\n _context10.next = 8;\n break;\n }\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, id);\n _context10.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(suggestionRef, Object.assign({\n id: suggestionRef.id\n }, suggestionData));\n case 6:\n _context10.next = 11;\n break;\n case 8:\n _suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection);\n _context10.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_suggestionRef, suggestionData);\n case 11:\n _context10.next = 17;\n break;\n case 13:\n _context10.prev = 13;\n _context10.t0 = _context10[\"catch\"](0);\n console.log(\"Error creating suggestion: \", _context10.t0);\n throw _context10.t0;\n case 17:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10, null, [[0, 13]]);\n }));\n}\n// Upvote a suggestion for a user\n// takes in suggestion id, user HSAid\n// returns error if transaction failed\nfunction upvoteSuggestion(suggestionId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var suggestionRef;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n _context11.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId); // Atomically add a update to the upvote array field.\n _context11.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(suggestionRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 4:\n _context11.next = 10;\n break;\n case 6:\n _context11.prev = 6;\n _context11.t0 = _context11[\"catch\"](0);\n console.log(\"Error upvoting suggestion: \", _context11.t0);\n throw _context11.t0;\n case 10:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11, null, [[0, 6]]);\n }));\n}\n//creates a comment\n// takes in commenters id, suggestion id and content as string\n// throws error if transaction failed\nfunction createComment(\n// change to subcollection\ncommenterHsaId, suggestionId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var suggestionRef, commentCollection, commentRef;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n _context12.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context12.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\");\n case 4:\n commentCollection = _context12.sent;\n _context12.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(commentCollection);\n case 7:\n commentRef = _context12.sent;\n _context12.next = 10;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(commentRef, {\n id: commentRef.id,\n commenterHsaId: commenterHsaId,\n content: content,\n dateCreated: new Date(),\n upvotes: []\n });\n case 10:\n _context12.next = 16;\n break;\n case 12:\n _context12.prev = 12;\n _context12.t0 = _context12[\"catch\"](0);\n console.log(\"Error creating comment: \", _context12.t0);\n throw _context12.t0;\n case 16:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12, null, [[0, 12]]);\n }));\n}\n// Upvote a comment for a user\n// takes in suggestionId, commentId and userId as strings\n// return error if transaction failed\nfunction upvoteComment(suggestionId, commentId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var suggestionRef, commentRef;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n _context13.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n commentRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionRef, \"comment\", commentId); // Atomically add a update to the upvote array field.\n _context13.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(commentRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 5:\n _context13.next = 11;\n break;\n case 7:\n _context13.prev = 7;\n _context13.t0 = _context13[\"catch\"](0);\n console.log(\"Error upvoting comment: \", _context13.t0);\n throw _context13.t0;\n case 11:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13, null, [[0, 7]]);\n }));\n}\n//add a note to a user\n// takes in userHsaId and content as string\n// throws error if transaction failed\nfunction addNoteToUser(userHsaId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var userRef, docRef;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n _context14.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, userHsaId);\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userRef, \"notes\");\n _context14.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n content: content,\n dateCreated: new Date()\n });\n case 5:\n _context14.next = 11;\n break;\n case 7:\n _context14.prev = 7;\n _context14.t0 = _context14[\"catch\"](0);\n console.log(\"Error adding document: \", _context14.t0);\n throw _context14.t0;\n case 11:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14, null, [[0, 7]]);\n }));\n}\n// export to setters to be able to use in other files\n\n//////////////////////////////////////////////GETTERS/////////////////////////////////////////////////////////////////////\n// Get any object\n// input is the database type as a string.\n// output is the whole collection of that type.\nfunction getObject(collectionPath) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n var collectionRef, querySnapshot, result;\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n _context15.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionPath);\n _context15.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n querySnapshot = _context15.sent;\n result = [];\n querySnapshot.forEach(function (doc) {\n result.push(doc.data());\n });\n return _context15.abrupt(\"return\", result);\n case 10:\n _context15.prev = 10;\n _context15.t0 = _context15[\"catch\"](0);\n console.error(\"Error getting collection data\", _context15.t0);\n throw _context15.t0;\n case 14:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15, null, [[0, 10]]);\n }));\n}\n/**\n * Asynchronously retrieves a single document object from the specified collection path and document ID.\n * If the document does not exist, logs a warning and returns null.\n *\n * @param {string} collectionPath - The path to the collection in the database (\"improvementWork\", \"hospital\", \"suggestion\", \"task\", \"unit\", \"users\")\n * @param {string} documentId - The ID of the document to retrieve.\n * @returns {Promise<any|null>} A promise that resolves to the document object if found, or null if not.\n *\n * @throws Will throw an error if there is an issue during retrieval from the database.\n */\nfunction getObjectById(collectionPath, documentId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {\n var docRef, docSnapshot;\n return _regeneratorRuntime().wrap(function _callee16$(_context16) {\n while (1) switch (_context16.prev = _context16.next) {\n case 0:\n _context16.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, collectionPath, documentId);\n _context16.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDoc)(docRef);\n case 4:\n docSnapshot = _context16.sent;\n if (!docSnapshot.exists()) {\n _context16.next = 9;\n break;\n }\n return _context16.abrupt(\"return\", Object.assign({\n id: docSnapshot.id\n }, docSnapshot.data()));\n case 9:\n console.warn(\"No such document! \".concat(collectionPath, \"/\").concat(documentId));\n return _context16.abrupt(\"return\", null);\n case 11:\n _context16.next = 17;\n break;\n case 13:\n _context16.prev = 13;\n _context16.t0 = _context16[\"catch\"](0);\n console.error(\"Error getting object\", _context16.t0);\n throw _context16.t0;\n case 17:\n case \"end\":\n return _context16.stop();\n }\n }, _callee16, null, [[0, 13]]);\n }));\n}\n/**\n * Asynchronously retrieves comments for a given suggestion.\n *\n * @param {Object} params - The parameters for fetching comments.\n * @param {string} params.suggestionId - The ID of the suggestion to fetch comments for.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - The criterion to sort the comments by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Determines if the sorting should be in ascending order. Defaults to false (descending).\n * @returns {Promise<any[]>} A promise that resolves to an array of comment objects.\n *\n * @throws Will throw an error if the comments cannot be retrieved.\n */\nfunction getComments(_ref) {\n var suggestionId = _ref.suggestionId,\n _ref$sortBy = _ref.sortBy,\n sortBy = _ref$sortBy === void 0 ? \"dateCreated\" : _ref$sortBy,\n _ref$ascending = _ref.ascending,\n ascending = _ref$ascending === void 0 ? false : _ref$ascending;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {\n var suggestionRef, commentsQuery, commentsSnapshot, comments;\n return _regeneratorRuntime().wrap(function _callee17$(_context17) {\n while (1) switch (_context17.prev = _context17.next) {\n case 0:\n _context17.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, \"suggestionCollection\", suggestionId);\n commentsQuery = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\"), (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n _context17.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(commentsQuery);\n case 5:\n commentsSnapshot = _context17.sent;\n comments = [];\n commentsSnapshot.forEach(function (doc) {\n comments.push(doc.data());\n });\n return _context17.abrupt(\"return\", comments);\n case 11:\n _context17.prev = 11;\n _context17.t0 = _context17[\"catch\"](0);\n console.error(\"Error getting comments for suggestion: \", _context17.t0);\n throw _context17.t0;\n case 15:\n case \"end\":\n return _context17.stop();\n }\n }, _callee17, null, [[0, 11]]);\n }));\n}\n//Filtering suggestions on unitId AND creatorHsaId\n//Sort suggestions on dateCreated OR upvotes\n/**\n * Asynchronously retrieves an array of suggestions from the database, with various filters and sorting options.\n *\n * @param {Object} params - The parameters for filtering and sorting suggestions.\n * @param {string} [params.id] - Optional ID to filter suggestions by a specific identifier.\n * @param {string} [params.creatorHsaId] - Optional HSA ID to filter suggestions by the creator's HSA ID.\n * @param {string} [params.unitId] - Optional unit ID to filter suggestions by a specific unit.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - Criterion to sort the suggestions by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Flag indicating if sorting should be ascending. Defaults to false (descending order).\n * @param {boolean} [params.isPublic=true] - Flag indicating whether to filter for public suggestions. Defaults to true.\n * @returns {Promise<any[]>} A promise that resolves to an array of suggestion objects.\n *\n * @throws Will throw an error if there is an issue retrieving suggestions.\n */\nfunction getSuggestions(_ref2) {\n var id = _ref2.id,\n creatorHsaId = _ref2.creatorHsaId,\n unitId = _ref2.unitId,\n _ref2$sortBy = _ref2.sortBy,\n sortBy = _ref2$sortBy === void 0 ? \"dateCreated\" : _ref2$sortBy,\n _ref2$ascending = _ref2.ascending,\n ascending = _ref2$ascending === void 0 ? false : _ref2$ascending,\n _ref2$isPublic = _ref2.isPublic,\n isPublic = _ref2$isPublic === void 0 ? true : _ref2$isPublic;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {\n var collectionRef, constraints, q, querySnapshot, suggestions;\n return _regeneratorRuntime().wrap(function _callee18$(_context18) {\n while (1) switch (_context18.prev = _context18.next) {\n case 0:\n _context18.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (creatorHsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"creatorHsaId\", \"==\", creatorHsaId));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"public\", \"==\", isPublic));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context18.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 11:\n querySnapshot = _context18.sent;\n suggestions = [];\n querySnapshot.forEach(function (doc) {\n suggestions.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context18.abrupt(\"return\", suggestions);\n case 17:\n _context18.prev = 17;\n _context18.t0 = _context18[\"catch\"](0);\n console.log(\"Error retrieving suggestions by department: \", _context18.t0);\n throw _context18.t0;\n case 21:\n case \"end\":\n return _context18.stop();\n }\n }, _callee18, null, [[0, 17]]);\n }));\n}\n/**\n * Asynchronously searches for hospital documents in the database.\n * It can filter the results by the hospital's name, ID, or both.\n * If no parameters are provided, it retrieves all hospitals.\n *\n * @param {Object} params - An object containing the search parameters.\n * @param {string} [params.hospitalName] - Optional name of the hospital to filter the search.\n * @param {string} [params.hospitalId] - Optional unique identifier of the hospital to filter the search.\n * @returns {Promise<any[]>} A promise that resolves to an array of hospital objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getHospitals(_ref3) {\n var hospitalName = _ref3.hospitalName,\n hospitalId = _ref3.hospitalId;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {\n var collectionRef, constraints, q, querySnapshot, hospitals;\n return _regeneratorRuntime().wrap(function _callee19$(_context19) {\n while (1) switch (_context19.prev = _context19.next) {\n case 0:\n _context19.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\n constraints = [];\n if (hospitalName) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", hospitalName));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hospitalId));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context19.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context19.sent;\n hospitals = [];\n querySnapshot.forEach(function (doc) {\n hospitals.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context19.abrupt(\"return\", hospitals);\n case 14:\n _context19.prev = 14;\n _context19.t0 = _context19[\"catch\"](0);\n console.log(\"Error retrieving Hospitals\", _context19.t0);\n throw _context19.t0;\n case 18:\n case \"end\":\n return _context19.stop();\n }\n }, _callee19, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of improvement work documents based on various filter criteria.\n * It supports filtering by ID, Nolan stage, unit ID, completion status, ongoing status, and patient risk level.\n * It also supports sorting by the start date of the improvement work in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.id] - Optional identifier to filter the improvement works.\n * @param {string} [params.nolanStage] - Optional Nolan stage to filter the improvement works.\n * @param {string} [params.unitId] - Optional unit ID to filter the improvement works.\n * @param {boolean} [params.completed] - Optional flag to filter the improvement works by their completion status.\n * @param {boolean} [params.ongoing] - Optional flag to filter the improvement works by their ongoing status.\n * @param {string} [params.patientRiskLevel] - Optional patient risk level to filter the improvement works.\n * @param {boolean} [params.ascendingDates=false] - Optional flag for sorting by date in ascending order. Defaults to false.\n * @returns {Promise<any[]>} A promise that resolves to an array of improvement work objects that match the criteria.\n *\n * @throws Will throw an error if there is a problem retrieving the improvement works.\n */\nfunction getImprovementWorks(_ref4) {\n var id = _ref4.id,\n nolanStage = _ref4.nolanStage,\n unitId = _ref4.unitId,\n completed = _ref4.completed,\n ongoing = _ref4.ongoing,\n patientRiskLevel = _ref4.patientRiskLevel,\n _ref4$ascendingDates = _ref4.ascendingDates,\n ascendingDates = _ref4$ascendingDates === void 0 ? false : _ref4$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {\n var collectionRef, constraints, q, querySnapshot, improvementWorks;\n return _regeneratorRuntime().wrap(function _callee20$(_context20) {\n while (1) switch (_context20.prev = _context20.next) {\n case 0:\n _context20.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (nolanStage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"currentStage\", \"==\", nolanStage));\n }\n if (completed != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"completed\", \"==\", completed));\n }\n if (ongoing !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"ongoing\", \"==\", ongoing));\n }\n if (patientRiskLevel) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"patientRiskLevel\", \"==\", patientRiskLevel));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"dateStarted\", ascendingDates ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context20.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 13:\n querySnapshot = _context20.sent;\n improvementWorks = [];\n querySnapshot.forEach(function (doc) {\n improvementWorks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context20.abrupt(\"return\", improvementWorks);\n case 19:\n _context20.prev = 19;\n _context20.t0 = _context20[\"catch\"](0);\n console.log(\"Error retrieving improvementWorks: \", _context20.t0);\n throw _context20.t0;\n case 23:\n case \"end\":\n return _context20.stop();\n }\n }, _callee20, null, [[0, 19]]);\n }));\n}\nfunction getImprovementWorkOwner(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {\n var constraints, q, querySnapshot, owner;\n return _regeneratorRuntime().wrap(function _callee21$(_context21) {\n while (1) switch (_context21.prev = _context21.next) {\n case 0:\n _context21.prev = 0;\n constraints = [];\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"isOwner\", \"==\", true));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context21.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 7:\n querySnapshot = _context21.sent;\n if (!querySnapshot.empty) {\n _context21.next = 13;\n break;\n }\n console.log(\"Improvement work \", improvementWorkId, \" has no owner\");\n return _context21.abrupt(\"return\", null);\n case 13:\n owner = querySnapshot.docs[0].data().userHsaId;\n return _context21.abrupt(\"return\", owner);\n case 15:\n _context21.next = 20;\n break;\n case 17:\n _context21.prev = 17;\n _context21.t0 = _context21[\"catch\"](0);\n console.log(_context21.t0);\n case 20:\n case \"end\":\n return _context21.stop();\n }\n }, _callee21, null, [[0, 17]]);\n }));\n}\nfunction getImprovementWorkResponsible(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {\n var constraints, q, querySnapshot, responsible;\n return _regeneratorRuntime().wrap(function _callee22$(_context22) {\n while (1) switch (_context22.prev = _context22.next) {\n case 0:\n _context22.prev = 0;\n constraints = [];\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"isResponsibleFor\", \"==\", true));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context22.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 7:\n querySnapshot = _context22.sent;\n if (!querySnapshot.empty) {\n _context22.next = 13;\n break;\n }\n console.log(\"Improvement work \", improvementWorkId, \" has no responsible\");\n return _context22.abrupt(\"return\", null);\n case 13:\n responsible = querySnapshot.docs[0].data().userHsaId;\n return _context22.abrupt(\"return\", responsible);\n case 15:\n _context22.next = 20;\n break;\n case 17:\n _context22.prev = 17;\n _context22.t0 = _context22[\"catch\"](0);\n console.log(_context22.t0);\n case 20:\n case \"end\":\n return _context22.stop();\n }\n }, _callee22, null, [[0, 17]]);\n }));\n}\n// TODO getUsersForTask!\n/**\n * Asynchronously retrieves user documents from the database based on various filter criteria.\n * It can filter by the Health Savings Account ID (hsaId), unit ID, and unique identifier (uid).\n * Additionally, it can sort the results by first name in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.hsaId] - Optional HSA ID to filter the users.\n * @param {string} [params.unitId] - Optional unit ID to filter the users.\n * @param {boolean} [params.ascendingFirstNames=false] - Optional flag to sort by first names in ascending order. Defaults to false (descending order).\n * @param {string} [params.uid] - Optional unique identifier to filter the users.\n * @returns {Promise<any[]>} A promise that resolves to an array of user objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUsers(_ref5) {\n var hsaId = _ref5.hsaId,\n unitId = _ref5.unitId,\n _ref5$ascendingFirstN = _ref5.ascendingFirstNames,\n ascendingFirstNames = _ref5$ascendingFirstN === void 0 ? false : _ref5$ascendingFirstN,\n uid = _ref5.uid;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {\n var collectionRef, constraints, q, querySnapshot, users;\n return _regeneratorRuntime().wrap(function _callee23$(_context23) {\n while (1) switch (_context23.prev = _context23.next) {\n case 0:\n _context23.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\n constraints = [];\n if (hsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hsaId));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (uid) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"uid\", \"==\", uid));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"firstName\", ascendingFirstNames ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context23.next = 10;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 10:\n querySnapshot = _context23.sent;\n users = [];\n querySnapshot.forEach(function (doc) {\n users.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context23.abrupt(\"return\", users);\n case 16:\n _context23.prev = 16;\n _context23.t0 = _context23[\"catch\"](0);\n console.log(\"Error retrieving users by department: \", _context23.t0);\n throw _context23.t0;\n case 20:\n case \"end\":\n return _context23.stop();\n }\n }, _callee23, null, [[0, 16]]);\n }));\n}\n// TODO getTasksForUser!\n/**\n * Asynchronously retrieves an array of task documents from the database based on several filter and sorting criteria.\n * Filters include task ID, user ID and their responsibility status, and related improvement work ID.\n * Results can be sorted by date either in ascending or descending order.\n *\n * @param {Object} params - Parameters to filter and sort the task results.\n * @param {string} [params.taskId] - Optional task ID to filter the tasks.\n * @param {string} [params.userId] - Optional user ID to identify tasks related to a user.\n * @param {boolean} [params.isResponsibleFor] - Optional flag to filter tasks where the user is marked as responsible.\n * @param {string} [params.improvementWorkId] - Optional improvement work ID to filter tasks related to a specific improvement work.\n * @param {boolean} [params.ascendingDates=false] - Optional flag to sort tasks by date in ascending order; defaults to descending order.\n * @returns {Promise<any[]>} A promise that resolves to an array of task objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getTasks(_ref6) {\n var improvementWorkId = _ref6.improvementWorkId,\n stage = _ref6.stage,\n _ref6$ascendingDates = _ref6.ascendingDates,\n ascendingDates = _ref6$ascendingDates === void 0 ? false : _ref6$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {\n var collectionRef, constraints, q, querySnapshot, tasks;\n return _regeneratorRuntime().wrap(function _callee24$(_context24) {\n while (1) switch (_context24.prev = _context24.next) {\n case 0:\n _context24.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\n constraints = []; // FUTURE FEATURE: Filter on userHsaId AND improvementWork\n // if (userHsaId && isResponsibleFor !== undefined) {\n // constraints.push(\n // where(\"members\", \"array-contains\", {\n // userHsaId: userHsaId,\n // isResponsibleFor: isResponsibleFor,\n // })\n // );\n // }\n if (stage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"stage\", \"==\", stage));\n }\n if (improvementWorkId != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"startDate\", ascendingDates ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context24.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context24.sent;\n tasks = [];\n querySnapshot.forEach(function (doc) {\n tasks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context24.abrupt(\"return\", tasks);\n case 14:\n _context24.prev = 14;\n _context24.t0 = _context24[\"catch\"](0);\n console.log(\"Error retrieving task by department: \", _context24.t0);\n throw _context24.t0;\n case 18:\n case \"end\":\n return _context24.stop();\n }\n }, _callee24, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of unit documents from the database based on various filter criteria.\n * Filters can be applied based on unit ID, hospital ID, and unit name.\n * Additionally, results can be sorted by unit names in ascending or descending order.\n *\n * @param {Object} params - The parameters object containing filter and sorting options.\n * @param {string} [params.unitId] - Optional unit ID to filter the units.\n * @param {string} [params.hospitalId] - Optional hospital ID to filter units within a specific hospital.\n * @param {string} [params.name] - Optional name to filter units by a specific name.\n * @param {boolean} [params.ascendingUnitNames=false] - Optional flag to sort units by name in ascending order, defaults to descending.\n * @returns {Promise<any[]>} A promise that resolves to an array of unit objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUnits(_ref7) {\n var unitId = _ref7.unitId,\n hospitalId = _ref7.hospitalId,\n name = _ref7.name,\n _ref7$ascendingUnitNa = _ref7.ascendingUnitNames,\n ascendingUnitNames = _ref7$ascendingUnitNa === void 0 ? false : _ref7$ascendingUnitNa;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {\n var collectionRef, constraints, q, querySnapshot, units;\n return _regeneratorRuntime().wrap(function _callee25$(_context25) {\n while (1) switch (_context25.prev = _context25.next) {\n case 0:\n _context25.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\n constraints = [];\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", unitId));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"hospitalId\", \"==\", hospitalId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"name\", ascendingUnitNames ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context25.next = 9;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 9:\n querySnapshot = _context25.sent;\n units = [];\n querySnapshot.forEach(function (doc) {\n units.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context25.abrupt(\"return\", units);\n case 15:\n _context25.prev = 15;\n _context25.t0 = _context25[\"catch\"](0);\n console.log(\"Error retrieving units by hospitalId: \", _context25.t0);\n throw _context25.t0;\n case 19:\n case \"end\":\n return _context25.stop();\n }\n }, _callee25, null, [[0, 15]]);\n }));\n}\nfunction getImprovementWorksForUser(userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {\n var q, querySnapshot, improvementWorks, _iterator, _step, _doc, improvementWorkId, improvementWorkDoc;\n return _regeneratorRuntime().wrap(function _callee26$(_context26) {\n while (1) switch (_context26.prev = _context26.next) {\n case 0:\n _context26.prev = 0;\n console.log(\"Getting improvementworks for user: \", userHsaId);\n // Query the userImprovementWork collection for relations involving this user\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(userImprovementWorkCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)('userHsaId', '==', userHsaId));\n _context26.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 5:\n querySnapshot = _context26.sent;\n // Fetch each related improvementWork document\n improvementWorks = [];\n _iterator = _createForOfIteratorHelper(querySnapshot.docs);\n _context26.prev = 8;\n _iterator.s();\n case 10:\n if ((_step = _iterator.n()).done) {\n _context26.next = 19;\n break;\n }\n _doc = _step.value;\n improvementWorkId = _doc.data().improvementWorkId;\n _context26.next = 15;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 15:\n improvementWorkDoc = _context26.sent;\n improvementWorks.push(improvementWorkDoc);\n case 17:\n _context26.next = 10;\n break;\n case 19:\n _context26.next = 24;\n break;\n case 21:\n _context26.prev = 21;\n _context26.t0 = _context26[\"catch\"](8);\n _iterator.e(_context26.t0);\n case 24:\n _context26.prev = 24;\n _iterator.f();\n return _context26.finish(24);\n case 27:\n return _context26.abrupt(\"return\", improvementWorks);\n case 30:\n _context26.prev = 30;\n _context26.t1 = _context26[\"catch\"](0);\n console.error(\"Error getting improvement works for user: \", _context26.t1);\n throw _context26.t1;\n case 34:\n case \"end\":\n return _context26.stop();\n }\n }, _callee26, null, [[0, 30], [8, 21, 24, 27]]);\n }));\n}\nfunction getUsersForImprovementWork(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {\n var q, querySnapshot, users, _iterator2, _step2, _doc2, userHsaId, userDoc;\n return _regeneratorRuntime().wrap(function _callee27$(_context27) {\n while (1) switch (_context27.prev = _context27.next) {\n case 0:\n _context27.prev = 0;\n console.log(\"Getting users for improvementwork: \", improvementWorkId);\n // Query the userImprovementWork collection for relations involving this improvementWork\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(userImprovementWorkCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)('improvementWorkId', '==', improvementWorkId));\n _context27.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 5:\n querySnapshot = _context27.sent;\n // Fetch each related user document\n users = [];\n _iterator2 = _createForOfIteratorHelper(querySnapshot.docs);\n _context27.prev = 8;\n _iterator2.s();\n case 10:\n if ((_step2 = _iterator2.n()).done) {\n _context27.next = 19;\n break;\n }\n _doc2 = _step2.value;\n userHsaId = _doc2.data().userHsaId;\n _context27.next = 15;\n return getObjectById(\"users\", userHsaId);\n case 15:\n userDoc = _context27.sent;\n users.push(userDoc);\n case 17:\n _context27.next = 10;\n break;\n case 19:\n _context27.next = 24;\n break;\n case 21:\n _context27.prev = 21;\n _context27.t0 = _context27[\"catch\"](8);\n _iterator2.e(_context27.t0);\n case 24:\n _context27.prev = 24;\n _iterator2.f();\n return _context27.finish(24);\n case 27:\n return _context27.abrupt(\"return\", users);\n case 30:\n _context27.prev = 30;\n _context27.t1 = _context27[\"catch\"](0);\n console.error(\"Error getting users for improvementWork: \", _context27.t1);\n throw _context27.t1;\n case 34:\n case \"end\":\n return _context27.stop();\n }\n }, _callee27, null, [[0, 30], [8, 21, 24, 27]]);\n }));\n}\n// export getters to be able to use in other files\n\n////////////////////////////////////DELETING/////////////////////////////////////////////\n// delete an instance of a type\nfunction deleteInstance(docType, docId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee28$(_context28) {\n while (1) switch (_context28.prev = _context28.next) {\n case 0:\n _context28.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context28.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(docRef);\n case 4:\n console.log(\"\".concat(docType, \" deleted successfully.\"));\n _context28.next = 11;\n break;\n case 7:\n _context28.prev = 7;\n _context28.t0 = _context28[\"catch\"](0);\n console.error(\"Error deleting \".concat(docType, \":\"), _context28.t0);\n throw _context28.t0;\n case 11:\n case \"end\":\n return _context28.stop();\n }\n }, _callee28, null, [[0, 7]]);\n }));\n}\n// delete all instances of a type\nfunction deleteAllDocumentsInCollection(collectionName) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {\n var _this = this;\n var collectionRef, snapshot, deletePromises;\n return _regeneratorRuntime().wrap(function _callee30$(_context30) {\n while (1) switch (_context30.prev = _context30.next) {\n case 0:\n _context30.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionName);\n _context30.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n snapshot = _context30.sent;\n // Delete all documents in the collection\n deletePromises = snapshot.docs.map(function (doc) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {\n return _regeneratorRuntime().wrap(function _callee29$(_context29) {\n while (1) switch (_context29.prev = _context29.next) {\n case 0:\n _context29.next = 2;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(doc.ref);\n case 2:\n case \"end\":\n return _context29.stop();\n }\n }, _callee29);\n }));\n });\n _context30.next = 8;\n return Promise.all(deletePromises);\n case 8:\n console.log(\"All documents in the \".concat(collectionName, \" collection deleted successfully.\"));\n _context30.next = 15;\n break;\n case 11:\n _context30.prev = 11;\n _context30.t0 = _context30[\"catch\"](0);\n console.error(\"Error deleting all documents in \".concat(collectionName, \":\"), _context30.t0);\n throw _context30.t0;\n case 15:\n case \"end\":\n return _context30.stop();\n }\n }, _callee30, null, [[0, 11]]);\n }));\n}\n////////////////////////////////////UPDATING/////////////////////////////////////////////\n// update a field in an instance\nfunction updateInstance(docType, docId, updates) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee31$(_context31) {\n while (1) switch (_context31.prev = _context31.next) {\n case 0:\n _context31.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context31.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(docRef, updates);\n case 4:\n console.log(\"\".concat(docType, \" updated successfully.\"));\n _context31.next = 11;\n break;\n case 7:\n _context31.prev = 7;\n _context31.t0 = _context31[\"catch\"](0);\n console.error(\"Error updating \".concat(docType, \":\"), _context31.t0);\n throw _context31.t0;\n case 11:\n case \"end\":\n return _context31.stop();\n }\n }, _callee31, null, [[0, 7]]);\n }));\n}\n// changes the ongoing status of an improvement work. if ongoing it is paused, if if paused onging.\n// user must be a manager\nfunction startOrPauseImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee32$(_context32) {\n while (1) switch (_context32.prev = _context32.next) {\n case 0:\n _context32.prev = 0;\n _context32.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context32.sent;\n _context32.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context32.sent;\n if (!(!user || !user.manager)) {\n _context32.next = 11;\n break;\n }\n throw new Error(\"User can't change improvementWork status\");\n case 11:\n if (!improvementWork) {\n _context32.next = 18;\n break;\n }\n update = {\n ongoing: !improvementWork.ongoing\n };\n _context32.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n _context32.next = 19;\n break;\n case 18:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n case 19:\n _context32.next = 25;\n break;\n case 21:\n _context32.prev = 21;\n _context32.t0 = _context32[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context32.t0);\n throw _context32.t0;\n case 25:\n case \"end\":\n return _context32.stop();\n }\n }, _callee32, null, [[0, 21]]);\n }));\n}\nfunction changePatientRiskLevel(userId, improvementWorkId, patientRiskLevel) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee33$(_context33) {\n while (1) switch (_context33.prev = _context33.next) {\n case 0:\n _context33.prev = 0;\n _context33.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context33.sent;\n _context33.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context33.sent;\n if (!(!user || !user.manager)) {\n _context33.next = 11;\n break;\n }\n throw new Error(\"User can't change patientRiskLevel in improvement work\");\n case 11:\n if (!improvementWork) {\n _context33.next = 18;\n break;\n }\n update = {\n patientRiskLevel: patientRiskLevel\n };\n _context33.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n _context33.next = 19;\n break;\n case 18:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n case 19:\n _context33.next = 25;\n break;\n case 21:\n _context33.prev = 21;\n _context33.t0 = _context33[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context33.t0);\n throw _context33.t0;\n case 25:\n case \"end\":\n return _context33.stop();\n }\n }, _callee33, null, [[0, 21]]);\n }));\n}\n// finalizes the improvement work. ongoing is set to false.\n// user must be a manager\nfunction finalizeImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {\n var user, update;\n return _regeneratorRuntime().wrap(function _callee34$(_context34) {\n while (1) switch (_context34.prev = _context34.next) {\n case 0:\n _context34.prev = 0;\n _context34.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context34.sent;\n if (!(!user || !user.manager)) {\n _context34.next = 8;\n break;\n }\n throw new Error(\"User can't finalize improvementWork status\");\n case 8:\n update = {\n completed: true,\n ongoing: false\n };\n _context34.next = 11;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 11:\n _context34.next = 16;\n break;\n case 13:\n _context34.prev = 13;\n _context34.t0 = _context34[\"catch\"](0);\n console.log(_context34.t0);\n case 16:\n case \"end\":\n return _context34.stop();\n }\n }, _callee34, null, [[0, 13]]);\n }));\n}\n\n//////////////////////////////// for later sprint\n//function add_upvotes\n//function add_notes\n//function add_intrested_users\n\n//# sourceURL=webpack://c3/./client/Database/database.js?"); /***/ }), @@ -106,7 +106,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \*******************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ submitHandler: () => (/* binding */ submitHandler)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n\n\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\nfunction loadFilter() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var selectHospitalHTML, selectUnitHTML, allHospitals, allUnits;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n selectHospitalHTML = $('#selectHospital'); // loads the select type from html\n selectUnitHTML = $('#selectDepartment'); // loads the select type from html\n _context.next = 4;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({});\n case 4:\n allHospitals = _context.sent;\n _context.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({});\n case 7:\n allUnits = _context.sent;\n //here you can put constraints\n console.log(allHospitals);\n console.log(allUnits);\n allHospitals.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(user.name);\n selectHospitalHTML.append(optionElement);\n });\n allUnits.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(user.name);\n selectUnitHTML.append(optionElement);\n });\n case 12:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction populateOptions(object, selectElement) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var options;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObject)(object);\n case 2:\n options = _context2.sent;\n options.forEach(function (option) {\n var optionElement = document.createElement(\"option\");\n optionElement.value = option.id; // Set the value\n optionElement.text = option.name; // Set the text\n optionElement.classList.add(\"option\"); // Add the 'option' class\n selectElement.appendChild(optionElement);\n });\n case 4:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\n// Define the submitHandler function\nfunction submitHandler() {\n var selectDepartment = document.getElementById(\"selectHospital\");\n var selectUnit = document.getElementById(\"selectDepartment\");\n //populateOptions(\"hospital\", selectDepartment);\n //populateOptions(\"unit\", selectUnit);\n // JavaScript to get the inputted text when the form is submitted\n var inputBoxFormNameInput = document.getElementById(\"inputBoxFormNameInput\");\n var inputBoxFormName = document.getElementById(\"inputBoxFormName\");\n var inputBoxFormAreaInput = document.getElementById(\"inputBoxFormAreaInput\");\n var inputBoxFormArea = document.getElementById(\"inputBoxFormArea\");\n var inputBoxFormContentInput = document.getElementById(\"inputBoxFormContentInput\");\n var inputBoxFormContent = document.getElementById(\"inputBoxFormContent\");\n var inputBoxFormPurposeInput = document.getElementById(\"inputBoxFormPurposeInput\");\n var inputBoxFormPurpose = document.getElementById(\"inputBoxFormPurpose\");\n var inputBoxFormMeasureInput = document.getElementById(\"inputBoxFormMeasureInput\");\n var inputBoxFormMeasure = document.getElementById(\"inputBoxFormMeasure\");\n var inputBoxFormIdeasInput = document.getElementById(\"inputBoxFormIdeasInput\");\n var inputBoxFormIdeas = document.getElementById(\"inputBoxFormIdeas\");\n var submitButton = document.getElementById(\"suggestionButton\");\n inputBoxFormName.addEventListener(\"submit\", function (e) {\n e.preventDefault();\n });\n inputBoxFormArea.addEventListener(\"submit\", function (e) {\n e.preventDefault();\n });\n inputBoxFormContent.addEventListener(\"submit\", function (e) {\n e.preventDefault();\n });\n inputBoxFormPurpose.addEventListener(\"submit\", function (e) {\n e.preventDefault();\n });\n inputBoxFormMeasure.addEventListener(\"submit\", function (e) {\n e.preventDefault();\n });\n inputBoxFormIdeas.addEventListener(\"submit\", function (e) {\n e.preventDefault();\n });\n // Get values from each form and do something with them\n var nameInput = inputBoxFormNameInput.value;\n var areaInput = inputBoxFormAreaInput.value;\n var contentInput = inputBoxFormContentInput.value;\n var purposeInput = inputBoxFormPurposeInput.value;\n var measureInput = inputBoxFormMeasureInput.value;\n var ideasInput = inputBoxFormIdeasInput.value;\n try {\n // Call the createSuggestion function with the obtained values\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.createSuggestion)(\"<Header>\", \"<Department>\", nameInput, areaInput, contentInput, purposeInput, measureInput, ideasInput, selectUnit.value, selectDepartment.value, true);\n alert(\"created successfully\");\n } catch (_a) {\n alert(\"Error creating\");\n }\n}\nfunction loadPage() {\n var container = document.querySelector('#container-fluid');\n if (!container) return; // Stop if the container isn't found\n var scriptElement = document.createElement('script');\n scriptElement.src = '../dist/makeSuggestion.bundle.js';\n container.appendChild(scriptElement);\n var linkElement1 = document.createElement('link');\n linkElement1.rel = 'stylesheet';\n linkElement1.href = 'Make_Suggestion_Code/makeSuggestion.css';\n document.head.appendChild(linkElement1);\n var linkElement2 = document.createElement('link');\n linkElement2.rel = 'stylesheet';\n linkElement2.href = 'Activity_card_code/activitity_card.css';\n document.head.appendChild(linkElement2);\n fetch('Make_Suggestion_Code/makeSuggestion.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n var suggestionPage = tempContainer.querySelector('#suggestionPage');\n if (suggestionPage) {\n container.insertBefore(suggestionPage, container.firstChild);\n var submitButton = document.getElementById('suggestionButton');\n if (submitButton) {\n submitButton.addEventListener('click', submitHandler);\n } else {\n console.error(\"Error: 'suggestionButton' not found\");\n }\n loadFilter();\n }\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n}\n\n//# sourceURL=webpack://c3/./client/Make_Suggestion_Code/makeSuggestion.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ submitHandler: () => (/* binding */ submitHandler)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n\n\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\nfunction loadFilter() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var selectHospitalHTML, selectUnitHTML, allHospitals, allUnits;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n selectHospitalHTML = $('#selectHospital'); // loads the select type from html\n selectUnitHTML = $('#selectDepartment'); // loads the select type from html\n _context.next = 4;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({});\n case 4:\n allHospitals = _context.sent;\n _context.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({});\n case 7:\n allUnits = _context.sent;\n //here you can put constraints\n console.log(allHospitals);\n console.log(allUnits);\n allHospitals.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(user.name);\n selectHospitalHTML.append(optionElement);\n });\n allUnits.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(user.name);\n selectUnitHTML.append(optionElement);\n });\n case 12:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction populateOptions(object, selectElement) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var options;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObject)(object);\n case 2:\n options = _context2.sent;\n options.forEach(function (option) {\n var optionElement = document.createElement(\"option\");\n optionElement.value = option.id; // Set the value\n optionElement.text = option.name; // Set the text\n optionElement.classList.add(\"option\"); // Add the 'option' class\n selectElement.appendChild(optionElement);\n });\n case 4:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\n// Define the submitHandler function\nfunction submitHandler() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var selectDepartment, selectUnit, inputBoxFormNameInput, inputBoxFormName, inputBoxFormAreaInput, inputBoxFormArea, inputBoxFormContentInput, inputBoxFormContent, inputBoxFormPurposeInput, inputBoxFormPurpose, inputBoxFormMeasureInput, inputBoxFormMeasure, inputBoxFormIdeasInput, inputBoxFormIdeas, submitButton, nameInput, areaInput, contentInput, purposeInput, measureInput, ideasInput, tmp, uid, user;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n selectDepartment = document.getElementById(\"selectHospital\");\n selectUnit = document.getElementById(\"selectDepartment\"); //populateOptions(\"hospital\", selectDepartment);\n //populateOptions(\"unit\", selectUnit);\n // JavaScript to get the inputted text when the form is submitted\n inputBoxFormNameInput = document.getElementById(\"inputBoxFormNameInput\");\n inputBoxFormName = document.getElementById(\"inputBoxFormName\");\n inputBoxFormAreaInput = document.getElementById(\"inputBoxFormAreaInput\");\n inputBoxFormArea = document.getElementById(\"inputBoxFormArea\");\n inputBoxFormContentInput = document.getElementById(\"inputBoxFormContentInput\");\n inputBoxFormContent = document.getElementById(\"inputBoxFormContent\");\n inputBoxFormPurposeInput = document.getElementById(\"inputBoxFormPurposeInput\");\n inputBoxFormPurpose = document.getElementById(\"inputBoxFormPurpose\");\n inputBoxFormMeasureInput = document.getElementById(\"inputBoxFormMeasureInput\");\n inputBoxFormMeasure = document.getElementById(\"inputBoxFormMeasure\");\n inputBoxFormIdeasInput = document.getElementById(\"inputBoxFormIdeasInput\");\n inputBoxFormIdeas = document.getElementById(\"inputBoxFormIdeas\");\n submitButton = document.getElementById(\"suggestionButton\");\n inputBoxFormName.addEventListener(\"submit\", function (e) {\n e.preventDefault();\n });\n inputBoxFormArea.addEventListener(\"submit\", function (e) {\n e.preventDefault();\n });\n inputBoxFormContent.addEventListener(\"submit\", function (e) {\n e.preventDefault();\n });\n inputBoxFormPurpose.addEventListener(\"submit\", function (e) {\n e.preventDefault();\n });\n inputBoxFormMeasure.addEventListener(\"submit\", function (e) {\n e.preventDefault();\n });\n inputBoxFormIdeas.addEventListener(\"submit\", function (e) {\n e.preventDefault();\n });\n // Get values from each form and do something with them\n nameInput = inputBoxFormNameInput.value;\n areaInput = inputBoxFormAreaInput.value;\n contentInput = inputBoxFormContentInput.value;\n purposeInput = inputBoxFormPurposeInput.value;\n measureInput = inputBoxFormMeasureInput.value;\n ideasInput = inputBoxFormIdeasInput.value;\n tmp = localStorage.getItem('user');\n if (tmp) {\n _context3.next = 31;\n break;\n }\n console.log(\"there is not an user in localStorage\");\n return _context3.abrupt(\"return\");\n case 31:\n uid = JSON.parse(tmp)[0].uid;\n _context3.next = 34;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({\n uid: uid\n });\n case 34:\n user = _context3.sent;\n console.log(user);\n console.log(user[0].uid);\n console.log(user[0].id);\n console.log(user[0].creatorHsaId);\n try {\n if (user[0].id) {\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.createSuggestion)(null, user[0].id,\n //The unique identifyer for the user, not the idea\n nameInput, areaInput, contentInput, purposeInput, measureInput, ideasInput, selectUnit.value, selectDepartment.value, true);\n }\n // Call the createSuggestion function with the obtained values \n alert(\"created successfully\");\n } catch (_a) {\n alert(\"Error creating\");\n }\n case 40:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction loadPage() {\n var container = document.querySelector('#container-fluid');\n if (!container) return; // Stop if the container isn't found\n var scriptElement = document.createElement('script');\n scriptElement.src = '../dist/makeSuggestion.bundle.js';\n container.appendChild(scriptElement);\n var linkElement1 = document.createElement('link');\n linkElement1.rel = 'stylesheet';\n linkElement1.href = 'Make_Suggestion_Code/makeSuggestion.css';\n document.head.appendChild(linkElement1);\n var linkElement2 = document.createElement('link');\n linkElement2.rel = 'stylesheet';\n linkElement2.href = 'Activity_card_code/activitity_card.css';\n document.head.appendChild(linkElement2);\n fetch('Make_Suggestion_Code/makeSuggestion.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n var suggestionPage = tempContainer.querySelector('#suggestionPage');\n if (suggestionPage) {\n container.insertBefore(suggestionPage, container.firstChild);\n var submitButton = document.getElementById('suggestionButton');\n if (submitButton) {\n submitButton.addEventListener('click', submitHandler);\n } else {\n console.error(\"Error: 'suggestionButton' not found\");\n }\n loadFilter();\n }\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n}\n\n//# sourceURL=webpack://c3/./client/Make_Suggestion_Code/makeSuggestion.js?"); /***/ }), diff --git a/client/dist/pageHandler.bundle.js b/client/dist/pageHandler.bundle.js index 4a4747974db7823552b92822dee60e5b787e3f1b..b699229cc351487342645e3997323e63cacd10e6 100644 --- a/client/dist/pageHandler.bundle.js +++ b/client/dist/pageHandler.bundle.js @@ -106,7 +106,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \*************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addDocumentToImprovementWork: () => (/* binding */ addDocumentToImprovementWork),\n/* harmony export */ addMemberToImprovementWork: () => (/* binding */ addMemberToImprovementWork),\n/* harmony export */ addMemberToTask: () => (/* binding */ addMemberToTask),\n/* harmony export */ addNoteToUser: () => (/* binding */ addNoteToUser),\n/* harmony export */ auth: () => (/* binding */ auth),\n/* harmony export */ changePatientRiskLevel: () => (/* binding */ changePatientRiskLevel),\n/* harmony export */ createComment: () => (/* binding */ createComment),\n/* harmony export */ createHospital: () => (/* binding */ createHospital),\n/* harmony export */ createImprovementWork: () => (/* binding */ createImprovementWork),\n/* harmony export */ createSuggestion: () => (/* binding */ createSuggestion),\n/* harmony export */ createTaskOnImprovementWork: () => (/* binding */ createTaskOnImprovementWork),\n/* harmony export */ createUnit: () => (/* binding */ createUnit),\n/* harmony export */ createUser: () => (/* binding */ createUser),\n/* harmony export */ createdDocumentInKnowledgeBank: () => (/* binding */ createdDocumentInKnowledgeBank),\n/* harmony export */ db: () => (/* binding */ db),\n/* harmony export */ deleteAllDocumentsInCollection: () => (/* binding */ deleteAllDocumentsInCollection),\n/* harmony export */ deleteInstance: () => (/* binding */ deleteInstance),\n/* harmony export */ finalizeImprovementWork: () => (/* binding */ finalizeImprovementWork),\n/* harmony export */ getComments: () => (/* binding */ getComments),\n/* harmony export */ getHospitals: () => (/* binding */ getHospitals),\n/* harmony export */ getImprovementWorks: () => (/* binding */ getImprovementWorks),\n/* harmony export */ getObject: () => (/* binding */ getObject),\n/* harmony export */ getObjectById: () => (/* binding */ getObjectById),\n/* harmony export */ getSuggestions: () => (/* binding */ getSuggestions),\n/* harmony export */ getTasks: () => (/* binding */ getTasks),\n/* harmony export */ getUnits: () => (/* binding */ getUnits),\n/* harmony export */ getUsers: () => (/* binding */ getUsers),\n/* harmony export */ startOrPauseImprovementWork: () => (/* binding */ startOrPauseImprovementWork),\n/* harmony export */ updateInstance: () => (/* binding */ updateInstance),\n/* harmony export */ upvoteComment: () => (/* binding */ upvoteComment),\n/* harmony export */ upvoteSuggestion: () => (/* binding */ upvoteSuggestion)\n/* harmony export */ });\n/* harmony import */ var firebase_app__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! firebase/app */ \"./node_modules/firebase/app/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_firestore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! firebase/firestore */ \"./node_modules/firebase/firestore/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_auth__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! firebase/auth */ \"./node_modules/firebase/auth/dist/esm/index.esm.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nvar firebaseConfig = {\n apiKey: \"AIzaSyDqkaVZMr11J4mfnR0auqoQilZyPfyD-x4\",\n authDomain: \"c3solutions-dc109.firebaseapp.com\",\n projectId: \"c3solutions-dc109\",\n storageBucket: \"c3solutions-dc109.appspot.com\",\n messagingSenderId: \"902143402555\",\n appId: \"1:902143402555:web:29213e81de0a0cba38b21e\"\n};\nvar app = (0,firebase_app__WEBPACK_IMPORTED_MODULE_0__.initializeApp)(firebaseConfig);\nvar auth = (0,firebase_auth__WEBPACK_IMPORTED_MODULE_2__.getAuth)();\nvar db = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getFirestore)(app);\nvar userCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\nvar unitCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\nvar improvementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\nvar taskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\nvar hospitalCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\nvar suggestionCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\nvar knowledgeDocumentCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"knowledgeDocument\");\n////////////////////////////////////////Setters///////////////////////////////////////////////////////////////////\n// Function to create user a new user in database\n// takes in userId, unitId, firstname, lastname, email and password as string\n// throws error if transaction failed\nfunction createUser(hsaId, unitId, firstName, lastName, email, manager, uid) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var userRef, unitRef;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, hsaId);\n _context.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(userRef, {\n id: userRef.id,\n uid: uid,\n unitId: unitId,\n firstName: firstName,\n lastName: lastName,\n email: email,\n improvementWorks: [],\n tasks: [],\n manager: manager\n });\n case 4:\n // Atomically add user to unit.\n unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection, unitId);\n _context.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(unitRef, {\n members: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userRef.id)\n });\n case 7:\n _context.next = 12;\n break;\n case 9:\n _context.prev = 9;\n _context.t0 = _context[\"catch\"](0);\n console.log(_context.t0);\n case 12:\n case \"end\":\n return _context.stop();\n }\n }, _callee, null, [[0, 9]]);\n }));\n}\n//Adds a new improvementWork to the database\n// takes in Id, name, currentStage in PDSA, content, unitId refers to as string and if completed as boolean\n// throws error if transaction failed\nfunction createImprovementWork(id, name, currentStage, content,\n// Är detta description bör detta förtydligas. \nunitId, purpose,\n//Bör tas bort motsvaras av p2- mål med projektet\npatientRiskLevel, area,\n// patientRiskLevel: \"Green\" | \"Blue\" | \"Orange\" | \"Red\"\n//Questions in planning stage\np1, p2, p3, p4, p5, p6, p7,\n//Questions in Doing (G) stage\ng1, g2, g3, g4, g5,\n//Questions in stydy stage\ns1, s2, s3,\n//Questions in acting stage\na1, a2, a3, a4) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var improvementWorkRef;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.prev = 0;\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, id);\n _context2.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(improvementWorkRef, {\n id: improvementWorkRef.id,\n currentStage: currentStage,\n name: name,\n content: content,\n purpose: purpose,\n dateStarted: new Date(),\n unitId: unitId,\n completed: false,\n ongoing: false,\n tasks: [],\n members: [],\n patientRiskLevel: patientRiskLevel,\n area: area,\n p1: p1,\n p2: p2,\n p3: p3,\n p4: p4,\n p5: p5,\n p6: p6,\n p7: p7,\n g1: g1,\n g2: g2,\n g3: g3,\n g4: g4,\n g5: g5,\n s1: s1,\n s2: s2,\n s3: s3,\n a1: a1,\n a2: a2,\n a3: a3,\n a4: a4\n });\n case 4:\n _context2.next = 10;\n break;\n case 6:\n _context2.prev = 6;\n _context2.t0 = _context2[\"catch\"](0);\n console.log(\"Error creating improvementWork: \", _context2.t0);\n throw _context2.t0;\n case 10:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, null, [[0, 6]]);\n }));\n}\n//create task to improvementWork\n// takes in improvementWorkId, name, deadline date, start date, stage in PDSA and content as string\n// throws error if transaction failed\nfunction createTaskOnImprovementWork(taskId, improvementWorkId, name, deadlineDate, startDate, stage, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var ref, improvementWorkRef;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.prev = 0;\n ref = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection, taskId);\n _context3.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(ref, {\n id: ref.id,\n improvementWorkId: improvementWorkId,\n name: name,\n deadlineDate: deadlineDate,\n startDate: startDate,\n stage: stage,\n content: content,\n members: []\n });\n case 4:\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, improvementWorkId); // Atomically add task to the tasks array field.\n _context3.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(improvementWorkRef, {\n tasks: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(taskId)\n });\n case 7:\n _context3.next = 13;\n break;\n case 9:\n _context3.prev = 9;\n _context3.t0 = _context3[\"catch\"](0);\n console.log(\"Error creating task: \", _context3.t0);\n throw _context3.t0;\n case 13:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, null, [[0, 9]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction createdDocumentInKnowledgeBank(documentUrl, name) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n _context4.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(knowledgeDocumentCollection);\n _context4.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n name: name\n });\n case 4:\n _context4.next = 10;\n break;\n case 6:\n _context4.prev = 6;\n _context4.t0 = _context4[\"catch\"](0);\n console.log(\"Error adding document: \", _context4.t0);\n throw _context4.t0;\n case 10:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4, null, [[0, 6]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction addDocumentToImprovementWork(documentUrl, name, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var improvementWorkRef, docRef;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n _context5.prev = 0;\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, improvementWorkId);\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkRef, \"documents\");\n _context5.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n timestamp: new Date(),\n name: name\n });\n case 5:\n _context5.next = 11;\n break;\n case 7:\n _context5.prev = 7;\n _context5.t0 = _context5[\"catch\"](0);\n console.log(\"Error adding document: \", _context5.t0);\n throw _context5.t0;\n case 11:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5, null, [[0, 7]]);\n }));\n}\n//add a member to a improvementWork\n// takes in id, users HSAid, improvementWorks id as string and if is owner, is responsible as boolean\n// throws error if transaction failed\nfunction addMemberToImprovementWork(userHsaId, improvementWorkId, isOwner, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var improvementWorkRef, userRef;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n _context6.prev = 0;\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, improvementWorkId); // return;\n // Atomically update the members array in the improvementWork document\n _context6.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(improvementWorkRef, {\n members: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)({\n userHsaId: userHsaId,\n isOwner: isOwner,\n isResponsibleFor: isResponsibleFor\n })\n });\n case 4:\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, userHsaId); // Atomically add improvementWork to user\n _context6.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(userRef, {\n improvementWorks: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)({\n improvementWorkId: improvementWorkId,\n isOwner: isOwner,\n isResponsibleFor: isResponsibleFor\n })\n });\n case 7:\n _context6.next = 13;\n break;\n case 9:\n _context6.prev = 9;\n _context6.t0 = _context6[\"catch\"](0);\n console.log(\"Error adding member: \", _context6.t0);\n throw _context6.t0;\n case 13:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6, null, [[0, 9]]);\n }));\n}\n//create a hospital\n// takes in ID, name as string\n// throws error if transaction failed\nfunction createHospital(hospitalId,\n// should be auto?\nname) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var ref;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.prev = 0;\n ref = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection, hospitalId);\n _context7.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(ref, {\n id: ref.id,\n name: name,\n units: []\n });\n case 4:\n _context7.next = 10;\n break;\n case 6:\n _context7.prev = 6;\n _context7.t0 = _context7[\"catch\"](0);\n console.log(\"Error creating hospital: \", _context7.t0);\n throw _context7.t0;\n case 10:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7, null, [[0, 6]]);\n }));\n}\n//create a unit\n// takes in id, hospitals id and name as string\n// throws error if transaction failed\nfunction createUnit(unitId,\n//should be auto?\nhospitalId, name) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var unitRef, hospitalRef;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n _context8.prev = 0;\n unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection, unitId);\n _context8.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(unitRef, {\n id: unitRef.id,\n hospitalId: hospitalId,\n name: name,\n members: []\n });\n case 4:\n // Atomically add unit to hospital.\n hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection, hospitalId);\n _context8.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(hospitalRef, {\n units: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(unitRef.id)\n });\n case 7:\n _context8.next = 13;\n break;\n case 9:\n _context8.prev = 9;\n _context8.t0 = _context8[\"catch\"](0);\n console.log(\"Error creating unit: \", _context8.t0);\n throw _context8.t0;\n case 13:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8, null, [[0, 9]]);\n }));\n}\n//adds a member to task\n// takes in ID, the added members hsaId, task id as string and if person is responsible as boolean\n// throws error if transaction failed\nfunction addMemberToTask(userHsaId, taskId, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var taskRef, userRef;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n _context9.prev = 0;\n // Atomically add a member to task.\n taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection, taskId);\n _context9.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(taskRef, {\n members: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)({\n userHsaId: userHsaId,\n isResponsibleFor: isResponsibleFor\n })\n });\n case 4:\n // Atomically add a task to user.\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, userHsaId);\n _context9.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(userRef, {\n tasks: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)({\n taskId: taskId,\n isResponsibleFor: isResponsibleFor\n })\n });\n case 7:\n _context9.next = 13;\n break;\n case 9:\n _context9.prev = 9;\n _context9.t0 = _context9[\"catch\"](0);\n console.log(\"Error adding member: \", _context9.t0);\n throw _context9.t0;\n case 13:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9, null, [[0, 9]]);\n }));\n}\n//creates a suggestion\n// takes in ID, the creators hsaId, name, content and the responding unitId as string\n// throws error if transaction failed\nfunction createSuggestion(id, creatorHsaId, name, area, content, purpose, measure, ideas,\n//need: boolean,\nunitId, departmentId, isPublic) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var suggestionRef, commentCollection;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n _context10.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, id);\n _context10.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(suggestionRef, {\n id: suggestionRef.id,\n creatorHsaId: creatorHsaId,\n name: name,\n area: area,\n content: content,\n purpose: purpose,\n measure: measure,\n ideas: ideas,\n //need: need,\n unitId: unitId,\n departmentId: departmentId,\n \"public\": isPublic,\n upvotes: [],\n comments: [],\n dateCreated: new Date()\n });\n case 4:\n _context10.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\");\n case 6:\n commentCollection = _context10.sent;\n _context10.next = 9;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(commentCollection);\n case 9:\n _context10.next = 15;\n break;\n case 11:\n _context10.prev = 11;\n _context10.t0 = _context10[\"catch\"](0);\n console.log(\"Error creating suggestion: \", _context10.t0);\n throw _context10.t0;\n case 15:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10, null, [[0, 11]]);\n }));\n}\n// Upvote a suggestion for a user\n// takes in suggestion id, user HSAid\n// returns error if transaction failed\nfunction upvoteSuggestion(suggestionId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var suggestionRef;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n _context11.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId); // Atomically add a update to the upvote array field.\n _context11.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(suggestionRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 4:\n _context11.next = 10;\n break;\n case 6:\n _context11.prev = 6;\n _context11.t0 = _context11[\"catch\"](0);\n console.log(\"Error upvoting suggestion: \", _context11.t0);\n throw _context11.t0;\n case 10:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11, null, [[0, 6]]);\n }));\n}\n//creates a comment\n// takes in commenters id, suggestion id and content as string\n// throws error if transaction failed\nfunction createComment(\n// change to subcollection\ncommenterHsaId, suggestionId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var suggestionRef, commentCollection, commentRef;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n _context12.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context12.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\");\n case 4:\n commentCollection = _context12.sent;\n _context12.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(commentCollection);\n case 7:\n commentRef = _context12.sent;\n _context12.next = 10;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(commentRef, {\n id: commentRef.id,\n commenterHsaId: commenterHsaId,\n content: content,\n dateCreated: new Date(),\n upvotes: []\n });\n case 10:\n _context12.next = 16;\n break;\n case 12:\n _context12.prev = 12;\n _context12.t0 = _context12[\"catch\"](0);\n console.log(\"Error creating comment: \", _context12.t0);\n throw _context12.t0;\n case 16:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12, null, [[0, 12]]);\n }));\n}\n// Upvote a comment for a user\n// takes in suggestionId, commentId and userId as strings\n// return error if transaction failed\nfunction upvoteComment(suggestionId, commentId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var suggestionRef, commentRef;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n _context13.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n commentRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionRef, \"comment\", commentId); // Atomically add a update to the upvote array field.\n _context13.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(commentRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 5:\n _context13.next = 11;\n break;\n case 7:\n _context13.prev = 7;\n _context13.t0 = _context13[\"catch\"](0);\n console.log(\"Error upvoting comment: \", _context13.t0);\n throw _context13.t0;\n case 11:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13, null, [[0, 7]]);\n }));\n}\n//add a note to a user\n// takes in userHsaId and content as string\n// throws error if transaction failed\nfunction addNoteToUser(userHsaId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var userRef, docRef;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n _context14.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, userHsaId);\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userRef, \"notes\");\n _context14.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n content: content,\n dateCreated: new Date()\n });\n case 5:\n _context14.next = 11;\n break;\n case 7:\n _context14.prev = 7;\n _context14.t0 = _context14[\"catch\"](0);\n console.log(\"Error adding document: \", _context14.t0);\n throw _context14.t0;\n case 11:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14, null, [[0, 7]]);\n }));\n}\n// export to setters to be able to use in other files\n\n//////////////////////////////////////////////GETTERS/////////////////////////////////////////////////////////////////////\n// Get any object\n// input is the database type as a string.\n// output is the whole collection of that type.\nfunction getObject(collectionPath) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n var collectionRef, querySnapshot, result;\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n _context15.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionPath);\n _context15.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n querySnapshot = _context15.sent;\n result = [];\n querySnapshot.forEach(function (doc) {\n result.push(doc.data());\n });\n return _context15.abrupt(\"return\", result);\n case 10:\n _context15.prev = 10;\n _context15.t0 = _context15[\"catch\"](0);\n console.error(\"Error getting collection data\", _context15.t0);\n throw _context15.t0;\n case 14:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15, null, [[0, 10]]);\n }));\n}\n/**\n * Asynchronously retrieves a single document object from the specified collection path and document ID.\n * If the document does not exist, logs a warning and returns null.\n *\n * @param {string} collectionPath - The path to the collection in the database (\"improvementWork\", \"hospital\", \"suggestion\", \"task\", \"unit\", \"users\")\n * @param {string} documentId - The ID of the document to retrieve.\n * @returns {Promise<any|null>} A promise that resolves to the document object if found, or null if not.\n *\n * @throws Will throw an error if there is an issue during retrieval from the database.\n */\nfunction getObjectById(collectionPath, documentId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {\n var docRef, docSnapshot;\n return _regeneratorRuntime().wrap(function _callee16$(_context16) {\n while (1) switch (_context16.prev = _context16.next) {\n case 0:\n _context16.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, collectionPath, documentId);\n _context16.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDoc)(docRef);\n case 4:\n docSnapshot = _context16.sent;\n if (!docSnapshot.exists()) {\n _context16.next = 9;\n break;\n }\n return _context16.abrupt(\"return\", docSnapshot.data());\n case 9:\n console.warn(\"No such document! \".concat(collectionPath, \"/\").concat(documentId));\n return _context16.abrupt(\"return\", null);\n case 11:\n _context16.next = 17;\n break;\n case 13:\n _context16.prev = 13;\n _context16.t0 = _context16[\"catch\"](0);\n console.error(\"Error getting object\", _context16.t0);\n throw _context16.t0;\n case 17:\n case \"end\":\n return _context16.stop();\n }\n }, _callee16, null, [[0, 13]]);\n }));\n}\n/**\n * Asynchronously retrieves comments for a given suggestion.\n *\n * @param {Object} params - The parameters for fetching comments.\n * @param {string} params.suggestionId - The ID of the suggestion to fetch comments for.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - The criterion to sort the comments by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Determines if the sorting should be in ascending order. Defaults to false (descending).\n * @returns {Promise<any[]>} A promise that resolves to an array of comment objects.\n *\n * @throws Will throw an error if the comments cannot be retrieved.\n */\nfunction getComments(_ref) {\n var suggestionId = _ref.suggestionId,\n _ref$sortBy = _ref.sortBy,\n sortBy = _ref$sortBy === void 0 ? \"dateCreated\" : _ref$sortBy,\n _ref$ascending = _ref.ascending,\n ascending = _ref$ascending === void 0 ? false : _ref$ascending;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {\n var suggestionRef, commentsQuery, commentsSnapshot, comments;\n return _regeneratorRuntime().wrap(function _callee17$(_context17) {\n while (1) switch (_context17.prev = _context17.next) {\n case 0:\n _context17.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, \"suggestionCollection\", suggestionId);\n commentsQuery = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\"), (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n _context17.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(commentsQuery);\n case 5:\n commentsSnapshot = _context17.sent;\n comments = [];\n commentsSnapshot.forEach(function (doc) {\n comments.push(doc.data());\n });\n return _context17.abrupt(\"return\", comments);\n case 11:\n _context17.prev = 11;\n _context17.t0 = _context17[\"catch\"](0);\n console.error(\"Error getting comments for suggestion: \", _context17.t0);\n throw _context17.t0;\n case 15:\n case \"end\":\n return _context17.stop();\n }\n }, _callee17, null, [[0, 11]]);\n }));\n}\n//Filtering suggestions on unitId AND creatorHsaId\n//Sort suggestions on dateCreated OR upvotes\n/**\n * Asynchronously retrieves an array of suggestions from the database, with various filters and sorting options.\n *\n * @param {Object} params - The parameters for filtering and sorting suggestions.\n * @param {string} [params.id] - Optional ID to filter suggestions by a specific identifier.\n * @param {string} [params.creatorHsaId] - Optional HSA ID to filter suggestions by the creator's HSA ID.\n * @param {string} [params.unitId] - Optional unit ID to filter suggestions by a specific unit.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - Criterion to sort the suggestions by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Flag indicating if sorting should be ascending. Defaults to false (descending order).\n * @param {boolean} [params.isPublic=true] - Flag indicating whether to filter for public suggestions. Defaults to true.\n * @returns {Promise<any[]>} A promise that resolves to an array of suggestion objects.\n *\n * @throws Will throw an error if there is an issue retrieving suggestions.\n */\nfunction getSuggestions(_ref2) {\n var id = _ref2.id,\n creatorHsaId = _ref2.creatorHsaId,\n unitId = _ref2.unitId,\n _ref2$sortBy = _ref2.sortBy,\n sortBy = _ref2$sortBy === void 0 ? \"dateCreated\" : _ref2$sortBy,\n _ref2$ascending = _ref2.ascending,\n ascending = _ref2$ascending === void 0 ? false : _ref2$ascending,\n _ref2$isPublic = _ref2.isPublic,\n isPublic = _ref2$isPublic === void 0 ? true : _ref2$isPublic;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {\n var collectionRef, constraints, q, querySnapshot, suggestions;\n return _regeneratorRuntime().wrap(function _callee18$(_context18) {\n while (1) switch (_context18.prev = _context18.next) {\n case 0:\n _context18.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (creatorHsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"creatorHsaId\", \"==\", creatorHsaId));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"public\", \"==\", isPublic));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context18.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 11:\n querySnapshot = _context18.sent;\n suggestions = [];\n querySnapshot.forEach(function (doc) {\n suggestions.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context18.abrupt(\"return\", suggestions);\n case 17:\n _context18.prev = 17;\n _context18.t0 = _context18[\"catch\"](0);\n console.log(\"Error retrieving suggestions by department: \", _context18.t0);\n throw _context18.t0;\n case 21:\n case \"end\":\n return _context18.stop();\n }\n }, _callee18, null, [[0, 17]]);\n }));\n}\n/**\n * Asynchronously searches for hospital documents in the database.\n * It can filter the results by the hospital's name, ID, or both.\n * If no parameters are provided, it retrieves all hospitals.\n *\n * @param {Object} params - An object containing the search parameters.\n * @param {string} [params.hospitalName] - Optional name of the hospital to filter the search.\n * @param {string} [params.hospitalId] - Optional unique identifier of the hospital to filter the search.\n * @returns {Promise<any[]>} A promise that resolves to an array of hospital objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getHospitals(_ref3) {\n var hospitalName = _ref3.hospitalName,\n hospitalId = _ref3.hospitalId;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {\n var collectionRef, constraints, q, querySnapshot, hospitals;\n return _regeneratorRuntime().wrap(function _callee19$(_context19) {\n while (1) switch (_context19.prev = _context19.next) {\n case 0:\n _context19.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\n constraints = [];\n if (hospitalName) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", hospitalName));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hospitalId));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context19.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context19.sent;\n hospitals = [];\n querySnapshot.forEach(function (doc) {\n hospitals.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context19.abrupt(\"return\", hospitals);\n case 14:\n _context19.prev = 14;\n _context19.t0 = _context19[\"catch\"](0);\n console.log(\"Error retrieving Hospitals\", _context19.t0);\n throw _context19.t0;\n case 18:\n case \"end\":\n return _context19.stop();\n }\n }, _callee19, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of improvement work documents based on various filter criteria.\n * It supports filtering by ID, Nolan stage, unit ID, completion status, ongoing status, and patient risk level.\n * It also supports sorting by the start date of the improvement work in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.id] - Optional identifier to filter the improvement works.\n * @param {string} [params.nolanStage] - Optional Nolan stage to filter the improvement works.\n * @param {string} [params.unitId] - Optional unit ID to filter the improvement works.\n * @param {boolean} [params.completed] - Optional flag to filter the improvement works by their completion status.\n * @param {boolean} [params.ongoing] - Optional flag to filter the improvement works by their ongoing status.\n * @param {string} [params.patientRiskLevel] - Optional patient risk level to filter the improvement works.\n * @param {boolean} [params.ascendingDates=false] - Optional flag for sorting by date in ascending order. Defaults to false.\n * @returns {Promise<any[]>} A promise that resolves to an array of improvement work objects that match the criteria.\n *\n * @throws Will throw an error if there is a problem retrieving the improvement works.\n */\nfunction getImprovementWorks(_ref4) {\n var id = _ref4.id,\n nolanStage = _ref4.nolanStage,\n unitId = _ref4.unitId,\n completed = _ref4.completed,\n ongoing = _ref4.ongoing,\n patientRiskLevel = _ref4.patientRiskLevel,\n _ref4$ascendingDates = _ref4.ascendingDates,\n ascendingDates = _ref4$ascendingDates === void 0 ? false : _ref4$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {\n var collectionRef, constraints, q, querySnapshot, improvementWorks;\n return _regeneratorRuntime().wrap(function _callee20$(_context20) {\n while (1) switch (_context20.prev = _context20.next) {\n case 0:\n _context20.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (nolanStage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"currentStage\", \"==\", nolanStage));\n }\n if (completed != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"completed\", \"==\", completed));\n }\n if (ongoing !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"ongoing\", \"==\", ongoing));\n }\n if (patientRiskLevel) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"patientRiskLevel\", \"==\", patientRiskLevel));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"dateStarted\", ascendingDates ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context20.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 13:\n querySnapshot = _context20.sent;\n improvementWorks = [];\n querySnapshot.forEach(function (doc) {\n improvementWorks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context20.abrupt(\"return\", improvementWorks);\n case 19:\n _context20.prev = 19;\n _context20.t0 = _context20[\"catch\"](0);\n console.log(\"Error retrieving improvementWorks: \", _context20.t0);\n throw _context20.t0;\n case 23:\n case \"end\":\n return _context20.stop();\n }\n }, _callee20, null, [[0, 19]]);\n }));\n}\n/**\n * Asynchronously retrieves user documents from the database based on various filter criteria.\n * It can filter by the Health Savings Account ID (hsaId), unit ID, and unique identifier (uid).\n * Additionally, it can sort the results by first name in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.hsaId] - Optional HSA ID to filter the users.\n * @param {string} [params.unitId] - Optional unit ID to filter the users.\n * @param {boolean} [params.ascendingFirstNames=false] - Optional flag to sort by first names in ascending order. Defaults to false (descending order).\n * @param {string} [params.uid] - Optional unique identifier to filter the users.\n * @returns {Promise<any[]>} A promise that resolves to an array of user objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUsers(_ref5) {\n var hsaId = _ref5.hsaId,\n unitId = _ref5.unitId,\n _ref5$ascendingFirstN = _ref5.ascendingFirstNames,\n ascendingFirstNames = _ref5$ascendingFirstN === void 0 ? false : _ref5$ascendingFirstN,\n uid = _ref5.uid;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {\n var collectionRef, constraints, q, querySnapshot, users;\n return _regeneratorRuntime().wrap(function _callee21$(_context21) {\n while (1) switch (_context21.prev = _context21.next) {\n case 0:\n _context21.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\n constraints = [];\n if (hsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hsaId));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (uid) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"uid\", \"==\", uid));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"firstName\", ascendingFirstNames ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context21.next = 10;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 10:\n querySnapshot = _context21.sent;\n users = [];\n querySnapshot.forEach(function (doc) {\n users.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context21.abrupt(\"return\", users);\n case 16:\n _context21.prev = 16;\n _context21.t0 = _context21[\"catch\"](0);\n console.log(\"Error retrieving users by department: \", _context21.t0);\n throw _context21.t0;\n case 20:\n case \"end\":\n return _context21.stop();\n }\n }, _callee21, null, [[0, 16]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of task documents from the database based on several filter and sorting criteria.\n * Filters include task ID, user ID and their responsibility status, and related improvement work ID.\n * Results can be sorted by date either in ascending or descending order.\n *\n * @param {Object} params - Parameters to filter and sort the task results.\n * @param {string} [params.taskId] - Optional task ID to filter the tasks.\n * @param {string} [params.userId] - Optional user ID to identify tasks related to a user.\n * @param {boolean} [params.isResponsibleFor] - Optional flag to filter tasks where the user is marked as responsible.\n * @param {string} [params.improvementWorkId] - Optional improvement work ID to filter tasks related to a specific improvement work.\n * @param {boolean} [params.ascendingDates=false] - Optional flag to sort tasks by date in ascending order; defaults to descending order.\n * @returns {Promise<any[]>} A promise that resolves to an array of task objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getTasks(_ref6) {\n var taskId = _ref6.taskId,\n userId = _ref6.userId,\n isResponsibleFor = _ref6.isResponsibleFor,\n improvementWorkId = _ref6.improvementWorkId,\n _ref6$ascendingDates = _ref6.ascendingDates,\n ascendingDates = _ref6$ascendingDates === void 0 ? false : _ref6$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {\n var collectionRef, constraints, q, querySnapshot, tasks;\n return _regeneratorRuntime().wrap(function _callee22$(_context22) {\n while (1) switch (_context22.prev = _context22.next) {\n case 0:\n _context22.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\n constraints = [];\n if (taskId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", taskId));\n }\n if (userId && isResponsibleFor !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"members\", \"array-contains\", {\n userHsaId: userId,\n isResponsibleFor: isResponsibleFor\n }));\n }\n if (improvementWorkId != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"startDate\", ascendingDates ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context22.next = 9;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 9:\n querySnapshot = _context22.sent;\n tasks = [];\n querySnapshot.forEach(function (doc) {\n tasks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context22.abrupt(\"return\", tasks);\n case 15:\n _context22.prev = 15;\n _context22.t0 = _context22[\"catch\"](0);\n console.log(\"Error retrieving task by department: \", _context22.t0);\n throw _context22.t0;\n case 19:\n case \"end\":\n return _context22.stop();\n }\n }, _callee22, null, [[0, 15]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of unit documents from the database based on various filter criteria.\n * Filters can be applied based on unit ID, hospital ID, and unit name.\n * Additionally, results can be sorted by unit names in ascending or descending order.\n *\n * @param {Object} params - The parameters object containing filter and sorting options.\n * @param {string} [params.unitId] - Optional unit ID to filter the units.\n * @param {string} [params.hospitalId] - Optional hospital ID to filter units within a specific hospital.\n * @param {string} [params.name] - Optional name to filter units by a specific name.\n * @param {boolean} [params.ascendingUnitNames=false] - Optional flag to sort units by name in ascending order, defaults to descending.\n * @returns {Promise<any[]>} A promise that resolves to an array of unit objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUnits(_ref7) {\n var unitId = _ref7.unitId,\n hospitalId = _ref7.hospitalId,\n name = _ref7.name,\n _ref7$ascendingUnitNa = _ref7.ascendingUnitNames,\n ascendingUnitNames = _ref7$ascendingUnitNa === void 0 ? false : _ref7$ascendingUnitNa;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {\n var collectionRef, constraints, q, querySnapshot, units;\n return _regeneratorRuntime().wrap(function _callee23$(_context23) {\n while (1) switch (_context23.prev = _context23.next) {\n case 0:\n _context23.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\n constraints = [];\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", unitId));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"hospitalId\", \"==\", hospitalId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"name\", ascendingUnitNames ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context23.next = 9;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 9:\n querySnapshot = _context23.sent;\n units = [];\n querySnapshot.forEach(function (doc) {\n units.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context23.abrupt(\"return\", units);\n case 15:\n _context23.prev = 15;\n _context23.t0 = _context23[\"catch\"](0);\n console.log(\"Error retrieving units by hospitalId: \", _context23.t0);\n throw _context23.t0;\n case 19:\n case \"end\":\n return _context23.stop();\n }\n }, _callee23, null, [[0, 15]]);\n }));\n}\n//getMembersFilteredAndSorted() -> Get all members of a project (sorted by firstName?)\n// export getters to be able to use in other files\n\n////////////////////////////////////DELETING/////////////////////////////////////////////\n// delete an instance of a type\nfunction deleteInstance(docType, docId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee24$(_context24) {\n while (1) switch (_context24.prev = _context24.next) {\n case 0:\n _context24.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context24.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(docRef);\n case 4:\n console.log(\"\".concat(docType, \" deleted successfully.\"));\n _context24.next = 11;\n break;\n case 7:\n _context24.prev = 7;\n _context24.t0 = _context24[\"catch\"](0);\n console.error(\"Error deleting \".concat(docType, \":\"), _context24.t0);\n throw _context24.t0;\n case 11:\n case \"end\":\n return _context24.stop();\n }\n }, _callee24, null, [[0, 7]]);\n }));\n}\n// delete all instances of a type\nfunction deleteAllDocumentsInCollection(collectionName) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {\n var _this = this;\n var collectionRef, snapshot, deletePromises;\n return _regeneratorRuntime().wrap(function _callee26$(_context26) {\n while (1) switch (_context26.prev = _context26.next) {\n case 0:\n _context26.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionName);\n _context26.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n snapshot = _context26.sent;\n // Delete all documents in the collection\n deletePromises = snapshot.docs.map(function (doc) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {\n return _regeneratorRuntime().wrap(function _callee25$(_context25) {\n while (1) switch (_context25.prev = _context25.next) {\n case 0:\n _context25.next = 2;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(doc.ref);\n case 2:\n case \"end\":\n return _context25.stop();\n }\n }, _callee25);\n }));\n });\n _context26.next = 8;\n return Promise.all(deletePromises);\n case 8:\n console.log(\"All documents in the \".concat(collectionName, \" collection deleted successfully.\"));\n _context26.next = 15;\n break;\n case 11:\n _context26.prev = 11;\n _context26.t0 = _context26[\"catch\"](0);\n console.error(\"Error deleting all documents in \".concat(collectionName, \":\"), _context26.t0);\n throw _context26.t0;\n case 15:\n case \"end\":\n return _context26.stop();\n }\n }, _callee26, null, [[0, 11]]);\n }));\n}\n////////////////////////////////////UPDATING/////////////////////////////////////////////\n// update a field in an instance\nfunction updateInstance(docType, docId, updates) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee27$(_context27) {\n while (1) switch (_context27.prev = _context27.next) {\n case 0:\n _context27.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context27.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(docRef, updates);\n case 4:\n console.log(\"\".concat(docType, \" updated successfully.\"));\n _context27.next = 11;\n break;\n case 7:\n _context27.prev = 7;\n _context27.t0 = _context27[\"catch\"](0);\n console.error(\"Error updating \".concat(docType, \":\"), _context27.t0);\n throw _context27.t0;\n case 11:\n case \"end\":\n return _context27.stop();\n }\n }, _callee27, null, [[0, 7]]);\n }));\n}\n// changes the ongoing status of an improvement work. if ongoing it is paused, if if paused onging.\n// user must be a manager\nfunction startOrPauseImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee28$(_context28) {\n while (1) switch (_context28.prev = _context28.next) {\n case 0:\n _context28.prev = 0;\n _context28.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context28.sent;\n _context28.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context28.sent;\n if (!(!user || !user.manager)) {\n _context28.next = 11;\n break;\n }\n throw new Error(\"User can't change improvementWork status\");\n case 11:\n if (!improvementWork) {\n _context28.next = 18;\n break;\n }\n update = {\n ongoing: !improvementWork.ongoing\n };\n _context28.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n _context28.next = 19;\n break;\n case 18:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n case 19:\n _context28.next = 25;\n break;\n case 21:\n _context28.prev = 21;\n _context28.t0 = _context28[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context28.t0);\n throw _context28.t0;\n case 25:\n case \"end\":\n return _context28.stop();\n }\n }, _callee28, null, [[0, 21]]);\n }));\n}\nfunction changePatientRiskLevel(userId, improvementWorkId, patientRiskLevel) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee29$(_context29) {\n while (1) switch (_context29.prev = _context29.next) {\n case 0:\n _context29.prev = 0;\n _context29.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context29.sent;\n _context29.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context29.sent;\n if (!(!user || !user.manager)) {\n _context29.next = 11;\n break;\n }\n throw new Error(\"User can't change patientRiskLevel in improvement work\");\n case 11:\n if (!improvementWork) {\n _context29.next = 18;\n break;\n }\n update = {\n patientRiskLevel: patientRiskLevel\n };\n _context29.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n _context29.next = 19;\n break;\n case 18:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n case 19:\n _context29.next = 25;\n break;\n case 21:\n _context29.prev = 21;\n _context29.t0 = _context29[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context29.t0);\n throw _context29.t0;\n case 25:\n case \"end\":\n return _context29.stop();\n }\n }, _callee29, null, [[0, 21]]);\n }));\n}\n// finalizes the improvement work. ongoing is set to false.\n// user must be a manager\nfunction finalizeImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {\n var user, update;\n return _regeneratorRuntime().wrap(function _callee30$(_context30) {\n while (1) switch (_context30.prev = _context30.next) {\n case 0:\n _context30.prev = 0;\n _context30.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context30.sent;\n if (!(!user || !user.manager)) {\n _context30.next = 8;\n break;\n }\n throw new Error(\"User can't finalize improvementWork status\");\n case 8:\n update = {\n completed: true,\n ongoing: false\n };\n _context30.next = 11;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 11:\n _context30.next = 16;\n break;\n case 13:\n _context30.prev = 13;\n _context30.t0 = _context30[\"catch\"](0);\n console.log(_context30.t0);\n case 16:\n case \"end\":\n return _context30.stop();\n }\n }, _callee30, null, [[0, 13]]);\n }));\n}\n\n//////////////////////////////// for later sprint\n//function add_upvotes\n//function add_notes\n//function add_intrested_users\n\n//# sourceURL=webpack://c3/./client/Database/database.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addDocumentToImprovementWork: () => (/* binding */ addDocumentToImprovementWork),\n/* harmony export */ addMemberToImprovementWork: () => (/* binding */ addMemberToImprovementWork),\n/* harmony export */ addMemberToTask: () => (/* binding */ addMemberToTask),\n/* harmony export */ addNoteToUser: () => (/* binding */ addNoteToUser),\n/* harmony export */ auth: () => (/* binding */ auth),\n/* harmony export */ changePatientRiskLevel: () => (/* binding */ changePatientRiskLevel),\n/* harmony export */ createComment: () => (/* binding */ createComment),\n/* harmony export */ createHospital: () => (/* binding */ createHospital),\n/* harmony export */ createImprovementWork: () => (/* binding */ createImprovementWork),\n/* harmony export */ createSuggestion: () => (/* binding */ createSuggestion),\n/* harmony export */ createTaskOnImprovementWork: () => (/* binding */ createTaskOnImprovementWork),\n/* harmony export */ createUnit: () => (/* binding */ createUnit),\n/* harmony export */ createUser: () => (/* binding */ createUser),\n/* harmony export */ createdDocumentInKnowledgeBank: () => (/* binding */ createdDocumentInKnowledgeBank),\n/* harmony export */ db: () => (/* binding */ db),\n/* harmony export */ deleteAllDocumentsInCollection: () => (/* binding */ deleteAllDocumentsInCollection),\n/* harmony export */ deleteInstance: () => (/* binding */ deleteInstance),\n/* harmony export */ finalizeImprovementWork: () => (/* binding */ finalizeImprovementWork),\n/* harmony export */ getComments: () => (/* binding */ getComments),\n/* harmony export */ getHospitals: () => (/* binding */ getHospitals),\n/* harmony export */ getImprovementWorkOwner: () => (/* binding */ getImprovementWorkOwner),\n/* harmony export */ getImprovementWorkResponsible: () => (/* binding */ getImprovementWorkResponsible),\n/* harmony export */ getImprovementWorks: () => (/* binding */ getImprovementWorks),\n/* harmony export */ getImprovementWorksForUser: () => (/* binding */ getImprovementWorksForUser),\n/* harmony export */ getObject: () => (/* binding */ getObject),\n/* harmony export */ getObjectById: () => (/* binding */ getObjectById),\n/* harmony export */ getSuggestions: () => (/* binding */ getSuggestions),\n/* harmony export */ getTasks: () => (/* binding */ getTasks),\n/* harmony export */ getUnits: () => (/* binding */ getUnits),\n/* harmony export */ getUsers: () => (/* binding */ getUsers),\n/* harmony export */ getUsersForImprovementWork: () => (/* binding */ getUsersForImprovementWork),\n/* harmony export */ startOrPauseImprovementWork: () => (/* binding */ startOrPauseImprovementWork),\n/* harmony export */ updateInstance: () => (/* binding */ updateInstance),\n/* harmony export */ upvoteComment: () => (/* binding */ upvoteComment),\n/* harmony export */ upvoteSuggestion: () => (/* binding */ upvoteSuggestion)\n/* harmony export */ });\n/* harmony import */ var firebase_app__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! firebase/app */ \"./node_modules/firebase/app/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_firestore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! firebase/firestore */ \"./node_modules/firebase/firestore/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_auth__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! firebase/auth */ \"./node_modules/firebase/auth/dist/esm/index.esm.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nvar firebaseConfig = {\n apiKey: \"AIzaSyDqkaVZMr11J4mfnR0auqoQilZyPfyD-x4\",\n authDomain: \"c3solutions-dc109.firebaseapp.com\",\n projectId: \"c3solutions-dc109\",\n storageBucket: \"c3solutions-dc109.appspot.com\",\n messagingSenderId: \"902143402555\",\n appId: \"1:902143402555:web:29213e81de0a0cba38b21e\"\n};\n/*const firebaseConfig = {\n apiKey: \"AIzaSyBIsZq_yOsJljp1woIxndJO1GkW6soh-g4\",\n authDomain: \"company3-456bb.firebaseapp.com\",\n projectId: \"company3-456bb\",\n storageBucket: \"company3-456bb.appspot.com\",\n messagingSenderId: \"310033686522\",\n appId: \"1:310033686522:web:63198bb0db679c98ee4e43\",\n measurementId: \"G-PFLDQY00DB\"\n};*/\n// const firebaseConfig = {\n// apiKey: \"AIzaSyBIsZq_yOsJljp1woIxndJO1GkW6soh-g4\",\n// authDomain: \"company3-456bb.firebaseapp.com\",\n// projectId: \"company3-456bb\",\n// storageBucket: \"company3-456bb.appspot.com\",\n// messagingSenderId: \"310033686522\",\n// appId: \"1:310033686522:web:63198bb0db679c98ee4e43\",\n// measurementId: \"G-PFLDQY00DB\"\n// };\nvar app = (0,firebase_app__WEBPACK_IMPORTED_MODULE_0__.initializeApp)(firebaseConfig);\nvar auth = (0,firebase_auth__WEBPACK_IMPORTED_MODULE_2__.getAuth)();\nvar db = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getFirestore)(app);\nvar userCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\nvar unitCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\nvar improvementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\nvar taskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\nvar hospitalCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\nvar suggestionCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\nvar knowledgeDocumentCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"knowledgeDocument\");\nvar userImprovementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"userImprovementWork\");\nvar userTaskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"userTask\");\n////////////////////////////////////////Setters///////////////////////////////////////////////////////////////////\n// Function to create user a new user in database\n// takes in userId, unitId, firstname, lastname, email and password as string\n// throws error if transaction failed\nfunction createUser(hsaId, unitId, firstName, lastName, email, manager, uid) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var userRef, unitRef;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, hsaId);\n _context.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(userRef, {\n id: userRef.id,\n uid: uid,\n unitId: unitId,\n firstName: firstName,\n lastName: lastName,\n email: email,\n // TODO Replace with userImprovementWork collection\n improvementWorks: [],\n tasks: [],\n manager: manager\n });\n case 4:\n // Atomically add user to unit.\n unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection, unitId);\n _context.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(unitRef, {\n members: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userRef.id)\n });\n case 7:\n _context.next = 12;\n break;\n case 9:\n _context.prev = 9;\n _context.t0 = _context[\"catch\"](0);\n console.log(_context.t0);\n case 12:\n case \"end\":\n return _context.stop();\n }\n }, _callee, null, [[0, 9]]);\n }));\n}\nfunction createImprovementWork(id, name, currentStage, content,\n// Är detta description bör detta förtydligas. \nunitId, purpose,\n//Bör tas bort motsvaras av p2- mål med projektet\npatientRiskLevel, area,\n//Questions in planning stage\np1, p2, p3, p4, p5, p6, p7,\n//Questions in Doing (G) stage\ng1, g2, g3, g4, g5,\n//Questions in stydy stage\ns1, s2, s3,\n//Questions in acting stage\na1, a2, a3, a4) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var improvementWorkData, improvementWorkRef, _improvementWorkRef;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.prev = 0;\n improvementWorkData = {\n name: name,\n currentStage: currentStage,\n content: content,\n purpose: purpose,\n dateStarted: new Date(),\n unitId: unitId,\n completed: false,\n ongoing: false,\n tasks: [],\n // TODO Remove members array\n members: [],\n patientRiskLevel: patientRiskLevel,\n area: area,\n p1: p1,\n p2: p2,\n p3: p3,\n p4: p4,\n p5: p5,\n p6: p6,\n p7: p7,\n g1: g1,\n g2: g2,\n g3: g3,\n g4: g4,\n g5: g5,\n s1: s1,\n s2: s2,\n s3: s3,\n a1: a1,\n a2: a2,\n a3: a3,\n a4: a4\n };\n if (!id) {\n _context2.next = 8;\n break;\n }\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, id);\n _context2.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(improvementWorkRef, Object.assign({\n id: improvementWorkRef.id\n }, improvementWorkData));\n case 6:\n _context2.next = 11;\n break;\n case 8:\n _improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection);\n _context2.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_improvementWorkRef, improvementWorkData);\n case 11:\n _context2.next = 17;\n break;\n case 13:\n _context2.prev = 13;\n _context2.t0 = _context2[\"catch\"](0);\n console.log(\"Error creating improvementWork: \", _context2.t0);\n throw _context2.t0;\n case 17:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, null, [[0, 13]]);\n }));\n}\nfunction addMemberToTask(userHsaId, taskId, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var relationRef;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.prev = 0;\n relationRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userTaskCollection);\n _context3.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(relationRef, {\n id: relationRef.id,\n userHsaId: userHsaId,\n taskId: taskId,\n isResponsibleFor: isResponsibleFor\n });\n case 4:\n _context3.next = 10;\n break;\n case 6:\n _context3.prev = 6;\n _context3.t0 = _context3[\"catch\"](0);\n console.log(\"Error adding member to task: \", _context3.t0);\n throw _context3.t0;\n case 10:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, null, [[0, 6]]);\n }));\n}\nfunction addMemberToImprovementWork(userHsaId, improvementWorkId, isOwner, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var relationRef;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n _context4.prev = 0;\n relationRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userImprovementWorkCollection);\n _context4.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(relationRef, {\n id: relationRef.id,\n userHsaId: userHsaId,\n improvementWorkId: improvementWorkId,\n isOwner: isOwner,\n isResponsibleFor: isResponsibleFor\n });\n case 4:\n _context4.next = 10;\n break;\n case 6:\n _context4.prev = 6;\n _context4.t0 = _context4[\"catch\"](0);\n console.log(\"Error adding member to improvementWork: \", _context4.t0);\n throw _context4.t0;\n case 10:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4, null, [[0, 6]]);\n }));\n}\nfunction createTaskOnImprovementWork(taskId, improvementWorkId, name, deadlineDate, startDate, stage, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var taskData, taskRef, _taskRef;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n _context5.prev = 0;\n taskData = {\n improvementWorkId: improvementWorkId,\n name: name,\n deadlineDate: deadlineDate,\n startDate: startDate,\n stage: stage,\n content: content,\n members: [] // Initialize with an empty array\n };\n if (!taskId) {\n _context5.next = 8;\n break;\n }\n taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection, taskId);\n _context5.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(taskRef, Object.assign({\n id: taskRef.id\n }, taskData));\n case 6:\n _context5.next = 11;\n break;\n case 8:\n _taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection);\n _context5.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_taskRef, taskData);\n case 11:\n _context5.next = 17;\n break;\n case 13:\n _context5.prev = 13;\n _context5.t0 = _context5[\"catch\"](0);\n console.log(\"Error creating task: \", _context5.t0);\n throw _context5.t0;\n case 17:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5, null, [[0, 13]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction createdDocumentInKnowledgeBank(documentUrl, name) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n _context6.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(knowledgeDocumentCollection);\n _context6.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n name: name\n });\n case 4:\n _context6.next = 10;\n break;\n case 6:\n _context6.prev = 6;\n _context6.t0 = _context6[\"catch\"](0);\n console.log(\"Error adding document: \", _context6.t0);\n throw _context6.t0;\n case 10:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6, null, [[0, 6]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction addDocumentToImprovementWork(documentUrl, name, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var improvementWorkRef, docRef;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.prev = 0;\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, improvementWorkId);\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkRef, \"documents\");\n _context7.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n timestamp: new Date(),\n name: name\n });\n case 5:\n _context7.next = 11;\n break;\n case 7:\n _context7.prev = 7;\n _context7.t0 = _context7[\"catch\"](0);\n console.log(\"Error adding document: \", _context7.t0);\n throw _context7.t0;\n case 11:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7, null, [[0, 7]]);\n }));\n}\nfunction createHospital(hospitalId,\n// should be auto?\nname) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var hospitalData, hospitalRef, _hospitalRef;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n _context8.prev = 0;\n hospitalData = {\n name: name,\n units: []\n };\n if (!hospitalId) {\n _context8.next = 8;\n break;\n }\n hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection, hospitalId);\n _context8.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(hospitalRef, Object.assign({\n id: hospitalRef.id\n }, hospitalData));\n case 6:\n _context8.next = 11;\n break;\n case 8:\n _hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection);\n _context8.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_hospitalRef, hospitalData);\n case 11:\n _context8.next = 17;\n break;\n case 13:\n _context8.prev = 13;\n _context8.t0 = _context8[\"catch\"](0);\n console.log(\"Error creating hospital: \", _context8.t0);\n throw _context8.t0;\n case 17:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8, null, [[0, 13]]);\n }));\n}\nfunction createUnit(unitId,\n//should be auto?\nhospitalId, name) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var unitData, unitRef, _unitRef;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n _context9.prev = 0;\n unitData = {\n hospitalId: hospitalId,\n name: name,\n members: []\n };\n if (!unitId) {\n _context9.next = 8;\n break;\n }\n unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection, unitId);\n _context9.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(unitRef, Object.assign({\n id: unitRef.id\n }, unitData));\n case 6:\n _context9.next = 11;\n break;\n case 8:\n _unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection);\n _context9.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_unitRef, unitData);\n case 11:\n _context9.next = 17;\n break;\n case 13:\n _context9.prev = 13;\n _context9.t0 = _context9[\"catch\"](0);\n console.log(\"Error creating unit: \", _context9.t0);\n throw _context9.t0;\n case 17:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9, null, [[0, 13]]);\n }));\n}\nfunction createSuggestion(id, creatorHsaId, name, area, content, purpose, measure, ideas,\n//need: boolean,\nunitId, departmentId, isPublic) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var suggestionData, suggestionRef, _suggestionRef;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n _context10.prev = 0;\n suggestionData = {\n creatorHsaId: creatorHsaId,\n name: name,\n area: area,\n content: content,\n purpose: purpose,\n measure: measure,\n ideas: ideas,\n //need,\n unitId: unitId,\n departmentId: departmentId,\n \"public\": isPublic,\n upvotes: [],\n comments: [],\n dateCreated: new Date()\n };\n if (!id) {\n _context10.next = 8;\n break;\n }\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, id);\n _context10.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(suggestionRef, Object.assign({\n id: suggestionRef.id\n }, suggestionData));\n case 6:\n _context10.next = 11;\n break;\n case 8:\n _suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection);\n _context10.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_suggestionRef, suggestionData);\n case 11:\n _context10.next = 17;\n break;\n case 13:\n _context10.prev = 13;\n _context10.t0 = _context10[\"catch\"](0);\n console.log(\"Error creating suggestion: \", _context10.t0);\n throw _context10.t0;\n case 17:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10, null, [[0, 13]]);\n }));\n}\n// Upvote a suggestion for a user\n// takes in suggestion id, user HSAid\n// returns error if transaction failed\nfunction upvoteSuggestion(suggestionId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var suggestionRef;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n _context11.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId); // Atomically add a update to the upvote array field.\n _context11.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(suggestionRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 4:\n _context11.next = 10;\n break;\n case 6:\n _context11.prev = 6;\n _context11.t0 = _context11[\"catch\"](0);\n console.log(\"Error upvoting suggestion: \", _context11.t0);\n throw _context11.t0;\n case 10:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11, null, [[0, 6]]);\n }));\n}\n//creates a comment\n// takes in commenters id, suggestion id and content as string\n// throws error if transaction failed\nfunction createComment(\n// change to subcollection\ncommenterHsaId, suggestionId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var suggestionRef, commentCollection, commentRef;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n _context12.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context12.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\");\n case 4:\n commentCollection = _context12.sent;\n _context12.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(commentCollection);\n case 7:\n commentRef = _context12.sent;\n _context12.next = 10;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(commentRef, {\n id: commentRef.id,\n commenterHsaId: commenterHsaId,\n content: content,\n dateCreated: new Date(),\n upvotes: []\n });\n case 10:\n _context12.next = 16;\n break;\n case 12:\n _context12.prev = 12;\n _context12.t0 = _context12[\"catch\"](0);\n console.log(\"Error creating comment: \", _context12.t0);\n throw _context12.t0;\n case 16:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12, null, [[0, 12]]);\n }));\n}\n// Upvote a comment for a user\n// takes in suggestionId, commentId and userId as strings\n// return error if transaction failed\nfunction upvoteComment(suggestionId, commentId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var suggestionRef, commentRef;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n _context13.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n commentRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionRef, \"comment\", commentId); // Atomically add a update to the upvote array field.\n _context13.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(commentRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 5:\n _context13.next = 11;\n break;\n case 7:\n _context13.prev = 7;\n _context13.t0 = _context13[\"catch\"](0);\n console.log(\"Error upvoting comment: \", _context13.t0);\n throw _context13.t0;\n case 11:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13, null, [[0, 7]]);\n }));\n}\n//add a note to a user\n// takes in userHsaId and content as string\n// throws error if transaction failed\nfunction addNoteToUser(userHsaId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var userRef, docRef;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n _context14.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, userHsaId);\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userRef, \"notes\");\n _context14.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n content: content,\n dateCreated: new Date()\n });\n case 5:\n _context14.next = 11;\n break;\n case 7:\n _context14.prev = 7;\n _context14.t0 = _context14[\"catch\"](0);\n console.log(\"Error adding document: \", _context14.t0);\n throw _context14.t0;\n case 11:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14, null, [[0, 7]]);\n }));\n}\n// export to setters to be able to use in other files\n\n//////////////////////////////////////////////GETTERS/////////////////////////////////////////////////////////////////////\n// Get any object\n// input is the database type as a string.\n// output is the whole collection of that type.\nfunction getObject(collectionPath) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n var collectionRef, querySnapshot, result;\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n _context15.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionPath);\n _context15.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n querySnapshot = _context15.sent;\n result = [];\n querySnapshot.forEach(function (doc) {\n result.push(doc.data());\n });\n return _context15.abrupt(\"return\", result);\n case 10:\n _context15.prev = 10;\n _context15.t0 = _context15[\"catch\"](0);\n console.error(\"Error getting collection data\", _context15.t0);\n throw _context15.t0;\n case 14:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15, null, [[0, 10]]);\n }));\n}\n/**\n * Asynchronously retrieves a single document object from the specified collection path and document ID.\n * If the document does not exist, logs a warning and returns null.\n *\n * @param {string} collectionPath - The path to the collection in the database (\"improvementWork\", \"hospital\", \"suggestion\", \"task\", \"unit\", \"users\")\n * @param {string} documentId - The ID of the document to retrieve.\n * @returns {Promise<any|null>} A promise that resolves to the document object if found, or null if not.\n *\n * @throws Will throw an error if there is an issue during retrieval from the database.\n */\nfunction getObjectById(collectionPath, documentId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {\n var docRef, docSnapshot;\n return _regeneratorRuntime().wrap(function _callee16$(_context16) {\n while (1) switch (_context16.prev = _context16.next) {\n case 0:\n _context16.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, collectionPath, documentId);\n _context16.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDoc)(docRef);\n case 4:\n docSnapshot = _context16.sent;\n if (!docSnapshot.exists()) {\n _context16.next = 9;\n break;\n }\n return _context16.abrupt(\"return\", Object.assign({\n id: docSnapshot.id\n }, docSnapshot.data()));\n case 9:\n console.warn(\"No such document! \".concat(collectionPath, \"/\").concat(documentId));\n return _context16.abrupt(\"return\", null);\n case 11:\n _context16.next = 17;\n break;\n case 13:\n _context16.prev = 13;\n _context16.t0 = _context16[\"catch\"](0);\n console.error(\"Error getting object\", _context16.t0);\n throw _context16.t0;\n case 17:\n case \"end\":\n return _context16.stop();\n }\n }, _callee16, null, [[0, 13]]);\n }));\n}\n/**\n * Asynchronously retrieves comments for a given suggestion.\n *\n * @param {Object} params - The parameters for fetching comments.\n * @param {string} params.suggestionId - The ID of the suggestion to fetch comments for.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - The criterion to sort the comments by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Determines if the sorting should be in ascending order. Defaults to false (descending).\n * @returns {Promise<any[]>} A promise that resolves to an array of comment objects.\n *\n * @throws Will throw an error if the comments cannot be retrieved.\n */\nfunction getComments(_ref) {\n var suggestionId = _ref.suggestionId,\n _ref$sortBy = _ref.sortBy,\n sortBy = _ref$sortBy === void 0 ? \"dateCreated\" : _ref$sortBy,\n _ref$ascending = _ref.ascending,\n ascending = _ref$ascending === void 0 ? false : _ref$ascending;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {\n var suggestionRef, commentsQuery, commentsSnapshot, comments;\n return _regeneratorRuntime().wrap(function _callee17$(_context17) {\n while (1) switch (_context17.prev = _context17.next) {\n case 0:\n _context17.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, \"suggestionCollection\", suggestionId);\n commentsQuery = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\"), (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n _context17.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(commentsQuery);\n case 5:\n commentsSnapshot = _context17.sent;\n comments = [];\n commentsSnapshot.forEach(function (doc) {\n comments.push(doc.data());\n });\n return _context17.abrupt(\"return\", comments);\n case 11:\n _context17.prev = 11;\n _context17.t0 = _context17[\"catch\"](0);\n console.error(\"Error getting comments for suggestion: \", _context17.t0);\n throw _context17.t0;\n case 15:\n case \"end\":\n return _context17.stop();\n }\n }, _callee17, null, [[0, 11]]);\n }));\n}\n//Filtering suggestions on unitId AND creatorHsaId\n//Sort suggestions on dateCreated OR upvotes\n/**\n * Asynchronously retrieves an array of suggestions from the database, with various filters and sorting options.\n *\n * @param {Object} params - The parameters for filtering and sorting suggestions.\n * @param {string} [params.id] - Optional ID to filter suggestions by a specific identifier.\n * @param {string} [params.creatorHsaId] - Optional HSA ID to filter suggestions by the creator's HSA ID.\n * @param {string} [params.unitId] - Optional unit ID to filter suggestions by a specific unit.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - Criterion to sort the suggestions by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Flag indicating if sorting should be ascending. Defaults to false (descending order).\n * @param {boolean} [params.isPublic=true] - Flag indicating whether to filter for public suggestions. Defaults to true.\n * @returns {Promise<any[]>} A promise that resolves to an array of suggestion objects.\n *\n * @throws Will throw an error if there is an issue retrieving suggestions.\n */\nfunction getSuggestions(_ref2) {\n var id = _ref2.id,\n creatorHsaId = _ref2.creatorHsaId,\n unitId = _ref2.unitId,\n _ref2$sortBy = _ref2.sortBy,\n sortBy = _ref2$sortBy === void 0 ? \"dateCreated\" : _ref2$sortBy,\n _ref2$ascending = _ref2.ascending,\n ascending = _ref2$ascending === void 0 ? false : _ref2$ascending,\n _ref2$isPublic = _ref2.isPublic,\n isPublic = _ref2$isPublic === void 0 ? true : _ref2$isPublic;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {\n var collectionRef, constraints, q, querySnapshot, suggestions;\n return _regeneratorRuntime().wrap(function _callee18$(_context18) {\n while (1) switch (_context18.prev = _context18.next) {\n case 0:\n _context18.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (creatorHsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"creatorHsaId\", \"==\", creatorHsaId));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"public\", \"==\", isPublic));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context18.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 11:\n querySnapshot = _context18.sent;\n suggestions = [];\n querySnapshot.forEach(function (doc) {\n suggestions.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context18.abrupt(\"return\", suggestions);\n case 17:\n _context18.prev = 17;\n _context18.t0 = _context18[\"catch\"](0);\n console.log(\"Error retrieving suggestions by department: \", _context18.t0);\n throw _context18.t0;\n case 21:\n case \"end\":\n return _context18.stop();\n }\n }, _callee18, null, [[0, 17]]);\n }));\n}\n/**\n * Asynchronously searches for hospital documents in the database.\n * It can filter the results by the hospital's name, ID, or both.\n * If no parameters are provided, it retrieves all hospitals.\n *\n * @param {Object} params - An object containing the search parameters.\n * @param {string} [params.hospitalName] - Optional name of the hospital to filter the search.\n * @param {string} [params.hospitalId] - Optional unique identifier of the hospital to filter the search.\n * @returns {Promise<any[]>} A promise that resolves to an array of hospital objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getHospitals(_ref3) {\n var hospitalName = _ref3.hospitalName,\n hospitalId = _ref3.hospitalId;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {\n var collectionRef, constraints, q, querySnapshot, hospitals;\n return _regeneratorRuntime().wrap(function _callee19$(_context19) {\n while (1) switch (_context19.prev = _context19.next) {\n case 0:\n _context19.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\n constraints = [];\n if (hospitalName) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", hospitalName));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hospitalId));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context19.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context19.sent;\n hospitals = [];\n querySnapshot.forEach(function (doc) {\n hospitals.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context19.abrupt(\"return\", hospitals);\n case 14:\n _context19.prev = 14;\n _context19.t0 = _context19[\"catch\"](0);\n console.log(\"Error retrieving Hospitals\", _context19.t0);\n throw _context19.t0;\n case 18:\n case \"end\":\n return _context19.stop();\n }\n }, _callee19, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of improvement work documents based on various filter criteria.\n * It supports filtering by ID, Nolan stage, unit ID, completion status, ongoing status, and patient risk level.\n * It also supports sorting by the start date of the improvement work in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.id] - Optional identifier to filter the improvement works.\n * @param {string} [params.nolanStage] - Optional Nolan stage to filter the improvement works.\n * @param {string} [params.unitId] - Optional unit ID to filter the improvement works.\n * @param {boolean} [params.completed] - Optional flag to filter the improvement works by their completion status.\n * @param {boolean} [params.ongoing] - Optional flag to filter the improvement works by their ongoing status.\n * @param {string} [params.patientRiskLevel] - Optional patient risk level to filter the improvement works.\n * @param {boolean} [params.ascendingDates=false] - Optional flag for sorting by date in ascending order. Defaults to false.\n * @returns {Promise<any[]>} A promise that resolves to an array of improvement work objects that match the criteria.\n *\n * @throws Will throw an error if there is a problem retrieving the improvement works.\n */\nfunction getImprovementWorks(_ref4) {\n var id = _ref4.id,\n nolanStage = _ref4.nolanStage,\n unitId = _ref4.unitId,\n completed = _ref4.completed,\n ongoing = _ref4.ongoing,\n patientRiskLevel = _ref4.patientRiskLevel,\n _ref4$ascendingDates = _ref4.ascendingDates,\n ascendingDates = _ref4$ascendingDates === void 0 ? false : _ref4$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {\n var collectionRef, constraints, q, querySnapshot, improvementWorks;\n return _regeneratorRuntime().wrap(function _callee20$(_context20) {\n while (1) switch (_context20.prev = _context20.next) {\n case 0:\n _context20.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (nolanStage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"currentStage\", \"==\", nolanStage));\n }\n if (completed != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"completed\", \"==\", completed));\n }\n if (ongoing !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"ongoing\", \"==\", ongoing));\n }\n if (patientRiskLevel) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"patientRiskLevel\", \"==\", patientRiskLevel));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"dateStarted\", ascendingDates ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context20.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 13:\n querySnapshot = _context20.sent;\n improvementWorks = [];\n querySnapshot.forEach(function (doc) {\n improvementWorks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context20.abrupt(\"return\", improvementWorks);\n case 19:\n _context20.prev = 19;\n _context20.t0 = _context20[\"catch\"](0);\n console.log(\"Error retrieving improvementWorks: \", _context20.t0);\n throw _context20.t0;\n case 23:\n case \"end\":\n return _context20.stop();\n }\n }, _callee20, null, [[0, 19]]);\n }));\n}\nfunction getImprovementWorkOwner(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {\n var constraints, q, querySnapshot, owner;\n return _regeneratorRuntime().wrap(function _callee21$(_context21) {\n while (1) switch (_context21.prev = _context21.next) {\n case 0:\n _context21.prev = 0;\n constraints = [];\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"isOwner\", \"==\", true));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context21.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 7:\n querySnapshot = _context21.sent;\n if (!querySnapshot.empty) {\n _context21.next = 13;\n break;\n }\n console.log(\"Improvement work \", improvementWorkId, \" has no owner\");\n return _context21.abrupt(\"return\", null);\n case 13:\n owner = querySnapshot.docs[0].data().userHsaId;\n return _context21.abrupt(\"return\", owner);\n case 15:\n _context21.next = 20;\n break;\n case 17:\n _context21.prev = 17;\n _context21.t0 = _context21[\"catch\"](0);\n console.log(_context21.t0);\n case 20:\n case \"end\":\n return _context21.stop();\n }\n }, _callee21, null, [[0, 17]]);\n }));\n}\nfunction getImprovementWorkResponsible(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {\n var constraints, q, querySnapshot, responsible;\n return _regeneratorRuntime().wrap(function _callee22$(_context22) {\n while (1) switch (_context22.prev = _context22.next) {\n case 0:\n _context22.prev = 0;\n constraints = [];\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"isResponsibleFor\", \"==\", true));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context22.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 7:\n querySnapshot = _context22.sent;\n if (!querySnapshot.empty) {\n _context22.next = 13;\n break;\n }\n console.log(\"Improvement work \", improvementWorkId, \" has no responsible\");\n return _context22.abrupt(\"return\", null);\n case 13:\n responsible = querySnapshot.docs[0].data().userHsaId;\n return _context22.abrupt(\"return\", responsible);\n case 15:\n _context22.next = 20;\n break;\n case 17:\n _context22.prev = 17;\n _context22.t0 = _context22[\"catch\"](0);\n console.log(_context22.t0);\n case 20:\n case \"end\":\n return _context22.stop();\n }\n }, _callee22, null, [[0, 17]]);\n }));\n}\n// TODO getUsersForTask!\n/**\n * Asynchronously retrieves user documents from the database based on various filter criteria.\n * It can filter by the Health Savings Account ID (hsaId), unit ID, and unique identifier (uid).\n * Additionally, it can sort the results by first name in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.hsaId] - Optional HSA ID to filter the users.\n * @param {string} [params.unitId] - Optional unit ID to filter the users.\n * @param {boolean} [params.ascendingFirstNames=false] - Optional flag to sort by first names in ascending order. Defaults to false (descending order).\n * @param {string} [params.uid] - Optional unique identifier to filter the users.\n * @returns {Promise<any[]>} A promise that resolves to an array of user objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUsers(_ref5) {\n var hsaId = _ref5.hsaId,\n unitId = _ref5.unitId,\n _ref5$ascendingFirstN = _ref5.ascendingFirstNames,\n ascendingFirstNames = _ref5$ascendingFirstN === void 0 ? false : _ref5$ascendingFirstN,\n uid = _ref5.uid;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {\n var collectionRef, constraints, q, querySnapshot, users;\n return _regeneratorRuntime().wrap(function _callee23$(_context23) {\n while (1) switch (_context23.prev = _context23.next) {\n case 0:\n _context23.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\n constraints = [];\n if (hsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hsaId));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (uid) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"uid\", \"==\", uid));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"firstName\", ascendingFirstNames ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context23.next = 10;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 10:\n querySnapshot = _context23.sent;\n users = [];\n querySnapshot.forEach(function (doc) {\n users.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context23.abrupt(\"return\", users);\n case 16:\n _context23.prev = 16;\n _context23.t0 = _context23[\"catch\"](0);\n console.log(\"Error retrieving users by department: \", _context23.t0);\n throw _context23.t0;\n case 20:\n case \"end\":\n return _context23.stop();\n }\n }, _callee23, null, [[0, 16]]);\n }));\n}\n// TODO getTasksForUser!\n/**\n * Asynchronously retrieves an array of task documents from the database based on several filter and sorting criteria.\n * Filters include task ID, user ID and their responsibility status, and related improvement work ID.\n * Results can be sorted by date either in ascending or descending order.\n *\n * @param {Object} params - Parameters to filter and sort the task results.\n * @param {string} [params.taskId] - Optional task ID to filter the tasks.\n * @param {string} [params.userId] - Optional user ID to identify tasks related to a user.\n * @param {boolean} [params.isResponsibleFor] - Optional flag to filter tasks where the user is marked as responsible.\n * @param {string} [params.improvementWorkId] - Optional improvement work ID to filter tasks related to a specific improvement work.\n * @param {boolean} [params.ascendingDates=false] - Optional flag to sort tasks by date in ascending order; defaults to descending order.\n * @returns {Promise<any[]>} A promise that resolves to an array of task objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getTasks(_ref6) {\n var improvementWorkId = _ref6.improvementWorkId,\n stage = _ref6.stage,\n _ref6$ascendingDates = _ref6.ascendingDates,\n ascendingDates = _ref6$ascendingDates === void 0 ? false : _ref6$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {\n var collectionRef, constraints, q, querySnapshot, tasks;\n return _regeneratorRuntime().wrap(function _callee24$(_context24) {\n while (1) switch (_context24.prev = _context24.next) {\n case 0:\n _context24.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\n constraints = []; // FUTURE FEATURE: Filter on userHsaId AND improvementWork\n // if (userHsaId && isResponsibleFor !== undefined) {\n // constraints.push(\n // where(\"members\", \"array-contains\", {\n // userHsaId: userHsaId,\n // isResponsibleFor: isResponsibleFor,\n // })\n // );\n // }\n if (stage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"stage\", \"==\", stage));\n }\n if (improvementWorkId != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"startDate\", ascendingDates ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context24.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context24.sent;\n tasks = [];\n querySnapshot.forEach(function (doc) {\n tasks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context24.abrupt(\"return\", tasks);\n case 14:\n _context24.prev = 14;\n _context24.t0 = _context24[\"catch\"](0);\n console.log(\"Error retrieving task by department: \", _context24.t0);\n throw _context24.t0;\n case 18:\n case \"end\":\n return _context24.stop();\n }\n }, _callee24, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of unit documents from the database based on various filter criteria.\n * Filters can be applied based on unit ID, hospital ID, and unit name.\n * Additionally, results can be sorted by unit names in ascending or descending order.\n *\n * @param {Object} params - The parameters object containing filter and sorting options.\n * @param {string} [params.unitId] - Optional unit ID to filter the units.\n * @param {string} [params.hospitalId] - Optional hospital ID to filter units within a specific hospital.\n * @param {string} [params.name] - Optional name to filter units by a specific name.\n * @param {boolean} [params.ascendingUnitNames=false] - Optional flag to sort units by name in ascending order, defaults to descending.\n * @returns {Promise<any[]>} A promise that resolves to an array of unit objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUnits(_ref7) {\n var unitId = _ref7.unitId,\n hospitalId = _ref7.hospitalId,\n name = _ref7.name,\n _ref7$ascendingUnitNa = _ref7.ascendingUnitNames,\n ascendingUnitNames = _ref7$ascendingUnitNa === void 0 ? false : _ref7$ascendingUnitNa;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {\n var collectionRef, constraints, q, querySnapshot, units;\n return _regeneratorRuntime().wrap(function _callee25$(_context25) {\n while (1) switch (_context25.prev = _context25.next) {\n case 0:\n _context25.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\n constraints = [];\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", unitId));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"hospitalId\", \"==\", hospitalId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"name\", ascendingUnitNames ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context25.next = 9;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 9:\n querySnapshot = _context25.sent;\n units = [];\n querySnapshot.forEach(function (doc) {\n units.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context25.abrupt(\"return\", units);\n case 15:\n _context25.prev = 15;\n _context25.t0 = _context25[\"catch\"](0);\n console.log(\"Error retrieving units by hospitalId: \", _context25.t0);\n throw _context25.t0;\n case 19:\n case \"end\":\n return _context25.stop();\n }\n }, _callee25, null, [[0, 15]]);\n }));\n}\nfunction getImprovementWorksForUser(userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {\n var q, querySnapshot, improvementWorks, _iterator, _step, _doc, improvementWorkId, improvementWorkDoc;\n return _regeneratorRuntime().wrap(function _callee26$(_context26) {\n while (1) switch (_context26.prev = _context26.next) {\n case 0:\n _context26.prev = 0;\n console.log(\"Getting improvementworks for user: \", userHsaId);\n // Query the userImprovementWork collection for relations involving this user\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(userImprovementWorkCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)('userHsaId', '==', userHsaId));\n _context26.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 5:\n querySnapshot = _context26.sent;\n // Fetch each related improvementWork document\n improvementWorks = [];\n _iterator = _createForOfIteratorHelper(querySnapshot.docs);\n _context26.prev = 8;\n _iterator.s();\n case 10:\n if ((_step = _iterator.n()).done) {\n _context26.next = 19;\n break;\n }\n _doc = _step.value;\n improvementWorkId = _doc.data().improvementWorkId;\n _context26.next = 15;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 15:\n improvementWorkDoc = _context26.sent;\n improvementWorks.push(improvementWorkDoc);\n case 17:\n _context26.next = 10;\n break;\n case 19:\n _context26.next = 24;\n break;\n case 21:\n _context26.prev = 21;\n _context26.t0 = _context26[\"catch\"](8);\n _iterator.e(_context26.t0);\n case 24:\n _context26.prev = 24;\n _iterator.f();\n return _context26.finish(24);\n case 27:\n return _context26.abrupt(\"return\", improvementWorks);\n case 30:\n _context26.prev = 30;\n _context26.t1 = _context26[\"catch\"](0);\n console.error(\"Error getting improvement works for user: \", _context26.t1);\n throw _context26.t1;\n case 34:\n case \"end\":\n return _context26.stop();\n }\n }, _callee26, null, [[0, 30], [8, 21, 24, 27]]);\n }));\n}\nfunction getUsersForImprovementWork(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {\n var q, querySnapshot, users, _iterator2, _step2, _doc2, userHsaId, userDoc;\n return _regeneratorRuntime().wrap(function _callee27$(_context27) {\n while (1) switch (_context27.prev = _context27.next) {\n case 0:\n _context27.prev = 0;\n console.log(\"Getting users for improvementwork: \", improvementWorkId);\n // Query the userImprovementWork collection for relations involving this improvementWork\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(userImprovementWorkCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)('improvementWorkId', '==', improvementWorkId));\n _context27.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 5:\n querySnapshot = _context27.sent;\n // Fetch each related user document\n users = [];\n _iterator2 = _createForOfIteratorHelper(querySnapshot.docs);\n _context27.prev = 8;\n _iterator2.s();\n case 10:\n if ((_step2 = _iterator2.n()).done) {\n _context27.next = 19;\n break;\n }\n _doc2 = _step2.value;\n userHsaId = _doc2.data().userHsaId;\n _context27.next = 15;\n return getObjectById(\"users\", userHsaId);\n case 15:\n userDoc = _context27.sent;\n users.push(userDoc);\n case 17:\n _context27.next = 10;\n break;\n case 19:\n _context27.next = 24;\n break;\n case 21:\n _context27.prev = 21;\n _context27.t0 = _context27[\"catch\"](8);\n _iterator2.e(_context27.t0);\n case 24:\n _context27.prev = 24;\n _iterator2.f();\n return _context27.finish(24);\n case 27:\n return _context27.abrupt(\"return\", users);\n case 30:\n _context27.prev = 30;\n _context27.t1 = _context27[\"catch\"](0);\n console.error(\"Error getting users for improvementWork: \", _context27.t1);\n throw _context27.t1;\n case 34:\n case \"end\":\n return _context27.stop();\n }\n }, _callee27, null, [[0, 30], [8, 21, 24, 27]]);\n }));\n}\n// export getters to be able to use in other files\n\n////////////////////////////////////DELETING/////////////////////////////////////////////\n// delete an instance of a type\nfunction deleteInstance(docType, docId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee28$(_context28) {\n while (1) switch (_context28.prev = _context28.next) {\n case 0:\n _context28.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context28.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(docRef);\n case 4:\n console.log(\"\".concat(docType, \" deleted successfully.\"));\n _context28.next = 11;\n break;\n case 7:\n _context28.prev = 7;\n _context28.t0 = _context28[\"catch\"](0);\n console.error(\"Error deleting \".concat(docType, \":\"), _context28.t0);\n throw _context28.t0;\n case 11:\n case \"end\":\n return _context28.stop();\n }\n }, _callee28, null, [[0, 7]]);\n }));\n}\n// delete all instances of a type\nfunction deleteAllDocumentsInCollection(collectionName) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {\n var _this = this;\n var collectionRef, snapshot, deletePromises;\n return _regeneratorRuntime().wrap(function _callee30$(_context30) {\n while (1) switch (_context30.prev = _context30.next) {\n case 0:\n _context30.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionName);\n _context30.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n snapshot = _context30.sent;\n // Delete all documents in the collection\n deletePromises = snapshot.docs.map(function (doc) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {\n return _regeneratorRuntime().wrap(function _callee29$(_context29) {\n while (1) switch (_context29.prev = _context29.next) {\n case 0:\n _context29.next = 2;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(doc.ref);\n case 2:\n case \"end\":\n return _context29.stop();\n }\n }, _callee29);\n }));\n });\n _context30.next = 8;\n return Promise.all(deletePromises);\n case 8:\n console.log(\"All documents in the \".concat(collectionName, \" collection deleted successfully.\"));\n _context30.next = 15;\n break;\n case 11:\n _context30.prev = 11;\n _context30.t0 = _context30[\"catch\"](0);\n console.error(\"Error deleting all documents in \".concat(collectionName, \":\"), _context30.t0);\n throw _context30.t0;\n case 15:\n case \"end\":\n return _context30.stop();\n }\n }, _callee30, null, [[0, 11]]);\n }));\n}\n////////////////////////////////////UPDATING/////////////////////////////////////////////\n// update a field in an instance\nfunction updateInstance(docType, docId, updates) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee31$(_context31) {\n while (1) switch (_context31.prev = _context31.next) {\n case 0:\n _context31.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context31.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(docRef, updates);\n case 4:\n console.log(\"\".concat(docType, \" updated successfully.\"));\n _context31.next = 11;\n break;\n case 7:\n _context31.prev = 7;\n _context31.t0 = _context31[\"catch\"](0);\n console.error(\"Error updating \".concat(docType, \":\"), _context31.t0);\n throw _context31.t0;\n case 11:\n case \"end\":\n return _context31.stop();\n }\n }, _callee31, null, [[0, 7]]);\n }));\n}\n// changes the ongoing status of an improvement work. if ongoing it is paused, if if paused onging.\n// user must be a manager\nfunction startOrPauseImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee32$(_context32) {\n while (1) switch (_context32.prev = _context32.next) {\n case 0:\n _context32.prev = 0;\n _context32.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context32.sent;\n _context32.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context32.sent;\n if (!(!user || !user.manager)) {\n _context32.next = 11;\n break;\n }\n throw new Error(\"User can't change improvementWork status\");\n case 11:\n if (!improvementWork) {\n _context32.next = 18;\n break;\n }\n update = {\n ongoing: !improvementWork.ongoing\n };\n _context32.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n _context32.next = 19;\n break;\n case 18:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n case 19:\n _context32.next = 25;\n break;\n case 21:\n _context32.prev = 21;\n _context32.t0 = _context32[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context32.t0);\n throw _context32.t0;\n case 25:\n case \"end\":\n return _context32.stop();\n }\n }, _callee32, null, [[0, 21]]);\n }));\n}\nfunction changePatientRiskLevel(userId, improvementWorkId, patientRiskLevel) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee33$(_context33) {\n while (1) switch (_context33.prev = _context33.next) {\n case 0:\n _context33.prev = 0;\n _context33.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context33.sent;\n _context33.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context33.sent;\n if (!(!user || !user.manager)) {\n _context33.next = 11;\n break;\n }\n throw new Error(\"User can't change patientRiskLevel in improvement work\");\n case 11:\n if (!improvementWork) {\n _context33.next = 18;\n break;\n }\n update = {\n patientRiskLevel: patientRiskLevel\n };\n _context33.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n _context33.next = 19;\n break;\n case 18:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n case 19:\n _context33.next = 25;\n break;\n case 21:\n _context33.prev = 21;\n _context33.t0 = _context33[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context33.t0);\n throw _context33.t0;\n case 25:\n case \"end\":\n return _context33.stop();\n }\n }, _callee33, null, [[0, 21]]);\n }));\n}\n// finalizes the improvement work. ongoing is set to false.\n// user must be a manager\nfunction finalizeImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {\n var user, update;\n return _regeneratorRuntime().wrap(function _callee34$(_context34) {\n while (1) switch (_context34.prev = _context34.next) {\n case 0:\n _context34.prev = 0;\n _context34.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context34.sent;\n if (!(!user || !user.manager)) {\n _context34.next = 8;\n break;\n }\n throw new Error(\"User can't finalize improvementWork status\");\n case 8:\n update = {\n completed: true,\n ongoing: false\n };\n _context34.next = 11;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 11:\n _context34.next = 16;\n break;\n case 13:\n _context34.prev = 13;\n _context34.t0 = _context34[\"catch\"](0);\n console.log(_context34.t0);\n case 16:\n case \"end\":\n return _context34.stop();\n }\n }, _callee34, null, [[0, 13]]);\n }));\n}\n\n//////////////////////////////// for later sprint\n//function add_upvotes\n//function add_notes\n//function add_intrested_users\n\n//# sourceURL=webpack://c3/./client/Database/database.js?"); /***/ }), @@ -206,7 +206,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \***************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n/*\n//SAMPLES, TO BE REPLACED BY DB\nconst sampleUnits: Unit[] = [\n {\n ID: \"1\",\n hospital_ID: \"1\",\n name: \"Akuten\"\n },\n\n {\n ID: \"2\",\n hospital_ID: \"1\",\n name: \"BB\"\n },\n {\n ID: \"3\",\n hospital_ID: \"1\",\n name: \"Onkolog\"\n },\n\n\n];\n\nconst unitNameLookup: Record<string, string> = {};\nsampleUnits.forEach((unit) => {\n unitNameLookup[unit.ID] = unit.name;\n});\n*/\n/*\nconst sampleProjects: Project[] = [\n {\n id: \"1\",\n name: \"Birthing of a Child\",\n current_stage: \"In Progress\",\n content: \"This is project 1.\",\n unitId: \"2\",\n dateStarted: new Date(\"2023-01-15\"),\n },\n {\n id: \"2\",\n name: \"How to save a life\",\n current_stage: \"Completed\",\n content: \"This is project 2.\",\n unitId: \"1\",\n dateStarted: new Date(\"2023-02-20\"),\n },\n {\n id: \"3\",\n name: \"BB tutorial\",\n current_stage: \"Completed\",\n content: \"This is project 3.\",\n unitId: \"2\",\n dateStarted: new Date(\"2023-06-05\"),\n },\n {\n id: \"4\",\n name: \"Cancerbehandling 101\",\n current_stage: \"Completed\",\n content: \"This is project 4.\",\n unitId: \"3\",\n dateStarted: new Date(\"2023-10-24\"),\n },\n];\n\n\n\nsampleProjects.sort((a,b) => b.dateStarted.getTime() - a.dateStarted.getTime()); //SORTING THE PROJECTS FROM NEWEST TO OLDEST\n*/\nfunction getCompletedProjects() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var CompletedProjects;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({\n completed: true\n });\n case 2:\n CompletedProjects = _context.sent;\n return _context.abrupt(\"return\", CompletedProjects);\n case 4:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\n//let completedImprovmentWorks = await getImprovementWorks({});\n//TO MAKE DATE APPEAR NICELY\nfunction formatDate(timeStamp) {\n var date = timeStamp.toDate();\n var day = String(date.getDate()).toString();\n var month = String(date.getMonth() + 1).toString(); // Adding 1 because months are zero-based\n var year = String(date.getFullYear()).toString();\n if (parseInt(month, 10) < 10) {\n return \"\".concat(day, \"/0\").concat(month, \"/\").concat(year);\n }\n return \"\".concat(day, \"/\").concat(month, \"/\").concat(year);\n}\n//TO CREATE GRID HTML ELEMENT OF PROJECTS \nfunction createGridRow(project) {\n var row = document.createElement(\"div\");\n row.className = \"grid-row\";\n var unitName = project.unitId || 'Unknown Unit';\n row.innerHTML = \"\\n <div class=\\\"column\\\">\".concat(project.name, \"</div>\\n <div class=\\\"column\\\">\").concat(unitName, \"</div>\\n <div class=\\\"column\\\">\").concat(formatDate(project.dateStarted), \"</div>\\n <div class=\\\"column\\\">Link-placeholder</div>\\n \");\n return row;\n}\n//TO ADD GRID ELEMENTS TO GRID-CONTAINER\nfunction addGridRows() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var gridContainer, projects;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n gridContainer = document.getElementById(\"grid-container\");\n _context2.next = 3;\n return getCompletedProjects();\n case 3:\n projects = _context2.sent;\n console.log(projects);\n projects.forEach(function (project) {\n var row = createGridRow(project);\n if (gridContainer != null) {\n gridContainer.appendChild(row);\n }\n });\n /*\n projects.forEach((project) => {\n const row = createGridRow(project);\n if(gridContainer != null) {\n gridContainer.appendChild(row);\n }\n });\n */\n case 6:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nvar departmentDropdown = document.getElementById(\"departmentDropdown\"); //INSTANCING THE FILTER HTLM ELEMENTS\nvar dateDropdown = document.getElementById(\"dateDropdown\");\nvar searchInput = document.getElementById(\"searchInput\");\nvar selectedDepartment = \"all\";\nvar selectedDateFilter = \"newest\";\nvar searchQuery;\n//TO MAKE DEPARTMENTDROPDOWN CONTAIN ALL THE UNITS FROM DB\n/*\nasync function fillDropdown() {\nsampleUnits.forEach((unit) => {\n const option = document.createElement(\"option\");\n option.value = unit.ID;\n option.textContent = unit.name;\n //departmentDropdown.appendChild(option);\n});\n}\n*/\n/*\n//FILTERING BY DEPARTMENT AND DATE\nfunction filterProjects(selectedDepartment: string, selectedDateFilter: string, searchQuery: String) {\n\n if(selectedDateFilter == \"oldest\") { //FILTER BY DATE\n sampleProjects.sort((a,b) => a.dateStarted.getTime() - b.dateStarted.getTime());\n }\n else {\n sampleProjects.sort((a,b) => b.dateStarted.getTime() - a.dateStarted.getTime());\n }\n\n let filteredProjects = sampleProjects; //FILTER BY DEPARTMENT\n if (selectedDepartment !== \"all\") {\n filteredProjects = filteredProjects.filter((project) => project.unitId === selectedDepartment);\n }\n\n if(searchQuery) { //SEARCH\n filteredProjects = filteredProjects.filter((project) =>\n project.name.toLowerCase().indexOf(searchQuery.toLowerCase()) !== -1\n );\n }\n\n if(gridContainer != null) { //PRINTING TO THE GRID\n gridContainer.innerHTML = ''; //CLEAR THE GRID\n filteredProjects.forEach((project) => {\n const row = createGridRow(project);\n if (gridContainer) {\n gridContainer.appendChild(row);\n }\n });\n}\n\n}\n*/\n//EVENT-LISTENERERS\n/*\ndepartmentDropdown.addEventListener(\"change\", () => {\n selectedDepartment = departmentDropdown.value;\n\n filterProjects(selectedDepartment, selectedDateFilter, searchQuery);\n});\n\ndateDropdown.addEventListener(\"change\", () => {\n selectedDateFilter = dateDropdown.value;\n filterProjects(selectedDepartment,selectedDateFilter, searchQuery);\n})\n\nsearchInput.addEventListener(\"input\", () => {\n searchQuery = searchInput.value.trim();\n filterProjects(selectedDepartment, selectedDateFilter, searchQuery);\n})\n\n*/\nfunction loadPage() {\n var container = document.querySelector('#container-fluid');\n if (!container) return; // Stop if the container isn't found\n fetch('Knowledgebank/completedProjects.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.maincontainer');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n //fillDropdown();\n addGridRows();\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n}\n\n//# sourceURL=webpack://c3/./client/KnowledgeBank/completedProjects.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\nfunction getCompletedProjects() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var CompletedProjects;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({\n completed: true\n });\n case 2:\n CompletedProjects = _context.sent;\n return _context.abrupt(\"return\", CompletedProjects);\n case 4:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\n//TO MAKE DATE APPEAR NICELY\nfunction formatDate(timeStamp) {\n var date = timeStamp.toDate();\n var day = String(date.getDate()).toString();\n var month = String(date.getMonth() + 1).toString(); // Adding 1 because months are zero-based\n var year = String(date.getFullYear()).toString();\n if (parseInt(month, 10) < 10) {\n return \"\".concat(day, \"/0\").concat(month, \"/\").concat(year);\n }\n return \"\".concat(day, \"/\").concat(month, \"/\").concat(year);\n}\n//TO CREATE GRID HTML ELEMENT OF PROJECTS \nfunction createGridRow(project) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var unit, row, unitName;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", project.unitId);\n case 2:\n unit = _context2.sent;\n row = document.createElement(\"div\");\n row.className = \"grid-row\";\n unitName = \"Unspecified Unit\";\n if (unit) {\n unitName = unit.name;\n }\n row.innerHTML = \"\\n <div class=\\\"column\\\">\".concat(project.name, \"</div>\\n <div class=\\\"column\\\">\").concat(unitName, \"</div>\\n <div class=\\\"column\\\">\").concat(formatDate(project.dateStarted), \"</div>\\n <div class=\\\"column\\\">Link-placeholder</div>\\n \");\n return _context2.abrupt(\"return\", row);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\n//TO ADD GRID ELEMENTS TO GRID-CONTAINER\nfunction addGridRows() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var _this = this;\n var gridContainer, projects;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n gridContainer = document.getElementById(\"grid-container\");\n _context4.next = 3;\n return getCompletedProjects();\n case 3:\n projects = _context4.sent;\n console.log(projects);\n projects.forEach(function (project) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var row;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n row = createGridRow(project);\n if (!(gridContainer != null)) {\n _context3.next = 7;\n break;\n }\n _context3.t0 = gridContainer;\n _context3.next = 5;\n return row;\n case 5:\n _context3.t1 = _context3.sent;\n _context3.t0.appendChild.call(_context3.t0, _context3.t1);\n case 7:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n });\n case 6:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n}\nfunction fillDropdown() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var departmentDropdown, units;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n departmentDropdown = document.getElementById(\"departmentDropdown\");\n _context5.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({});\n case 3:\n units = _context5.sent;\n console.log(units);\n units.forEach(function (unit) {\n var option = document.createElement(\"option\");\n option.value = unit.Id;\n option.textContent = unit.name;\n departmentDropdown.appendChild(option);\n });\n case 6:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\n//FILTERING BY DEPARTMENT AND DATE\nfunction filterProjects(selectedDepartment, selectedDateFilter, searchQuery) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var _this2 = this;\n var projects, filteredProjects, gridContainer;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.next = 2;\n return getCompletedProjects();\n case 2:\n projects = _context7.sent;\n if (selectedDateFilter == \"oldest\") {\n //FILTER BY DATE\n projects.sort(function (a, b) {\n return a.dateStarted.getTime() - b.dateStarted.getTime();\n });\n } else {\n projects.sort(function (a, b) {\n return b.dateStarted.getTime() - a.dateStarted.getTime();\n });\n }\n filteredProjects = projects; //FILTER BY DEPARTMENT\n if (selectedDepartment !== \"all\") {\n filteredProjects = filteredProjects.filter(function (project) {\n return project.unitId === selectedDepartment;\n });\n }\n if (searchQuery) {\n //SEARCH\n filteredProjects = filteredProjects.filter(function (project) {\n return project.name.toLowerCase().indexOf(searchQuery.toLowerCase()) !== -1;\n });\n }\n gridContainer = document.getElementById(\"grid-container\");\n if (gridContainer != null) {\n //PRINTING TO THE GRID\n gridContainer.innerHTML = ''; //CLEAR THE GRID\n filteredProjects.forEach(function (project) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var row;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n row = createGridRow(project);\n if (!gridContainer) {\n _context6.next = 7;\n break;\n }\n _context6.t0 = gridContainer;\n _context6.next = 5;\n return row;\n case 5:\n _context6.t1 = _context6.sent;\n _context6.t0.appendChild.call(_context6.t0, _context6.t1);\n case 7:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n });\n }\n case 9:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\n//EVENT-LISTENERERS\n/*\ndepartmentDropdown.addEventListener(\"change\", () => {\n selectedDepartment = departmentDropdown.value;\n\n filterProjects(selectedDepartment, selectedDateFilter, searchQuery);\n});\n/*\ndateDropdown.addEventListener(\"change\", () => {\n selectedDateFilter = dateDropdown.value;\n filterProjects(selectedDepartment,selectedDateFilter, searchQuery);\n})\n\nsearchInput.addEventListener(\"input\", () => {\n searchQuery = searchInput.value.trim();\n filterProjects(selectedDepartment, selectedDateFilter, searchQuery);\n})\n\n*/\nfunction loadPage() {\n var container = document.querySelector('#container-fluid');\n if (!container) return; // Stop if the container isn't found\n fetch('Knowledgebank/completedProjects.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.maincontainer');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n var dateDropdown = document.getElementById(\"dateDropdown\");\n var searchInput = document.getElementById(\"searchInput\");\n var selectedDepartment = \"all\";\n var selectedDateFilter = \"newest\";\n var searchQuery;\n fillDropdown();\n addGridRows();\n console.log(getCompletedProjects());\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n}\n\n//# sourceURL=webpack://c3/./client/KnowledgeBank/completedProjects.js?"); /***/ }), @@ -236,7 +236,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \*******************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ submitHandler: () => (/* binding */ submitHandler)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n\n\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\nfunction loadFilter() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var selectHospitalHTML, selectUnitHTML, allHospitals, allUnits;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n selectHospitalHTML = $('#selectHospital'); // loads the select type from html\n selectUnitHTML = $('#selectDepartment'); // loads the select type from html\n _context.next = 4;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({});\n case 4:\n allHospitals = _context.sent;\n _context.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({});\n case 7:\n allUnits = _context.sent;\n //here you can put constraints\n console.log(allHospitals);\n console.log(allUnits);\n allHospitals.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(user.name);\n selectHospitalHTML.append(optionElement);\n });\n allUnits.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(user.name);\n selectUnitHTML.append(optionElement);\n });\n case 12:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction populateOptions(object, selectElement) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var options;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObject)(object);\n case 2:\n options = _context2.sent;\n options.forEach(function (option) {\n var optionElement = document.createElement(\"option\");\n optionElement.value = option.id; // Set the value\n optionElement.text = option.name; // Set the text\n optionElement.classList.add(\"option\"); // Add the 'option' class\n selectElement.appendChild(optionElement);\n });\n case 4:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\n// Define the submitHandler function\nfunction submitHandler() {\n var selectDepartment = document.getElementById(\"selectHospital\");\n var selectUnit = document.getElementById(\"selectDepartment\");\n //populateOptions(\"hospital\", selectDepartment);\n //populateOptions(\"unit\", selectUnit);\n // JavaScript to get the inputted text when the form is submitted\n var inputBoxFormNameInput = document.getElementById(\"inputBoxFormNameInput\");\n var inputBoxFormName = document.getElementById(\"inputBoxFormName\");\n var inputBoxFormAreaInput = document.getElementById(\"inputBoxFormAreaInput\");\n var inputBoxFormArea = document.getElementById(\"inputBoxFormArea\");\n var inputBoxFormContentInput = document.getElementById(\"inputBoxFormContentInput\");\n var inputBoxFormContent = document.getElementById(\"inputBoxFormContent\");\n var inputBoxFormPurposeInput = document.getElementById(\"inputBoxFormPurposeInput\");\n var inputBoxFormPurpose = document.getElementById(\"inputBoxFormPurpose\");\n var inputBoxFormMeasureInput = document.getElementById(\"inputBoxFormMeasureInput\");\n var inputBoxFormMeasure = document.getElementById(\"inputBoxFormMeasure\");\n var inputBoxFormIdeasInput = document.getElementById(\"inputBoxFormIdeasInput\");\n var inputBoxFormIdeas = document.getElementById(\"inputBoxFormIdeas\");\n var submitButton = document.getElementById(\"suggestionButton\");\n inputBoxFormName.addEventListener(\"submit\", function (e) {\n e.preventDefault();\n });\n inputBoxFormArea.addEventListener(\"submit\", function (e) {\n e.preventDefault();\n });\n inputBoxFormContent.addEventListener(\"submit\", function (e) {\n e.preventDefault();\n });\n inputBoxFormPurpose.addEventListener(\"submit\", function (e) {\n e.preventDefault();\n });\n inputBoxFormMeasure.addEventListener(\"submit\", function (e) {\n e.preventDefault();\n });\n inputBoxFormIdeas.addEventListener(\"submit\", function (e) {\n e.preventDefault();\n });\n // Get values from each form and do something with them\n var nameInput = inputBoxFormNameInput.value;\n var areaInput = inputBoxFormAreaInput.value;\n var contentInput = inputBoxFormContentInput.value;\n var purposeInput = inputBoxFormPurposeInput.value;\n var measureInput = inputBoxFormMeasureInput.value;\n var ideasInput = inputBoxFormIdeasInput.value;\n try {\n // Call the createSuggestion function with the obtained values\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.createSuggestion)(\"<Header>\", \"<Department>\", nameInput, areaInput, contentInput, purposeInput, measureInput, ideasInput, selectUnit.value, selectDepartment.value, true);\n alert(\"created successfully\");\n } catch (_a) {\n alert(\"Error creating\");\n }\n}\nfunction loadPage() {\n var container = document.querySelector('#container-fluid');\n if (!container) return; // Stop if the container isn't found\n var scriptElement = document.createElement('script');\n scriptElement.src = '../dist/makeSuggestion.bundle.js';\n container.appendChild(scriptElement);\n var linkElement1 = document.createElement('link');\n linkElement1.rel = 'stylesheet';\n linkElement1.href = 'Make_Suggestion_Code/makeSuggestion.css';\n document.head.appendChild(linkElement1);\n var linkElement2 = document.createElement('link');\n linkElement2.rel = 'stylesheet';\n linkElement2.href = 'Activity_card_code/activitity_card.css';\n document.head.appendChild(linkElement2);\n fetch('Make_Suggestion_Code/makeSuggestion.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n var suggestionPage = tempContainer.querySelector('#suggestionPage');\n if (suggestionPage) {\n container.insertBefore(suggestionPage, container.firstChild);\n var submitButton = document.getElementById('suggestionButton');\n if (submitButton) {\n submitButton.addEventListener('click', submitHandler);\n } else {\n console.error(\"Error: 'suggestionButton' not found\");\n }\n loadFilter();\n }\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n}\n\n//# sourceURL=webpack://c3/./client/Make_Suggestion_Code/makeSuggestion.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ submitHandler: () => (/* binding */ submitHandler)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n\n\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\nfunction loadFilter() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var selectHospitalHTML, selectUnitHTML, allHospitals, allUnits;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n selectHospitalHTML = $('#selectHospital'); // loads the select type from html\n selectUnitHTML = $('#selectDepartment'); // loads the select type from html\n _context.next = 4;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({});\n case 4:\n allHospitals = _context.sent;\n _context.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({});\n case 7:\n allUnits = _context.sent;\n //here you can put constraints\n console.log(allHospitals);\n console.log(allUnits);\n allHospitals.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(user.name);\n selectHospitalHTML.append(optionElement);\n });\n allUnits.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(user.name);\n selectUnitHTML.append(optionElement);\n });\n case 12:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction populateOptions(object, selectElement) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var options;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObject)(object);\n case 2:\n options = _context2.sent;\n options.forEach(function (option) {\n var optionElement = document.createElement(\"option\");\n optionElement.value = option.id; // Set the value\n optionElement.text = option.name; // Set the text\n optionElement.classList.add(\"option\"); // Add the 'option' class\n selectElement.appendChild(optionElement);\n });\n case 4:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\n// Define the submitHandler function\nfunction submitHandler() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var selectDepartment, selectUnit, inputBoxFormNameInput, inputBoxFormName, inputBoxFormAreaInput, inputBoxFormArea, inputBoxFormContentInput, inputBoxFormContent, inputBoxFormPurposeInput, inputBoxFormPurpose, inputBoxFormMeasureInput, inputBoxFormMeasure, inputBoxFormIdeasInput, inputBoxFormIdeas, submitButton, nameInput, areaInput, contentInput, purposeInput, measureInput, ideasInput, tmp, uid, user;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n selectDepartment = document.getElementById(\"selectHospital\");\n selectUnit = document.getElementById(\"selectDepartment\"); //populateOptions(\"hospital\", selectDepartment);\n //populateOptions(\"unit\", selectUnit);\n // JavaScript to get the inputted text when the form is submitted\n inputBoxFormNameInput = document.getElementById(\"inputBoxFormNameInput\");\n inputBoxFormName = document.getElementById(\"inputBoxFormName\");\n inputBoxFormAreaInput = document.getElementById(\"inputBoxFormAreaInput\");\n inputBoxFormArea = document.getElementById(\"inputBoxFormArea\");\n inputBoxFormContentInput = document.getElementById(\"inputBoxFormContentInput\");\n inputBoxFormContent = document.getElementById(\"inputBoxFormContent\");\n inputBoxFormPurposeInput = document.getElementById(\"inputBoxFormPurposeInput\");\n inputBoxFormPurpose = document.getElementById(\"inputBoxFormPurpose\");\n inputBoxFormMeasureInput = document.getElementById(\"inputBoxFormMeasureInput\");\n inputBoxFormMeasure = document.getElementById(\"inputBoxFormMeasure\");\n inputBoxFormIdeasInput = document.getElementById(\"inputBoxFormIdeasInput\");\n inputBoxFormIdeas = document.getElementById(\"inputBoxFormIdeas\");\n submitButton = document.getElementById(\"suggestionButton\");\n inputBoxFormName.addEventListener(\"submit\", function (e) {\n e.preventDefault();\n });\n inputBoxFormArea.addEventListener(\"submit\", function (e) {\n e.preventDefault();\n });\n inputBoxFormContent.addEventListener(\"submit\", function (e) {\n e.preventDefault();\n });\n inputBoxFormPurpose.addEventListener(\"submit\", function (e) {\n e.preventDefault();\n });\n inputBoxFormMeasure.addEventListener(\"submit\", function (e) {\n e.preventDefault();\n });\n inputBoxFormIdeas.addEventListener(\"submit\", function (e) {\n e.preventDefault();\n });\n // Get values from each form and do something with them\n nameInput = inputBoxFormNameInput.value;\n areaInput = inputBoxFormAreaInput.value;\n contentInput = inputBoxFormContentInput.value;\n purposeInput = inputBoxFormPurposeInput.value;\n measureInput = inputBoxFormMeasureInput.value;\n ideasInput = inputBoxFormIdeasInput.value;\n tmp = localStorage.getItem('user');\n if (tmp) {\n _context3.next = 31;\n break;\n }\n console.log(\"there is not an user in localStorage\");\n return _context3.abrupt(\"return\");\n case 31:\n uid = JSON.parse(tmp)[0].uid;\n _context3.next = 34;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({\n uid: uid\n });\n case 34:\n user = _context3.sent;\n console.log(user);\n console.log(user[0].uid);\n console.log(user[0].id);\n console.log(user[0].creatorHsaId);\n try {\n if (user[0].id) {\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.createSuggestion)(null, user[0].id,\n //The unique identifyer for the user, not the idea\n nameInput, areaInput, contentInput, purposeInput, measureInput, ideasInput, selectUnit.value, selectDepartment.value, true);\n }\n // Call the createSuggestion function with the obtained values \n alert(\"created successfully\");\n } catch (_a) {\n alert(\"Error creating\");\n }\n case 40:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction loadPage() {\n var container = document.querySelector('#container-fluid');\n if (!container) return; // Stop if the container isn't found\n var scriptElement = document.createElement('script');\n scriptElement.src = '../dist/makeSuggestion.bundle.js';\n container.appendChild(scriptElement);\n var linkElement1 = document.createElement('link');\n linkElement1.rel = 'stylesheet';\n linkElement1.href = 'Make_Suggestion_Code/makeSuggestion.css';\n document.head.appendChild(linkElement1);\n var linkElement2 = document.createElement('link');\n linkElement2.rel = 'stylesheet';\n linkElement2.href = 'Activity_card_code/activitity_card.css';\n document.head.appendChild(linkElement2);\n fetch('Make_Suggestion_Code/makeSuggestion.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n var suggestionPage = tempContainer.querySelector('#suggestionPage');\n if (suggestionPage) {\n container.insertBefore(suggestionPage, container.firstChild);\n var submitButton = document.getElementById('suggestionButton');\n if (submitButton) {\n submitButton.addEventListener('click', submitHandler);\n } else {\n console.error(\"Error: 'suggestionButton' not found\");\n }\n loadFilter();\n }\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n}\n\n//# sourceURL=webpack://c3/./client/Make_Suggestion_Code/makeSuggestion.js?"); /***/ }), @@ -246,7 +246,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadCurrentProjects: () => (/* binding */ loadCurrentProjects),\n/* harmony export */ loadProjectPageA: () => (/* binding */ loadProjectPageA),\n/* harmony export */ loadProjectPageG: () => (/* binding */ loadProjectPageG),\n/* harmony export */ loadProjectPageP: () => (/* binding */ loadProjectPageP),\n/* harmony export */ loadProjectPageS: () => (/* binding */ loadProjectPageS)\n/* harmony export */ });\n/* harmony import */ var _currentProjects_currentProjects_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../currentProjects/currentProjects.js */ \"./client/currentProjects/currentProjects.js\");\n/* harmony import */ var _Make_Suggestion_Code_makeSuggestion_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Make_Suggestion_Code/makeSuggestion.js */ \"./client/Make_Suggestion_Code/makeSuggestion.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _KnowledgeBank_knowledgeBank_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../KnowledgeBank/knowledgeBank.js */ \"./client/KnowledgeBank/knowledgeBank.js\");\n/* harmony import */ var _KnowledgeBank_completedProjects_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../KnowledgeBank/completedProjects.js */ \"./client/KnowledgeBank/completedProjects.js\");\n/* harmony import */ var _KnowledgeBank_Nolans_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../KnowledgeBank/Nolans.js */ \"./client/KnowledgeBank/Nolans.js\");\n/* harmony import */ var _KnowledgeBank_genImprovMethods_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../KnowledgeBank/genImprovMethods.js */ \"./client/KnowledgeBank/genImprovMethods.js\");\n/* harmony import */ var _KnowledgeBank_ContactOrganization_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../KnowledgeBank/ContactOrganization.js */ \"./client/KnowledgeBank/ContactOrganization.js\");\n/* harmony import */ var _KnowledgeBank_Nolans1_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../KnowledgeBank/Nolans1.js */ \"./client/KnowledgeBank/Nolans1.js\");\n/* harmony import */ var _KnowledgeBank_Nolans2_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../KnowledgeBank/Nolans2.js */ \"./client/KnowledgeBank/Nolans2.js\");\n/* harmony import */ var _KnowledgeBank_Nolans3_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../KnowledgeBank/Nolans3.js */ \"./client/KnowledgeBank/Nolans3.js\");\n/* harmony import */ var _KnowledgeBank_Nolans4_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../KnowledgeBank/Nolans4.js */ \"./client/KnowledgeBank/Nolans4.js\");\n/* harmony import */ var _KnowledgeBank_Nolans5_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../KnowledgeBank/Nolans5.js */ \"./client/KnowledgeBank/Nolans5.js\");\n/* harmony import */ var _KnowledgeBank_Nolans6_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../KnowledgeBank/Nolans6.js */ \"./client/KnowledgeBank/Nolans6.js\");\n/* harmony import */ var _KnowledgeBank_Nolans7_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../KnowledgeBank/Nolans7.js */ \"./client/KnowledgeBank/Nolans7.js\");\n/* harmony import */ var _homePage_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../homePage.js */ \"./client/homePage.js\");\n/* harmony import */ var _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../projectPage/projectPageP.js */ \"./client/projectPage/projectPageP.js\");\n/* harmony import */ var _projectPage_projectPageG_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../projectPage/projectPageG.js */ \"./client/projectPage/projectPageG.js\");\n/* harmony import */ var _projectPage_projectPageS_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../projectPage/projectPageS.js */ \"./client/projectPage/projectPageS.js\");\n/* harmony import */ var _projectPage_projectPageA_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../projectPage/projectPageA.js */ \"./client/projectPage/projectPageA.js\");\n/* harmony import */ var _login_login_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../login/login.js */ \"./client/login/login.js\");\n/* harmony import */ var _login_register_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../login/register.js */ \"./client/login/register.js\");\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../initiateForbattringsarbete/initiateIdea.js */ \"./client/initiateForbattringsarbete/initiateIdea.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n//loading elements\nvar currentProjectButton = document.getElementById(\"currentProjects\");\nvar ideaBankButton = document.getElementById(\"ideaBankView\");\nvar knowledgeBankButton = document.getElementById(\"knowledgeBankView\");\nvar logOutButton = document.getElementById(\"log-out-button\");\nvar myProfileButton = document.getElementById(\"profileView\");\nvar makeSuggestionButton = document.getElementById(\"suggestionView\");\nvar settingsButton = document.getElementById(\"settingsView\");\nvar supportButton = document.getElementById(\"supportView\");\n//Event-listener checks, to make sure they only load once\nvar NolansEventListenersAdded = false;\nvar knowledgeBankListenersAdded = false;\nvar currentProjectsListenersAdded = false;\n//Loads loginPage as first view\nloadLoginPage();\nfunction setTitle(text) {\n var title = document.getElementById(\"titleCurrentPage\");\n if (title) {\n title.textContent = text;\n }\n}\n//Function to hide HTML elements\nfunction hideElement(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"none\";\n }\n}\nfunction removeDisplayStyle(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"\";\n }\n}\nfunction setFlexDisplay(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"flex\";\n }\n}\nfunction loadRegisterPage() {\n clearContent();\n _login_register_js__WEBPACK_IMPORTED_MODULE_21__.loadPage();\n var eventListener = function eventListener(event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var target;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n target = event.target;\n if (!(target.id === \"register-button\")) {\n _context.next = 8;\n break;\n }\n _context.next = 4;\n return _login_register_js__WEBPACK_IMPORTED_MODULE_21__.handleRegister();\n case 4:\n if (!_context.sent) {\n _context.next = 8;\n break;\n }\n hideElement(\"register-container\");\n loggedIn();\n document.removeEventListener(\"click\", eventListener);\n case 8:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n };\n document.addEventListener(\"click\", eventListener);\n}\nfunction loadLoginPage() {\n clearContent();\n _login_login_js__WEBPACK_IMPORTED_MODULE_20__.loadPage();\n var eventListener = function eventListener(event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var target;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n target = event.target;\n if (!(target.id === \"button-login\")) {\n _context2.next = 7;\n break;\n }\n _context2.next = 4;\n return _login_login_js__WEBPACK_IMPORTED_MODULE_20__.handleLogin();\n case 4:\n if (!_context2.sent) {\n _context2.next = 7;\n break;\n }\n hideElement(\"login-container\");\n loggedIn();\n case 7:\n if (target.id === \"button-register\") {\n loadRegisterPage();\n hideElement(\"login-container\");\n setFlexDisplay(\"register-container\");\n }\n case 8:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n };\n document.addEventListener(\"click\", eventListener);\n}\n//help function after logging in successfully \nfunction loggedIn() {\n setFlexDisplay(\"main\");\n loadMyProfile();\n}\nfunction logOut() {\n hideElement(\"main\");\n removeDisplayStyle(\"login-container\");\n console.log(\"du klickade på logga ut knappen\");\n _Database_authentication_js__WEBPACK_IMPORTED_MODULE_22__.logout();\n}\nfunction clearContent() {\n var container = $(\"#container-fluid\");\n container.empty();\n var clonedContainer = container.clone();\n container.replaceWith(clonedContainer);\n}\nfunction loadCurrentProjects() {\n clearContent();\n setTitle(\"Pågående förbättringsarbeten\");\n _currentProjects_currentProjects_js__WEBPACK_IMPORTED_MODULE_0__.loadPage(currentProjectsListenersAdded);\n currentProjectsListenersAdded = true;\n}\nfunction loadSuggestionPage() {\n clearContent();\n setTitle(\"Ge förslag\");\n _Make_Suggestion_Code_makeSuggestion_js__WEBPACK_IMPORTED_MODULE_1__.loadPage();\n}\nfunction loadInitiatePage(id) {\n clearContent();\n setTitle(\"Gör ditt förslag till ett förbättringsarbete!\");\n _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_23__.loadPage(id);\n}\nfunction loadIdeaBank() {\n clearContent();\n setTitle(\"Alla Idéer\");\n _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadPage();\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n //adds an event listener for the initiate page \n if (target && target.className === \"initiateProjectButton\") {\n var cardId = \"suggestion\" + target.id.replace(\"initiateProjectFromCard\", \"\");\n loadInitiatePage(cardId);\n }\n });\n}\nfunction loadKnowledgeBank() {\n clearContent();\n setTitle(\"Kunskapsbanken\");\n _KnowledgeBank_knowledgeBank_js__WEBPACK_IMPORTED_MODULE_3__.loadPage();\n //Loading Page-specific eventlistneres\n if (!knowledgeBankListenersAdded) {\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"buttons-kunskapsbanken-button1\") {\n loadNolansMain();\n } else if (target.id === \"buttons-kunskapsbanken-button2\") {\n loadGenImprovMethods();\n } else if (target.id === \"buttons-kunskapsbanken-button3\") {\n loadCompletedProjects();\n } else if (target.id === \"buttons-kunskapsbanken-button4\") {\n loadContactOrganizations();\n } else if (target.id === \"knowledge-backbutton\") {\n loadKnowledgeBank();\n }\n });\n knowledgeBankListenersAdded = true;\n }\n}\nfunction loadGenImprovMethods() {\n clearContent();\n setTitle(\"Generella förbättringsmetoder\");\n _KnowledgeBank_genImprovMethods_js__WEBPACK_IMPORTED_MODULE_6__.loadPage();\n}\nfunction loadContactOrganizations() {\n clearContent();\n setTitle(\"Kontaktinformation\");\n _KnowledgeBank_ContactOrganization_js__WEBPACK_IMPORTED_MODULE_7__.loadPage();\n}\nfunction loadNolansMain() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans_js__WEBPACK_IMPORTED_MODULE_5__.loadPage();\n if (!NolansEventListenersAdded) {\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"SattaMalSyfte\") {\n clearContent();\n loadNolans1();\n } else if (target.id === \"MataFoljaUpp\") {\n clearContent();\n loadNolans2();\n } else if (target.id === \"SamlaIdeer\") {\n clearContent();\n loadNolans3();\n } else if (target.id === \"nolansBackButton\") {\n clearContent();\n loadKnowledgeBank();\n } else if (target.id === \"nolans4\") {\n clearContent();\n loadNolans4();\n } else if (target.id === \"nolans5\") {\n clearContent();\n loadNolans5();\n } else if (target.id === \"nolans6\") {\n clearContent();\n loadNolans6();\n } else if (target.id === \"nolans7\") {\n clearContent();\n loadNolans7();\n }\n });\n NolansEventListenersAdded = true;\n }\n}\nfunction loadNolans1() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans1_js__WEBPACK_IMPORTED_MODULE_8__.loadPage();\n}\nfunction loadNolans2() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans2_js__WEBPACK_IMPORTED_MODULE_9__.loadPage();\n}\nfunction loadNolans3() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans3_js__WEBPACK_IMPORTED_MODULE_10__.loadPage();\n}\nfunction loadNolans4() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans4_js__WEBPACK_IMPORTED_MODULE_11__.loadPage();\n}\nfunction loadNolans5() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans5_js__WEBPACK_IMPORTED_MODULE_12__.loadPage();\n}\nfunction loadNolans6() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans6_js__WEBPACK_IMPORTED_MODULE_13__.loadPage();\n}\nfunction loadNolans7() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans7_js__WEBPACK_IMPORTED_MODULE_14__.loadPage();\n}\nfunction loadProjectPageP(projectId) {\n clearContent();\n setTitle(\"Planera\");\n _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_16__.loadPage(projectId);\n}\nfunction loadProjectPageG(projectId) {\n clearContent();\n setTitle(\"Göra\");\n _projectPage_projectPageG_js__WEBPACK_IMPORTED_MODULE_17__.loadPage(projectId);\n}\nfunction loadProjectPageS(projectId) {\n clearContent();\n setTitle(\"Studera\");\n _projectPage_projectPageS_js__WEBPACK_IMPORTED_MODULE_18__.loadPage(projectId);\n}\nfunction loadProjectPageA(projectId) {\n clearContent();\n setTitle(\"Agera\");\n _projectPage_projectPageA_js__WEBPACK_IMPORTED_MODULE_19__.loadPage(projectId);\n}\nfunction loadCompletedProjects() {\n clearContent();\n setTitle(\"Avslutade förbättringsarbeten\");\n _KnowledgeBank_completedProjects_js__WEBPACK_IMPORTED_MODULE_4__.loadPage();\n //Page-specific eventlisteners\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"departmentDropdown\") {} else if (target.id === \"dateDropdown\") {}\n });\n}\nfunction loadMyProfile() {\n clearContent();\n setTitle(\"Din Profil\");\n _homePage_js__WEBPACK_IMPORTED_MODULE_15__.loadPage(); //fix containers\n}\n\nfunction loadSettings() {\n clearContent();\n setTitle(\"Inställningar\");\n //load settings function\n}\n\nfunction loadSupport() {\n clearContent();\n setTitle(\"Hjälp och Support\");\n //load support function\n}\n\nlogOutButton.addEventListener(\"click\", logOut);\ncurrentProjectButton.addEventListener(\"click\", loadCurrentProjects);\nideaBankButton.addEventListener(\"click\", loadIdeaBank);\nmakeSuggestionButton.addEventListener(\"click\", loadSuggestionPage);\nknowledgeBankButton.addEventListener(\"click\", loadKnowledgeBank);\nmyProfileButton.addEventListener(\"click\", loadMyProfile);\nsettingsButton.addEventListener(\"click\", loadSettings);\nsupportButton.addEventListener(\"click\", loadSupport);\n\n//# sourceURL=webpack://c3/./client/SidebarAndHeader/pageHandler.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadCurrentProjects: () => (/* binding */ loadCurrentProjects),\n/* harmony export */ loadProjectPageA: () => (/* binding */ loadProjectPageA),\n/* harmony export */ loadProjectPageG: () => (/* binding */ loadProjectPageG),\n/* harmony export */ loadProjectPageP: () => (/* binding */ loadProjectPageP),\n/* harmony export */ loadProjectPageS: () => (/* binding */ loadProjectPageS)\n/* harmony export */ });\n/* harmony import */ var _currentProjects_currentProjects_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../currentProjects/currentProjects.js */ \"./client/currentProjects/currentProjects.js\");\n/* harmony import */ var _Make_Suggestion_Code_makeSuggestion_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Make_Suggestion_Code/makeSuggestion.js */ \"./client/Make_Suggestion_Code/makeSuggestion.js\");\n/* harmony import */ var _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ideaBank/ideaBank.js */ \"./client/ideaBank/ideaBank.js\");\n/* harmony import */ var _KnowledgeBank_knowledgeBank_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../KnowledgeBank/knowledgeBank.js */ \"./client/KnowledgeBank/knowledgeBank.js\");\n/* harmony import */ var _KnowledgeBank_completedProjects_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../KnowledgeBank/completedProjects.js */ \"./client/KnowledgeBank/completedProjects.js\");\n/* harmony import */ var _KnowledgeBank_Nolans_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../KnowledgeBank/Nolans.js */ \"./client/KnowledgeBank/Nolans.js\");\n/* harmony import */ var _KnowledgeBank_genImprovMethods_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../KnowledgeBank/genImprovMethods.js */ \"./client/KnowledgeBank/genImprovMethods.js\");\n/* harmony import */ var _KnowledgeBank_ContactOrganization_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../KnowledgeBank/ContactOrganization.js */ \"./client/KnowledgeBank/ContactOrganization.js\");\n/* harmony import */ var _KnowledgeBank_Nolans1_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../KnowledgeBank/Nolans1.js */ \"./client/KnowledgeBank/Nolans1.js\");\n/* harmony import */ var _KnowledgeBank_Nolans2_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../KnowledgeBank/Nolans2.js */ \"./client/KnowledgeBank/Nolans2.js\");\n/* harmony import */ var _KnowledgeBank_Nolans3_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../KnowledgeBank/Nolans3.js */ \"./client/KnowledgeBank/Nolans3.js\");\n/* harmony import */ var _KnowledgeBank_Nolans4_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../KnowledgeBank/Nolans4.js */ \"./client/KnowledgeBank/Nolans4.js\");\n/* harmony import */ var _KnowledgeBank_Nolans5_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../KnowledgeBank/Nolans5.js */ \"./client/KnowledgeBank/Nolans5.js\");\n/* harmony import */ var _KnowledgeBank_Nolans6_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../KnowledgeBank/Nolans6.js */ \"./client/KnowledgeBank/Nolans6.js\");\n/* harmony import */ var _KnowledgeBank_Nolans7_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../KnowledgeBank/Nolans7.js */ \"./client/KnowledgeBank/Nolans7.js\");\n/* harmony import */ var _homePage_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../homePage.js */ \"./client/homePage.js\");\n/* harmony import */ var _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../projectPage/projectPageP.js */ \"./client/projectPage/projectPageP.js\");\n/* harmony import */ var _projectPage_projectPageG_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../projectPage/projectPageG.js */ \"./client/projectPage/projectPageG.js\");\n/* harmony import */ var _projectPage_projectPageS_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../projectPage/projectPageS.js */ \"./client/projectPage/projectPageS.js\");\n/* harmony import */ var _projectPage_projectPageA_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../projectPage/projectPageA.js */ \"./client/projectPage/projectPageA.js\");\n/* harmony import */ var _login_login_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../login/login.js */ \"./client/login/login.js\");\n/* harmony import */ var _login_register_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../login/register.js */ \"./client/login/register.js\");\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../initiateForbattringsarbete/initiateIdea.js */ \"./client/initiateForbattringsarbete/initiateIdea.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n//loading elements\nvar currentProjectButton = document.getElementById(\"currentProjects\");\nvar ideaBankButton = document.getElementById(\"ideaBankView\");\nvar knowledgeBankButton = document.getElementById(\"knowledgeBankView\");\nvar logOutButton = document.getElementById(\"log-out-button\");\nvar myProfileButton = document.getElementById(\"profileView\");\nvar makeSuggestionButton = document.getElementById(\"suggestionView\");\nvar settingsButton = document.getElementById(\"settingsView\");\nvar supportButton = document.getElementById(\"supportView\");\n//Event-listener checks, to make sure they only load once\nvar NolansEventListenersAdded = false;\nvar knowledgeBankListenersAdded = false;\nvar currentProjectsListenersAdded = false;\n//Loads loginPage as first view\nloadLoginPage();\nfunction setTitle(text) {\n var title = document.getElementById(\"titleCurrentPage\");\n if (title) {\n title.textContent = text;\n }\n}\n//Function to hide HTML elements\nfunction hideElement(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"none\";\n }\n}\nfunction removeDisplayStyle(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"\";\n }\n}\nfunction setFlexDisplay(elementId) {\n var element = document.getElementById(elementId);\n if (element) {\n element.style.display = \"flex\";\n }\n}\nfunction loadRegisterPage() {\n clearContent();\n _login_register_js__WEBPACK_IMPORTED_MODULE_21__.loadPage();\n var eventListener = function eventListener(event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var target;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n target = event.target;\n if (!(target.id === \"register-button\")) {\n _context.next = 8;\n break;\n }\n _context.next = 4;\n return _login_register_js__WEBPACK_IMPORTED_MODULE_21__.handleRegister();\n case 4:\n if (!_context.sent) {\n _context.next = 8;\n break;\n }\n hideElement(\"register-container\");\n loggedIn();\n document.removeEventListener(\"click\", eventListener);\n case 8:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n };\n document.addEventListener(\"click\", eventListener);\n}\nfunction loadLoginPage() {\n clearContent();\n _login_login_js__WEBPACK_IMPORTED_MODULE_20__.loadPage();\n var eventListener = function eventListener(event) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var target;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n target = event.target;\n if (!(target.id === \"button-login\")) {\n _context2.next = 7;\n break;\n }\n _context2.next = 4;\n return _login_login_js__WEBPACK_IMPORTED_MODULE_20__.handleLogin();\n case 4:\n if (!_context2.sent) {\n _context2.next = 7;\n break;\n }\n hideElement(\"login-container\");\n loggedIn();\n case 7:\n if (target.id === \"button-register\") {\n loadRegisterPage();\n hideElement(\"login-container\");\n setFlexDisplay(\"register-container\");\n }\n case 8:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n };\n document.addEventListener(\"click\", eventListener);\n}\n//help function after logging in successfully \nfunction loggedIn() {\n setFlexDisplay(\"main\");\n loadMyProfile();\n}\nfunction logOut() {\n hideElement(\"main\");\n removeDisplayStyle(\"login-container\");\n console.log(\"du klickade på logga ut knappen\");\n _Database_authentication_js__WEBPACK_IMPORTED_MODULE_22__.logout();\n}\nfunction clearContent() {\n var container = $(\"#container-fluid\");\n container.empty();\n var clonedContainer = container.clone();\n container.replaceWith(clonedContainer);\n}\nfunction loadCurrentProjects() {\n clearContent();\n setTitle(\"Pågående förbättringsarbeten\");\n _currentProjects_currentProjects_js__WEBPACK_IMPORTED_MODULE_0__.loadPage(currentProjectsListenersAdded);\n currentProjectsListenersAdded = true;\n}\nfunction loadSuggestionPage() {\n clearContent();\n setTitle(\"Ge förslag\");\n _Make_Suggestion_Code_makeSuggestion_js__WEBPACK_IMPORTED_MODULE_1__.loadPage();\n}\nfunction loadInitiatePage(id) {\n clearContent();\n setTitle(\"Gör ditt förslag till ett förbättringsarbete!\");\n _initiateForbattringsarbete_initiateIdea_js__WEBPACK_IMPORTED_MODULE_23__.loadPage(id);\n}\nfunction loadIdeaBank() {\n clearContent();\n setTitle(\"Alla Idéer\");\n _ideaBank_ideaBank_js__WEBPACK_IMPORTED_MODULE_2__.loadPage();\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n //adds an event listener for the initiate page \n if (target && target.className === \"initiateProjectButton\") {\n var cardId = target.id.replace(\"initiateProjectFromCard\", \"\");\n loadInitiatePage(cardId);\n }\n });\n}\nfunction loadKnowledgeBank() {\n clearContent();\n setTitle(\"Kunskapsbanken\");\n _KnowledgeBank_knowledgeBank_js__WEBPACK_IMPORTED_MODULE_3__.loadPage();\n //Loading Page-specific eventlistneres\n if (!knowledgeBankListenersAdded) {\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"buttons-kunskapsbanken-button1\") {\n loadNolansMain();\n } else if (target.id === \"buttons-kunskapsbanken-button2\") {\n loadGenImprovMethods();\n } else if (target.id === \"buttons-kunskapsbanken-button3\") {\n loadCompletedProjects();\n } else if (target.id === \"buttons-kunskapsbanken-button4\") {\n loadContactOrganizations();\n } else if (target.id === \"knowledge-backbutton\") {\n loadKnowledgeBank();\n }\n });\n knowledgeBankListenersAdded = true;\n }\n}\nfunction loadGenImprovMethods() {\n clearContent();\n setTitle(\"Generella förbättringsmetoder\");\n _KnowledgeBank_genImprovMethods_js__WEBPACK_IMPORTED_MODULE_6__.loadPage();\n}\nfunction loadContactOrganizations() {\n clearContent();\n setTitle(\"Kontaktinformation\");\n _KnowledgeBank_ContactOrganization_js__WEBPACK_IMPORTED_MODULE_7__.loadPage();\n}\nfunction loadNolansMain() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans_js__WEBPACK_IMPORTED_MODULE_5__.loadPage();\n if (!NolansEventListenersAdded) {\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"SattaMalSyfte\") {\n clearContent();\n loadNolans1();\n } else if (target.id === \"MataFoljaUpp\") {\n clearContent();\n loadNolans2();\n } else if (target.id === \"SamlaIdeer\") {\n clearContent();\n loadNolans3();\n } else if (target.id === \"nolansBackButton\") {\n clearContent();\n loadKnowledgeBank();\n } else if (target.id === \"nolans4\") {\n clearContent();\n loadNolans4();\n } else if (target.id === \"nolans5\") {\n clearContent();\n loadNolans5();\n } else if (target.id === \"nolans6\") {\n clearContent();\n loadNolans6();\n } else if (target.id === \"nolans7\") {\n clearContent();\n loadNolans7();\n }\n });\n NolansEventListenersAdded = true;\n }\n}\nfunction loadNolans1() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans1_js__WEBPACK_IMPORTED_MODULE_8__.loadPage();\n}\nfunction loadNolans2() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans2_js__WEBPACK_IMPORTED_MODULE_9__.loadPage();\n}\nfunction loadNolans3() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans3_js__WEBPACK_IMPORTED_MODULE_10__.loadPage();\n}\nfunction loadNolans4() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans4_js__WEBPACK_IMPORTED_MODULE_11__.loadPage();\n}\nfunction loadNolans5() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans5_js__WEBPACK_IMPORTED_MODULE_12__.loadPage();\n}\nfunction loadNolans6() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans6_js__WEBPACK_IMPORTED_MODULE_13__.loadPage();\n}\nfunction loadNolans7() {\n clearContent();\n setTitle(\"Nolans förbättringsmodell\");\n _KnowledgeBank_Nolans7_js__WEBPACK_IMPORTED_MODULE_14__.loadPage();\n}\nfunction loadProjectPageP(projectId) {\n clearContent();\n setTitle(\"Planera\");\n _projectPage_projectPageP_js__WEBPACK_IMPORTED_MODULE_16__.loadPage(projectId);\n}\nfunction loadProjectPageG(projectId) {\n clearContent();\n setTitle(\"Göra\");\n _projectPage_projectPageG_js__WEBPACK_IMPORTED_MODULE_17__.loadPage(projectId);\n}\nfunction loadProjectPageS(projectId) {\n clearContent();\n setTitle(\"Studera\");\n _projectPage_projectPageS_js__WEBPACK_IMPORTED_MODULE_18__.loadPage(projectId);\n}\nfunction loadProjectPageA(projectId) {\n clearContent();\n setTitle(\"Agera\");\n _projectPage_projectPageA_js__WEBPACK_IMPORTED_MODULE_19__.loadPage(projectId);\n}\nfunction loadCompletedProjects() {\n clearContent();\n setTitle(\"Avslutade förbättringsarbeten\");\n _KnowledgeBank_completedProjects_js__WEBPACK_IMPORTED_MODULE_4__.loadPage();\n //Page-specific eventlisteners\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n if (target.id === \"departmentDropdown\") {} else if (target.id === \"dateDropdown\") {}\n });\n}\nfunction loadMyProfile() {\n clearContent();\n setTitle(\"Din Profil\");\n _homePage_js__WEBPACK_IMPORTED_MODULE_15__.loadPage(); //fix containers\n}\n\nfunction loadSettings() {\n clearContent();\n setTitle(\"Inställningar\");\n //load settings function\n}\n\nfunction loadSupport() {\n clearContent();\n setTitle(\"Hjälp och Support\");\n //load support function\n}\n\nlogOutButton.addEventListener(\"click\", logOut);\ncurrentProjectButton.addEventListener(\"click\", loadCurrentProjects);\nideaBankButton.addEventListener(\"click\", loadIdeaBank);\nmakeSuggestionButton.addEventListener(\"click\", loadSuggestionPage);\nknowledgeBankButton.addEventListener(\"click\", loadKnowledgeBank);\nmyProfileButton.addEventListener(\"click\", loadMyProfile);\nsettingsButton.addEventListener(\"click\", loadSettings);\nsupportButton.addEventListener(\"click\", loadSupport);\n\n//# sourceURL=webpack://c3/./client/SidebarAndHeader/pageHandler.js?"); /***/ }), @@ -256,7 +256,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \***************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n\n\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\nvar projectCards = {};\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = '^ Stäng detaljer';\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = '> Mer information';\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert('The initiate project page should now be loaded');\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"totalExpandedOngoingWorkCard\\\">\\n <div class=\\\"flex-container ongoingCard\\\" id=\\\"\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\" id=\\\"pinkFaded\\\"></div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n </div>\\n\\n <button data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton\\\" role=\\\"button\\\">G\\xE5 till projektsidan</button>\\n\\n\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n <p id=\\\"ongoingSeeDetailsButton\").concat(this.id, \"\\\" class = \\\"moreInfoClass\\\">> Mer information</p>\\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}();\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var container;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n container = document.querySelector('#container-fluid');\n if (container) {\n _context.next = 3;\n break;\n }\n return _context.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n projectCards = {};\n fetch('currentProjects/currentProjects.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.filterBar');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n getProjects(container, listenersLoaded);\n case 6:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction getProjects(selectElement, listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var _this = this;\n var data, id;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({});\n case 2:\n data = _context3.sent;\n id = 0;\n data.forEach(function (project) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var title, department, name, description, i, card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n title = project.name;\n _context2.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)('unit', project.unitId);\n case 3:\n department = _context2.sent;\n if (!department) {\n _context2.next = 21;\n break;\n }\n name = \"Projektledare\"; //Waiting for backend fix\n description = project.content;\n i = id;\n card = new projectCard(i, name, department.name, title, description, project.id);\n projectCards[i] = card;\n cardHTML = card.generateHTML();\n addEventListener(listenersLoaded, project.id, card);\n div = document.createElement('div');\n div.className = 'projectCardCardDiv'; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context2.next = 17;\n break;\n }\n return _context2.abrupt(\"return\");\n case 17:\n selectElement.appendChild(div); // Stop if the container isn't found\n id++;\n _context2.next = 22;\n break;\n case 21:\n console.log(project.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist \n case 22:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n });\n case 5:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction addEventListener(listenersLoaded, projectId, card) {\n if (!listenersLoaded) {\n $(document).on('click', '#' + projectId, function (event) {\n var element = event.target;\n if (element.classList.contains('moreInfoClass')) {\n var expandedDiv = document.getElementById('expandedOngoingWorkCard' + projectId);\n if (expandedDiv && expandedDiv.style.display === 'none') {\n card.showMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"ongoingSeeDetailsButton\" + projectId);\n } else {\n card.closeMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"ongoingSeeDetailsButton\" + projectId);\n }\n } else {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n }\n });\n }\n}\n\n//# sourceURL=webpack://c3/./client/currentProjects/currentProjects.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n\n\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\nvar projectCards = {};\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId, currentStage) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n this.stage = currentStage;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = '^ Stäng detaljer';\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = '> Mer information';\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert('The initiate project page should now be loaded');\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"totalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: pointer;\\\" class=\\\"flex-container ongoingCard\\\" id=\\\"\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\" id=\\\"pinkFaded\\\"></div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n </div>\\n\\n <button data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton\\\" role=\\\"button\\\">G\\xE5 till projektsidan</button>\\n\\n <div class=\\\"statusText\\\">\\n Status: \").concat(this.stage, \"\\n </div>\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n <p id=\\\"ongoingSeeDetailsButton\").concat(this.projectId, \"\\\" class = \\\"moreInfoClass\\\">> Mer information</p>\\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}();\nfunction loadPage(listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var container;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n container = document.querySelector('#container-fluid');\n if (container) {\n _context.next = 3;\n break;\n }\n return _context.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n projectCards = {};\n fetch('currentProjects/currentProjects.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.filterBar');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n getProjects(container, listenersLoaded);\n case 6:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction getProjects(selectElement, listenersLoaded) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var _this = this;\n var data, id;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getImprovementWorks)({});\n case 2:\n data = _context3.sent;\n id = 0;\n data.forEach(function (project) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var title, department, name, description, i, card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n title = project.name;\n _context2.next = 3;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)('unit', project.unitId);\n case 3:\n department = _context2.sent;\n if (!department) {\n _context2.next = 21;\n break;\n }\n name = \"Projektledare\"; //Waiting for backend fix\n description = project.content;\n i = id;\n card = new projectCard(i, name, department.name, title, description, project.id, project.currentStage);\n projectCards[i] = card;\n cardHTML = card.generateHTML();\n addEventListener(listenersLoaded, project.id, card);\n div = document.createElement('div');\n div.className = 'projectCardCardDiv'; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context2.next = 17;\n break;\n }\n return _context2.abrupt(\"return\");\n case 17:\n selectElement.appendChild(div); // Stop if the container isn't found\n id++;\n _context2.next = 22;\n break;\n case 21:\n console.log(project.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist \n case 22:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n });\n case 5:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction addEventListener(listenersLoaded, projectId, card) {\n if (!listenersLoaded) {\n $(document).on('click', '#' + projectId, function (event) {\n var element = event.target;\n if (element.classList.contains('moreInfoClass')) {\n var expandedDiv = document.getElementById('expandedOngoingWorkCard' + projectId);\n if (expandedDiv && expandedDiv.style.display === 'none') {\n card.showMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"ongoingSeeDetailsButton\" + projectId);\n } else {\n card.closeMoreInfo(\"expandedOngoingWorkCard\" + projectId, \"ongoingSeeDetailsButton\" + projectId);\n }\n } else if (element.classList.contains('projectButton')) {\n var currentStage = card.stage;\n if (currentStage === 'Agera') {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageA)(projectId);\n } else if (currentStage === 'Studera') {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageS)(projectId);\n } else if (currentStage === 'Göra') {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageG)(projectId);\n } else if (currentStage === 'Planera') {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n } else if (currentStage === 'Avslutat') {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_1__.loadProjectPageP)(projectId);\n }\n }\n });\n }\n}\n\n//# sourceURL=webpack://c3/./client/currentProjects/currentProjects.js?"); /***/ }), @@ -266,7 +266,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \****************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../client/Database/database.js */ \"./client/Database/database.js\");\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\nfunction logoutUser(event) {\n event.preventDefault();\n alert('logout');\n (0,_Database_authentication_js__WEBPACK_IMPORTED_MODULE_0__.logout)();\n}\n//Mock-data, to be replaced\nvar homePageSampleProjects = [{\n ID: \"1\",\n name: \"Birthing of a Child\",\n current_stage: \"In Progress\",\n content: \"This is project 1.\",\n unit_ID: \"2\",\n date_started: new Date(\"2023-01-15\")\n}, {\n ID: \"2\",\n name: \"How to save a life\",\n current_stage: \"Completed\",\n content: \"This is project 2.\",\n unit_ID: \"1\",\n date_started: new Date(\"2023-02-20\")\n}, {\n ID: \"3\",\n name: \"BB tutorial\",\n current_stage: \"Completed\",\n content: \"This is project 3.\",\n unit_ID: \"2\",\n date_started: new Date(\"2023-06-05\")\n}, {\n ID: \"4\",\n name: \"Cancerbehandling 101\",\n current_stage: \"Completed\",\n content: \"This is project 4.\",\n unit_ID: \"3\",\n date_started: new Date(\"2023-10-24\")\n}, {\n ID: \"5\",\n name: \"Cancerbehandling 101\",\n current_stage: \"Completed\",\n content: \"This is project 4.\",\n unit_ID: \"3\",\n date_started: new Date(\"2023-10-24\")\n}, {\n ID: \"6\",\n name: \"Cancerbehandling 101\",\n current_stage: \"Completed\",\n content: \"This is project 4.\",\n unit_ID: \"3\",\n date_started: new Date(\"2023-10-24\")\n}];\nvar signedInUserHsaID = \"alijoh234\";\nvar myIdeaCards = {};\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n }\n _createClass(IdeaCard, [{\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImage\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFaded\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n </div>\\n <div class=\\\"ideaCardUpvotes\\\">\\n <img src=\\\"images/upvoteIcon.png\\\" class =\\\"upvoteIcon\\\" alt=\\\"upvoteIcon\\\">\\n <p id =\\\"upvoteNumber\\\" class=\\\"ideaCardFont\\\">\").concat(this.upvoteCount, \"</p>\\n </div>\\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <p class=\\\"ideaCardFont\\\">Kommentarer</p>\\n <p class=\\\"ideaCardFont\\\">Komment 1</p>\\n <p class=\\\"ideaCardFont\\\">K0mment 2</p>\\n </div>\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProject\\\" onclick=\\\"myIdeaCards[\").concat(this.id, \"].loadInitiatePage()\\\">Initiera Project</button>\\n </div>\\n </div>\\n </div>\\n </div>\");\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var user, userSuggestions, counter;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"users\", signedInUserHsaID);\n case 2:\n user = _context2.sent;\n _context2.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 5:\n userSuggestions = _context2.sent;\n //If there exist filter use those instead to get matching suggestions rest should not need to be changed\n counter = 0;\n userSuggestions.forEach(function (suggestion) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context.sent;\n _context.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context.sent;\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter);\n counter = counter + 1;\n case 8:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n case 8:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount);\n cardHTML = card.generateHTML();\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n container.appendChild(div);\n case 7:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction loadPage() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this2 = this;\n var container;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n container = document.querySelector('#container-fluid');\n if (container) {\n _context5.next = 3;\n break;\n }\n return _context5.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n fetch('homePage.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var tempContainer, specificElement, tmp, user, suggestionContainer, nameHeaderElement, nameElement, emailElement, roleElement, unitElement, userFullName, userUnits, userUnit;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n // Create a temporary container element to hold the loaded content\n tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n specificElement = tempContainer.querySelector('.main-content');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n tmp = localStorage.getItem('user');\n console.log(tmp);\n if (tmp) {\n _context4.next = 9;\n break;\n }\n console.log(\"there is not an user in localStorage\");\n return _context4.abrupt(\"return\");\n case 9:\n user = JSON.parse(tmp)[0];\n displayProjects(user);\n //displaySuggestions(user);\n suggestionContainer = document.getElementById(\"suggestion-container\");\n if (!suggestionContainer) {\n _context4.next = 15;\n break;\n }\n _context4.next = 15;\n return createNewCards(\"HomePageIdeaCardDiv\", suggestionContainer);\n case 15:\n console.log(user.firstName + \"user.firstname\");\n nameHeaderElement = document.getElementById('user-name-header');\n nameElement = document.getElementById('user-name');\n emailElement = document.getElementById('user-email');\n roleElement = document.getElementById('user-role');\n unitElement = document.getElementById(\"user-unit\");\n userFullName = user.firstName + \" \" + user.lastName;\n _context4.next = 24;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getUnits)({\n unitId: user.unitId\n });\n case 24:\n userUnits = _context4.sent;\n userUnit = userUnits[0];\n if (emailElement && roleElement && nameElement && unitElement && nameHeaderElement) {\n nameHeaderElement.textContent = userFullName;\n nameElement.textContent = userFullName;\n unitElement.textContent = userUnit.name;\n emailElement.textContent = user.email;\n roleElement.textContent = \"undefined\";\n }\n case 27:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n case 4:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction displayProjects(user) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var container, userImprovementWorks;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n container = document.getElementById('project-container');\n userImprovementWorks = user.improvementWorks;\n userImprovementWorks.forEach(function (project) {\n console.log(project.improvementWorkId);\n var improvementWork = (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"improvementWork\", project.improvementWorkId);\n var projectBox = document.createElement('div');\n projectBox.classList.add('project-box');\n var projectName = document.createElement('h2');\n projectName.textContent = project.name;\n projectBox.appendChild(projectName);\n container === null || container === void 0 ? void 0 : container.appendChild(projectBox);\n });\n case 3:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n}\nfunction displaySuggestions(user) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var container, userSuggestions;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n container = document.getElementById('suggestion-container');\n _context7.next = 3;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 3:\n userSuggestions = _context7.sent;\n userSuggestions.forEach(function (suggestion) {\n var suggestionBox = document.createElement('div');\n suggestionBox.classList.add('suggestion-box');\n var suggestionName = document.createElement('h2');\n suggestionName.textContent = suggestion.name;\n var suggestionDescription = document.createElement('p');\n suggestionDescription.textContent = suggestion.area;\n suggestionDescription.classList.add('suggestion-description');\n suggestionDescription.style.display = 'none'; // Initially hide the description\n var expandButton = document.createElement('button');\n expandButton.textContent = 'Expand';\n expandButton.addEventListener('click', function () {\n if (suggestionDescription.style.display === 'none') {\n suggestionDescription.style.display = 'block';\n expandButton.textContent = 'Collapse';\n } else {\n suggestionDescription.style.display = 'none';\n expandButton.textContent = 'Expand';\n }\n });\n suggestionBox.appendChild(suggestionName);\n suggestionBox.appendChild(expandButton);\n suggestionBox.appendChild(suggestionDescription);\n container === null || container === void 0 ? void 0 : container.appendChild(suggestionBox);\n });\n case 5:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/homePage.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_authentication_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Database/authentication.js */ \"./client/Database/authentication.js\");\n/* harmony import */ var _client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../client/Database/database.js */ \"./client/Database/database.js\");\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\nfunction logoutUser(event) {\n event.preventDefault();\n alert('logout');\n (0,_Database_authentication_js__WEBPACK_IMPORTED_MODULE_0__.logout)();\n}\nvar myIdeaCards = {};\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n }\n _createClass(IdeaCard, [{\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImage\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFaded\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n </div>\\n <div class=\\\"ideaCardUpvotes\\\">\\n <img src=\\\"images/upvoteIcon.png\\\" class =\\\"upvoteIcon\\\" alt=\\\"upvoteIcon\\\">\\n <p id =\\\"upvoteNumber\\\" class=\\\"ideaCardFont\\\">\").concat(this.upvoteCount, \"</p>\\n </div>\\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <p class=\\\"ideaCardFont\\\">Kommentarer</p>\\n <p class=\\\"ideaCardFont\\\">Komment 1</p>\\n <p class=\\\"ideaCardFont\\\">K0mment 2</p>\\n </div>\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProject\\\" onclick=\\\"myIdeaCards[\").concat(this.id, \"].loadInitiatePage()\\\">Initiera Project</button>\\n </div>\\n </div>\\n </div>\\n </div>\");\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container, signedInUserHsaID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var user, userSuggestions, counter;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"users\", signedInUserHsaID);\n case 2:\n user = _context2.sent;\n _context2.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getSuggestions)({\n creatorHsaId: user.id\n });\n case 5:\n userSuggestions = _context2.sent;\n //If there exist filter use those instead to get matching suggestions rest should not need to be changed\n counter = 0;\n userSuggestions.forEach(function (suggestion) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context.sent;\n _context.next = 5;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context.sent;\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter);\n counter = counter + 1;\n case 8:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n case 8:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount);\n cardHTML = card.generateHTML();\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n container.appendChild(div);\n case 7:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction loadPage() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var _this2 = this;\n var container;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n container = document.querySelector('#container-fluid');\n if (container) {\n _context5.next = 3;\n break;\n }\n return _context5.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n fetch('homePage.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var tempContainer, specificElement, tmp, user, suggestionContainer, nameHeaderElement, nameElement, emailElement, roleElement, unitElement, userFullName, userUnits, userUnit, projectContainer;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n // Create a temporary container element to hold the loaded content\n tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n specificElement = tempContainer.querySelector('.main-content');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n tmp = localStorage.getItem('user');\n console.log(tmp);\n if (tmp) {\n _context4.next = 9;\n break;\n }\n console.log(\"there is not an user in localStorage\");\n return _context4.abrupt(\"return\");\n case 9:\n user = JSON.parse(tmp)[0];\n suggestionContainer = document.getElementById(\"suggestion-container\");\n if (!suggestionContainer) {\n _context4.next = 14;\n break;\n }\n _context4.next = 14;\n return createNewCards(\"HomePageIdeaCardDiv\", suggestionContainer, user.id);\n case 14:\n console.log(user.firstName + \"user.firstname\");\n nameHeaderElement = document.getElementById('user-name-header');\n nameElement = document.getElementById('user-name');\n emailElement = document.getElementById('user-email');\n roleElement = document.getElementById('user-role');\n unitElement = document.getElementById(\"user-unit\");\n userFullName = user.firstName + \" \" + user.lastName;\n _context4.next = 23;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getUnits)({\n unitId: user.unitId\n });\n case 23:\n userUnits = _context4.sent;\n userUnit = userUnits[0];\n if (emailElement && roleElement && nameElement && unitElement && nameHeaderElement) {\n nameHeaderElement.textContent = userFullName;\n nameElement.textContent = userFullName;\n unitElement.textContent = userUnit.name;\n emailElement.textContent = user.email;\n roleElement.textContent = \"undefined\";\n }\n projectContainer = document.getElementById(\"project-container\");\n if (!projectContainer) {\n _context4.next = 30;\n break;\n }\n _context4.next = 30;\n return getProjects(projectContainer, user.id);\n case 30:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n case 4:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5);\n }));\n}\nfunction getProjects(selectElement, /*listenersLoaded:boolean,*/userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var _this3 = this;\n var data, id;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.next = 2;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getImprovementWorksForUser)(userHsaId);\n case 2:\n data = _context7.sent;\n id = 0;\n data.forEach(function (project) {\n return __awaiter(_this3, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var title, department, name, description, i, card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n title = project.name;\n _context6.next = 3;\n return (0,_client_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)('unit', project.unitId);\n case 3:\n department = _context6.sent;\n if (!department) {\n _context6.next = 20;\n break;\n }\n name = \"Projektledare\"; //Waiting for backend fix\n description = project.content;\n i = id;\n card = new projectCard(i, name, department.name, title, description, project.id);\n projectCards[i] = card;\n cardHTML = card.generateHTML(); //addEventListener(listenersLoaded, project.id, card);\n div = document.createElement('div');\n div.className = 'homePageProjectCardDiv'; // Set the class name(s) here\n div.innerHTML = cardHTML;\n if (selectElement) {\n _context6.next = 16;\n break;\n }\n return _context6.abrupt(\"return\");\n case 16:\n selectElement.appendChild(div); // Stop if the container isn't found\n id++;\n _context6.next = 21;\n break;\n case 20:\n console.log(project.unitId + \" is not a unit\"); //Unit Ids on improvement work that do not exist \n case 21:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6);\n }));\n });\n case 5:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7);\n }));\n}\nvar projectCards = {};\nvar projectCard = /*#__PURE__*/function () {\n function projectCard(id, name, department, title, description, projectId) {\n _classCallCheck(this, projectCard);\n this.name = name;\n this.department = department;\n this.title = title;\n this.description = description;\n this.id = id;\n this.projectId = projectId;\n }\n _createClass(projectCard, [{\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = '^ Stäng detaljer';\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = '> Mer information';\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert('The initiate project page should now be loaded');\n }\n }, {\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"homeTotalExpandedOngoingWorkCard\\\">\\n <div style=\\\"cursor: pointer;\\\" class=\\\"flex-container ongoingCard\\\" id=\\\"\".concat(this.projectId, \"\\\">\\n <div class=\\\"ongoingCardImageContainer toSinglePage\\\">\\n <div class = \\\"flex-box ongoingCardImage toSinglePage\\\" id=\\\"pinkFaded\\\"></div>\\n </div>\\n <div class=\\\"div ongoingCardInfo toSinglePage\\\">\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardManager\\\">\").concat(this.name, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardDepartment\\\">\").concat(this.department, \"</p>\\n <p class=\\\"toSinglePage\\\" id=\\\"ongoingCardIdeaTitle\\\">\").concat(this.title, \"</p>\\n </div>\\n\\n <!--<button data-project-id=\\\"\").concat(this.id, \"\\\" class=\\\"projectButton\\\" role=\\\"button\\\">G\\xE5 till projektsidan</button>-->\\n\\n\\n <div class=\\\"container ongoingSeeCardDetails toSinglePage\\\">\\n <div class=\\\"ongoingSeeCardDetailsInner\\\">\\n <p id=\\\"ongoingSeeDetailsButton\").concat(this.projectId, \"\\\" class = \\\"moreInfoClass\\\">> Mer information</p>\\n </div>\\n </div>\\n </div> \\n <div class = \\\"expandedOngoingWorkCard\\\" id=\\\"expandedOngoingWorkCard\").concat(this.projectId, \"\\\" style=\\\"display: none;\\\">\\n <div class =\\\"expandedTextOngoingWorkCard\\\">\\n \").concat(this.description, \"\\n </div>\\n </div>\\n </div> \");\n }\n }]);\n return projectCard;\n}();\n\n//# sourceURL=webpack://c3/./client/homePage.js?"); /***/ }), @@ -276,7 +276,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \*************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ testFunc: () => (/* binding */ testFunc)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n//import {loadInitiatePage} from \"../SidebarAndHeader/pageHandler.js\";\nvar myIdeaCards = {};\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n }\n _createClass(IdeaCard, [{\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImage\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFaded\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n </div>\\n <div class=\\\"ideaCardUpvotes\\\">\\n <img src=\\\"images/upvoteIcon.png\\\" class =\\\"upvoteIcon\\\" alt=\\\"upvoteIcon\\\">\\n <p id =\\\"upvoteNumber\\\" class=\\\"ideaCardFont\\\">\").concat(this.upvoteCount, \"</p>\\n </div>\\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <p class=\\\"ideaCardFont\\\">Kommentarer</p>\\n <p class=\\\"ideaCardFont\\\">Komment 7</p>\\n <p class=\\\"ideaCardFont\\\">K0mment 2</p>\\n </div>\\n\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.id, \"\\\">Initiera Project</button>\\n </div>\\n </div>\\n </div>\\n </div>\");\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n window.location.href = '../client/projectPage/projectPageP.html';\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var suggestions, counter;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 2:\n suggestions = _context2.sent;\n //If there exist filter use those instead to get matching suggestions rest should not need to be changed\n counter = 1;\n suggestions.forEach(function (suggestion) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context.sent;\n _context.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context.sent;\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter);\n counter = counter + 1;\n case 8:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n case 5:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount);\n cardHTML = card.generateHTML();\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n container.appendChild(div);\n case 7:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction testFunc() {\n console.log(\"Test func works\");\n}\nfunction loadPage() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var container, scriptElement;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context4.next = 3;\n break;\n }\n return _context4.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n scriptElement = document.createElement(\"script\");\n scriptElement.src = \"../dist/ideaBank.bundle.js\";\n container.appendChild(scriptElement);\n fetch(\"ideaBank/ideaBank.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBar\");\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n myIdeaCards = {};\n _context4.next = 10;\n return createNewCards(\"IdeaCardDiv\", container);\n case 10:\n addListner(myIdeaCards, container);\n case 11:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n}\nfunction addListner(cardArray, element) {\n element.addEventListener(\"click\", function (event) {\n var target = event.target;\n //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n var cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n var card = cardArray[cardId];\n var expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n //adds an event listener for the initiate page \n // if (target && target.className === \"initiateProjectButton\") {\n // const cardId = parseInt(target.id.replace(\"initiateProjectFromCard\", \"\"), 10);\n // if (cardArray[cardId]) {\n // $(\"#container-fluid\").empty();\n // loadInitiatePage(cardId);\n // }\n //}\n });\n}\n\n//# sourceURL=webpack://c3/./client/ideaBank/ideaBank.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage),\n/* harmony export */ testFunc: () => (/* binding */ testFunc)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n//import {loadInitiatePage} from \"../SidebarAndHeader/pageHandler.js\";\nvar myIdeaCards = {};\nvar IdeaCard = /*#__PURE__*/function () {\n function IdeaCard(id, header, department, name, description, upvoteCount, suggestionID) {\n _classCallCheck(this, IdeaCard);\n this.header = header;\n this.department = department;\n this.name = name;\n this.description = description;\n this.upvoteCount = upvoteCount;\n this.id = id;\n this.suggestionID = suggestionID;\n }\n _createClass(IdeaCard, [{\n key: \"generateHTML\",\n value: function generateHTML() {\n return \"<div class=\\\"totalExpandedIdeaCard\\\">\\n <div class=\\\"ideaCard\\\">\\n <div class=\\\"ideaCardBorder\\\">\\n <div class=\\\"ideaCardImage\\\">\\n <img src=\\\"../images/pinkFaded.png\\\" class =\\\"pinkFaded\\\" alt=\\\"pinkFaded\\\">\\n </div>\\n <div class=\\\"ideaCardMiddleText\\\">\\n <p id=\\\"ideaCardHeader\\\" class=\\\"ideaCardFont\\\">\".concat(this.header, \"</p>\\n <p id=\\\"ideaCardDepartment\\\" class=\\\"ideaCardFont\\\">\").concat(this.department, \"</p>\\n <p id=\\\"ideaCardName\\\" class=\\\"ideaCardFont\\\">\").concat(this.name, \"</p>\\n <p id=\\\"ideaCardMoreInfo\").concat(this.id, \"\\\" class=\\\"ideaCardFont moreInfoClass\\\"> > Mer information</p>\\n </div>\\n </div>\\n <div class=\\\"ideaCardUpvotes\\\">\\n <img src=\\\"images/upvoteIcon.png\\\" class =\\\"upvoteIcon\\\" alt=\\\"upvoteIcon\\\">\\n <p id =\\\"upvoteNumber\\\" class=\\\"ideaCardFont\\\">\").concat(this.upvoteCount, \"</p>\\n </div>\\n </div>\\n <div id=\\\"expandedContent\").concat(this.id, \"\\\" class= \\\"expandedIdeaContent\\\" style =\\\"display : none;\\\">\\n <div class=\\\"expandedDescriptionText\\\">\\n <p class=\\\"ideaCardFont\\\" id=\\\"expandedHeader\\\">Om ideen</p>\\n <p id=\\\"expandedDescription\\\">\").concat(this.description, \"</p>\\n </div>\\n <div class=\\\"expandedCommentAndButton id = \\\"expandedCommentAndButton\").concat(this.id, \"\\\">\\n <div class=\\\"expandedComment\\\">\\n <p class=\\\"ideaCardFont\\\">Kommentarer</p>\\n <p class=\\\"ideaCardFont\\\">Komment 7</p>\\n <p class=\\\"ideaCardFont\\\">K0mment 2</p>\\n </div>\\n\\n <div class=\\\"expandedButton\\\">\\n <button class=\\\"initiateProjectButton\\\" id=\\\"initiateProjectFromCard\").concat(this.suggestionID, \"\\\">Initiera Project</button>\\n </div>\\n </div>\\n </div>\\n </div>\");\n }\n }, {\n key: \"showMoreInfo\",\n value: function showMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"flex\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"^ Stäng detaljer\";\n }\n }\n }, {\n key: \"closeMoreInfo\",\n value: function closeMoreInfo(blockId, thisTextId) {\n var blockElement = document.getElementById(blockId);\n if (blockElement) {\n blockElement.style.display = \"none\";\n }\n var textElement = document.getElementById(thisTextId);\n if (textElement) {\n textElement.innerText = \"> Mer information\";\n }\n }\n }, {\n key: \"loadInitiatePage\",\n value: function loadInitiatePage() {\n alert(\"The initiate project page should now be loaded\");\n window.location.href = '../client/projectPage/projectPageP.html';\n }\n }]);\n return IdeaCard;\n}();\nfunction createNewCards(className, container) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var _this = this;\n var suggestions, counter;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getSuggestions)({});\n case 2:\n suggestions = _context2.sent;\n //If there exist filter use those instead to get matching suggestions rest should not need to be changed\n counter = 1;\n suggestions.forEach(function (suggestion) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var unit, user;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"unit\", suggestion.unitId);\n case 2:\n unit = _context.sent;\n _context.next = 5;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"users\", suggestion.creatorHsaId);\n case 5:\n user = _context.sent;\n console.log(suggestion);\n createNewIdeaCard(suggestion.name, unit.name, user.firstName + \" \" + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter, suggestion.id);\n counter = counter + 1;\n case 9:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n });\n case 5:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID, suggestionID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var card, cardHTML, div;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n card = new IdeaCard(ID, header, department, name, description, upvoteCount, suggestionID);\n cardHTML = card.generateHTML();\n myIdeaCards[ID] = card;\n div = document.createElement(\"div\");\n div.className = className; // Set the class name(s) here\n div.innerHTML = cardHTML;\n container.appendChild(div);\n case 7:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction testFunc() {\n console.log(\"Test func works\");\n}\nfunction loadPage() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var container, scriptElement;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n container = document.querySelector(\"#container-fluid\");\n if (container) {\n _context4.next = 3;\n break;\n }\n return _context4.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n scriptElement = document.createElement(\"script\");\n scriptElement.src = \"../dist/ideaBank.bundle.js\";\n container.appendChild(scriptElement);\n fetch(\"ideaBank/ideaBank.html\").then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement(\"div\");\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector(\".filterBar\");\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n }\n })[\"catch\"](function (error) {\n console.error(\"Failed to load the external HTML file:\", error);\n });\n myIdeaCards = {};\n _context4.next = 10;\n return createNewCards(\"IdeaCardDiv\", container);\n case 10:\n addListner(myIdeaCards, container);\n case 11:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n}\nfunction addListner(cardArray, element) {\n element.addEventListener(\"click\", function (event) {\n var target = event.target;\n //Adds an eventlistener for the more info of the card\n if (target && target.className === \"ideaCardFont moreInfoClass\") {\n var cardId = parseInt(target.id.replace(\"ideaCardMoreInfo\", \"\"), 10);\n if (cardArray[cardId]) {\n var card = cardArray[cardId];\n var expandedDiv = document.getElementById(\"expandedContent\".concat(cardId));\n if (expandedDiv) {\n if (expandedDiv.style.display === \"none\") {\n card.showMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n } else {\n card.closeMoreInfo(\"expandedContent\".concat(cardId), \"ideaCardMoreInfo\".concat(cardId));\n }\n } else {\n console.error(\"Expanded div not found\");\n }\n }\n }\n //adds an event listener for the initiate page \n // if (target && target.className === \"initiateProjectButton\") {\n // const cardId = parseInt(target.id.replace(\"initiateProjectFromCard\", \"\"), 10);\n // if (cardArray[cardId]) {\n // $(\"#container-fluid\").empty();\n // loadInitiatePage(cardId);\n // }\n //}\n });\n}\n\n//# sourceURL=webpack://c3/./client/ideaBank/ideaBank.js?"); /***/ }), @@ -286,7 +286,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \***********************************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n//Globala varibler för projekledare & Users\nvar selectedEmployees = [];\nfunction loadEmployees() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var selectProjectLeaderHTML, selectEmployeeHTML, allUsers, allProjectLeaders, selectHospitalHTML, selectUnitHTML, allHospitals, allUnits;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n selectProjectLeaderHTML = $('#projectLeader'); // loads the select type from html\n selectEmployeeHTML = $('#selectEmployee'); // loads the select type from html\n _context.next = 4;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 4:\n allUsers = _context.sent;\n _context.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 7:\n allProjectLeaders = _context.sent;\n //here you can put constraints\n allUsers.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(\"\".concat(user.firstName) + \" \" + \"\".concat(user.lastName));\n selectEmployeeHTML.append(optionElement);\n });\n allProjectLeaders.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(\"\".concat(user.firstName) + \" \" + \"\".concat(user.lastName));\n selectProjectLeaderHTML.append(optionElement);\n });\n selectHospitalHTML = $('#selectHospital'); // loads the select type from html\n selectUnitHTML = $('#selectDepartment'); // loads the select type from html\n _context.next = 14;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({});\n case 14:\n allHospitals = _context.sent;\n _context.next = 17;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({});\n case 17:\n allUnits = _context.sent;\n //here you can put constraints\n console.log(allHospitals);\n console.log(allUnits);\n allHospitals.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(user.name);\n selectHospitalHTML.append(optionElement);\n });\n allUnits.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(user.name);\n selectUnitHTML.append(optionElement);\n });\n case 22:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction assignedEmployer() {\n var employeeList = $('#selectEmployee');\n var selectedBox = $('#selectedEmployees');\n var selectedOption = employeeList.find('option:selected');\n var selectedText = selectedOption.text();\n selectedBox.append(createAssignedEmployeeDesign(selectedText, selectedOption, employeeList));\n selectedEmployees.push(String(selectedOption.val()));\n employeeList.find('option:selected').remove();\n employeeList.prop('selectedIndex', 0);\n}\nfunction createAssignedEmployeeDesign(s, x, employeeList) {\n var container = $('<div>').addClass('selectedEmployeeBubble'); // Create a div element and add a class\n var textSpan = $('<span>').addClass('ideaCardFont').text(s); // Create a span element, set text, and add a class\n var deleteButton = $('<button>').addClass('employeeDeleteButton').text('X'); // Create a button element, set text, and add a class\n deleteButton.on('click', function () {\n container.remove();\n employeeList.append(x);\n employeeList.prop('selectedIndex', 0);\n //removes from global list\n var index = selectedEmployees.indexOf(String(x.val()));\n if (index !== -1) {\n selectedEmployees.splice(index, 1);\n }\n });\n container.append(textSpan, deleteButton); // Append the span and button to the div container\n return container;\n}\n//Functions to load the page\nfunction loadPage(id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var container, linkelementCSS, linkQuestionCSS, linkActivitycardCSS, scriptElement, generatedHTML, generatedElement;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n container = document.querySelector('#container-fluid');\n if (container) {\n _context2.next = 3;\n break;\n }\n return _context2.abrupt(\"return\");\n case 3:\n // Stop if the container isn't found\n linkelementCSS = document.createElement('link');\n linkelementCSS.rel = 'styleSheet';\n linkelementCSS.href = 'initiateForbattringsarbete/initiateIdea.css';\n document.head.appendChild(linkelementCSS);\n linkQuestionCSS = document.createElement('link');\n linkQuestionCSS.rel = 'styleSheet';\n linkQuestionCSS.href = 'Make_Suggestion_Code/makeSuggestion.css';\n document.head.appendChild(linkQuestionCSS);\n linkActivitycardCSS = document.createElement(\"link\");\n linkActivitycardCSS.rel = \"stylesheet\";\n linkActivitycardCSS.href = 'Activity_card_code/activitity_card.css';\n document.head.appendChild(linkActivitycardCSS);\n scriptElement = document.createElement(\"script\");\n scriptElement.src = \"../dist/initiateIdea.bundle.js\";\n container.appendChild(scriptElement);\n _context2.next = 20;\n return generateQuestionHTML(id);\n case 20:\n generatedHTML = _context2.sent;\n generatedElement = document.createRange().createContextualFragment(generatedHTML);\n fetch('initiateForbattringsarbete/initiateIdea.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.initiateIdeaWholePage');\n //Eventlistenerbuttons:\n var createButton = document.getElementById('createProjectFromSuggestionButton');\n var selectEmployeeButton = document.getElementById('selectEmployee');\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n //adds an event listener for the initiate page \n if (target.id === \"createProjectFromSuggestionButton\") {\n createProject();\n }\n });\n document.addEventListener(\"change\", function (event) {\n var target = event.target;\n //adds an event listener for the initiate page \n if (target.id === \"selectEmployee\") {\n assignedEmployer();\n }\n });\n if (specificElement) {\n // Insert the generated element before the specific element\n container.insertBefore(generatedElement, container.firstChild);\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n selectedEmployees = []; //clears the global employee list\n loadEmployees();\n }\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n case 23:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction createProject() {\n var inputSelectProjectleaderInput = document.getElementById(\"projectLeader\");\n var selectDepartment = document.getElementById(\"selectHospital\");\n var selectUnit = document.getElementById(\"selectDepartment\");\n var inputBoxFormNameInput = document.getElementById(\"inputBoxFormNameInput\");\n var inputBoxFormAreaInput = document.getElementById(\"inputBoxFormAreaInput\");\n var inputBoxFormContentInput = document.getElementById(\"inputBoxFormContentInput\");\n var inputBoxFormPurposeInput = document.getElementById(\"inputBoxFormPurposeInput\");\n var inputBoxFormMeasureInput = document.getElementById(\"inputBoxFormMeasureInput\");\n var inputBoxFormIdeasInput = document.getElementById(\"inputBoxFormIdeasInput\");\n alert(\"Kul att du försöker! Detta är inte klart ännu... \\n Däremot är värdena följande: \\n\" + inputSelectProjectleaderInput.options[inputSelectProjectleaderInput.selectedIndex].value + \"\\n\" + selectDepartment.options[selectDepartment.selectedIndex].value + \"\\n\" + selectUnit.options[selectUnit.selectedIndex].value + \"\\n\" + selectedEmployees + \"\\n\" + inputBoxFormNameInput.value + \"\\n\" + inputBoxFormAreaInput.value + \"\\n\" + inputBoxFormContentInput.value + \"\\n\" + inputBoxFormPurposeInput.value + \"\\n\" + inputBoxFormMeasureInput.value + \"\\n\" + inputBoxFormIdeasInput.value + \"\\n\");\n console.log(selectedEmployees);\n}\nfunction generateQuestionHTML(suggestionID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var suggestionData;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"suggestion\", suggestionID);\n case 2:\n suggestionData = _context3.sent;\n return _context3.abrupt(\"return\", \"\\n <div class=\\\"filter-section\\\">\\n <div class=\\\"makeSuggestionFilterButtons\\\">\\n <select name=\\\"department\\\" id=\\\"selectHospital\\\" class=\\\"filterButtons\\\"> </select>\\n\\n <select name=\\\"section\\\" id=\\\"selectDepartment\\\" class=\\\"filterButtons\\\">\\n </select>\\n\\n </div>\\n</div>\\n\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">Rubrik *</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormName\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormNameInput\\\"\\n placeholder=\\\"Vad vill du kalla ditt f\\xF6rslag?\\\"\\n value = \\\"\" + suggestionData.name + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Vilket \\xE4r omr\\xE5det f\\xF6r f\\xF6rb\\xE4ttringen? *\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormArea\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormAreaInput\\\"\\n placeholder=\\\"Ber\\xE4tta om omr\\xE5de ditt f\\xF6rslag hade f\\xF6rb\\xE4ttrat.\\\"\\n value = \\\"\" + suggestionData.area + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\" id=\\\"middleShadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">Bakgrund *</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormContent\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormContentInput\\\"\\n placeholder=\\\"Beskriv problemet\\\"\\n value = \\\"\" + suggestionData.content + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Vilket syfte har f\\xF6rb\\xE4ttringen? *\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormPurpose\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormPurposeInput\\\"\\n placeholder=\\\"Vad ska \\xE5stadkommas och varf\\xF6r? Kom ih\\xE5g att f\\xE5 med patientperspektivet\\\"\\n value = \\\"\" + suggestionData.purpose + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Hur ska det m\\xE4tas?\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormMeasure\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormMeasureInput\\\"\\n placeholder=\\\"Hur vet vi att en f\\xF6r\\xE4ndring \\xE4r en f\\xF6rb\\xE4ttring?\\\"\\n value = \\\"\" + suggestionData.measure + \"\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">Id\\xE9er</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeas\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeasInput\\\"\\n placeholder=\\\"Vilka f\\xF6r\\xE4ndringar kan pr\\xF6vas f\\xF6r att uppn\\xE5 en f\\xF6rb\\xE4ttring?\\\"\\n value = \\\"\" + suggestionData.ideas + \"\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n<button id=\\\"createProjectFromSuggestionButton\\\">Skapa f\\xF6rb\\xE4ttringsarbete!</button>\");\n case 4:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/initiateForbattringsarbete/initiateIdea.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n//Globala varibler för projekledare & Users\nvar selectedEmployees = [];\nfunction loadEmployees() {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var selectProjectLeaderHTML, selectEmployeeHTML, allUsers, allProjectLeaders, selectHospitalHTML, selectUnitHTML, allHospitals, allUnits;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n selectProjectLeaderHTML = $('#projectLeader'); // loads the select type from html\n selectEmployeeHTML = $('#selectEmployee'); // loads the select type from html\n _context.next = 4;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 4:\n allUsers = _context.sent;\n _context.next = 7;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUsers)({});\n case 7:\n allProjectLeaders = _context.sent;\n //here you can put constraints\n allUsers.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(\"\".concat(user.firstName) + \" \" + \"\".concat(user.lastName));\n selectEmployeeHTML.append(optionElement);\n });\n allProjectLeaders.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(\"\".concat(user.firstName) + \" \" + \"\".concat(user.lastName));\n selectProjectLeaderHTML.append(optionElement);\n });\n selectHospitalHTML = $('#selectHospital'); // loads the select type from html\n selectUnitHTML = $('#selectDepartment'); // loads the select type from html\n _context.next = 14;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getHospitals)({});\n case 14:\n allHospitals = _context.sent;\n _context.next = 17;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getUnits)({});\n case 17:\n allUnits = _context.sent;\n //here you can put constraints\n console.log(allHospitals);\n console.log(allUnits);\n allHospitals.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(user.name);\n selectHospitalHTML.append(optionElement);\n });\n allUnits.forEach(function (user) {\n var optionElement = $('<option>').addClass('ideaCardFont').val(user.id).text(user.name);\n selectUnitHTML.append(optionElement);\n });\n case 22:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction assignedEmployer() {\n var employeeList = $('#selectEmployee');\n var selectedBox = $('#selectedEmployees');\n var selectedOption = employeeList.find('option:selected');\n var selectedText = selectedOption.text();\n selectedBox.append(createAssignedEmployeeDesign(selectedText, selectedOption, employeeList));\n selectedEmployees.push(String(selectedOption.val()));\n employeeList.find('option:selected').remove();\n employeeList.prop('selectedIndex', 0);\n}\nfunction createAssignedEmployeeDesign(s, x, employeeList) {\n var container = $('<div>').addClass('selectedEmployeeBubble'); // Create a div element and add a class\n var textSpan = $('<span>').addClass('ideaCardFont').text(s); // Create a span element, set text, and add a class\n var deleteButton = $('<button>').addClass('employeeDeleteButton').text('X'); // Create a button element, set text, and add a class\n deleteButton.on('click', function () {\n container.remove();\n employeeList.append(x);\n employeeList.prop('selectedIndex', 0);\n //removes from global list\n var index = selectedEmployees.indexOf(String(x.val()));\n if (index !== -1) {\n selectedEmployees.splice(index, 1);\n }\n });\n container.append(textSpan, deleteButton); // Append the span and button to the div container\n return container;\n}\n//Functions to load the page\nfunction clearFromEventListeners(container) {\n var clonedContainer = container.cloneNode(true);\n container.replaceWith(clonedContainer);\n console.log(\"cleared\");\n}\nfunction loadPage(id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var container, linkelementCSS, linkQuestionCSS, linkActivitycardCSS, scriptElement, generatedHTML, generatedElement;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n console.log(id);\n container = document.querySelector('#container-fluid');\n if (container) {\n _context2.next = 4;\n break;\n }\n return _context2.abrupt(\"return\");\n case 4:\n // Stop if the container isn't found\n linkelementCSS = document.createElement('link');\n linkelementCSS.rel = 'styleSheet';\n linkelementCSS.href = 'initiateForbattringsarbete/initiateIdea.css';\n document.head.appendChild(linkelementCSS);\n linkQuestionCSS = document.createElement('link');\n linkQuestionCSS.rel = 'styleSheet';\n linkQuestionCSS.href = 'Make_Suggestion_Code/makeSuggestion.css';\n document.head.appendChild(linkQuestionCSS);\n linkActivitycardCSS = document.createElement(\"link\");\n linkActivitycardCSS.rel = \"stylesheet\";\n linkActivitycardCSS.href = 'Activity_card_code/activitity_card.css';\n document.head.appendChild(linkActivitycardCSS);\n scriptElement = document.createElement(\"script\");\n scriptElement.src = \"../dist/initiateIdea.bundle.js\";\n container.appendChild(scriptElement);\n _context2.next = 21;\n return generateQuestionHTML(id);\n case 21:\n generatedHTML = _context2.sent;\n generatedElement = document.createRange().createContextualFragment(generatedHTML);\n fetch('initiateForbattringsarbete/initiateIdea.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.initiateIdeaWholePage');\n //Eventlistenerbuttons:\n var createButton = document.getElementById('createProjectFromSuggestionButton');\n var selectEmployeeButton = document.getElementById('selectEmployee');\n document.addEventListener(\"click\", function (event) {\n var target = event.target;\n //adds an event listener for the initiate page \n if (target.id === \"createProjectFromSuggestionButton\") {\n createProject();\n }\n });\n document.addEventListener(\"change\", function (event) {\n var target = event.target;\n //adds an event listener for the initiate page \n if (target.id === \"selectEmployee\") {\n assignedEmployer();\n }\n });\n if (specificElement) {\n // Insert the generated element before the specific element\n container.insertBefore(generatedElement, container.firstChild);\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n selectedEmployees = []; //clears the global employee list\n loadEmployees();\n }\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n case 24:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction createProject() {\n var inputSelectProjectleaderInput = document.getElementById(\"projectLeader\");\n var selectDepartment = document.getElementById(\"selectHospital\");\n var selectUnit = document.getElementById(\"selectDepartment\");\n var inputBoxFormNameInput = document.getElementById(\"inputBoxFormNameInput\");\n var inputBoxFormAreaInput = document.getElementById(\"inputBoxFormAreaInput\");\n var inputBoxFormContentInput = document.getElementById(\"inputBoxFormContentInput\");\n var inputBoxFormPurposeInput = document.getElementById(\"inputBoxFormPurposeInput\");\n var inputBoxFormMeasureInput = document.getElementById(\"inputBoxFormMeasureInput\");\n var inputBoxFormIdeasInput = document.getElementById(\"inputBoxFormIdeasInput\");\n alert(\"Kul att du försöker! Detta är inte klart ännu... \\n Däremot är värdena följande: \\n\" + inputSelectProjectleaderInput.options[inputSelectProjectleaderInput.selectedIndex].value + \"\\n\" + selectDepartment.options[selectDepartment.selectedIndex].value + \"\\n\" + selectUnit.options[selectUnit.selectedIndex].value + \"\\n\" + selectedEmployees + \"\\n\" + inputBoxFormNameInput.value + \"\\n\" + inputBoxFormAreaInput.value + \"\\n\" + inputBoxFormContentInput.value + \"\\n\" + inputBoxFormPurposeInput.value + \"\\n\" + inputBoxFormMeasureInput.value + \"\\n\" + inputBoxFormIdeasInput.value + \"\\n\");\n console.log(selectedEmployees);\n}\nfunction generateQuestionHTML(suggestionID) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var suggestionData;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_0__.getObjectById)(\"suggestion\", suggestionID);\n case 2:\n suggestionData = _context3.sent;\n return _context3.abrupt(\"return\", \"\\n <div class=\\\"filter-section\\\">\\n <div class=\\\"makeSuggestionFilterButtons\\\">\\n <select name=\\\"department\\\" id=\\\"selectHospital\\\" class=\\\"filterButtons\\\"> </select>\\n\\n <select name=\\\"section\\\" id=\\\"selectDepartment\\\" class=\\\"filterButtons\\\">\\n </select>\\n\\n </div>\\n</div>\\n\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">Rubrik *</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormName\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormNameInput\\\"\\n placeholder=\\\"Vad vill du kalla ditt f\\xF6rslag?\\\"\\n value = \\\"\" + suggestionData.name + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Vilket \\xE4r omr\\xE5det f\\xF6r f\\xF6rb\\xE4ttringen? *\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormArea\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormAreaInput\\\"\\n placeholder=\\\"Ber\\xE4tta om omr\\xE5de ditt f\\xF6rslag hade f\\xF6rb\\xE4ttrat.\\\"\\n value = \\\"\" + suggestionData.area + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\" id=\\\"middleShadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">Bakgrund *</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormContent\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormContentInput\\\"\\n placeholder=\\\"Beskriv problemet\\\"\\n value = \\\"\" + suggestionData.content + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Vilket syfte har f\\xF6rb\\xE4ttringen? *\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormPurpose\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormPurposeInput\\\"\\n placeholder=\\\"Vad ska \\xE5stadkommas och varf\\xF6r? Kom ih\\xE5g att f\\xE5 med patientperspektivet\\\"\\n value = \\\"\" + suggestionData.purpose + \"\\\"\\n required\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">\\n Hur ska det m\\xE4tas?\\n </p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormMeasure\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormMeasureInput\\\"\\n placeholder=\\\"Hur vet vi att en f\\xF6r\\xE4ndring \\xE4r en f\\xF6rb\\xE4ttring?\\\"\\n value = \\\"\" + suggestionData.measure + \"\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n\\n<div class=\\\"activityCard\\\" id=\\\"suggestionCard\\\">\\n<div class=\\\"activityCardBorder\\\">\\n <div class=\\\"shadowText\\\">\\n <p id=\\\"suggestionQuestion\\\" class=\\\"activityCardFont\\\">Id\\xE9er</p>\\n </div>\\n <div class=\\\"inputBox\\\">\\n <form\\n action=\\\"/url\\\"\\n method=\\\"POST\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeas\\\"\\n >\\n <input\\n type=\\\"text\\\"\\n class=\\\"inputBoxForm\\\"\\n id=\\\"inputBoxFormIdeasInput\\\"\\n placeholder=\\\"Vilka f\\xF6r\\xE4ndringar kan pr\\xF6vas f\\xF6r att uppn\\xE5 en f\\xF6rb\\xE4ttring?\\\"\\n value = \\\"\" + suggestionData.ideas + \"\\\"\\n />\\n </form>\\n </div>\\n</div>\\n</div>\\n<button id=\\\"createProjectFromSuggestionButton\\\">Skapa f\\xF6rb\\xE4ttringsarbete!</button>\");\n case 4:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/initiateForbattringsarbete/initiateIdea.js?"); /***/ }), @@ -316,7 +316,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \********************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nfunction loadPage(projectId) {\n var container = document.querySelector('#container-fluid');\n var nextPageButton = document.getElementById('toCurrentProjects');\n if (!container) return; // Stop if the container isn't found\n fetch('projectPage/ProjectPageA.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.wholePageA');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n initializeTooltips();\n }\n });\n container.addEventListener('click', function (event) {\n var target = event.target; // Type assertion\n if (target.id === 'toCurrentProjects') {\n finalize(projectId);\n } else if (target.id === 'toP') {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageP)(projectId);\n } else if (target.id === 'toG') {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageG)(projectId);\n } else if (target.id === 'toS') {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageS)(projectId);\n }\n });\n function initializeTooltips() {\n // Use jQuery to select the elements and initialize the tooltip\n $('[data-toggle=\"tooltip\"]').tooltip({\n delay: {\n \"show\": 0,\n \"hide\": 100\n }\n });\n }\n}\nfunction finalize(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var user, userId;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n user = localStorage.getItem('user');\n if (user) {\n userId = JSON.parse(user)[0].id;\n }\n console.log(userId);\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.finalizeImprovementWork)(userId, projectId);\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadCurrentProjects)();\n case 5:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPageA.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nfunction updateStage(stage, id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", id, {\n currentStage: stage\n });\n case 1:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction loadPage(projectId) {\n var container = document.querySelector('#container-fluid');\n var nextPageButton = document.getElementById('toCurrentProjects');\n if (!container) return; // Stop if the container isn't found\n updateStage(\"Agera\", projectId);\n fetch('projectPage/ProjectPageA.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.wholePageA');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n initializeTooltips();\n }\n });\n container.addEventListener('click', function (event) {\n var target = event.target; // Type assertion\n if (target.id === 'toCurrentProjects') {\n updateStage(\"Avslutat\", projectId);\n finalize(projectId);\n } else if (target.id === 'toP') {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageP)(projectId);\n } else if (target.id === 'toG') {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageG)(projectId);\n } else if (target.id === 'toS') {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageS)(projectId);\n } else if (target.id === \"saveEditBtnA\") {\n saveImprovementWorkEditA(projectId);\n }\n });\n function initializeTooltips() {\n // Use jQuery to select the elements and initialize the tooltip\n $('[data-toggle=\"tooltip\"]').tooltip({\n delay: {\n \"show\": 0,\n \"hide\": 100\n }\n });\n }\n loadImprovementWorkDataPageA(projectId);\n}\nfunction loadImprovementWorkDataPageA(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var improvementWork, title, a1, a2, a3, a4;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)('improvementWork', projectId);\n case 2:\n improvementWork = _context2.sent;\n title = document.getElementById(\"title\");\n a1 = document.getElementById(\"a1\");\n a2 = document.getElementById(\"a2\");\n a3 = document.getElementById(\"a3\");\n a4 = document.getElementById(\"a4\");\n title.textContent = improvementWork.name;\n a1.value = improvementWork.a1;\n a2.value = improvementWork.a2;\n a3.value = improvementWork.a3;\n a4.value = improvementWork.a4;\n case 13:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction finalize(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var user, userId;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n user = localStorage.getItem('user');\n if (user) {\n userId = JSON.parse(user)[0].id;\n }\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.finalizeImprovementWork)(userId, projectId);\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadCurrentProjects)();\n case 4:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction saveImprovementWorkEditA(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var a1, a2, a3, a4, update;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n a1 = document.getElementById(\"a1\");\n a2 = document.getElementById(\"a2\");\n a3 = document.getElementById(\"a3\");\n a4 = document.getElementById(\"a4\");\n update = {\n a1: a1.value,\n a2: a2.value,\n a3: a3.value,\n a4: a4.value\n };\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", projectId, update);\n case 6:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPageA.js?"); /***/ }), @@ -326,7 +326,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \********************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n\nfunction loadPage(projectId) {\n var container = document.querySelector('#container-fluid');\n var nextPageButton = document.getElementById('toS');\n if (!container) return; // Stop if the container isn't found\n fetch('projectPage/ProjectPageG.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.wholePageG');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n initializeTooltips();\n }\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n container.addEventListener('click', function (event) {\n var target = event.target; // Type assertion\n if (target.id === 'toS') {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageS)(projectId);\n } else if (target.id === 'toP') {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageP)(projectId);\n }\n });\n function initializeTooltips() {\n // Use jQuery to select the elements and initialize the tooltip\n $('[data-toggle=\"tooltip\"]').tooltip({\n delay: {\n \"show\": 0,\n \"hide\": 100\n }\n });\n }\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPageG.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\nfunction updateStage(stage, id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", id, {\n currentStage: stage\n });\n case 1:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction loadPage(projectId) {\n var container = document.querySelector('#container-fluid');\n var nextPageButton = document.getElementById('toS');\n if (!container) return; // Stop if the container isn't found\n updateStage(\"Göra\", projectId);\n fetch('projectPage/ProjectPageG.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.wholePageG');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n initializeTooltips();\n }\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n container.addEventListener('click', function (event) {\n var target = event.target; // Type assertion\n if (target.id === 'toS') {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageS)(projectId);\n } else if (target.id === 'toP') {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageP)(projectId);\n } else if (target.id === \"saveEditBtnG\") {\n saveImprovementWorkEditG(projectId);\n }\n });\n loadImprovementWorkDataPageG(projectId);\n function initializeTooltips() {\n // Use jQuery to select the elements and initialize the tooltip\n $('[data-toggle=\"tooltip\"]').tooltip({\n delay: {\n \"show\": 0,\n \"hide\": 100\n }\n });\n }\n}\nfunction loadImprovementWorkDataPageG(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var improvementWork, title, g1, g2, g3, g4, g5;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)('improvementWork', projectId);\n case 2:\n improvementWork = _context2.sent;\n title = document.getElementById(\"title\");\n g1 = document.getElementById(\"g1\");\n g2 = document.getElementById(\"g2\");\n g3 = document.getElementById(\"g3\");\n g4 = document.getElementById(\"g4\");\n g5 = document.getElementById(\"g5\");\n title.textContent = improvementWork.name;\n g1.value = improvementWork.g1;\n g2.value = improvementWork.g2;\n g3.value = improvementWork.g3;\n g4.value = improvementWork.g4;\n g5.value = improvementWork.g5;\n case 15:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction saveImprovementWorkEditG(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var g1, g2, g3, g4, g5, update;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n g1 = document.getElementById(\"g1\");\n g2 = document.getElementById(\"g2\");\n g3 = document.getElementById(\"g3\");\n g4 = document.getElementById(\"g4\");\n g5 = document.getElementById(\"g5\");\n update = {\n g1: g1.value,\n g2: g2.value,\n g3: g3.value,\n g4: g4.value,\n g5: g5.value\n };\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", projectId, update);\n case 7:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPageG.js?"); /***/ }), @@ -336,7 +336,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \********************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\nfunction loadPage(projectId) {\n var container = document.querySelector('#container-fluid');\n var nextPageButton = document.getElementById('toG');\n if (!container) return; // Stop if the container isn't found\n fetch('projectPage/ProjectPageP.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.wholePageP');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n initializeTooltips();\n }\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n container.addEventListener('click', function (event) {\n var target = event.target; // Type assertion\n if (target.matches('[data-toggle=\"tooltip\"]') && !target.dataset.tooltipInitialized) {\n $(target).tooltip();\n target.dataset.tooltipInitialized = 'true';\n }\n if (target.id === 'toG') {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageG)(projectId);\n }\n });\n loadImprovementWorkDataPageP(projectId);\n}\nfunction initializeTooltips() {\n // Use jQuery to select the elements and initialize the tooltip\n $('[data-toggle=\"tooltip\"]').tooltip({\n delay: {\n \"show\": 0,\n \"hide\": 100\n }\n });\n}\nfunction loadImprovementWorkDataPageP(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var data;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)('improvementWork', projectId);\n case 2:\n data = _context.sent;\n console.log(data.name);\n case 4:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPageP.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\nfunction updateStage(stage, id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", id, {\n currentStage: stage\n });\n case 1:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction loadPage(projectId) {\n var container = document.querySelector('#container-fluid');\n var nextPageButton = document.getElementById('toG');\n if (!container) return; // Stop if the container isn't found\n updateStage(\"Planera\", projectId);\n fetch('projectPage/ProjectPageP.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.wholePageP');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n initializeTooltips();\n }\n })[\"catch\"](function (error) {\n console.error('Failed to load the external HTML file:', error);\n });\n container.addEventListener('click', function (event) {\n var target = event.target; // Type assertion\n if (target.matches('[data-toggle=\"tooltip\"]') && !target.dataset.tooltipInitialized) {\n $(target).tooltip();\n target.dataset.tooltipInitialized = 'true';\n }\n if (target.id === 'toG') {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageG)(projectId);\n }\n if (target.id === \"saveEditBtnP\") {\n saveImprovementWorkEditP(projectId);\n }\n });\n loadImprovementWorkDataPageP(projectId);\n}\nfunction initializeTooltips() {\n // Use jQuery to select the elements and initialize the tooltip\n $('[data-toggle=\"tooltip\"]').tooltip({\n delay: {\n \"show\": 0,\n \"hide\": 100\n }\n });\n}\nfunction loadImprovementWorkDataPageP(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var improvementWork, titleP, p1, p2, p3, p4, p5, p6, p7;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)('improvementWork', projectId);\n case 2:\n improvementWork = _context2.sent;\n titleP = document.getElementById(\"title\");\n p1 = document.getElementById(\"p1\");\n p2 = document.getElementById(\"p2\");\n p3 = document.getElementById(\"p3\");\n p4 = document.getElementById(\"p4\");\n p5 = document.getElementById(\"p5\");\n p6 = document.getElementById(\"p6\");\n p7 = document.getElementById(\"p7\");\n titleP.textContent = improvementWork.name;\n p1.value = improvementWork.p1;\n p2.value = improvementWork.p2;\n p3.value = improvementWork.p3;\n p4.value = improvementWork.p4;\n p5.value = improvementWork.p5;\n p6.value = improvementWork.p6;\n p7.value = improvementWork.p7;\n case 19:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction saveImprovementWorkEditP(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var p1, p2, p3, p4, p5, p6, p7, update;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n p1 = document.getElementById(\"p1\");\n p2 = document.getElementById(\"p2\");\n p3 = document.getElementById(\"p3\");\n p4 = document.getElementById(\"p4\");\n p5 = document.getElementById(\"p5\");\n p6 = document.getElementById(\"p6\");\n p7 = document.getElementById(\"p7\");\n update = {\n p1: p1.value,\n p2: p2.value,\n p3: p3.value,\n p4: p4.value,\n p5: p5.value,\n p6: p6.value,\n p7: p7.value\n };\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", projectId, update);\n case 9:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPageP.js?"); /***/ }), @@ -346,7 +346,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \********************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n\nfunction loadPage(projectId) {\n var container = document.querySelector('#container-fluid');\n var nextPageButton = document.getElementById('toA');\n if (!container) return; // Stop if the container isn't found\n fetch('projectPage/ProjectPageS.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.wholePageS');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n initializeTooltips();\n }\n });\n container.addEventListener('click', function (event) {\n var target = event.target; // Type assertion\n if (target.id === 'toA') {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageA)(projectId);\n } else if (target.id === 'toP') {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageP)(projectId);\n } else if (target.id === 'toG') {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageG)(projectId);\n }\n });\n function initializeTooltips() {\n // Use jQuery to select the elements and initialize the tooltip\n $('[data-toggle=\"tooltip\"]').tooltip({\n delay: {\n \"show\": 0,\n \"hide\": 100\n }\n });\n }\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPageS.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPage: () => (/* binding */ loadPage)\n/* harmony export */ });\n/* harmony import */ var _SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../SidebarAndHeader/pageHandler.js */ \"./client/SidebarAndHeader/pageHandler.js\");\n/* harmony import */ var _Database_database_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Database/database.js */ \"./client/Database/database.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\nfunction updateStage(stage, id) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", id, {\n currentStage: stage\n });\n case 1:\n case \"end\":\n return _context.stop();\n }\n }, _callee);\n }));\n}\nfunction loadPage(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var container, nextPageButton, initializeTooltips;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n initializeTooltips = function _initializeTooltips() {\n // Use jQuery to select the elements and initialize the tooltip\n $('[data-toggle=\"tooltip\"]').tooltip({\n delay: {\n \"show\": 0,\n \"hide\": 100\n }\n });\n };\n container = document.querySelector('#container-fluid');\n nextPageButton = document.getElementById('toA');\n if (container) {\n _context2.next = 5;\n break;\n }\n return _context2.abrupt(\"return\");\n case 5:\n // Stop if the container isn't found\n updateStage(\"Studera\", projectId);\n fetch('projectPage/ProjectPageS.html').then(function (response) {\n return response.text();\n }).then(function (data) {\n // Create a temporary container element to hold the loaded content\n var tempContainer = document.createElement('div');\n tempContainer.innerHTML = data;\n // Select the specific element with the class you want\n var specificElement = tempContainer.querySelector('.wholePageS');\n if (specificElement) {\n // Insert the specific element into the target element\n container.insertBefore(specificElement, container.firstChild);\n initializeTooltips();\n }\n });\n container.addEventListener('click', function (event) {\n var target = event.target; // Type assertion\n if (target.id === 'toA') {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageA)(projectId);\n } else if (target.id === 'toP') {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageP)(projectId);\n } else if (target.id === 'toG') {\n (0,_SidebarAndHeader_pageHandler_js__WEBPACK_IMPORTED_MODULE_0__.loadProjectPageG)(projectId);\n } else if (target.id === \"saveEditBtnS\") {\n saveImprovementWorkEditS(projectId);\n }\n });\n loadImprovementWorkDataPageS(projectId);\n case 9:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2);\n }));\n}\nfunction loadImprovementWorkDataPageS(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var improvementWork, title, s1, s2, s3;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.next = 2;\n return (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.getObjectById)('improvementWork', projectId);\n case 2:\n improvementWork = _context3.sent;\n title = document.getElementById(\"title\");\n s1 = document.getElementById(\"s1\");\n s2 = document.getElementById(\"s2\");\n s3 = document.getElementById(\"s3\");\n title.textContent = improvementWork.name;\n s1.value = improvementWork.s1;\n s2.value = improvementWork.s2;\n s3.value = improvementWork.s3;\n case 11:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3);\n }));\n}\nfunction saveImprovementWorkEditS(projectId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var s1, s2, s3, update;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n s1 = document.getElementById(\"s1\");\n s2 = document.getElementById(\"s2\");\n s3 = document.getElementById(\"s3\");\n update = {\n s1: s1.value,\n s2: s2.value,\n s3: s3.value\n };\n (0,_Database_database_js__WEBPACK_IMPORTED_MODULE_1__.updateInstance)(\"improvementWork\", projectId, update);\n case 5:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4);\n }));\n}\n\n//# sourceURL=webpack://c3/./client/projectPage/projectPageS.js?"); /***/ }), diff --git a/client/dist/register.bundle.js b/client/dist/register.bundle.js index 3a7dd5dbe6c1ca6b2e4a5efe69c5a5d852c9adf6..1d4c71fc2c134ca84beeb383abdc08b97830831a 100644 --- a/client/dist/register.bundle.js +++ b/client/dist/register.bundle.js @@ -106,7 +106,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \*************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addDocumentToImprovementWork: () => (/* binding */ addDocumentToImprovementWork),\n/* harmony export */ addMemberToImprovementWork: () => (/* binding */ addMemberToImprovementWork),\n/* harmony export */ addMemberToTask: () => (/* binding */ addMemberToTask),\n/* harmony export */ addNoteToUser: () => (/* binding */ addNoteToUser),\n/* harmony export */ auth: () => (/* binding */ auth),\n/* harmony export */ changePatientRiskLevel: () => (/* binding */ changePatientRiskLevel),\n/* harmony export */ createComment: () => (/* binding */ createComment),\n/* harmony export */ createHospital: () => (/* binding */ createHospital),\n/* harmony export */ createImprovementWork: () => (/* binding */ createImprovementWork),\n/* harmony export */ createSuggestion: () => (/* binding */ createSuggestion),\n/* harmony export */ createTaskOnImprovementWork: () => (/* binding */ createTaskOnImprovementWork),\n/* harmony export */ createUnit: () => (/* binding */ createUnit),\n/* harmony export */ createUser: () => (/* binding */ createUser),\n/* harmony export */ createdDocumentInKnowledgeBank: () => (/* binding */ createdDocumentInKnowledgeBank),\n/* harmony export */ db: () => (/* binding */ db),\n/* harmony export */ deleteAllDocumentsInCollection: () => (/* binding */ deleteAllDocumentsInCollection),\n/* harmony export */ deleteInstance: () => (/* binding */ deleteInstance),\n/* harmony export */ finalizeImprovementWork: () => (/* binding */ finalizeImprovementWork),\n/* harmony export */ getComments: () => (/* binding */ getComments),\n/* harmony export */ getHospitals: () => (/* binding */ getHospitals),\n/* harmony export */ getImprovementWorks: () => (/* binding */ getImprovementWorks),\n/* harmony export */ getObject: () => (/* binding */ getObject),\n/* harmony export */ getObjectById: () => (/* binding */ getObjectById),\n/* harmony export */ getSuggestions: () => (/* binding */ getSuggestions),\n/* harmony export */ getTasks: () => (/* binding */ getTasks),\n/* harmony export */ getUnits: () => (/* binding */ getUnits),\n/* harmony export */ getUsers: () => (/* binding */ getUsers),\n/* harmony export */ startOrPauseImprovementWork: () => (/* binding */ startOrPauseImprovementWork),\n/* harmony export */ updateInstance: () => (/* binding */ updateInstance),\n/* harmony export */ upvoteComment: () => (/* binding */ upvoteComment),\n/* harmony export */ upvoteSuggestion: () => (/* binding */ upvoteSuggestion)\n/* harmony export */ });\n/* harmony import */ var firebase_app__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! firebase/app */ \"./node_modules/firebase/app/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_firestore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! firebase/firestore */ \"./node_modules/firebase/firestore/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_auth__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! firebase/auth */ \"./node_modules/firebase/auth/dist/esm/index.esm.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nvar firebaseConfig = {\n apiKey: \"AIzaSyDqkaVZMr11J4mfnR0auqoQilZyPfyD-x4\",\n authDomain: \"c3solutions-dc109.firebaseapp.com\",\n projectId: \"c3solutions-dc109\",\n storageBucket: \"c3solutions-dc109.appspot.com\",\n messagingSenderId: \"902143402555\",\n appId: \"1:902143402555:web:29213e81de0a0cba38b21e\"\n};\nvar app = (0,firebase_app__WEBPACK_IMPORTED_MODULE_0__.initializeApp)(firebaseConfig);\nvar auth = (0,firebase_auth__WEBPACK_IMPORTED_MODULE_2__.getAuth)();\nvar db = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getFirestore)(app);\nvar userCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\nvar unitCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\nvar improvementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\nvar taskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\nvar hospitalCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\nvar suggestionCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\nvar knowledgeDocumentCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"knowledgeDocument\");\n////////////////////////////////////////Setters///////////////////////////////////////////////////////////////////\n// Function to create user a new user in database\n// takes in userId, unitId, firstname, lastname, email and password as string\n// throws error if transaction failed\nfunction createUser(hsaId, unitId, firstName, lastName, email, manager, uid) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var userRef, unitRef;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, hsaId);\n _context.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(userRef, {\n id: userRef.id,\n uid: uid,\n unitId: unitId,\n firstName: firstName,\n lastName: lastName,\n email: email,\n improvementWorks: [],\n tasks: [],\n manager: manager\n });\n case 4:\n // Atomically add user to unit.\n unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection, unitId);\n _context.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(unitRef, {\n members: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userRef.id)\n });\n case 7:\n _context.next = 12;\n break;\n case 9:\n _context.prev = 9;\n _context.t0 = _context[\"catch\"](0);\n console.log(_context.t0);\n case 12:\n case \"end\":\n return _context.stop();\n }\n }, _callee, null, [[0, 9]]);\n }));\n}\n//Adds a new improvementWork to the database\n// takes in Id, name, currentStage in PDSA, content, unitId refers to as string and if completed as boolean\n// throws error if transaction failed\nfunction createImprovementWork(id, name, currentStage, content,\n// Är detta description bör detta förtydligas. \nunitId, purpose,\n//Bör tas bort motsvaras av p2- mål med projektet\npatientRiskLevel, area,\n// patientRiskLevel: \"Green\" | \"Blue\" | \"Orange\" | \"Red\"\n//Questions in planning stage\np1, p2, p3, p4, p5, p6, p7,\n//Questions in Doing (G) stage\ng1, g2, g3, g4, g5,\n//Questions in stydy stage\ns1, s2, s3,\n//Questions in acting stage\na1, a2, a3, a4) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var improvementWorkRef;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.prev = 0;\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, id);\n _context2.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(improvementWorkRef, {\n id: improvementWorkRef.id,\n currentStage: currentStage,\n name: name,\n content: content,\n purpose: purpose,\n dateStarted: new Date(),\n unitId: unitId,\n completed: false,\n ongoing: false,\n tasks: [],\n members: [],\n patientRiskLevel: patientRiskLevel,\n area: area,\n p1: p1,\n p2: p2,\n p3: p3,\n p4: p4,\n p5: p5,\n p6: p6,\n p7: p7,\n g1: g1,\n g2: g2,\n g3: g3,\n g4: g4,\n g5: g5,\n s1: s1,\n s2: s2,\n s3: s3,\n a1: a1,\n a2: a2,\n a3: a3,\n a4: a4\n });\n case 4:\n _context2.next = 10;\n break;\n case 6:\n _context2.prev = 6;\n _context2.t0 = _context2[\"catch\"](0);\n console.log(\"Error creating improvementWork: \", _context2.t0);\n throw _context2.t0;\n case 10:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, null, [[0, 6]]);\n }));\n}\n//create task to improvementWork\n// takes in improvementWorkId, name, deadline date, start date, stage in PDSA and content as string\n// throws error if transaction failed\nfunction createTaskOnImprovementWork(taskId, improvementWorkId, name, deadlineDate, startDate, stage, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var ref, improvementWorkRef;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.prev = 0;\n ref = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection, taskId);\n _context3.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(ref, {\n id: ref.id,\n improvementWorkId: improvementWorkId,\n name: name,\n deadlineDate: deadlineDate,\n startDate: startDate,\n stage: stage,\n content: content,\n members: []\n });\n case 4:\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, improvementWorkId); // Atomically add task to the tasks array field.\n _context3.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(improvementWorkRef, {\n tasks: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(taskId)\n });\n case 7:\n _context3.next = 13;\n break;\n case 9:\n _context3.prev = 9;\n _context3.t0 = _context3[\"catch\"](0);\n console.log(\"Error creating task: \", _context3.t0);\n throw _context3.t0;\n case 13:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, null, [[0, 9]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction createdDocumentInKnowledgeBank(documentUrl, name) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n _context4.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(knowledgeDocumentCollection);\n _context4.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n name: name\n });\n case 4:\n _context4.next = 10;\n break;\n case 6:\n _context4.prev = 6;\n _context4.t0 = _context4[\"catch\"](0);\n console.log(\"Error adding document: \", _context4.t0);\n throw _context4.t0;\n case 10:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4, null, [[0, 6]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction addDocumentToImprovementWork(documentUrl, name, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var improvementWorkRef, docRef;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n _context5.prev = 0;\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, improvementWorkId);\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkRef, \"documents\");\n _context5.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n timestamp: new Date(),\n name: name\n });\n case 5:\n _context5.next = 11;\n break;\n case 7:\n _context5.prev = 7;\n _context5.t0 = _context5[\"catch\"](0);\n console.log(\"Error adding document: \", _context5.t0);\n throw _context5.t0;\n case 11:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5, null, [[0, 7]]);\n }));\n}\n//add a member to a improvementWork\n// takes in id, users HSAid, improvementWorks id as string and if is owner, is responsible as boolean\n// throws error if transaction failed\nfunction addMemberToImprovementWork(userHsaId, improvementWorkId, isOwner, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var improvementWorkRef, userRef;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n _context6.prev = 0;\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, improvementWorkId); // return;\n // Atomically update the members array in the improvementWork document\n _context6.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(improvementWorkRef, {\n members: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)({\n userHsaId: userHsaId,\n isOwner: isOwner,\n isResponsibleFor: isResponsibleFor\n })\n });\n case 4:\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, userHsaId); // Atomically add improvementWork to user\n _context6.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(userRef, {\n improvementWorks: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)({\n improvementWorkId: improvementWorkId,\n isOwner: isOwner,\n isResponsibleFor: isResponsibleFor\n })\n });\n case 7:\n _context6.next = 13;\n break;\n case 9:\n _context6.prev = 9;\n _context6.t0 = _context6[\"catch\"](0);\n console.log(\"Error adding member: \", _context6.t0);\n throw _context6.t0;\n case 13:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6, null, [[0, 9]]);\n }));\n}\n//create a hospital\n// takes in ID, name as string\n// throws error if transaction failed\nfunction createHospital(hospitalId,\n// should be auto?\nname) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var ref;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.prev = 0;\n ref = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection, hospitalId);\n _context7.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(ref, {\n id: ref.id,\n name: name,\n units: []\n });\n case 4:\n _context7.next = 10;\n break;\n case 6:\n _context7.prev = 6;\n _context7.t0 = _context7[\"catch\"](0);\n console.log(\"Error creating hospital: \", _context7.t0);\n throw _context7.t0;\n case 10:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7, null, [[0, 6]]);\n }));\n}\n//create a unit\n// takes in id, hospitals id and name as string\n// throws error if transaction failed\nfunction createUnit(unitId,\n//should be auto?\nhospitalId, name) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var unitRef, hospitalRef;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n _context8.prev = 0;\n unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection, unitId);\n _context8.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(unitRef, {\n id: unitRef.id,\n hospitalId: hospitalId,\n name: name,\n members: []\n });\n case 4:\n // Atomically add unit to hospital.\n hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection, hospitalId);\n _context8.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(hospitalRef, {\n units: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(unitRef.id)\n });\n case 7:\n _context8.next = 13;\n break;\n case 9:\n _context8.prev = 9;\n _context8.t0 = _context8[\"catch\"](0);\n console.log(\"Error creating unit: \", _context8.t0);\n throw _context8.t0;\n case 13:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8, null, [[0, 9]]);\n }));\n}\n//adds a member to task\n// takes in ID, the added members hsaId, task id as string and if person is responsible as boolean\n// throws error if transaction failed\nfunction addMemberToTask(userHsaId, taskId, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var taskRef, userRef;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n _context9.prev = 0;\n // Atomically add a member to task.\n taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection, taskId);\n _context9.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(taskRef, {\n members: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)({\n userHsaId: userHsaId,\n isResponsibleFor: isResponsibleFor\n })\n });\n case 4:\n // Atomically add a task to user.\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, userHsaId);\n _context9.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(userRef, {\n tasks: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)({\n taskId: taskId,\n isResponsibleFor: isResponsibleFor\n })\n });\n case 7:\n _context9.next = 13;\n break;\n case 9:\n _context9.prev = 9;\n _context9.t0 = _context9[\"catch\"](0);\n console.log(\"Error adding member: \", _context9.t0);\n throw _context9.t0;\n case 13:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9, null, [[0, 9]]);\n }));\n}\n//creates a suggestion\n// takes in ID, the creators hsaId, name, content and the responding unitId as string\n// throws error if transaction failed\nfunction createSuggestion(id, creatorHsaId, name, area, content, purpose, measure, ideas,\n//need: boolean,\nunitId, departmentId, isPublic) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var suggestionRef, commentCollection;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n _context10.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, id);\n _context10.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(suggestionRef, {\n id: suggestionRef.id,\n creatorHsaId: creatorHsaId,\n name: name,\n area: area,\n content: content,\n purpose: purpose,\n measure: measure,\n ideas: ideas,\n //need: need,\n unitId: unitId,\n departmentId: departmentId,\n \"public\": isPublic,\n upvotes: [],\n comments: [],\n dateCreated: new Date()\n });\n case 4:\n _context10.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\");\n case 6:\n commentCollection = _context10.sent;\n _context10.next = 9;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(commentCollection);\n case 9:\n _context10.next = 15;\n break;\n case 11:\n _context10.prev = 11;\n _context10.t0 = _context10[\"catch\"](0);\n console.log(\"Error creating suggestion: \", _context10.t0);\n throw _context10.t0;\n case 15:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10, null, [[0, 11]]);\n }));\n}\n// Upvote a suggestion for a user\n// takes in suggestion id, user HSAid\n// returns error if transaction failed\nfunction upvoteSuggestion(suggestionId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var suggestionRef;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n _context11.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId); // Atomically add a update to the upvote array field.\n _context11.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(suggestionRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 4:\n _context11.next = 10;\n break;\n case 6:\n _context11.prev = 6;\n _context11.t0 = _context11[\"catch\"](0);\n console.log(\"Error upvoting suggestion: \", _context11.t0);\n throw _context11.t0;\n case 10:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11, null, [[0, 6]]);\n }));\n}\n//creates a comment\n// takes in commenters id, suggestion id and content as string\n// throws error if transaction failed\nfunction createComment(\n// change to subcollection\ncommenterHsaId, suggestionId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var suggestionRef, commentCollection, commentRef;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n _context12.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context12.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\");\n case 4:\n commentCollection = _context12.sent;\n _context12.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(commentCollection);\n case 7:\n commentRef = _context12.sent;\n _context12.next = 10;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(commentRef, {\n id: commentRef.id,\n commenterHsaId: commenterHsaId,\n content: content,\n dateCreated: new Date(),\n upvotes: []\n });\n case 10:\n _context12.next = 16;\n break;\n case 12:\n _context12.prev = 12;\n _context12.t0 = _context12[\"catch\"](0);\n console.log(\"Error creating comment: \", _context12.t0);\n throw _context12.t0;\n case 16:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12, null, [[0, 12]]);\n }));\n}\n// Upvote a comment for a user\n// takes in suggestionId, commentId and userId as strings\n// return error if transaction failed\nfunction upvoteComment(suggestionId, commentId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var suggestionRef, commentRef;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n _context13.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n commentRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionRef, \"comment\", commentId); // Atomically add a update to the upvote array field.\n _context13.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(commentRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 5:\n _context13.next = 11;\n break;\n case 7:\n _context13.prev = 7;\n _context13.t0 = _context13[\"catch\"](0);\n console.log(\"Error upvoting comment: \", _context13.t0);\n throw _context13.t0;\n case 11:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13, null, [[0, 7]]);\n }));\n}\n//add a note to a user\n// takes in userHsaId and content as string\n// throws error if transaction failed\nfunction addNoteToUser(userHsaId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var userRef, docRef;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n _context14.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, userHsaId);\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userRef, \"notes\");\n _context14.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n content: content,\n dateCreated: new Date()\n });\n case 5:\n _context14.next = 11;\n break;\n case 7:\n _context14.prev = 7;\n _context14.t0 = _context14[\"catch\"](0);\n console.log(\"Error adding document: \", _context14.t0);\n throw _context14.t0;\n case 11:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14, null, [[0, 7]]);\n }));\n}\n// export to setters to be able to use in other files\n\n//////////////////////////////////////////////GETTERS/////////////////////////////////////////////////////////////////////\n// Get any object\n// input is the database type as a string.\n// output is the whole collection of that type.\nfunction getObject(collectionPath) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n var collectionRef, querySnapshot, result;\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n _context15.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionPath);\n _context15.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n querySnapshot = _context15.sent;\n result = [];\n querySnapshot.forEach(function (doc) {\n result.push(doc.data());\n });\n return _context15.abrupt(\"return\", result);\n case 10:\n _context15.prev = 10;\n _context15.t0 = _context15[\"catch\"](0);\n console.error(\"Error getting collection data\", _context15.t0);\n throw _context15.t0;\n case 14:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15, null, [[0, 10]]);\n }));\n}\n/**\n * Asynchronously retrieves a single document object from the specified collection path and document ID.\n * If the document does not exist, logs a warning and returns null.\n *\n * @param {string} collectionPath - The path to the collection in the database (\"improvementWork\", \"hospital\", \"suggestion\", \"task\", \"unit\", \"users\")\n * @param {string} documentId - The ID of the document to retrieve.\n * @returns {Promise<any|null>} A promise that resolves to the document object if found, or null if not.\n *\n * @throws Will throw an error if there is an issue during retrieval from the database.\n */\nfunction getObjectById(collectionPath, documentId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {\n var docRef, docSnapshot;\n return _regeneratorRuntime().wrap(function _callee16$(_context16) {\n while (1) switch (_context16.prev = _context16.next) {\n case 0:\n _context16.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, collectionPath, documentId);\n _context16.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDoc)(docRef);\n case 4:\n docSnapshot = _context16.sent;\n if (!docSnapshot.exists()) {\n _context16.next = 9;\n break;\n }\n return _context16.abrupt(\"return\", docSnapshot.data());\n case 9:\n console.warn(\"No such document! \".concat(collectionPath, \"/\").concat(documentId));\n return _context16.abrupt(\"return\", null);\n case 11:\n _context16.next = 17;\n break;\n case 13:\n _context16.prev = 13;\n _context16.t0 = _context16[\"catch\"](0);\n console.error(\"Error getting object\", _context16.t0);\n throw _context16.t0;\n case 17:\n case \"end\":\n return _context16.stop();\n }\n }, _callee16, null, [[0, 13]]);\n }));\n}\n/**\n * Asynchronously retrieves comments for a given suggestion.\n *\n * @param {Object} params - The parameters for fetching comments.\n * @param {string} params.suggestionId - The ID of the suggestion to fetch comments for.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - The criterion to sort the comments by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Determines if the sorting should be in ascending order. Defaults to false (descending).\n * @returns {Promise<any[]>} A promise that resolves to an array of comment objects.\n *\n * @throws Will throw an error if the comments cannot be retrieved.\n */\nfunction getComments(_ref) {\n var suggestionId = _ref.suggestionId,\n _ref$sortBy = _ref.sortBy,\n sortBy = _ref$sortBy === void 0 ? \"dateCreated\" : _ref$sortBy,\n _ref$ascending = _ref.ascending,\n ascending = _ref$ascending === void 0 ? false : _ref$ascending;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {\n var suggestionRef, commentsQuery, commentsSnapshot, comments;\n return _regeneratorRuntime().wrap(function _callee17$(_context17) {\n while (1) switch (_context17.prev = _context17.next) {\n case 0:\n _context17.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, \"suggestionCollection\", suggestionId);\n commentsQuery = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\"), (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n _context17.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(commentsQuery);\n case 5:\n commentsSnapshot = _context17.sent;\n comments = [];\n commentsSnapshot.forEach(function (doc) {\n comments.push(doc.data());\n });\n return _context17.abrupt(\"return\", comments);\n case 11:\n _context17.prev = 11;\n _context17.t0 = _context17[\"catch\"](0);\n console.error(\"Error getting comments for suggestion: \", _context17.t0);\n throw _context17.t0;\n case 15:\n case \"end\":\n return _context17.stop();\n }\n }, _callee17, null, [[0, 11]]);\n }));\n}\n//Filtering suggestions on unitId AND creatorHsaId\n//Sort suggestions on dateCreated OR upvotes\n/**\n * Asynchronously retrieves an array of suggestions from the database, with various filters and sorting options.\n *\n * @param {Object} params - The parameters for filtering and sorting suggestions.\n * @param {string} [params.id] - Optional ID to filter suggestions by a specific identifier.\n * @param {string} [params.creatorHsaId] - Optional HSA ID to filter suggestions by the creator's HSA ID.\n * @param {string} [params.unitId] - Optional unit ID to filter suggestions by a specific unit.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - Criterion to sort the suggestions by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Flag indicating if sorting should be ascending. Defaults to false (descending order).\n * @param {boolean} [params.isPublic=true] - Flag indicating whether to filter for public suggestions. Defaults to true.\n * @returns {Promise<any[]>} A promise that resolves to an array of suggestion objects.\n *\n * @throws Will throw an error if there is an issue retrieving suggestions.\n */\nfunction getSuggestions(_ref2) {\n var id = _ref2.id,\n creatorHsaId = _ref2.creatorHsaId,\n unitId = _ref2.unitId,\n _ref2$sortBy = _ref2.sortBy,\n sortBy = _ref2$sortBy === void 0 ? \"dateCreated\" : _ref2$sortBy,\n _ref2$ascending = _ref2.ascending,\n ascending = _ref2$ascending === void 0 ? false : _ref2$ascending,\n _ref2$isPublic = _ref2.isPublic,\n isPublic = _ref2$isPublic === void 0 ? true : _ref2$isPublic;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {\n var collectionRef, constraints, q, querySnapshot, suggestions;\n return _regeneratorRuntime().wrap(function _callee18$(_context18) {\n while (1) switch (_context18.prev = _context18.next) {\n case 0:\n _context18.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (creatorHsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"creatorHsaId\", \"==\", creatorHsaId));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"public\", \"==\", isPublic));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context18.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 11:\n querySnapshot = _context18.sent;\n suggestions = [];\n querySnapshot.forEach(function (doc) {\n suggestions.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context18.abrupt(\"return\", suggestions);\n case 17:\n _context18.prev = 17;\n _context18.t0 = _context18[\"catch\"](0);\n console.log(\"Error retrieving suggestions by department: \", _context18.t0);\n throw _context18.t0;\n case 21:\n case \"end\":\n return _context18.stop();\n }\n }, _callee18, null, [[0, 17]]);\n }));\n}\n/**\n * Asynchronously searches for hospital documents in the database.\n * It can filter the results by the hospital's name, ID, or both.\n * If no parameters are provided, it retrieves all hospitals.\n *\n * @param {Object} params - An object containing the search parameters.\n * @param {string} [params.hospitalName] - Optional name of the hospital to filter the search.\n * @param {string} [params.hospitalId] - Optional unique identifier of the hospital to filter the search.\n * @returns {Promise<any[]>} A promise that resolves to an array of hospital objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getHospitals(_ref3) {\n var hospitalName = _ref3.hospitalName,\n hospitalId = _ref3.hospitalId;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {\n var collectionRef, constraints, q, querySnapshot, hospitals;\n return _regeneratorRuntime().wrap(function _callee19$(_context19) {\n while (1) switch (_context19.prev = _context19.next) {\n case 0:\n _context19.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\n constraints = [];\n if (hospitalName) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", hospitalName));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hospitalId));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context19.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context19.sent;\n hospitals = [];\n querySnapshot.forEach(function (doc) {\n hospitals.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context19.abrupt(\"return\", hospitals);\n case 14:\n _context19.prev = 14;\n _context19.t0 = _context19[\"catch\"](0);\n console.log(\"Error retrieving Hospitals\", _context19.t0);\n throw _context19.t0;\n case 18:\n case \"end\":\n return _context19.stop();\n }\n }, _callee19, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of improvement work documents based on various filter criteria.\n * It supports filtering by ID, Nolan stage, unit ID, completion status, ongoing status, and patient risk level.\n * It also supports sorting by the start date of the improvement work in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.id] - Optional identifier to filter the improvement works.\n * @param {string} [params.nolanStage] - Optional Nolan stage to filter the improvement works.\n * @param {string} [params.unitId] - Optional unit ID to filter the improvement works.\n * @param {boolean} [params.completed] - Optional flag to filter the improvement works by their completion status.\n * @param {boolean} [params.ongoing] - Optional flag to filter the improvement works by their ongoing status.\n * @param {string} [params.patientRiskLevel] - Optional patient risk level to filter the improvement works.\n * @param {boolean} [params.ascendingDates=false] - Optional flag for sorting by date in ascending order. Defaults to false.\n * @returns {Promise<any[]>} A promise that resolves to an array of improvement work objects that match the criteria.\n *\n * @throws Will throw an error if there is a problem retrieving the improvement works.\n */\nfunction getImprovementWorks(_ref4) {\n var id = _ref4.id,\n nolanStage = _ref4.nolanStage,\n unitId = _ref4.unitId,\n completed = _ref4.completed,\n ongoing = _ref4.ongoing,\n patientRiskLevel = _ref4.patientRiskLevel,\n _ref4$ascendingDates = _ref4.ascendingDates,\n ascendingDates = _ref4$ascendingDates === void 0 ? false : _ref4$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {\n var collectionRef, constraints, q, querySnapshot, improvementWorks;\n return _regeneratorRuntime().wrap(function _callee20$(_context20) {\n while (1) switch (_context20.prev = _context20.next) {\n case 0:\n _context20.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (nolanStage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"currentStage\", \"==\", nolanStage));\n }\n if (completed != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"completed\", \"==\", completed));\n }\n if (ongoing !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"ongoing\", \"==\", ongoing));\n }\n if (patientRiskLevel) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"patientRiskLevel\", \"==\", patientRiskLevel));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"dateStarted\", ascendingDates ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context20.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 13:\n querySnapshot = _context20.sent;\n improvementWorks = [];\n querySnapshot.forEach(function (doc) {\n improvementWorks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context20.abrupt(\"return\", improvementWorks);\n case 19:\n _context20.prev = 19;\n _context20.t0 = _context20[\"catch\"](0);\n console.log(\"Error retrieving improvementWorks: \", _context20.t0);\n throw _context20.t0;\n case 23:\n case \"end\":\n return _context20.stop();\n }\n }, _callee20, null, [[0, 19]]);\n }));\n}\n/**\n * Asynchronously retrieves user documents from the database based on various filter criteria.\n * It can filter by the Health Savings Account ID (hsaId), unit ID, and unique identifier (uid).\n * Additionally, it can sort the results by first name in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.hsaId] - Optional HSA ID to filter the users.\n * @param {string} [params.unitId] - Optional unit ID to filter the users.\n * @param {boolean} [params.ascendingFirstNames=false] - Optional flag to sort by first names in ascending order. Defaults to false (descending order).\n * @param {string} [params.uid] - Optional unique identifier to filter the users.\n * @returns {Promise<any[]>} A promise that resolves to an array of user objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUsers(_ref5) {\n var hsaId = _ref5.hsaId,\n unitId = _ref5.unitId,\n _ref5$ascendingFirstN = _ref5.ascendingFirstNames,\n ascendingFirstNames = _ref5$ascendingFirstN === void 0 ? false : _ref5$ascendingFirstN,\n uid = _ref5.uid;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {\n var collectionRef, constraints, q, querySnapshot, users;\n return _regeneratorRuntime().wrap(function _callee21$(_context21) {\n while (1) switch (_context21.prev = _context21.next) {\n case 0:\n _context21.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\n constraints = [];\n if (hsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hsaId));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (uid) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"uid\", \"==\", uid));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"firstName\", ascendingFirstNames ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context21.next = 10;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 10:\n querySnapshot = _context21.sent;\n users = [];\n querySnapshot.forEach(function (doc) {\n users.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context21.abrupt(\"return\", users);\n case 16:\n _context21.prev = 16;\n _context21.t0 = _context21[\"catch\"](0);\n console.log(\"Error retrieving users by department: \", _context21.t0);\n throw _context21.t0;\n case 20:\n case \"end\":\n return _context21.stop();\n }\n }, _callee21, null, [[0, 16]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of task documents from the database based on several filter and sorting criteria.\n * Filters include task ID, user ID and their responsibility status, and related improvement work ID.\n * Results can be sorted by date either in ascending or descending order.\n *\n * @param {Object} params - Parameters to filter and sort the task results.\n * @param {string} [params.taskId] - Optional task ID to filter the tasks.\n * @param {string} [params.userId] - Optional user ID to identify tasks related to a user.\n * @param {boolean} [params.isResponsibleFor] - Optional flag to filter tasks where the user is marked as responsible.\n * @param {string} [params.improvementWorkId] - Optional improvement work ID to filter tasks related to a specific improvement work.\n * @param {boolean} [params.ascendingDates=false] - Optional flag to sort tasks by date in ascending order; defaults to descending order.\n * @returns {Promise<any[]>} A promise that resolves to an array of task objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getTasks(_ref6) {\n var taskId = _ref6.taskId,\n userId = _ref6.userId,\n isResponsibleFor = _ref6.isResponsibleFor,\n improvementWorkId = _ref6.improvementWorkId,\n _ref6$ascendingDates = _ref6.ascendingDates,\n ascendingDates = _ref6$ascendingDates === void 0 ? false : _ref6$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {\n var collectionRef, constraints, q, querySnapshot, tasks;\n return _regeneratorRuntime().wrap(function _callee22$(_context22) {\n while (1) switch (_context22.prev = _context22.next) {\n case 0:\n _context22.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\n constraints = [];\n if (taskId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", taskId));\n }\n if (userId && isResponsibleFor !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"members\", \"array-contains\", {\n userHsaId: userId,\n isResponsibleFor: isResponsibleFor\n }));\n }\n if (improvementWorkId != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"startDate\", ascendingDates ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context22.next = 9;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 9:\n querySnapshot = _context22.sent;\n tasks = [];\n querySnapshot.forEach(function (doc) {\n tasks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context22.abrupt(\"return\", tasks);\n case 15:\n _context22.prev = 15;\n _context22.t0 = _context22[\"catch\"](0);\n console.log(\"Error retrieving task by department: \", _context22.t0);\n throw _context22.t0;\n case 19:\n case \"end\":\n return _context22.stop();\n }\n }, _callee22, null, [[0, 15]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of unit documents from the database based on various filter criteria.\n * Filters can be applied based on unit ID, hospital ID, and unit name.\n * Additionally, results can be sorted by unit names in ascending or descending order.\n *\n * @param {Object} params - The parameters object containing filter and sorting options.\n * @param {string} [params.unitId] - Optional unit ID to filter the units.\n * @param {string} [params.hospitalId] - Optional hospital ID to filter units within a specific hospital.\n * @param {string} [params.name] - Optional name to filter units by a specific name.\n * @param {boolean} [params.ascendingUnitNames=false] - Optional flag to sort units by name in ascending order, defaults to descending.\n * @returns {Promise<any[]>} A promise that resolves to an array of unit objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUnits(_ref7) {\n var unitId = _ref7.unitId,\n hospitalId = _ref7.hospitalId,\n name = _ref7.name,\n _ref7$ascendingUnitNa = _ref7.ascendingUnitNames,\n ascendingUnitNames = _ref7$ascendingUnitNa === void 0 ? false : _ref7$ascendingUnitNa;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {\n var collectionRef, constraints, q, querySnapshot, units;\n return _regeneratorRuntime().wrap(function _callee23$(_context23) {\n while (1) switch (_context23.prev = _context23.next) {\n case 0:\n _context23.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\n constraints = [];\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", unitId));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"hospitalId\", \"==\", hospitalId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"name\", ascendingUnitNames ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context23.next = 9;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 9:\n querySnapshot = _context23.sent;\n units = [];\n querySnapshot.forEach(function (doc) {\n units.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context23.abrupt(\"return\", units);\n case 15:\n _context23.prev = 15;\n _context23.t0 = _context23[\"catch\"](0);\n console.log(\"Error retrieving units by hospitalId: \", _context23.t0);\n throw _context23.t0;\n case 19:\n case \"end\":\n return _context23.stop();\n }\n }, _callee23, null, [[0, 15]]);\n }));\n}\n//getMembersFilteredAndSorted() -> Get all members of a project (sorted by firstName?)\n// export getters to be able to use in other files\n\n////////////////////////////////////DELETING/////////////////////////////////////////////\n// delete an instance of a type\nfunction deleteInstance(docType, docId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee24$(_context24) {\n while (1) switch (_context24.prev = _context24.next) {\n case 0:\n _context24.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context24.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(docRef);\n case 4:\n console.log(\"\".concat(docType, \" deleted successfully.\"));\n _context24.next = 11;\n break;\n case 7:\n _context24.prev = 7;\n _context24.t0 = _context24[\"catch\"](0);\n console.error(\"Error deleting \".concat(docType, \":\"), _context24.t0);\n throw _context24.t0;\n case 11:\n case \"end\":\n return _context24.stop();\n }\n }, _callee24, null, [[0, 7]]);\n }));\n}\n// delete all instances of a type\nfunction deleteAllDocumentsInCollection(collectionName) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {\n var _this = this;\n var collectionRef, snapshot, deletePromises;\n return _regeneratorRuntime().wrap(function _callee26$(_context26) {\n while (1) switch (_context26.prev = _context26.next) {\n case 0:\n _context26.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionName);\n _context26.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n snapshot = _context26.sent;\n // Delete all documents in the collection\n deletePromises = snapshot.docs.map(function (doc) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {\n return _regeneratorRuntime().wrap(function _callee25$(_context25) {\n while (1) switch (_context25.prev = _context25.next) {\n case 0:\n _context25.next = 2;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(doc.ref);\n case 2:\n case \"end\":\n return _context25.stop();\n }\n }, _callee25);\n }));\n });\n _context26.next = 8;\n return Promise.all(deletePromises);\n case 8:\n console.log(\"All documents in the \".concat(collectionName, \" collection deleted successfully.\"));\n _context26.next = 15;\n break;\n case 11:\n _context26.prev = 11;\n _context26.t0 = _context26[\"catch\"](0);\n console.error(\"Error deleting all documents in \".concat(collectionName, \":\"), _context26.t0);\n throw _context26.t0;\n case 15:\n case \"end\":\n return _context26.stop();\n }\n }, _callee26, null, [[0, 11]]);\n }));\n}\n////////////////////////////////////UPDATING/////////////////////////////////////////////\n// update a field in an instance\nfunction updateInstance(docType, docId, updates) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee27$(_context27) {\n while (1) switch (_context27.prev = _context27.next) {\n case 0:\n _context27.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context27.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(docRef, updates);\n case 4:\n console.log(\"\".concat(docType, \" updated successfully.\"));\n _context27.next = 11;\n break;\n case 7:\n _context27.prev = 7;\n _context27.t0 = _context27[\"catch\"](0);\n console.error(\"Error updating \".concat(docType, \":\"), _context27.t0);\n throw _context27.t0;\n case 11:\n case \"end\":\n return _context27.stop();\n }\n }, _callee27, null, [[0, 7]]);\n }));\n}\n// changes the ongoing status of an improvement work. if ongoing it is paused, if if paused onging.\n// user must be a manager\nfunction startOrPauseImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee28$(_context28) {\n while (1) switch (_context28.prev = _context28.next) {\n case 0:\n _context28.prev = 0;\n _context28.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context28.sent;\n _context28.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context28.sent;\n if (!(!user || !user.manager)) {\n _context28.next = 11;\n break;\n }\n throw new Error(\"User can't change improvementWork status\");\n case 11:\n if (!improvementWork) {\n _context28.next = 18;\n break;\n }\n update = {\n ongoing: !improvementWork.ongoing\n };\n _context28.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n _context28.next = 19;\n break;\n case 18:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n case 19:\n _context28.next = 25;\n break;\n case 21:\n _context28.prev = 21;\n _context28.t0 = _context28[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context28.t0);\n throw _context28.t0;\n case 25:\n case \"end\":\n return _context28.stop();\n }\n }, _callee28, null, [[0, 21]]);\n }));\n}\nfunction changePatientRiskLevel(userId, improvementWorkId, patientRiskLevel) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee29$(_context29) {\n while (1) switch (_context29.prev = _context29.next) {\n case 0:\n _context29.prev = 0;\n _context29.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context29.sent;\n _context29.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context29.sent;\n if (!(!user || !user.manager)) {\n _context29.next = 11;\n break;\n }\n throw new Error(\"User can't change patientRiskLevel in improvement work\");\n case 11:\n if (!improvementWork) {\n _context29.next = 18;\n break;\n }\n update = {\n patientRiskLevel: patientRiskLevel\n };\n _context29.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n _context29.next = 19;\n break;\n case 18:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n case 19:\n _context29.next = 25;\n break;\n case 21:\n _context29.prev = 21;\n _context29.t0 = _context29[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context29.t0);\n throw _context29.t0;\n case 25:\n case \"end\":\n return _context29.stop();\n }\n }, _callee29, null, [[0, 21]]);\n }));\n}\n// finalizes the improvement work. ongoing is set to false.\n// user must be a manager\nfunction finalizeImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {\n var user, update;\n return _regeneratorRuntime().wrap(function _callee30$(_context30) {\n while (1) switch (_context30.prev = _context30.next) {\n case 0:\n _context30.prev = 0;\n _context30.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context30.sent;\n if (!(!user || !user.manager)) {\n _context30.next = 8;\n break;\n }\n throw new Error(\"User can't finalize improvementWork status\");\n case 8:\n update = {\n completed: true,\n ongoing: false\n };\n _context30.next = 11;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 11:\n _context30.next = 16;\n break;\n case 13:\n _context30.prev = 13;\n _context30.t0 = _context30[\"catch\"](0);\n console.log(_context30.t0);\n case 16:\n case \"end\":\n return _context30.stop();\n }\n }, _callee30, null, [[0, 13]]);\n }));\n}\n\n//////////////////////////////// for later sprint\n//function add_upvotes\n//function add_notes\n//function add_intrested_users\n\n//# sourceURL=webpack://c3/./client/Database/database.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ addDocumentToImprovementWork: () => (/* binding */ addDocumentToImprovementWork),\n/* harmony export */ addMemberToImprovementWork: () => (/* binding */ addMemberToImprovementWork),\n/* harmony export */ addMemberToTask: () => (/* binding */ addMemberToTask),\n/* harmony export */ addNoteToUser: () => (/* binding */ addNoteToUser),\n/* harmony export */ auth: () => (/* binding */ auth),\n/* harmony export */ changePatientRiskLevel: () => (/* binding */ changePatientRiskLevel),\n/* harmony export */ createComment: () => (/* binding */ createComment),\n/* harmony export */ createHospital: () => (/* binding */ createHospital),\n/* harmony export */ createImprovementWork: () => (/* binding */ createImprovementWork),\n/* harmony export */ createSuggestion: () => (/* binding */ createSuggestion),\n/* harmony export */ createTaskOnImprovementWork: () => (/* binding */ createTaskOnImprovementWork),\n/* harmony export */ createUnit: () => (/* binding */ createUnit),\n/* harmony export */ createUser: () => (/* binding */ createUser),\n/* harmony export */ createdDocumentInKnowledgeBank: () => (/* binding */ createdDocumentInKnowledgeBank),\n/* harmony export */ db: () => (/* binding */ db),\n/* harmony export */ deleteAllDocumentsInCollection: () => (/* binding */ deleteAllDocumentsInCollection),\n/* harmony export */ deleteInstance: () => (/* binding */ deleteInstance),\n/* harmony export */ finalizeImprovementWork: () => (/* binding */ finalizeImprovementWork),\n/* harmony export */ getComments: () => (/* binding */ getComments),\n/* harmony export */ getHospitals: () => (/* binding */ getHospitals),\n/* harmony export */ getImprovementWorkOwner: () => (/* binding */ getImprovementWorkOwner),\n/* harmony export */ getImprovementWorkResponsible: () => (/* binding */ getImprovementWorkResponsible),\n/* harmony export */ getImprovementWorks: () => (/* binding */ getImprovementWorks),\n/* harmony export */ getImprovementWorksForUser: () => (/* binding */ getImprovementWorksForUser),\n/* harmony export */ getObject: () => (/* binding */ getObject),\n/* harmony export */ getObjectById: () => (/* binding */ getObjectById),\n/* harmony export */ getSuggestions: () => (/* binding */ getSuggestions),\n/* harmony export */ getTasks: () => (/* binding */ getTasks),\n/* harmony export */ getUnits: () => (/* binding */ getUnits),\n/* harmony export */ getUsers: () => (/* binding */ getUsers),\n/* harmony export */ getUsersForImprovementWork: () => (/* binding */ getUsersForImprovementWork),\n/* harmony export */ startOrPauseImprovementWork: () => (/* binding */ startOrPauseImprovementWork),\n/* harmony export */ updateInstance: () => (/* binding */ updateInstance),\n/* harmony export */ upvoteComment: () => (/* binding */ upvoteComment),\n/* harmony export */ upvoteSuggestion: () => (/* binding */ upvoteSuggestion)\n/* harmony export */ });\n/* harmony import */ var firebase_app__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! firebase/app */ \"./node_modules/firebase/app/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_firestore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! firebase/firestore */ \"./node_modules/firebase/firestore/dist/esm/index.esm.js\");\n/* harmony import */ var firebase_auth__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! firebase/auth */ \"./node_modules/firebase/auth/dist/esm/index.esm.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _regeneratorRuntime() { \"use strict\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = \"function\" == typeof Symbol ? Symbol : {}, a = i.iterator || \"@@iterator\", c = i.asyncIterator || \"@@asyncIterator\", u = i.toStringTag || \"@@toStringTag\"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, \"\"); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, \"_invoke\", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: \"normal\", arg: t.call(e, r) }; } catch (t) { return { type: \"throw\", arg: t }; } } e.wrap = wrap; var h = \"suspendedStart\", l = \"suspendedYield\", f = \"executing\", s = \"completed\", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { [\"next\", \"throw\", \"return\"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if (\"throw\" !== c.type) { var u = c.arg, h = u.value; return h && \"object\" == _typeof(h) && n.call(h, \"__await\") ? e.resolve(h.__await).then(function (t) { invoke(\"next\", t, i, a); }, function (t) { invoke(\"throw\", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke(\"throw\", t, i, a); }); } a(c.arg); } var r; o(this, \"_invoke\", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error(\"Generator is already running\"); if (o === s) { if (\"throw\" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if (\"next\" === n.method) n.sent = n._sent = n.arg;else if (\"throw\" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else \"return\" === n.method && n.abrupt(\"return\", n.arg); o = f; var p = tryCatch(e, r, n); if (\"normal\" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } \"throw\" === p.type && (o = s, n.method = \"throw\", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, \"throw\" === n && e.iterator[\"return\"] && (r.method = \"return\", r.arg = t, maybeInvokeDelegate(e, r), \"throw\" === r.method) || \"return\" !== n && (r.method = \"throw\", r.arg = new TypeError(\"The iterator does not provide a '\" + n + \"' method\")), y; var i = tryCatch(o, e.iterator, r.arg); if (\"throw\" === i.type) return r.method = \"throw\", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, \"return\" !== r.method && (r.method = \"next\", r.arg = t), r.delegate = null, y) : a : (r.method = \"throw\", r.arg = new TypeError(\"iterator result is not an object\"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = \"normal\", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: \"root\" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || \"\" === e) { var r = e[a]; if (r) return r.call(e); if (\"function\" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + \" is not iterable\"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, \"constructor\", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, \"constructor\", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, \"GeneratorFunction\"), e.isGeneratorFunction = function (t) { var e = \"function\" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || \"GeneratorFunction\" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, \"GeneratorFunction\")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, \"Generator\"), define(g, a, function () { return this; }), define(g, \"toString\", function () { return \"[object Generator]\"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = \"next\", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) \"t\" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if (\"throw\" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = \"throw\", a.arg = e, r.next = n, o && (r.method = \"next\", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if (\"root\" === i.tryLoc) return handle(\"end\"); if (i.tryLoc <= this.prev) { var c = n.call(i, \"catchLoc\"), u = n.call(i, \"finallyLoc\"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error(\"try statement without catch or finally\"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, \"finallyLoc\") && this.prev < o.finallyLoc) { var i = o; break; } } i && (\"break\" === t || \"continue\" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = \"next\", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if (\"throw\" === t.type) throw t.arg; return \"break\" === t.type || \"continue\" === t.type ? this.next = t.arg : \"return\" === t.type ? (this.rval = this.arg = t.arg, this.method = \"return\", this.next = \"end\") : \"normal\" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, \"catch\": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if (\"throw\" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error(\"illegal catch attempt\"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, \"next\" === this.method && (this.arg = t), y; } }, e; }\nvar __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\n\n\n\nvar firebaseConfig = {\n apiKey: \"AIzaSyDqkaVZMr11J4mfnR0auqoQilZyPfyD-x4\",\n authDomain: \"c3solutions-dc109.firebaseapp.com\",\n projectId: \"c3solutions-dc109\",\n storageBucket: \"c3solutions-dc109.appspot.com\",\n messagingSenderId: \"902143402555\",\n appId: \"1:902143402555:web:29213e81de0a0cba38b21e\"\n};\n/*const firebaseConfig = {\n apiKey: \"AIzaSyBIsZq_yOsJljp1woIxndJO1GkW6soh-g4\",\n authDomain: \"company3-456bb.firebaseapp.com\",\n projectId: \"company3-456bb\",\n storageBucket: \"company3-456bb.appspot.com\",\n messagingSenderId: \"310033686522\",\n appId: \"1:310033686522:web:63198bb0db679c98ee4e43\",\n measurementId: \"G-PFLDQY00DB\"\n};*/\n// const firebaseConfig = {\n// apiKey: \"AIzaSyBIsZq_yOsJljp1woIxndJO1GkW6soh-g4\",\n// authDomain: \"company3-456bb.firebaseapp.com\",\n// projectId: \"company3-456bb\",\n// storageBucket: \"company3-456bb.appspot.com\",\n// messagingSenderId: \"310033686522\",\n// appId: \"1:310033686522:web:63198bb0db679c98ee4e43\",\n// measurementId: \"G-PFLDQY00DB\"\n// };\nvar app = (0,firebase_app__WEBPACK_IMPORTED_MODULE_0__.initializeApp)(firebaseConfig);\nvar auth = (0,firebase_auth__WEBPACK_IMPORTED_MODULE_2__.getAuth)();\nvar db = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getFirestore)(app);\nvar userCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\nvar unitCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\nvar improvementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\nvar taskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\nvar hospitalCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\nvar suggestionCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\nvar knowledgeDocumentCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"knowledgeDocument\");\nvar userImprovementWorkCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"userImprovementWork\");\nvar userTaskCollection = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"userTask\");\n////////////////////////////////////////Setters///////////////////////////////////////////////////////////////////\n// Function to create user a new user in database\n// takes in userId, unitId, firstname, lastname, email and password as string\n// throws error if transaction failed\nfunction createUser(hsaId, unitId, firstName, lastName, email, manager, uid) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {\n var userRef, unitRef;\n return _regeneratorRuntime().wrap(function _callee$(_context) {\n while (1) switch (_context.prev = _context.next) {\n case 0:\n _context.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, hsaId);\n _context.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(userRef, {\n id: userRef.id,\n uid: uid,\n unitId: unitId,\n firstName: firstName,\n lastName: lastName,\n email: email,\n // TODO Replace with userImprovementWork collection\n improvementWorks: [],\n tasks: [],\n manager: manager\n });\n case 4:\n // Atomically add user to unit.\n unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection, unitId);\n _context.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(unitRef, {\n members: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userRef.id)\n });\n case 7:\n _context.next = 12;\n break;\n case 9:\n _context.prev = 9;\n _context.t0 = _context[\"catch\"](0);\n console.log(_context.t0);\n case 12:\n case \"end\":\n return _context.stop();\n }\n }, _callee, null, [[0, 9]]);\n }));\n}\nfunction createImprovementWork(id, name, currentStage, content,\n// Är detta description bör detta förtydligas. \nunitId, purpose,\n//Bör tas bort motsvaras av p2- mål med projektet\npatientRiskLevel, area,\n//Questions in planning stage\np1, p2, p3, p4, p5, p6, p7,\n//Questions in Doing (G) stage\ng1, g2, g3, g4, g5,\n//Questions in stydy stage\ns1, s2, s3,\n//Questions in acting stage\na1, a2, a3, a4) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {\n var improvementWorkData, improvementWorkRef, _improvementWorkRef;\n return _regeneratorRuntime().wrap(function _callee2$(_context2) {\n while (1) switch (_context2.prev = _context2.next) {\n case 0:\n _context2.prev = 0;\n improvementWorkData = {\n name: name,\n currentStage: currentStage,\n content: content,\n purpose: purpose,\n dateStarted: new Date(),\n unitId: unitId,\n completed: false,\n ongoing: false,\n tasks: [],\n // TODO Remove members array\n members: [],\n patientRiskLevel: patientRiskLevel,\n area: area,\n p1: p1,\n p2: p2,\n p3: p3,\n p4: p4,\n p5: p5,\n p6: p6,\n p7: p7,\n g1: g1,\n g2: g2,\n g3: g3,\n g4: g4,\n g5: g5,\n s1: s1,\n s2: s2,\n s3: s3,\n a1: a1,\n a2: a2,\n a3: a3,\n a4: a4\n };\n if (!id) {\n _context2.next = 8;\n break;\n }\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, id);\n _context2.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(improvementWorkRef, Object.assign({\n id: improvementWorkRef.id\n }, improvementWorkData));\n case 6:\n _context2.next = 11;\n break;\n case 8:\n _improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection);\n _context2.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_improvementWorkRef, improvementWorkData);\n case 11:\n _context2.next = 17;\n break;\n case 13:\n _context2.prev = 13;\n _context2.t0 = _context2[\"catch\"](0);\n console.log(\"Error creating improvementWork: \", _context2.t0);\n throw _context2.t0;\n case 17:\n case \"end\":\n return _context2.stop();\n }\n }, _callee2, null, [[0, 13]]);\n }));\n}\nfunction addMemberToTask(userHsaId, taskId, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {\n var relationRef;\n return _regeneratorRuntime().wrap(function _callee3$(_context3) {\n while (1) switch (_context3.prev = _context3.next) {\n case 0:\n _context3.prev = 0;\n relationRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userTaskCollection);\n _context3.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(relationRef, {\n id: relationRef.id,\n userHsaId: userHsaId,\n taskId: taskId,\n isResponsibleFor: isResponsibleFor\n });\n case 4:\n _context3.next = 10;\n break;\n case 6:\n _context3.prev = 6;\n _context3.t0 = _context3[\"catch\"](0);\n console.log(\"Error adding member to task: \", _context3.t0);\n throw _context3.t0;\n case 10:\n case \"end\":\n return _context3.stop();\n }\n }, _callee3, null, [[0, 6]]);\n }));\n}\nfunction addMemberToImprovementWork(userHsaId, improvementWorkId, isOwner, isResponsibleFor) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {\n var relationRef;\n return _regeneratorRuntime().wrap(function _callee4$(_context4) {\n while (1) switch (_context4.prev = _context4.next) {\n case 0:\n _context4.prev = 0;\n relationRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userImprovementWorkCollection);\n _context4.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(relationRef, {\n id: relationRef.id,\n userHsaId: userHsaId,\n improvementWorkId: improvementWorkId,\n isOwner: isOwner,\n isResponsibleFor: isResponsibleFor\n });\n case 4:\n _context4.next = 10;\n break;\n case 6:\n _context4.prev = 6;\n _context4.t0 = _context4[\"catch\"](0);\n console.log(\"Error adding member to improvementWork: \", _context4.t0);\n throw _context4.t0;\n case 10:\n case \"end\":\n return _context4.stop();\n }\n }, _callee4, null, [[0, 6]]);\n }));\n}\nfunction createTaskOnImprovementWork(taskId, improvementWorkId, name, deadlineDate, startDate, stage, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {\n var taskData, taskRef, _taskRef;\n return _regeneratorRuntime().wrap(function _callee5$(_context5) {\n while (1) switch (_context5.prev = _context5.next) {\n case 0:\n _context5.prev = 0;\n taskData = {\n improvementWorkId: improvementWorkId,\n name: name,\n deadlineDate: deadlineDate,\n startDate: startDate,\n stage: stage,\n content: content,\n members: [] // Initialize with an empty array\n };\n if (!taskId) {\n _context5.next = 8;\n break;\n }\n taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection, taskId);\n _context5.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(taskRef, Object.assign({\n id: taskRef.id\n }, taskData));\n case 6:\n _context5.next = 11;\n break;\n case 8:\n _taskRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(taskCollection);\n _context5.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_taskRef, taskData);\n case 11:\n _context5.next = 17;\n break;\n case 13:\n _context5.prev = 13;\n _context5.t0 = _context5[\"catch\"](0);\n console.log(\"Error creating task: \", _context5.t0);\n throw _context5.t0;\n case 17:\n case \"end\":\n return _context5.stop();\n }\n }, _callee5, null, [[0, 13]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction createdDocumentInKnowledgeBank(documentUrl, name) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee6$(_context6) {\n while (1) switch (_context6.prev = _context6.next) {\n case 0:\n _context6.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(knowledgeDocumentCollection);\n _context6.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n name: name\n });\n case 4:\n _context6.next = 10;\n break;\n case 6:\n _context6.prev = 6;\n _context6.t0 = _context6[\"catch\"](0);\n console.log(\"Error adding document: \", _context6.t0);\n throw _context6.t0;\n case 10:\n case \"end\":\n return _context6.stop();\n }\n }, _callee6, null, [[0, 6]]);\n }));\n}\n//add a document to a improvementWork\n// takes in, document url, name and improvementWork id refering to as string\n// throws error if transaction failed\nfunction addDocumentToImprovementWork(documentUrl, name, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {\n var improvementWorkRef, docRef;\n return _regeneratorRuntime().wrap(function _callee7$(_context7) {\n while (1) switch (_context7.prev = _context7.next) {\n case 0:\n _context7.prev = 0;\n improvementWorkRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkCollection, improvementWorkId);\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(improvementWorkRef, \"documents\");\n _context7.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n id: docRef.id,\n documentUrl: documentUrl,\n timestamp: new Date(),\n name: name\n });\n case 5:\n _context7.next = 11;\n break;\n case 7:\n _context7.prev = 7;\n _context7.t0 = _context7[\"catch\"](0);\n console.log(\"Error adding document: \", _context7.t0);\n throw _context7.t0;\n case 11:\n case \"end\":\n return _context7.stop();\n }\n }, _callee7, null, [[0, 7]]);\n }));\n}\nfunction createHospital(hospitalId,\n// should be auto?\nname) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {\n var hospitalData, hospitalRef, _hospitalRef;\n return _regeneratorRuntime().wrap(function _callee8$(_context8) {\n while (1) switch (_context8.prev = _context8.next) {\n case 0:\n _context8.prev = 0;\n hospitalData = {\n name: name,\n units: []\n };\n if (!hospitalId) {\n _context8.next = 8;\n break;\n }\n hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection, hospitalId);\n _context8.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(hospitalRef, Object.assign({\n id: hospitalRef.id\n }, hospitalData));\n case 6:\n _context8.next = 11;\n break;\n case 8:\n _hospitalRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(hospitalCollection);\n _context8.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_hospitalRef, hospitalData);\n case 11:\n _context8.next = 17;\n break;\n case 13:\n _context8.prev = 13;\n _context8.t0 = _context8[\"catch\"](0);\n console.log(\"Error creating hospital: \", _context8.t0);\n throw _context8.t0;\n case 17:\n case \"end\":\n return _context8.stop();\n }\n }, _callee8, null, [[0, 13]]);\n }));\n}\nfunction createUnit(unitId,\n//should be auto?\nhospitalId, name) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {\n var unitData, unitRef, _unitRef;\n return _regeneratorRuntime().wrap(function _callee9$(_context9) {\n while (1) switch (_context9.prev = _context9.next) {\n case 0:\n _context9.prev = 0;\n unitData = {\n hospitalId: hospitalId,\n name: name,\n members: []\n };\n if (!unitId) {\n _context9.next = 8;\n break;\n }\n unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection, unitId);\n _context9.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(unitRef, Object.assign({\n id: unitRef.id\n }, unitData));\n case 6:\n _context9.next = 11;\n break;\n case 8:\n _unitRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(unitCollection);\n _context9.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_unitRef, unitData);\n case 11:\n _context9.next = 17;\n break;\n case 13:\n _context9.prev = 13;\n _context9.t0 = _context9[\"catch\"](0);\n console.log(\"Error creating unit: \", _context9.t0);\n throw _context9.t0;\n case 17:\n case \"end\":\n return _context9.stop();\n }\n }, _callee9, null, [[0, 13]]);\n }));\n}\nfunction createSuggestion(id, creatorHsaId, name, area, content, purpose, measure, ideas,\n//need: boolean,\nunitId, departmentId, isPublic) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {\n var suggestionData, suggestionRef, _suggestionRef;\n return _regeneratorRuntime().wrap(function _callee10$(_context10) {\n while (1) switch (_context10.prev = _context10.next) {\n case 0:\n _context10.prev = 0;\n suggestionData = {\n creatorHsaId: creatorHsaId,\n name: name,\n area: area,\n content: content,\n purpose: purpose,\n measure: measure,\n ideas: ideas,\n //need,\n unitId: unitId,\n departmentId: departmentId,\n \"public\": isPublic,\n upvotes: [],\n comments: [],\n dateCreated: new Date()\n };\n if (!id) {\n _context10.next = 8;\n break;\n }\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, id);\n _context10.next = 6;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(suggestionRef, Object.assign({\n id: suggestionRef.id\n }, suggestionData));\n case 6:\n _context10.next = 11;\n break;\n case 8:\n _suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection);\n _context10.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(_suggestionRef, suggestionData);\n case 11:\n _context10.next = 17;\n break;\n case 13:\n _context10.prev = 13;\n _context10.t0 = _context10[\"catch\"](0);\n console.log(\"Error creating suggestion: \", _context10.t0);\n throw _context10.t0;\n case 17:\n case \"end\":\n return _context10.stop();\n }\n }, _callee10, null, [[0, 13]]);\n }));\n}\n// Upvote a suggestion for a user\n// takes in suggestion id, user HSAid\n// returns error if transaction failed\nfunction upvoteSuggestion(suggestionId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {\n var suggestionRef;\n return _regeneratorRuntime().wrap(function _callee11$(_context11) {\n while (1) switch (_context11.prev = _context11.next) {\n case 0:\n _context11.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId); // Atomically add a update to the upvote array field.\n _context11.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(suggestionRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 4:\n _context11.next = 10;\n break;\n case 6:\n _context11.prev = 6;\n _context11.t0 = _context11[\"catch\"](0);\n console.log(\"Error upvoting suggestion: \", _context11.t0);\n throw _context11.t0;\n case 10:\n case \"end\":\n return _context11.stop();\n }\n }, _callee11, null, [[0, 6]]);\n }));\n}\n//creates a comment\n// takes in commenters id, suggestion id and content as string\n// throws error if transaction failed\nfunction createComment(\n// change to subcollection\ncommenterHsaId, suggestionId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {\n var suggestionRef, commentCollection, commentRef;\n return _regeneratorRuntime().wrap(function _callee12$(_context12) {\n while (1) switch (_context12.prev = _context12.next) {\n case 0:\n _context12.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n _context12.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\");\n case 4:\n commentCollection = _context12.sent;\n _context12.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(commentCollection);\n case 7:\n commentRef = _context12.sent;\n _context12.next = 10;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(commentRef, {\n id: commentRef.id,\n commenterHsaId: commenterHsaId,\n content: content,\n dateCreated: new Date(),\n upvotes: []\n });\n case 10:\n _context12.next = 16;\n break;\n case 12:\n _context12.prev = 12;\n _context12.t0 = _context12[\"catch\"](0);\n console.log(\"Error creating comment: \", _context12.t0);\n throw _context12.t0;\n case 16:\n case \"end\":\n return _context12.stop();\n }\n }, _callee12, null, [[0, 12]]);\n }));\n}\n// Upvote a comment for a user\n// takes in suggestionId, commentId and userId as strings\n// return error if transaction failed\nfunction upvoteComment(suggestionId, commentId, userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {\n var suggestionRef, commentRef;\n return _regeneratorRuntime().wrap(function _callee13$(_context13) {\n while (1) switch (_context13.prev = _context13.next) {\n case 0:\n _context13.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionCollection, suggestionId);\n commentRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(suggestionRef, \"comment\", commentId); // Atomically add a update to the upvote array field.\n _context13.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(commentRef, {\n upvotes: (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.arrayUnion)(userHsaId)\n });\n case 5:\n _context13.next = 11;\n break;\n case 7:\n _context13.prev = 7;\n _context13.t0 = _context13[\"catch\"](0);\n console.log(\"Error upvoting comment: \", _context13.t0);\n throw _context13.t0;\n case 11:\n case \"end\":\n return _context13.stop();\n }\n }, _callee13, null, [[0, 7]]);\n }));\n}\n//add a note to a user\n// takes in userHsaId and content as string\n// throws error if transaction failed\nfunction addNoteToUser(userHsaId, content) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {\n var userRef, docRef;\n return _regeneratorRuntime().wrap(function _callee14$(_context14) {\n while (1) switch (_context14.prev = _context14.next) {\n case 0:\n _context14.prev = 0;\n userRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userCollection, userHsaId);\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(userRef, \"notes\");\n _context14.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.setDoc)(docRef, {\n content: content,\n dateCreated: new Date()\n });\n case 5:\n _context14.next = 11;\n break;\n case 7:\n _context14.prev = 7;\n _context14.t0 = _context14[\"catch\"](0);\n console.log(\"Error adding document: \", _context14.t0);\n throw _context14.t0;\n case 11:\n case \"end\":\n return _context14.stop();\n }\n }, _callee14, null, [[0, 7]]);\n }));\n}\n// export to setters to be able to use in other files\n\n//////////////////////////////////////////////GETTERS/////////////////////////////////////////////////////////////////////\n// Get any object\n// input is the database type as a string.\n// output is the whole collection of that type.\nfunction getObject(collectionPath) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {\n var collectionRef, querySnapshot, result;\n return _regeneratorRuntime().wrap(function _callee15$(_context15) {\n while (1) switch (_context15.prev = _context15.next) {\n case 0:\n _context15.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionPath);\n _context15.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n querySnapshot = _context15.sent;\n result = [];\n querySnapshot.forEach(function (doc) {\n result.push(doc.data());\n });\n return _context15.abrupt(\"return\", result);\n case 10:\n _context15.prev = 10;\n _context15.t0 = _context15[\"catch\"](0);\n console.error(\"Error getting collection data\", _context15.t0);\n throw _context15.t0;\n case 14:\n case \"end\":\n return _context15.stop();\n }\n }, _callee15, null, [[0, 10]]);\n }));\n}\n/**\n * Asynchronously retrieves a single document object from the specified collection path and document ID.\n * If the document does not exist, logs a warning and returns null.\n *\n * @param {string} collectionPath - The path to the collection in the database (\"improvementWork\", \"hospital\", \"suggestion\", \"task\", \"unit\", \"users\")\n * @param {string} documentId - The ID of the document to retrieve.\n * @returns {Promise<any|null>} A promise that resolves to the document object if found, or null if not.\n *\n * @throws Will throw an error if there is an issue during retrieval from the database.\n */\nfunction getObjectById(collectionPath, documentId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {\n var docRef, docSnapshot;\n return _regeneratorRuntime().wrap(function _callee16$(_context16) {\n while (1) switch (_context16.prev = _context16.next) {\n case 0:\n _context16.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, collectionPath, documentId);\n _context16.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDoc)(docRef);\n case 4:\n docSnapshot = _context16.sent;\n if (!docSnapshot.exists()) {\n _context16.next = 9;\n break;\n }\n return _context16.abrupt(\"return\", Object.assign({\n id: docSnapshot.id\n }, docSnapshot.data()));\n case 9:\n console.warn(\"No such document! \".concat(collectionPath, \"/\").concat(documentId));\n return _context16.abrupt(\"return\", null);\n case 11:\n _context16.next = 17;\n break;\n case 13:\n _context16.prev = 13;\n _context16.t0 = _context16[\"catch\"](0);\n console.error(\"Error getting object\", _context16.t0);\n throw _context16.t0;\n case 17:\n case \"end\":\n return _context16.stop();\n }\n }, _callee16, null, [[0, 13]]);\n }));\n}\n/**\n * Asynchronously retrieves comments for a given suggestion.\n *\n * @param {Object} params - The parameters for fetching comments.\n * @param {string} params.suggestionId - The ID of the suggestion to fetch comments for.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - The criterion to sort the comments by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Determines if the sorting should be in ascending order. Defaults to false (descending).\n * @returns {Promise<any[]>} A promise that resolves to an array of comment objects.\n *\n * @throws Will throw an error if the comments cannot be retrieved.\n */\nfunction getComments(_ref) {\n var suggestionId = _ref.suggestionId,\n _ref$sortBy = _ref.sortBy,\n sortBy = _ref$sortBy === void 0 ? \"dateCreated\" : _ref$sortBy,\n _ref$ascending = _ref.ascending,\n ascending = _ref$ascending === void 0 ? false : _ref$ascending;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {\n var suggestionRef, commentsQuery, commentsSnapshot, comments;\n return _regeneratorRuntime().wrap(function _callee17$(_context17) {\n while (1) switch (_context17.prev = _context17.next) {\n case 0:\n _context17.prev = 0;\n suggestionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, \"suggestionCollection\", suggestionId);\n commentsQuery = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(suggestionRef, \"comment\"), (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n _context17.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(commentsQuery);\n case 5:\n commentsSnapshot = _context17.sent;\n comments = [];\n commentsSnapshot.forEach(function (doc) {\n comments.push(doc.data());\n });\n return _context17.abrupt(\"return\", comments);\n case 11:\n _context17.prev = 11;\n _context17.t0 = _context17[\"catch\"](0);\n console.error(\"Error getting comments for suggestion: \", _context17.t0);\n throw _context17.t0;\n case 15:\n case \"end\":\n return _context17.stop();\n }\n }, _callee17, null, [[0, 11]]);\n }));\n}\n//Filtering suggestions on unitId AND creatorHsaId\n//Sort suggestions on dateCreated OR upvotes\n/**\n * Asynchronously retrieves an array of suggestions from the database, with various filters and sorting options.\n *\n * @param {Object} params - The parameters for filtering and sorting suggestions.\n * @param {string} [params.id] - Optional ID to filter suggestions by a specific identifier.\n * @param {string} [params.creatorHsaId] - Optional HSA ID to filter suggestions by the creator's HSA ID.\n * @param {string} [params.unitId] - Optional unit ID to filter suggestions by a specific unit.\n * @param {\"dateCreated\"|\"upvotes\"} [params.sortBy=\"dateCreated\"] - Criterion to sort the suggestions by. Defaults to \"dateCreated\".\n * @param {boolean} [params.ascending=false] - Flag indicating if sorting should be ascending. Defaults to false (descending order).\n * @param {boolean} [params.isPublic=true] - Flag indicating whether to filter for public suggestions. Defaults to true.\n * @returns {Promise<any[]>} A promise that resolves to an array of suggestion objects.\n *\n * @throws Will throw an error if there is an issue retrieving suggestions.\n */\nfunction getSuggestions(_ref2) {\n var id = _ref2.id,\n creatorHsaId = _ref2.creatorHsaId,\n unitId = _ref2.unitId,\n _ref2$sortBy = _ref2.sortBy,\n sortBy = _ref2$sortBy === void 0 ? \"dateCreated\" : _ref2$sortBy,\n _ref2$ascending = _ref2.ascending,\n ascending = _ref2$ascending === void 0 ? false : _ref2$ascending,\n _ref2$isPublic = _ref2.isPublic,\n isPublic = _ref2$isPublic === void 0 ? true : _ref2$isPublic;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {\n var collectionRef, constraints, q, querySnapshot, suggestions;\n return _regeneratorRuntime().wrap(function _callee18$(_context18) {\n while (1) switch (_context18.prev = _context18.next) {\n case 0:\n _context18.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"suggestion\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (creatorHsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"creatorHsaId\", \"==\", creatorHsaId));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"public\", \"==\", isPublic));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(sortBy, ascending ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context18.next = 11;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 11:\n querySnapshot = _context18.sent;\n suggestions = [];\n querySnapshot.forEach(function (doc) {\n suggestions.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context18.abrupt(\"return\", suggestions);\n case 17:\n _context18.prev = 17;\n _context18.t0 = _context18[\"catch\"](0);\n console.log(\"Error retrieving suggestions by department: \", _context18.t0);\n throw _context18.t0;\n case 21:\n case \"end\":\n return _context18.stop();\n }\n }, _callee18, null, [[0, 17]]);\n }));\n}\n/**\n * Asynchronously searches for hospital documents in the database.\n * It can filter the results by the hospital's name, ID, or both.\n * If no parameters are provided, it retrieves all hospitals.\n *\n * @param {Object} params - An object containing the search parameters.\n * @param {string} [params.hospitalName] - Optional name of the hospital to filter the search.\n * @param {string} [params.hospitalId] - Optional unique identifier of the hospital to filter the search.\n * @returns {Promise<any[]>} A promise that resolves to an array of hospital objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getHospitals(_ref3) {\n var hospitalName = _ref3.hospitalName,\n hospitalId = _ref3.hospitalId;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {\n var collectionRef, constraints, q, querySnapshot, hospitals;\n return _regeneratorRuntime().wrap(function _callee19$(_context19) {\n while (1) switch (_context19.prev = _context19.next) {\n case 0:\n _context19.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"hospital\");\n constraints = [];\n if (hospitalName) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", hospitalName));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hospitalId));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context19.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context19.sent;\n hospitals = [];\n querySnapshot.forEach(function (doc) {\n hospitals.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context19.abrupt(\"return\", hospitals);\n case 14:\n _context19.prev = 14;\n _context19.t0 = _context19[\"catch\"](0);\n console.log(\"Error retrieving Hospitals\", _context19.t0);\n throw _context19.t0;\n case 18:\n case \"end\":\n return _context19.stop();\n }\n }, _callee19, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of improvement work documents based on various filter criteria.\n * It supports filtering by ID, Nolan stage, unit ID, completion status, ongoing status, and patient risk level.\n * It also supports sorting by the start date of the improvement work in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.id] - Optional identifier to filter the improvement works.\n * @param {string} [params.nolanStage] - Optional Nolan stage to filter the improvement works.\n * @param {string} [params.unitId] - Optional unit ID to filter the improvement works.\n * @param {boolean} [params.completed] - Optional flag to filter the improvement works by their completion status.\n * @param {boolean} [params.ongoing] - Optional flag to filter the improvement works by their ongoing status.\n * @param {string} [params.patientRiskLevel] - Optional patient risk level to filter the improvement works.\n * @param {boolean} [params.ascendingDates=false] - Optional flag for sorting by date in ascending order. Defaults to false.\n * @returns {Promise<any[]>} A promise that resolves to an array of improvement work objects that match the criteria.\n *\n * @throws Will throw an error if there is a problem retrieving the improvement works.\n */\nfunction getImprovementWorks(_ref4) {\n var id = _ref4.id,\n nolanStage = _ref4.nolanStage,\n unitId = _ref4.unitId,\n completed = _ref4.completed,\n ongoing = _ref4.ongoing,\n patientRiskLevel = _ref4.patientRiskLevel,\n _ref4$ascendingDates = _ref4.ascendingDates,\n ascendingDates = _ref4$ascendingDates === void 0 ? false : _ref4$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {\n var collectionRef, constraints, q, querySnapshot, improvementWorks;\n return _regeneratorRuntime().wrap(function _callee20$(_context20) {\n while (1) switch (_context20.prev = _context20.next) {\n case 0:\n _context20.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"improvementWork\");\n constraints = [];\n if (id) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", id));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (nolanStage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"currentStage\", \"==\", nolanStage));\n }\n if (completed != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"completed\", \"==\", completed));\n }\n if (ongoing !== undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"ongoing\", \"==\", ongoing));\n }\n if (patientRiskLevel) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"patientRiskLevel\", \"==\", patientRiskLevel));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"dateStarted\", ascendingDates ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context20.next = 13;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 13:\n querySnapshot = _context20.sent;\n improvementWorks = [];\n querySnapshot.forEach(function (doc) {\n improvementWorks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context20.abrupt(\"return\", improvementWorks);\n case 19:\n _context20.prev = 19;\n _context20.t0 = _context20[\"catch\"](0);\n console.log(\"Error retrieving improvementWorks: \", _context20.t0);\n throw _context20.t0;\n case 23:\n case \"end\":\n return _context20.stop();\n }\n }, _callee20, null, [[0, 19]]);\n }));\n}\nfunction getImprovementWorkOwner(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {\n var constraints, q, querySnapshot, owner;\n return _regeneratorRuntime().wrap(function _callee21$(_context21) {\n while (1) switch (_context21.prev = _context21.next) {\n case 0:\n _context21.prev = 0;\n constraints = [];\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"isOwner\", \"==\", true));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context21.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 7:\n querySnapshot = _context21.sent;\n if (!querySnapshot.empty) {\n _context21.next = 13;\n break;\n }\n console.log(\"Improvement work \", improvementWorkId, \" has no owner\");\n return _context21.abrupt(\"return\", null);\n case 13:\n owner = querySnapshot.docs[0].data().userHsaId;\n return _context21.abrupt(\"return\", owner);\n case 15:\n _context21.next = 20;\n break;\n case 17:\n _context21.prev = 17;\n _context21.t0 = _context21[\"catch\"](0);\n console.log(_context21.t0);\n case 20:\n case \"end\":\n return _context21.stop();\n }\n }, _callee21, null, [[0, 17]]);\n }));\n}\nfunction getImprovementWorkResponsible(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {\n var constraints, q, querySnapshot, responsible;\n return _regeneratorRuntime().wrap(function _callee22$(_context22) {\n while (1) switch (_context22.prev = _context22.next) {\n case 0:\n _context22.prev = 0;\n constraints = [];\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"isResponsibleFor\", \"==\", true));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [userImprovementWorkCollection].concat(constraints));\n _context22.next = 7;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 7:\n querySnapshot = _context22.sent;\n if (!querySnapshot.empty) {\n _context22.next = 13;\n break;\n }\n console.log(\"Improvement work \", improvementWorkId, \" has no responsible\");\n return _context22.abrupt(\"return\", null);\n case 13:\n responsible = querySnapshot.docs[0].data().userHsaId;\n return _context22.abrupt(\"return\", responsible);\n case 15:\n _context22.next = 20;\n break;\n case 17:\n _context22.prev = 17;\n _context22.t0 = _context22[\"catch\"](0);\n console.log(_context22.t0);\n case 20:\n case \"end\":\n return _context22.stop();\n }\n }, _callee22, null, [[0, 17]]);\n }));\n}\n// TODO getUsersForTask!\n/**\n * Asynchronously retrieves user documents from the database based on various filter criteria.\n * It can filter by the Health Savings Account ID (hsaId), unit ID, and unique identifier (uid).\n * Additionally, it can sort the results by first name in either ascending or descending order.\n *\n * @param {Object} params - An object containing the filter and sorting parameters.\n * @param {string} [params.hsaId] - Optional HSA ID to filter the users.\n * @param {string} [params.unitId] - Optional unit ID to filter the users.\n * @param {boolean} [params.ascendingFirstNames=false] - Optional flag to sort by first names in ascending order. Defaults to false (descending order).\n * @param {string} [params.uid] - Optional unique identifier to filter the users.\n * @returns {Promise<any[]>} A promise that resolves to an array of user objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUsers(_ref5) {\n var hsaId = _ref5.hsaId,\n unitId = _ref5.unitId,\n _ref5$ascendingFirstN = _ref5.ascendingFirstNames,\n ascendingFirstNames = _ref5$ascendingFirstN === void 0 ? false : _ref5$ascendingFirstN,\n uid = _ref5.uid;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {\n var collectionRef, constraints, q, querySnapshot, users;\n return _regeneratorRuntime().wrap(function _callee23$(_context23) {\n while (1) switch (_context23.prev = _context23.next) {\n case 0:\n _context23.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"users\");\n constraints = [];\n if (hsaId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", hsaId));\n }\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"unitId\", \"==\", unitId));\n }\n if (uid) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"uid\", \"==\", uid));\n }\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"firstName\", ascendingFirstNames ? \"asc\" : \"desc\"));\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context23.next = 10;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 10:\n querySnapshot = _context23.sent;\n users = [];\n querySnapshot.forEach(function (doc) {\n users.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context23.abrupt(\"return\", users);\n case 16:\n _context23.prev = 16;\n _context23.t0 = _context23[\"catch\"](0);\n console.log(\"Error retrieving users by department: \", _context23.t0);\n throw _context23.t0;\n case 20:\n case \"end\":\n return _context23.stop();\n }\n }, _callee23, null, [[0, 16]]);\n }));\n}\n// TODO getTasksForUser!\n/**\n * Asynchronously retrieves an array of task documents from the database based on several filter and sorting criteria.\n * Filters include task ID, user ID and their responsibility status, and related improvement work ID.\n * Results can be sorted by date either in ascending or descending order.\n *\n * @param {Object} params - Parameters to filter and sort the task results.\n * @param {string} [params.taskId] - Optional task ID to filter the tasks.\n * @param {string} [params.userId] - Optional user ID to identify tasks related to a user.\n * @param {boolean} [params.isResponsibleFor] - Optional flag to filter tasks where the user is marked as responsible.\n * @param {string} [params.improvementWorkId] - Optional improvement work ID to filter tasks related to a specific improvement work.\n * @param {boolean} [params.ascendingDates=false] - Optional flag to sort tasks by date in ascending order; defaults to descending order.\n * @returns {Promise<any[]>} A promise that resolves to an array of task objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getTasks(_ref6) {\n var improvementWorkId = _ref6.improvementWorkId,\n stage = _ref6.stage,\n _ref6$ascendingDates = _ref6.ascendingDates,\n ascendingDates = _ref6$ascendingDates === void 0 ? false : _ref6$ascendingDates;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {\n var collectionRef, constraints, q, querySnapshot, tasks;\n return _regeneratorRuntime().wrap(function _callee24$(_context24) {\n while (1) switch (_context24.prev = _context24.next) {\n case 0:\n _context24.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"task\");\n constraints = []; // FUTURE FEATURE: Filter on userHsaId AND improvementWork\n // if (userHsaId && isResponsibleFor !== undefined) {\n // constraints.push(\n // where(\"members\", \"array-contains\", {\n // userHsaId: userHsaId,\n // isResponsibleFor: isResponsibleFor,\n // })\n // );\n // }\n if (stage) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"stage\", \"==\", stage));\n }\n if (improvementWorkId != undefined) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"improvementWorkId\", \"==\", improvementWorkId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"startDate\", ascendingDates ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context24.next = 8;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 8:\n querySnapshot = _context24.sent;\n tasks = [];\n querySnapshot.forEach(function (doc) {\n tasks.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context24.abrupt(\"return\", tasks);\n case 14:\n _context24.prev = 14;\n _context24.t0 = _context24[\"catch\"](0);\n console.log(\"Error retrieving task by department: \", _context24.t0);\n throw _context24.t0;\n case 18:\n case \"end\":\n return _context24.stop();\n }\n }, _callee24, null, [[0, 14]]);\n }));\n}\n/**\n * Asynchronously retrieves an array of unit documents from the database based on various filter criteria.\n * Filters can be applied based on unit ID, hospital ID, and unit name.\n * Additionally, results can be sorted by unit names in ascending or descending order.\n *\n * @param {Object} params - The parameters object containing filter and sorting options.\n * @param {string} [params.unitId] - Optional unit ID to filter the units.\n * @param {string} [params.hospitalId] - Optional hospital ID to filter units within a specific hospital.\n * @param {string} [params.name] - Optional name to filter units by a specific name.\n * @param {boolean} [params.ascendingUnitNames=false] - Optional flag to sort units by name in ascending order, defaults to descending.\n * @returns {Promise<any[]>} A promise that resolves to an array of unit objects that match the search criteria.\n *\n * @throws Will throw an error if there is an issue during the retrieval process.\n */\nfunction getUnits(_ref7) {\n var unitId = _ref7.unitId,\n hospitalId = _ref7.hospitalId,\n name = _ref7.name,\n _ref7$ascendingUnitNa = _ref7.ascendingUnitNames,\n ascendingUnitNames = _ref7$ascendingUnitNa === void 0 ? false : _ref7$ascendingUnitNa;\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {\n var collectionRef, constraints, q, querySnapshot, units;\n return _regeneratorRuntime().wrap(function _callee25$(_context25) {\n while (1) switch (_context25.prev = _context25.next) {\n case 0:\n _context25.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, \"unit\");\n constraints = [];\n if (unitId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"id\", \"==\", unitId));\n }\n if (name) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"name\", \"==\", name));\n }\n if (hospitalId) {\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)(\"hospitalId\", \"==\", hospitalId));\n constraints.push((0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.orderBy)(\"name\", ascendingUnitNames ? \"asc\" : \"desc\"));\n }\n q = firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query.apply(void 0, [collectionRef].concat(constraints));\n _context25.next = 9;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 9:\n querySnapshot = _context25.sent;\n units = [];\n querySnapshot.forEach(function (doc) {\n units.push(Object.assign({\n id: doc.id\n }, doc.data()));\n });\n return _context25.abrupt(\"return\", units);\n case 15:\n _context25.prev = 15;\n _context25.t0 = _context25[\"catch\"](0);\n console.log(\"Error retrieving units by hospitalId: \", _context25.t0);\n throw _context25.t0;\n case 19:\n case \"end\":\n return _context25.stop();\n }\n }, _callee25, null, [[0, 15]]);\n }));\n}\nfunction getImprovementWorksForUser(userHsaId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {\n var q, querySnapshot, improvementWorks, _iterator, _step, _doc, improvementWorkId, improvementWorkDoc;\n return _regeneratorRuntime().wrap(function _callee26$(_context26) {\n while (1) switch (_context26.prev = _context26.next) {\n case 0:\n _context26.prev = 0;\n console.log(\"Getting improvementworks for user: \", userHsaId);\n // Query the userImprovementWork collection for relations involving this user\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(userImprovementWorkCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)('userHsaId', '==', userHsaId));\n _context26.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 5:\n querySnapshot = _context26.sent;\n // Fetch each related improvementWork document\n improvementWorks = [];\n _iterator = _createForOfIteratorHelper(querySnapshot.docs);\n _context26.prev = 8;\n _iterator.s();\n case 10:\n if ((_step = _iterator.n()).done) {\n _context26.next = 19;\n break;\n }\n _doc = _step.value;\n improvementWorkId = _doc.data().improvementWorkId;\n _context26.next = 15;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 15:\n improvementWorkDoc = _context26.sent;\n improvementWorks.push(improvementWorkDoc);\n case 17:\n _context26.next = 10;\n break;\n case 19:\n _context26.next = 24;\n break;\n case 21:\n _context26.prev = 21;\n _context26.t0 = _context26[\"catch\"](8);\n _iterator.e(_context26.t0);\n case 24:\n _context26.prev = 24;\n _iterator.f();\n return _context26.finish(24);\n case 27:\n return _context26.abrupt(\"return\", improvementWorks);\n case 30:\n _context26.prev = 30;\n _context26.t1 = _context26[\"catch\"](0);\n console.error(\"Error getting improvement works for user: \", _context26.t1);\n throw _context26.t1;\n case 34:\n case \"end\":\n return _context26.stop();\n }\n }, _callee26, null, [[0, 30], [8, 21, 24, 27]]);\n }));\n}\nfunction getUsersForImprovementWork(improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {\n var q, querySnapshot, users, _iterator2, _step2, _doc2, userHsaId, userDoc;\n return _regeneratorRuntime().wrap(function _callee27$(_context27) {\n while (1) switch (_context27.prev = _context27.next) {\n case 0:\n _context27.prev = 0;\n console.log(\"Getting users for improvementwork: \", improvementWorkId);\n // Query the userImprovementWork collection for relations involving this improvementWork\n q = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.query)(userImprovementWorkCollection, (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.where)('improvementWorkId', '==', improvementWorkId));\n _context27.next = 5;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(q);\n case 5:\n querySnapshot = _context27.sent;\n // Fetch each related user document\n users = [];\n _iterator2 = _createForOfIteratorHelper(querySnapshot.docs);\n _context27.prev = 8;\n _iterator2.s();\n case 10:\n if ((_step2 = _iterator2.n()).done) {\n _context27.next = 19;\n break;\n }\n _doc2 = _step2.value;\n userHsaId = _doc2.data().userHsaId;\n _context27.next = 15;\n return getObjectById(\"users\", userHsaId);\n case 15:\n userDoc = _context27.sent;\n users.push(userDoc);\n case 17:\n _context27.next = 10;\n break;\n case 19:\n _context27.next = 24;\n break;\n case 21:\n _context27.prev = 21;\n _context27.t0 = _context27[\"catch\"](8);\n _iterator2.e(_context27.t0);\n case 24:\n _context27.prev = 24;\n _iterator2.f();\n return _context27.finish(24);\n case 27:\n return _context27.abrupt(\"return\", users);\n case 30:\n _context27.prev = 30;\n _context27.t1 = _context27[\"catch\"](0);\n console.error(\"Error getting users for improvementWork: \", _context27.t1);\n throw _context27.t1;\n case 34:\n case \"end\":\n return _context27.stop();\n }\n }, _callee27, null, [[0, 30], [8, 21, 24, 27]]);\n }));\n}\n// export getters to be able to use in other files\n\n////////////////////////////////////DELETING/////////////////////////////////////////////\n// delete an instance of a type\nfunction deleteInstance(docType, docId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee28$(_context28) {\n while (1) switch (_context28.prev = _context28.next) {\n case 0:\n _context28.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context28.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(docRef);\n case 4:\n console.log(\"\".concat(docType, \" deleted successfully.\"));\n _context28.next = 11;\n break;\n case 7:\n _context28.prev = 7;\n _context28.t0 = _context28[\"catch\"](0);\n console.error(\"Error deleting \".concat(docType, \":\"), _context28.t0);\n throw _context28.t0;\n case 11:\n case \"end\":\n return _context28.stop();\n }\n }, _callee28, null, [[0, 7]]);\n }));\n}\n// delete all instances of a type\nfunction deleteAllDocumentsInCollection(collectionName) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {\n var _this = this;\n var collectionRef, snapshot, deletePromises;\n return _regeneratorRuntime().wrap(function _callee30$(_context30) {\n while (1) switch (_context30.prev = _context30.next) {\n case 0:\n _context30.prev = 0;\n collectionRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.collection)(db, collectionName);\n _context30.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.getDocs)(collectionRef);\n case 4:\n snapshot = _context30.sent;\n // Delete all documents in the collection\n deletePromises = snapshot.docs.map(function (doc) {\n return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {\n return _regeneratorRuntime().wrap(function _callee29$(_context29) {\n while (1) switch (_context29.prev = _context29.next) {\n case 0:\n _context29.next = 2;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.deleteDoc)(doc.ref);\n case 2:\n case \"end\":\n return _context29.stop();\n }\n }, _callee29);\n }));\n });\n _context30.next = 8;\n return Promise.all(deletePromises);\n case 8:\n console.log(\"All documents in the \".concat(collectionName, \" collection deleted successfully.\"));\n _context30.next = 15;\n break;\n case 11:\n _context30.prev = 11;\n _context30.t0 = _context30[\"catch\"](0);\n console.error(\"Error deleting all documents in \".concat(collectionName, \":\"), _context30.t0);\n throw _context30.t0;\n case 15:\n case \"end\":\n return _context30.stop();\n }\n }, _callee30, null, [[0, 11]]);\n }));\n}\n////////////////////////////////////UPDATING/////////////////////////////////////////////\n// update a field in an instance\nfunction updateInstance(docType, docId, updates) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {\n var docRef;\n return _regeneratorRuntime().wrap(function _callee31$(_context31) {\n while (1) switch (_context31.prev = _context31.next) {\n case 0:\n _context31.prev = 0;\n docRef = (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.doc)(db, docType, docId);\n _context31.next = 4;\n return (0,firebase_firestore__WEBPACK_IMPORTED_MODULE_1__.updateDoc)(docRef, updates);\n case 4:\n console.log(\"\".concat(docType, \" updated successfully.\"));\n _context31.next = 11;\n break;\n case 7:\n _context31.prev = 7;\n _context31.t0 = _context31[\"catch\"](0);\n console.error(\"Error updating \".concat(docType, \":\"), _context31.t0);\n throw _context31.t0;\n case 11:\n case \"end\":\n return _context31.stop();\n }\n }, _callee31, null, [[0, 7]]);\n }));\n}\n// changes the ongoing status of an improvement work. if ongoing it is paused, if if paused onging.\n// user must be a manager\nfunction startOrPauseImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee32$(_context32) {\n while (1) switch (_context32.prev = _context32.next) {\n case 0:\n _context32.prev = 0;\n _context32.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context32.sent;\n _context32.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context32.sent;\n if (!(!user || !user.manager)) {\n _context32.next = 11;\n break;\n }\n throw new Error(\"User can't change improvementWork status\");\n case 11:\n if (!improvementWork) {\n _context32.next = 18;\n break;\n }\n update = {\n ongoing: !improvementWork.ongoing\n };\n _context32.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n _context32.next = 19;\n break;\n case 18:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n case 19:\n _context32.next = 25;\n break;\n case 21:\n _context32.prev = 21;\n _context32.t0 = _context32[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context32.t0);\n throw _context32.t0;\n case 25:\n case \"end\":\n return _context32.stop();\n }\n }, _callee32, null, [[0, 21]]);\n }));\n}\nfunction changePatientRiskLevel(userId, improvementWorkId, patientRiskLevel) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {\n var user, improvementWork, update;\n return _regeneratorRuntime().wrap(function _callee33$(_context33) {\n while (1) switch (_context33.prev = _context33.next) {\n case 0:\n _context33.prev = 0;\n _context33.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context33.sent;\n _context33.next = 6;\n return getObjectById(\"improvementWork\", improvementWorkId);\n case 6:\n improvementWork = _context33.sent;\n if (!(!user || !user.manager)) {\n _context33.next = 11;\n break;\n }\n throw new Error(\"User can't change patientRiskLevel in improvement work\");\n case 11:\n if (!improvementWork) {\n _context33.next = 18;\n break;\n }\n update = {\n patientRiskLevel: patientRiskLevel\n };\n _context33.next = 15;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 15:\n console.log(\"Improvement work \".concat(improvementWorkId, \" status updated.\"));\n _context33.next = 19;\n break;\n case 18:\n console.error(\"Improvement work with ID \".concat(improvementWorkId, \" not found.\"));\n case 19:\n _context33.next = 25;\n break;\n case 21:\n _context33.prev = 21;\n _context33.t0 = _context33[\"catch\"](0);\n console.error(\"Error starting/pausing improvement work:\", _context33.t0);\n throw _context33.t0;\n case 25:\n case \"end\":\n return _context33.stop();\n }\n }, _callee33, null, [[0, 21]]);\n }));\n}\n// finalizes the improvement work. ongoing is set to false.\n// user must be a manager\nfunction finalizeImprovementWork(userId, improvementWorkId) {\n return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {\n var user, update;\n return _regeneratorRuntime().wrap(function _callee34$(_context34) {\n while (1) switch (_context34.prev = _context34.next) {\n case 0:\n _context34.prev = 0;\n _context34.next = 3;\n return getObjectById(\"users\", userId);\n case 3:\n user = _context34.sent;\n if (!(!user || !user.manager)) {\n _context34.next = 8;\n break;\n }\n throw new Error(\"User can't finalize improvementWork status\");\n case 8:\n update = {\n completed: true,\n ongoing: false\n };\n _context34.next = 11;\n return updateInstance(\"improvementWork\", improvementWorkId, update);\n case 11:\n _context34.next = 16;\n break;\n case 13:\n _context34.prev = 13;\n _context34.t0 = _context34[\"catch\"](0);\n console.log(_context34.t0);\n case 16:\n case \"end\":\n return _context34.stop();\n }\n }, _callee34, null, [[0, 13]]);\n }));\n}\n\n//////////////////////////////// for later sprint\n//function add_upvotes\n//function add_notes\n//function add_intrested_users\n\n//# sourceURL=webpack://c3/./client/Database/database.js?"); /***/ }), diff --git a/client/homePage.js b/client/homePage.js index 79407f76db23052d76d5d4656e876fe7ce5dca1e..3aec133be35949ef61a7107fee2f09ddad5b74b3 100644 --- a/client/homePage.js +++ b/client/homePage.js @@ -8,64 +8,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }); }; import { logout } from "./Database/authentication.js"; -import { getSuggestions, getUnits, getObjectById } from "../client/Database/database.js"; +import { getSuggestions, getUnits, getObjectById, getImprovementWorksForUser } from "../client/Database/database.js"; function logoutUser(event) { event.preventDefault(); alert('logout'); logout(); } -//Mock-data, to be replaced -const homePageSampleProjects = [ - { - ID: "1", - name: "Birthing of a Child", - current_stage: "In Progress", - content: "This is project 1.", - unit_ID: "2", - date_started: new Date("2023-01-15"), - }, - { - ID: "2", - name: "How to save a life", - current_stage: "Completed", - content: "This is project 2.", - unit_ID: "1", - date_started: new Date("2023-02-20"), - }, - { - ID: "3", - name: "BB tutorial", - current_stage: "Completed", - content: "This is project 3.", - unit_ID: "2", - date_started: new Date("2023-06-05"), - }, - { - ID: "4", - name: "Cancerbehandling 101", - current_stage: "Completed", - content: "This is project 4.", - unit_ID: "3", - date_started: new Date("2023-10-24"), - }, - { - ID: "5", - name: "Cancerbehandling 101", - current_stage: "Completed", - content: "This is project 4.", - unit_ID: "3", - date_started: new Date("2023-10-24"), - }, - { - ID: "6", - name: "Cancerbehandling 101", - current_stage: "Completed", - content: "This is project 4.", - unit_ID: "3", - date_started: new Date("2023-10-24"), - }, -]; -let signedInUserHsaID = "alijoh234"; let myIdeaCards = {}; class IdeaCard { constructor(id, header, department, name, description, upvoteCount) { @@ -137,7 +85,7 @@ class IdeaCard { alert("The initiate project page should now be loaded"); } } -function createNewCards(className, container) { +function createNewCards(className, container, signedInUserHsaID) { return __awaiter(this, void 0, void 0, function* () { let user = yield getObjectById("users", signedInUserHsaID); let userSuggestions = yield getSuggestions({ creatorHsaId: user.id }); @@ -186,11 +134,9 @@ export function loadPage() { return; } var user = JSON.parse(tmp)[0]; - displayProjects(user); - //displaySuggestions(user); const suggestionContainer = document.getElementById("suggestion-container"); if (suggestionContainer) { - yield createNewCards("HomePageIdeaCardDiv", suggestionContainer); + yield createNewCards("HomePageIdeaCardDiv", suggestionContainer, user.id); } console.log(user.firstName + "user.firstname"); const nameHeaderElement = document.getElementById('user-name-header'); @@ -208,57 +154,104 @@ export function loadPage() { emailElement.textContent = user.email; roleElement.textContent = "undefined"; } + const projectContainer = document.getElementById("project-container"); + if (projectContainer) { + yield getProjects(projectContainer, user.id); + } })) .catch(error => { console.error('Failed to load the external HTML file:', error); }); }); } -function displayProjects(user) { +function getProjects(selectElement, /*listenersLoaded:boolean,*/ userHsaId) { return __awaiter(this, void 0, void 0, function* () { - const container = document.getElementById('project-container'); - let userImprovementWorks = user.improvementWorks; - userImprovementWorks.forEach((project) => { - console.log(project.improvementWorkId); - let improvementWork = getObjectById("improvementWork", project.improvementWorkId); - const projectBox = document.createElement('div'); - projectBox.classList.add('project-box'); - const projectName = document.createElement('h2'); - projectName.textContent = project.name; - projectBox.appendChild(projectName); - container === null || container === void 0 ? void 0 : container.appendChild(projectBox); - }); + const data = yield getImprovementWorksForUser(userHsaId); + let id = 0; + data.forEach((project) => __awaiter(this, void 0, void 0, function* () { + let title = project.name; + let department = yield getObjectById('unit', project.unitId); + if (department) { + let name = "Projektledare"; //Waiting for backend fix + let description = project.content; + let i = id; + let card = new projectCard(i, name, department.name, title, description, project.id); + projectCards[i] = card; + let cardHTML = card.generateHTML(); + //addEventListener(listenersLoaded, project.id, card); + let div = document.createElement('div'); + div.className = 'homePageProjectCardDiv'; // Set the class name(s) here + div.innerHTML = cardHTML; + if (!selectElement) + return; + selectElement.appendChild(div); // Stop if the container isn't found + id++; + } + else { + console.log(project.unitId + " is not a unit"); //Unit Ids on improvement work that do not exist + } + })); }); } -function displaySuggestions(user) { - return __awaiter(this, void 0, void 0, function* () { - const container = document.getElementById('suggestion-container'); - let userSuggestions = yield getSuggestions({ creatorHsaId: user.id }); - userSuggestions.forEach((suggestion) => { - const suggestionBox = document.createElement('div'); - suggestionBox.classList.add('suggestion-box'); - const suggestionName = document.createElement('h2'); - suggestionName.textContent = suggestion.name; - const suggestionDescription = document.createElement('p'); - suggestionDescription.textContent = suggestion.area; - suggestionDescription.classList.add('suggestion-description'); - suggestionDescription.style.display = 'none'; // Initially hide the description - const expandButton = document.createElement('button'); - expandButton.textContent = 'Expand'; - expandButton.addEventListener('click', () => { - if (suggestionDescription.style.display === 'none') { - suggestionDescription.style.display = 'block'; - expandButton.textContent = 'Collapse'; - } - else { - suggestionDescription.style.display = 'none'; - expandButton.textContent = 'Expand'; - } - }); - suggestionBox.appendChild(suggestionName); - suggestionBox.appendChild(expandButton); - suggestionBox.appendChild(suggestionDescription); - container === null || container === void 0 ? void 0 : container.appendChild(suggestionBox); - }); - }); +let projectCards = {}; +class projectCard { + constructor(id, name, department, title, description, projectId) { + this.name = name; + this.department = department; + this.title = title; + this.description = description; + this.id = id; + this.projectId = projectId; + } + showMoreInfo(blockId, thisTextId) { + const blockElement = document.getElementById(blockId); + if (blockElement) { + blockElement.style.display = "flex"; + } + const textElement = document.getElementById(thisTextId); + if (textElement) { + textElement.innerText = '^ Stäng detaljer'; + } + } + closeMoreInfo(blockId, thisTextId) { + const blockElement = document.getElementById(blockId); + if (blockElement) { + blockElement.style.display = "none"; + } + const textElement = document.getElementById(thisTextId); + if (textElement) { + textElement.innerText = '> Mer information'; + } + } + loadInitiatePage() { + alert('The initiate project page should now be loaded'); + } + generateHTML() { + return `<div class="homeTotalExpandedOngoingWorkCard"> + <div style="cursor: pointer;" class="flex-container ongoingCard" id="${this.projectId}"> + <div class="ongoingCardImageContainer toSinglePage"> + <div class = "flex-box ongoingCardImage toSinglePage" id="pinkFaded"></div> + </div> + <div class="div ongoingCardInfo toSinglePage"> + <p class="toSinglePage" id="ongoingCardManager">${this.name}</p> + <p class="toSinglePage" id="ongoingCardDepartment">${this.department}</p> + <p class="toSinglePage" id="ongoingCardIdeaTitle">${this.title}</p> + </div> + + <!--<button data-project-id="${this.id}" class="projectButton" role="button">Gå till projektsidan</button>--> + + + <div class="container ongoingSeeCardDetails toSinglePage"> + <div class="ongoingSeeCardDetailsInner"> + <p id="ongoingSeeDetailsButton${this.projectId}" class = "moreInfoClass">> Mer information</p> + </div> + </div> + </div> + <div class = "expandedOngoingWorkCard" id="expandedOngoingWorkCard${this.projectId}" style="display: none;"> + <div class ="expandedTextOngoingWorkCard"> + ${this.description} + </div> + </div> + </div> `; + } } diff --git a/client/homePage.ts b/client/homePage.ts index 86600390cb448cc08d66c87ab852625f21261bc2..b1dc63600d70d4b03283a34aa908d6c24a08e174 100644 --- a/client/homePage.ts +++ b/client/homePage.ts @@ -215,10 +215,7 @@ async function createNewIdeaCard( await createNewCards("HomePageIdeaCardDiv",suggestionContainer, user.id); } - const projectContainer = document.getElementById("project-container"); - if(projectContainer) { - await getProjects(projectContainer, user.id); - } + console.log(user.firstName + "user.firstname") const nameHeaderElement = document.getElementById('user-name-header') const nameElement = document.getElementById('user-name'); @@ -238,6 +235,10 @@ async function createNewIdeaCard( roleElement.textContent = "undefined"; } + const projectContainer = document.getElementById("project-container"); + if(projectContainer) { + await getProjects(projectContainer, user.id); + } }) .catch(error => { diff --git a/client/ideaBank/ideaBank.js b/client/ideaBank/ideaBank.js index efcf281e1f442f1e68254ee8930f4f0c6350d5f0..cde81343809d978a9ef4673b62da26699e28bd32 100644 --- a/client/ideaBank/ideaBank.js +++ b/client/ideaBank/ideaBank.js @@ -11,13 +11,14 @@ import { getObjectById, getSuggestions, } from "../Database/database.js"; //import {loadInitiatePage} from "../SidebarAndHeader/pageHandler.js"; let myIdeaCards = {}; class IdeaCard { - constructor(id, header, department, name, description, upvoteCount) { + constructor(id, header, department, name, description, upvoteCount, suggestionID) { this.header = header; this.department = department; this.name = name; this.description = description; this.upvoteCount = upvoteCount; this.id = id; + this.suggestionID = suggestionID; } generateHTML() { return `<div class="totalExpandedIdeaCard"> @@ -51,7 +52,7 @@ class IdeaCard { </div> <div class="expandedButton"> - <button class="initiateProjectButton" id="initiateProjectFromCard${this.id}">Initiera Project</button> + <button class="initiateProjectButton" id="initiateProjectFromCard${this.suggestionID}">Initiera Project</button> </div> </div> </div> @@ -90,14 +91,15 @@ function createNewCards(className, container) { suggestions.forEach((suggestion) => __awaiter(this, void 0, void 0, function* () { var unit = yield getObjectById("unit", suggestion.unitId); var user = yield getObjectById("users", suggestion.creatorHsaId); - createNewIdeaCard(suggestion.name, unit.name, user.firstName + " " + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter); + console.log(suggestion); + createNewIdeaCard(suggestion.name, unit.name, user.firstName + " " + user.lastName, suggestion.content, suggestion.upvotes.length, className, container, counter, suggestion.id); counter = counter + 1; })); }); } -function createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID) { +function createNewIdeaCard(header, department, name, description, upvoteCount, className, container, ID, suggestionID) { return __awaiter(this, void 0, void 0, function* () { - let card = new IdeaCard(ID, header, department, name, description, upvoteCount); + let card = new IdeaCard(ID, header, department, name, description, upvoteCount, suggestionID); let cardHTML = card.generateHTML(); myIdeaCards[ID] = card; let div = document.createElement("div"); diff --git a/client/ideaBank/ideaBank.ts b/client/ideaBank/ideaBank.ts index ed9e18fe5c57eadf9add58cfb078bb3bdae50870..f11cbc998e9e6afb0bdeb577e83ef63fbea8af11 100644 --- a/client/ideaBank/ideaBank.ts +++ b/client/ideaBank/ideaBank.ts @@ -15,6 +15,7 @@ class IdeaCard { private description: string; private upvoteCount: number; private id: number; + private suggestionID: string; constructor( id: number, @@ -22,7 +23,8 @@ class IdeaCard { department: string, name: string, description: string, - upvoteCount: number + upvoteCount: number, + suggestionID: string ) { this.header = header; this.department = department; @@ -30,6 +32,7 @@ class IdeaCard { this.description = description; this.upvoteCount = upvoteCount; this.id = id; + this.suggestionID = suggestionID; } generateHTML(): string { @@ -64,7 +67,7 @@ class IdeaCard { </div> <div class="expandedButton"> - <button class="initiateProjectButton" id="initiateProjectFromCard${this.id}">Initiera Project</button> + <button class="initiateProjectButton" id="initiateProjectFromCard${this.suggestionID}">Initiera Project</button> </div> </div> </div> @@ -106,6 +109,7 @@ async function createNewCards(className: string, container: Element) { suggestions.forEach(async (suggestion) => { var unit = await getObjectById("unit", suggestion.unitId); var user = await getObjectById("users", suggestion.creatorHsaId); + console.log(suggestion) createNewIdeaCard( suggestion.name, unit.name, @@ -114,7 +118,8 @@ async function createNewCards(className: string, container: Element) { suggestion.upvotes.length, className, container, - counter + counter, + suggestion.id ); counter = counter + 1; }); @@ -128,7 +133,8 @@ async function createNewIdeaCard( upvoteCount: number, className: string, container: Element, - ID: number + ID: number, + suggestionID: string ) { let card = new IdeaCard( ID, @@ -136,7 +142,8 @@ async function createNewIdeaCard( department, name, description, - upvoteCount + upvoteCount, + suggestionID ); let cardHTML = card.generateHTML(); myIdeaCards[ID] = card; diff --git a/client/initiateForbattringsarbete/initiateIdea.js b/client/initiateForbattringsarbete/initiateIdea.js index 94f1f5ea23729da5eb2147a9c7d27a19b43f2ba1..66a71f42d7a2e4d3cf500a7ac6b3a1b4285ebdea 100644 --- a/client/initiateForbattringsarbete/initiateIdea.js +++ b/client/initiateForbattringsarbete/initiateIdea.js @@ -76,8 +76,14 @@ function createAssignedEmployeeDesign(s, x, employeeList) { return container; } //Functions to load the page +function clearFromEventListeners(container) { + const clonedContainer = container.cloneNode(true); + container.replaceWith(clonedContainer); + console.log("cleared"); +} export function loadPage(id) { return __awaiter(this, void 0, void 0, function* () { + console.log(id); const container = document.querySelector('#container-fluid'); if (!container) return; // Stop if the container isn't found diff --git a/client/initiateForbattringsarbete/initiateIdea.ts b/client/initiateForbattringsarbete/initiateIdea.ts index 3b8d5502736aefbf537fd920b3ab68417f16fd01..e688ae95eddfa42f951dd597d6bba377a10db9ac 100644 --- a/client/initiateForbattringsarbete/initiateIdea.ts +++ b/client/initiateForbattringsarbete/initiateIdea.ts @@ -82,11 +82,17 @@ function createAssignedEmployeeDesign(s: string, x: JQuery<HTMLElement>, employe } //Functions to load the page +function clearFromEventListeners(container: Element) { + const clonedContainer = container.cloneNode(true); + container.replaceWith(clonedContainer); + console.log("cleared"); +} export async function loadPage (id: string) { + console.log(id); const container = document.querySelector('#container-fluid'); + if (!container) return; // Stop if the container isn't found - const linkelementCSS = document.createElement('link'); linkelementCSS.rel = 'styleSheet'; linkelementCSS.href = 'initiateForbattringsarbete/initiateIdea.css'; @@ -120,7 +126,7 @@ export async function loadPage (id: string) { //Eventlistenerbuttons: const createButton = document.getElementById('createProjectFromSuggestionButton') as HTMLButtonElement | null; const selectEmployeeButton = document.getElementById('selectEmployee'); - + document.addEventListener("click", function (event) { const target = event.target as HTMLElement; //adds an event listener for the initiate page @@ -138,7 +144,6 @@ export async function loadPage (id: string) { }); if (specificElement) { - // Insert the generated element before the specific element container.insertBefore(generatedElement, container.firstChild); // Insert the specific element into the target element diff --git a/client/projectPage/projectPageA.js b/client/projectPage/projectPageA.js index 0fbc9f98a6f685073075b81fa0fc2197ab35d2ba..d3c2df3075fc2ae4de211bbf5270b3d3d617ec99 100644 --- a/client/projectPage/projectPageA.js +++ b/client/projectPage/projectPageA.js @@ -8,13 +8,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }); }; import { loadCurrentProjects } from "../SidebarAndHeader/pageHandler.js"; -import { finalizeImprovementWork } from "../Database/database.js"; +import { getObjectById, finalizeImprovementWork, updateInstance } from "../Database/database.js"; import { loadProjectPageP, loadProjectPageS, loadProjectPageG } from "../SidebarAndHeader/pageHandler.js"; +function updateStage(stage, id) { + return __awaiter(this, void 0, void 0, function* () { + updateInstance("improvementWork", id, { currentStage: stage }); + }); +} export function loadPage(projectId) { const container = document.querySelector('#container-fluid'); const nextPageButton = document.getElementById('toCurrentProjects'); if (!container) return; // Stop if the container isn't found + updateStage("Agera", projectId); fetch('projectPage/ProjectPageA.html') .then(response => response.text()) .then(data => { @@ -32,6 +38,7 @@ export function loadPage(projectId) { container.addEventListener('click', (event) => { const target = event.target; // Type assertion if (target.id === 'toCurrentProjects') { + updateStage("Avslutat", projectId); finalize(projectId); } else if (target.id === 'toP') { @@ -43,11 +50,30 @@ export function loadPage(projectId) { else if (target.id === 'toS') { loadProjectPageS(projectId); } + else if (target.id === "saveEditBtnA") { + saveImprovementWorkEditA(projectId); + } }); function initializeTooltips() { // Use jQuery to select the elements and initialize the tooltip $('[data-toggle="tooltip"]').tooltip({ delay: { "show": 0, "hide": 100 } }); } + loadImprovementWorkDataPageA(projectId); +} +function loadImprovementWorkDataPageA(projectId) { + return __awaiter(this, void 0, void 0, function* () { + const improvementWork = yield getObjectById('improvementWork', projectId); + const title = document.getElementById("title"); + const a1 = document.getElementById("a1"); + const a2 = document.getElementById("a2"); + const a3 = document.getElementById("a3"); + const a4 = document.getElementById("a4"); + title.textContent = improvementWork.name; + a1.value = improvementWork.a1; + a2.value = improvementWork.a2; + a3.value = improvementWork.a3; + a4.value = improvementWork.a4; + }); } function finalize(projectId) { return __awaiter(this, void 0, void 0, function* () { @@ -55,8 +81,17 @@ function finalize(projectId) { if (user) { var userId = JSON.parse(user)[0].id; } - console.log(userId); finalizeImprovementWork(userId, projectId); loadCurrentProjects(); }); } +function saveImprovementWorkEditA(projectId) { + return __awaiter(this, void 0, void 0, function* () { + const a1 = document.getElementById("a1"); + const a2 = document.getElementById("a2"); + const a3 = document.getElementById("a3"); + const a4 = document.getElementById("a4"); + let update = { a1: a1.value, a2: a2.value, a3: a3.value, a4: a4.value }; + updateInstance("improvementWork", projectId, update); + }); +} diff --git a/client/projectPage/projectPageA.ts b/client/projectPage/projectPageA.ts index 90f50e721a62f21edf92c1873ecda7da5ee4ca7f..6c81724ff39e0801b61bbac8134f387c01a994b0 100644 --- a/client/projectPage/projectPageA.ts +++ b/client/projectPage/projectPageA.ts @@ -1,7 +1,11 @@ import { loadCurrentProjects } from "../SidebarAndHeader/pageHandler.js"; import {getObjectById, finalizeImprovementWork, updateInstance, getUnits, getHospitals} from "../Database/database.js"; import { updateDoc, doc } from "firebase/firestore"; -import { loadProjectPageP, loadProjectPageS,loadProjectPageG } from "../SidebarAndHeader/pageHandler.js"; +import { loadProjectPageP, loadProjectPageS,loadProjectPageG, loadProjectPageA } from "../SidebarAndHeader/pageHandler.js"; + +async function updateStage(stage : string, id : string){ + updateInstance("improvementWork", id, {currentStage:stage}) + } export function loadPage (projectId : string) { const container = document.querySelector('#container-fluid'); @@ -9,6 +13,8 @@ export function loadPage (projectId : string) { if (!container) return; // Stop if the container isn't found + updateStage("Agera", projectId); + fetch('projectPage/ProjectPageA.html') .then(response => response.text()) .then(data => { @@ -32,6 +38,7 @@ export function loadPage (projectId : string) { const target = event.target as HTMLElement; // Type assertion if (target.id === 'toCurrentProjects') { + updateStage("Avslutat", projectId); finalize(projectId); }else if(target.id === 'toP'){ loadProjectPageP(projectId); diff --git a/client/projectPage/projectPageG.js b/client/projectPage/projectPageG.js index 8778c12bcc91b0b64155c490d22fb86e57147788..babd3885ec92365b6e673dd796fc38bec67a1cfb 100644 --- a/client/projectPage/projectPageG.js +++ b/client/projectPage/projectPageG.js @@ -1,9 +1,25 @@ +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; import { loadProjectPageP, loadProjectPageS } from "../SidebarAndHeader/pageHandler.js"; +import { getObjectById, updateInstance } from "../Database/database.js"; +function updateStage(stage, id) { + return __awaiter(this, void 0, void 0, function* () { + updateInstance("improvementWork", id, { currentStage: stage }); + }); +} export function loadPage(projectId) { const container = document.querySelector('#container-fluid'); const nextPageButton = document.getElementById('toS'); if (!container) return; // Stop if the container isn't found + updateStage("Göra", projectId); fetch('projectPage/ProjectPageG.html') .then(response => response.text()) .then(data => { @@ -29,9 +45,41 @@ export function loadPage(projectId) { else if (target.id === 'toP') { loadProjectPageP(projectId); } + else if (target.id === "saveEditBtnG") { + saveImprovementWorkEditG(projectId); + } }); + loadImprovementWorkDataPageG(projectId); function initializeTooltips() { // Use jQuery to select the elements and initialize the tooltip $('[data-toggle="tooltip"]').tooltip({ delay: { "show": 0, "hide": 100 } }); } } +function loadImprovementWorkDataPageG(projectId) { + return __awaiter(this, void 0, void 0, function* () { + const improvementWork = yield getObjectById('improvementWork', projectId); + const title = document.getElementById("title"); + const g1 = document.getElementById("g1"); + const g2 = document.getElementById("g2"); + const g3 = document.getElementById("g3"); + const g4 = document.getElementById("g4"); + const g5 = document.getElementById("g5"); + title.textContent = improvementWork.name; + g1.value = improvementWork.g1; + g2.value = improvementWork.g2; + g3.value = improvementWork.g3; + g4.value = improvementWork.g4; + g5.value = improvementWork.g5; + }); +} +function saveImprovementWorkEditG(projectId) { + return __awaiter(this, void 0, void 0, function* () { + const g1 = document.getElementById("g1"); + const g2 = document.getElementById("g2"); + const g3 = document.getElementById("g3"); + const g4 = document.getElementById("g4"); + const g5 = document.getElementById("g5"); + let update = { g1: g1.value, g2: g2.value, g3: g3.value, g4: g4.value, g5: g5.value }; + updateInstance("improvementWork", projectId, update); + }); +} diff --git a/client/projectPage/projectPageG.ts b/client/projectPage/projectPageG.ts index 91e97523fd601acc818c60e1eb155ab2844307f7..a3fbf6d8dd540cc3f21668243d2feb48899ca8e7 100644 --- a/client/projectPage/projectPageG.ts +++ b/client/projectPage/projectPageG.ts @@ -1,12 +1,20 @@ import { loadProjectPageP, loadProjectPageS } from "../SidebarAndHeader/pageHandler.js"; import {getObjectById, updateInstance } from "../Database/database.js"; +async function updateStage(stage : string, id : string){ + updateInstance("improvementWork", id, {currentStage:stage}) +} + export function loadPage (projectId : string) { const container = document.querySelector('#container-fluid'); const nextPageButton = document.getElementById('toS') as HTMLElement; if (!container) return; // Stop if the container isn't found + updateStage("Göra", projectId); + + + fetch('projectPage/ProjectPageG.html') .then(response => response.text()) .then(data => { diff --git a/client/projectPage/projectPageP.js b/client/projectPage/projectPageP.js index a6edd293a0ed2deee174af29c3138baa8a9630ec..b3733c535fa3a1a765f4f46739b3d2272eb9c5fb 100644 --- a/client/projectPage/projectPageP.js +++ b/client/projectPage/projectPageP.js @@ -8,12 +8,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }); }; import { loadProjectPageG } from "../SidebarAndHeader/pageHandler.js"; -import { getObjectById } from "../Database/database.js"; +import { getObjectById, updateInstance } from "../Database/database.js"; +function updateStage(stage, id) { + return __awaiter(this, void 0, void 0, function* () { + updateInstance("improvementWork", id, { currentStage: stage }); + }); +} export function loadPage(projectId) { const container = document.querySelector('#container-fluid'); const nextPageButton = document.getElementById('toG'); if (!container) return; // Stop if the container isn't found + updateStage("Planera", projectId); fetch('projectPage/ProjectPageP.html') .then(response => response.text()) .then(data => { @@ -40,6 +46,9 @@ export function loadPage(projectId) { if (target.id === 'toG') { loadProjectPageG(projectId); } + if (target.id === "saveEditBtnP") { + saveImprovementWorkEditP(projectId); + } }); loadImprovementWorkDataPageP(projectId); } @@ -49,7 +58,35 @@ function initializeTooltips() { } function loadImprovementWorkDataPageP(projectId) { return __awaiter(this, void 0, void 0, function* () { - const data = yield getObjectById('improvementWork', projectId); - console.log(data.name); + const improvementWork = yield getObjectById('improvementWork', projectId); + const titleP = document.getElementById("title"); + const p1 = document.getElementById("p1"); + const p2 = document.getElementById("p2"); + const p3 = document.getElementById("p3"); + const p4 = document.getElementById("p4"); + const p5 = document.getElementById("p5"); + const p6 = document.getElementById("p6"); + const p7 = document.getElementById("p7"); + titleP.textContent = improvementWork.name; + p1.value = improvementWork.p1; + p2.value = improvementWork.p2; + p3.value = improvementWork.p3; + p4.value = improvementWork.p4; + p5.value = improvementWork.p5; + p6.value = improvementWork.p6; + p7.value = improvementWork.p7; + }); +} +function saveImprovementWorkEditP(projectId) { + return __awaiter(this, void 0, void 0, function* () { + const p1 = document.getElementById("p1"); + const p2 = document.getElementById("p2"); + const p3 = document.getElementById("p3"); + const p4 = document.getElementById("p4"); + const p5 = document.getElementById("p5"); + const p6 = document.getElementById("p6"); + const p7 = document.getElementById("p7"); + let update = { p1: p1.value, p2: p2.value, p3: p3.value, p4: p4.value, p5: p5.value, p6: p6.value, p7: p7.value }; + updateInstance("improvementWork", projectId, update); }); } diff --git a/client/projectPage/projectPageP.ts b/client/projectPage/projectPageP.ts index 727df7f137dc3c40f4fd263093033e97720ea4ad..0edda516fde168bd6c9e082b5d7814b44d2d45c0 100644 --- a/client/projectPage/projectPageP.ts +++ b/client/projectPage/projectPageP.ts @@ -1,5 +1,10 @@ import { loadProjectPageG } from "../SidebarAndHeader/pageHandler.js"; -import {getObjectById,updateInstance, getHospitals, getUnits, getImprovementWorks} from "../Database/database.js"; +import {getObjectById, updateInstance } from "../Database/database.js"; + +async function updateStage(stage : string, id : string){ + updateInstance("improvementWork", id, {currentStage:stage}) + } + export function loadPage (projectId:string) { @@ -8,11 +13,14 @@ export function loadPage (projectId:string) { if (!container) return; // Stop if the container isn't found + updateStage("Planera", projectId); fetch('projectPage/ProjectPageP.html') .then(response => response.text()) .then(data => { + + // Create a temporary container element to hold the loaded content const tempContainer = document.createElement('div'); tempContainer.innerHTML = data; diff --git a/client/projectPage/projectPageS.js b/client/projectPage/projectPageS.js index 788e36edf2ab7fdb747771d1394ad5bf84a2c04b..2ccf607a6f2ba90c16f415e097ff057c98771978 100644 --- a/client/projectPage/projectPageS.js +++ b/client/projectPage/projectPageS.js @@ -1,37 +1,81 @@ +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; import { loadProjectPageA, loadProjectPageP, loadProjectPageG } from "../SidebarAndHeader/pageHandler.js"; +import { getObjectById, updateInstance } from "../Database/database.js"; +function updateStage(stage, id) { + return __awaiter(this, void 0, void 0, function* () { + updateInstance("improvementWork", id, { currentStage: stage }); + }); +} export function loadPage(projectId) { - const container = document.querySelector('#container-fluid'); - const nextPageButton = document.getElementById('toA'); - if (!container) - return; // Stop if the container isn't found - fetch('projectPage/ProjectPageS.html') - .then(response => response.text()) - .then(data => { - // Create a temporary container element to hold the loaded content - const tempContainer = document.createElement('div'); - tempContainer.innerHTML = data; - // Select the specific element with the class you want - const specificElement = tempContainer.querySelector('.wholePageS'); - if (specificElement) { - // Insert the specific element into the target element - container.insertBefore(specificElement, container.firstChild); - initializeTooltips(); + return __awaiter(this, void 0, void 0, function* () { + const container = document.querySelector('#container-fluid'); + const nextPageButton = document.getElementById('toA'); + if (!container) + return; // Stop if the container isn't found + updateStage("Studera", projectId); + fetch('projectPage/ProjectPageS.html') + .then(response => response.text()) + .then(data => { + // Create a temporary container element to hold the loaded content + const tempContainer = document.createElement('div'); + tempContainer.innerHTML = data; + // Select the specific element with the class you want + const specificElement = tempContainer.querySelector('.wholePageS'); + if (specificElement) { + // Insert the specific element into the target element + container.insertBefore(specificElement, container.firstChild); + initializeTooltips(); + } + }); + container.addEventListener('click', (event) => { + const target = event.target; // Type assertion + if (target.id === 'toA') { + loadProjectPageA(projectId); + } + else if (target.id === 'toP') { + loadProjectPageP(projectId); + } + else if (target.id === 'toG') { + loadProjectPageG(projectId); + } + else if (target.id === "saveEditBtnS") { + saveImprovementWorkEditS(projectId); + } + }); + loadImprovementWorkDataPageS(projectId); + function initializeTooltips() { + // Use jQuery to select the elements and initialize the tooltip + $('[data-toggle="tooltip"]').tooltip({ delay: { "show": 0, "hide": 100 } }); } }); - container.addEventListener('click', (event) => { - const target = event.target; // Type assertion - if (target.id === 'toA') { - loadProjectPageA(projectId); - } - else if (target.id === 'toP') { - loadProjectPageP(projectId); - } - else if (target.id === 'toG') { - loadProjectPageG(projectId); - } +} +function loadImprovementWorkDataPageS(projectId) { + return __awaiter(this, void 0, void 0, function* () { + const improvementWork = yield getObjectById('improvementWork', projectId); + const title = document.getElementById("title"); + const s1 = document.getElementById("s1"); + const s2 = document.getElementById("s2"); + const s3 = document.getElementById("s3"); + title.textContent = improvementWork.name; + s1.value = improvementWork.s1; + s2.value = improvementWork.s2; + s3.value = improvementWork.s3; + }); +} +function saveImprovementWorkEditS(projectId) { + return __awaiter(this, void 0, void 0, function* () { + const s1 = document.getElementById("s1"); + const s2 = document.getElementById("s2"); + const s3 = document.getElementById("s3"); + let update = { s1: s1.value, s2: s2.value, s3: s3.value }; + updateInstance("improvementWork", projectId, update); }); - function initializeTooltips() { - // Use jQuery to select the elements and initialize the tooltip - $('[data-toggle="tooltip"]').tooltip({ delay: { "show": 0, "hide": 100 } }); - } } diff --git a/client/projectPage/projectPageS.ts b/client/projectPage/projectPageS.ts index fa543c566681bb7cb64ee5c91c0447f14db96a06..efa6edac804dbe3d78f7b0383cfe78762c36ca8a 100644 --- a/client/projectPage/projectPageS.ts +++ b/client/projectPage/projectPageS.ts @@ -1,12 +1,19 @@ import { loadProjectPageA,loadProjectPageP,loadProjectPageG, loadProjectPageS } from "../SidebarAndHeader/pageHandler.js"; import {getObjectById, updateInstance } from "../Database/database.js"; -export function loadPage (projectId : string) { +async function updateStage(stage : string, id : string){ + updateInstance("improvementWork", id, {currentStage:stage}) + } + +export async function loadPage (projectId : string) { const container = document.querySelector('#container-fluid'); const nextPageButton = document.getElementById('toA') as HTMLElement; if (!container) return; // Stop if the container isn't found + updateStage("Studera", projectId); + + fetch('projectPage/ProjectPageS.html') .then(response => response.text()) .then(data => {