Skip to content

Commit

Permalink
fix:(Invite)Users able to see moderated tests in shared with me
Browse files Browse the repository at this point in the history
  • Loading branch information
jvJUCA committed May 21, 2024
1 parent 4ef89ef commit 010be69
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 17 deletions.
1 change: 1 addition & 0 deletions src/components/organisms/ModeratedCoopsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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}`,
Expand Down
28 changes: 14 additions & 14 deletions src/controllers/TestController.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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) {
Expand All @@ -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)
Expand Down
1 change: 0 additions & 1 deletion src/controllers/UserController.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion src/views/admin/ManagerView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion src/views/public/ModeratedTestView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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)
Expand Down

0 comments on commit 010be69

Please sign in to comment.