implemented functionality to index page

This commit is contained in:
JonaKl
2024-05-13 09:44:58 +02:00
parent cfd19c2660
commit e9b042a2ea
4 changed files with 101 additions and 222 deletions

View File

@@ -3,11 +3,10 @@ import { chat } from 'src/models';
import { api } from 'src/boot/axios';
import { useUserStore } from 'stores/user-store';
const userStore = useUserStore();
export const useChatStore = defineStore('chatStore',{
state:() => ({
chats: [] as chat[],
chatsLoaded: false
}),
actions: {
async getChatsByUser(): Promise<chat[]> {
@@ -17,10 +16,12 @@ export const useChatStore = defineStore('chatStore',{
return this.chats;
},
async loadChatsByUser() : Promise<chat[]>{
this.chats = (await api.get("/users/chat/" + userStore.id)).data.response;
this.chats = (await api.get("/users/chat/" + useUserStore().id)).data.response;
this.chatsLoaded = true;
return this.chats;
},
async createChat(chatName: string, members: string[]){
const userStore = useUserStore();
if(userStore.id) {
if (!members.includes(userStore.id)) {
members.push(userStore.id);

View File

@@ -34,7 +34,6 @@ export const useUserStore = defineStore('userStore', {
usersLoaded: false,
keycloak: null as Keycloak | null,
id: "",
users: [] as ptpUser[],
}),
actions: {
async getPtpUserById(id : string) {
@@ -46,18 +45,18 @@ export const useUserStore = defineStore('userStore', {
async loadPtpUsersById(id : string) : Promise<responseModel> {
return (await api.get("/users/login/"+id)).data;
},
getAllPtpUsers() {
this.loadAllPtpUsers().then((response : ptpUser[]) => {
this.users = response;
this.usersLoaded = true;
})
},
async loadAllPtpUsers() {
return (await api.get("/users/user")).data;
},
async initKeycloak() : Promise<Keycloak>{
try {