diff --git a/src/components/organisms/ModeratedCoopsView.vue b/src/components/organisms/ModeratedCoopsView.vue index 11eed46e..4c77db7e 100644 --- a/src/components/organisms/ModeratedCoopsView.vue +++ b/src/components/organisms/ModeratedCoopsView.vue @@ -540,6 +540,7 @@ export default { this.$store.dispatch('addNotification', { userId: guest.userDocId, notification: new Notification({ + accessLevel: 1, title: `You have been invited to test ${this.test.testTitle}!`, description: this.inviteMessage, redirectsTo: `${path}/${this.test.id}/${guest.userDocId}`, diff --git a/src/controllers/TestController.js b/src/controllers/TestController.js index d925911d..ed1311da 100644 --- a/src/controllers/TestController.js +++ b/src/controllers/TestController.js @@ -26,7 +26,6 @@ export default class TestController extends Controller { return await super.create(COLLECTION, payload.toFirestore()) } - // async deleteTest(payload) { // await super.update('users', payload.testAdmin.userDocId, payload.auxUser) // return await super.delete(COLLECTION, payload.id) @@ -43,19 +42,21 @@ export default class TestController extends Controller { const collaborators = await testToDelete.data() const cooperators = collaborators.cooperators - if(cooperators){ - console.log(cooperators) - const promises = [] - - for (const cooperator of cooperators) { - // Add the call to remove notifications for the test being deleted - promises.push( - userController.removeTestFromUser(cooperator.userDocId, payload.id), - ) - promises.push(userController.removeNotificationsForTest(payload.id,cooperators)) + if (cooperators) { + console.log(cooperators) + const promises = [] + + for (const cooperator of cooperators) { + // Add the call to remove notifications for the test being deleted + promises.push( + userController.removeTestFromUser(cooperator.userDocId, payload.id), + ) + promises.push( + userController.removeNotificationsForTest(payload.id, cooperators), + ) + } + await Promise.all(promises) } - await Promise.all(promises) - } await super.update('users', payload.testAdmin.userDocId, payload.auxUser) await super.delete(COLLECTION, payload.id) } catch (error) { @@ -66,7 +67,6 @@ export default class TestController extends Controller { async updateTest(payload) { try { - return await super.update(COLLECTION, payload.id, payload.toFirestore()) } catch (e) { console.error(e) diff --git a/src/controllers/UserController.js b/src/controllers/UserController.js index f955467d..947d15e0 100644 --- a/src/controllers/UserController.js +++ b/src/controllers/UserController.js @@ -2,7 +2,6 @@ import Controller from '@/controllers/BaseController' import User from '@/models/UserModel' -import { log } from 'handlebars' const COLLECTION = 'users' export default class UserController extends Controller { diff --git a/src/views/admin/ManagerView.vue b/src/views/admin/ManagerView.vue index 64e27501..58a94749 100644 --- a/src/views/admin/ManagerView.vue +++ b/src/views/admin/ManagerView.vue @@ -485,7 +485,6 @@ export default { (coop) => coop.token === this.token, ) if (invitation) { - console.log('Caiu como invitation') // User invited, and they have an account if (this.user.email === invitation.email) { // Accept Collaboration diff --git a/src/views/public/ModeratedTestView.vue b/src/views/public/ModeratedTestView.vue index 9edf2e98..35a09421 100644 --- a/src/views/public/ModeratedTestView.vue +++ b/src/views/public/ModeratedTestView.vue @@ -978,7 +978,7 @@ export default { await this.verifyAdmin() if (this.token != null) { if (this.token == this.test.id) { - this.$toast.info('Use a session your session link to the test') + this.$toast.info('Use a session link to access your moderated test!') this.$router.push('/managerview/' + this.test.id) } this.sessionCooperator = this.test.cooperators.find( @@ -998,6 +998,14 @@ export default { this.$toast.info('Use a session your session link to the test') this.$router.push('/managerview/' + this.test.id) } + + if (!this.isAdmin) { + await this.$store.dispatch('acceptTestCollaboration', { + test: this.test, + cooperator: this.user, + }) + } + await this.mappingSteps() this.consentCompleted = this.currentUserTestAnswer.consentCompleted const ref = doc(db, 'tests/', this.roomTestId)