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({
-