Skip to content

Commit

Permalink
feat: 🚧 Add removeUserFromProject function
Browse files Browse the repository at this point in the history
  • Loading branch information
clairenollet committed Nov 10, 2022
1 parent d74b99d commit 9430fc6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
6 changes: 6 additions & 0 deletions apps/client/src/stores/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ export const useProjectStore = defineStore('project', () => {
await updateProject(selectedProject.value)
}

const removeUserFromProject = async (userEmail) => {
const userToRemove = await selectedProject.value.users.find(user => user.email === userEmail)
console.log(userToRemove)
}

return {
selectedProject,
projects,
Expand All @@ -41,5 +46,6 @@ export const useProjectStore = defineStore('project', () => {
createProject,
updateProject,
addUserToProject,
removeUserFromProject,
}
})
15 changes: 14 additions & 1 deletion apps/client/src/views/projects/DsoTeam.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ const headers = [
const rows = ref([])
// TODO : gérer DsfrTags
const setRows = () => {
rows.value = []
Expand All @@ -43,6 +42,7 @@ const setRows = () => {
if (selectedProject.value.users) {
selectedProject.value.users.forEach(user => {
rows.value.push([user.email, {
onClick: removeUserFromProject(user.email),
component: DsfrTag,
label: 'user',
class: 'fr-tag--dismiss',
Expand All @@ -54,6 +54,8 @@ const setRows = () => {
}
}
console.log('rows: ', rows.value)
const addUserToProject = async () => {
// TODO : récupérer données keycloak de l'utilisateur via son e-mail ?
newUser.value.id = 'xxxxxx'
Expand All @@ -73,6 +75,11 @@ const addUserToProject = async () => {
// })
}
const removeUserFromProject = async (userEmail) => {
console.log(userEmail)
await projectStore.removeUserFromProject(userEmail)
}
onMounted(() => {
setRows()
})
Expand Down Expand Up @@ -122,3 +129,9 @@ watch(projectStore.selectedProject, () => {
@click="addUserToProject()"
/>
</template>

<style>
.test {
background-color: aliceblue;
}
</style>

0 comments on commit 9430fc6

Please sign in to comment.