From 2bc17e8cf47cbf6d430a7289a5b48430a0f04395 Mon Sep 17 00:00:00 2001 From: Veljko Tosic Date: Sun, 8 Mar 2026 15:42:20 +0100 Subject: [PATCH] Now uses policy and max participants for creating whiteboards --- front/src/services/whiteboardService.ts | 5 +++-- front/src/stores/whiteboards.ts | 5 +++-- front/src/views/HomeView.vue | 6 +++++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/front/src/services/whiteboardService.ts b/front/src/services/whiteboardService.ts index 0757a88..d293a31 100644 --- a/front/src/services/whiteboardService.ts +++ b/front/src/services/whiteboardService.ts @@ -1,5 +1,6 @@ import type {JoinResult, Whiteboard} from "@/types"; import {api} from './api' +import type {WhiteboardJoinPolicy} from "@/enums"; export const whiteboardService = { async getWhiteboardHistory(): Promise { @@ -12,8 +13,8 @@ export const whiteboardService = { return raw.map(mapWhiteboard) }, - async createNewWhiteboard(title: string): Promise { - return await api.post('/api/Whiteboard', { title: title, maxParticipants: 10, joinPolicy: 0}) + async createNewWhiteboard(title: string, joinPolicy: WhiteboardJoinPolicy, maxParticipants: number): Promise { + return await api.post('/api/Whiteboard', { title: title, maxParticipants: maxParticipants, joinPolicy: joinPolicy}) }, async getWhiteboardById(id: string): Promise { diff --git a/front/src/stores/whiteboards.ts b/front/src/stores/whiteboards.ts index b544299..9422eab 100644 --- a/front/src/stores/whiteboards.ts +++ b/front/src/stores/whiteboards.ts @@ -2,6 +2,7 @@ import { defineStore } from 'pinia' import { ref } from 'vue' import type {JoinResult, Whiteboard} from '@/types' import { whiteboardService } from '@/services/whiteboardService' +import type {WhiteboardJoinPolicy} from "@/enums"; export const useWhiteboardsStore = defineStore('whiteboards', () => { const ownedWhiteboards = ref([]) @@ -35,13 +36,13 @@ export const useWhiteboardsStore = defineStore('whiteboards', () => { } } - async function createNewWhiteboard(title: string): Promise { + async function createNewWhiteboard(title: string, joinPolicy: WhiteboardJoinPolicy, maxParticipants: number): Promise { let newWhiteboard: Whiteboard; isLoading.value = true error.value = null try { - const newId = await whiteboardService.createNewWhiteboard(title) + const newId = await whiteboardService.createNewWhiteboard(title, joinPolicy, maxParticipants) newWhiteboard = await whiteboardService.getWhiteboardById(newId) } catch (err: any) { error.value = err.message ?? 'Failed to create whiteboard' diff --git a/front/src/views/HomeView.vue b/front/src/views/HomeView.vue index ae11470..415c6cc 100644 --- a/front/src/views/HomeView.vue +++ b/front/src/views/HomeView.vue @@ -25,7 +25,11 @@ async function handleCreateNewWhiteboard() { } try { - const newWhiteboardId = await whiteboards.createNewWhiteboard(whiteboardTitle.value.trim()) + const newWhiteboardId = await whiteboards.createNewWhiteboard( + whiteboardTitle.value.trim(), + selectedJoinPolicy.value, + maxParticipants.value + ) showCreateModal.value = false whiteboardTitle.value = ''