Merge pull request #48 from StewKI/feature-updated-whiteboard-creation-logic
Now uses policy and max participants for creating whiteboards
This commit is contained in:
@@ -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> {
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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 = ''
|
||||
|
||||
Reference in New Issue
Block a user