Now uses policy and max participants for creating whiteboards

This commit is contained in:
2026-03-08 15:42:20 +01:00
parent 897a46aa7b
commit 2bc17e8cf4
3 changed files with 11 additions and 5 deletions

View File

@@ -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<Whiteboard[]> {
@@ -12,8 +13,8 @@ export const whiteboardService = {
return raw.map(mapWhiteboard)
},
async createNewWhiteboard(title: string): Promise<string> {
return await api.post<string>('/api/Whiteboard', { title: title, maxParticipants: 10, joinPolicy: 0})
async createNewWhiteboard(title: string, joinPolicy: WhiteboardJoinPolicy, maxParticipants: number): Promise<string> {
return await api.post<string>('/api/Whiteboard', { title: title, maxParticipants: maxParticipants, joinPolicy: joinPolicy})
},
async getWhiteboardById(id: string): Promise<Whiteboard> {

View File

@@ -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<Whiteboard[]>([])
@@ -35,13 +36,13 @@ export const useWhiteboardsStore = defineStore('whiteboards', () => {
}
}
async function createNewWhiteboard(title: string): Promise<string> {
async function createNewWhiteboard(title: string, joinPolicy: WhiteboardJoinPolicy, maxParticipants: number): Promise<string> {
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'

View File

@@ -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 = ''