Skip to content

Commit

Permalink
fix: successfully checking if is Cooperator, admin or evaluator
Browse files Browse the repository at this point in the history
  • Loading branch information
jvJUCA committed Apr 22, 2024
1 parent 7ba181c commit 061d40e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
8 changes: 3 additions & 5 deletions src/controllers/UserController.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ export default class UserController extends Controller {

async markNotificationAsRead(payload) {
const userToUpdate = new User(payload.user)
console.log(userToUpdate)
const index = userToUpdate.notifications.findIndex(
(n) => n.createdDate === payload.notification.createdDate,
)
Expand Down Expand Up @@ -82,7 +81,9 @@ export default class UserController extends Controller {
)
console.log('depois do filtro: ', userData.notifications)
// Atualizar o documento do usuário com as notificações filtradas
await super.update('users', userId, { notifications: userData.notifications })
await super.update('users', userId, {
notifications: userData.notifications,
})
}
} else {
console.log(`User document with ID ${userDocID} not found.`)
Expand Down Expand Up @@ -114,7 +115,6 @@ export default class UserController extends Controller {
delete userData.myAnswers[testIdToRemove]
}


await super.update('users', userId, userData)

console.log(`Test ${testIdToRemove} removed from user ${userId}'s data.`)
Expand All @@ -123,6 +123,4 @@ export default class UserController extends Controller {
throw error
}
}


}
10 changes: 7 additions & 3 deletions src/views/admin/ManagerView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -394,16 +394,20 @@ export default {
// Check if the user is a collaborator or owner
const isTestOwner = this.test.testAdmin?.userDocId === this.user.id
if (isTestOwner) return 0
const answers = []
const answersEntries = Object.entries(this.user.myAnswers)
answersEntries.forEach((a) => {
answers.push(a[1])
})
const isCooperator = answers.find((a) => a.testDocId === this.test.id)
if (isCooperator) {
return isCooperator.accessLevel
const coopsInfo = this.test.cooperators.find(
(coops) => coops.userDocId === this.user.id,
)
if (coopsInfo) {
return coopsInfo.accessLevel
}
u
}
return 1
Expand Down

0 comments on commit 061d40e

Please sign in to comment.