From fbfbfb77be986175dfc95ca5f56a0b3a628af337 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jona=20Kl=C3=A4=C3=9F?= Date: Sun, 5 May 2024 21:58:09 +0200 Subject: [PATCH] now able to create chats with multiple users --- src/components/ProtectedData.vue | 72 ++++++++++++++++++++++++++++++-- src/stores/chat-store.ts | 12 ++++++ 2 files changed, 80 insertions(+), 4 deletions(-) diff --git a/src/components/ProtectedData.vue b/src/components/ProtectedData.vue index a096b8a..1c99b11 100644 --- a/src/components/ProtectedData.vue +++ b/src/components/ProtectedData.vue @@ -19,10 +19,25 @@ export default defineComponent({ const userLoaded = ref(false); const chatName = ref(''); + const userSearch = ref(''); const chats = ref([] as chat[]); const chatsLoaded = ref(false); + const matchingUsers = ref([] as ptpUser[]); + const usersForChat = ref([] as string[]); + + const usersForChatOptions = ref([] as {label: string, value: string}[]); + const updateUsersForChatOptions = async () =>{ + if(!usersLoaded.value){ + await loadUsers(); + } + usersForChatOptions.value = users.value + .filter((u, index) => u.keycloakID !== user.value.keycloakID && index < 5) + .map((u) => { + return {label: u.firstName + ' ' + u.lastName, value: u.keycloakID}; + }); + } const logout = () => { userStore.logout(); @@ -34,10 +49,13 @@ export default defineComponent({ await userStore.loadAllUsers(); usersLoaded.value = true; users.value = userStore.users; - } + }; const createChat = async(chatName: string)=>{ - await chatStore.createChat(chatName, userStore.users.map(u => u.keycloakID)); + if(chatName == ""){ + chatName = "Chat"; + } + await chatStore.createChat(chatName, usersForChat.value); } const loadChats = async() => { @@ -48,7 +66,7 @@ export default defineComponent({ usersLoaded.value = true; console.log(users.value); console.log(chats.value); - } + }; onMounted(async () => { userLoaded.value = userStore.userLoaded; user.value = userStore.user; @@ -70,6 +88,12 @@ export default defineComponent({ loadChats, chats, chatsLoaded, + + userSearch, + matchingUsers, + usersForChatOptions, + usersForChat, + updateUsersForChatOptions, }; }, }) @@ -96,7 +120,45 @@ export default defineComponent({
- + +
+ + + +
+
+ + + +

@@ -109,6 +171,8 @@ export default defineComponent({ + +