Added creating new whiteboards from home screen, refactoring
This commit is contained in:
@@ -1,6 +1,3 @@
|
||||
// A small fetch-based HTTP client with automatic token attach and refresh-on-401.
|
||||
// This avoids circular imports by reading/writing tokens directly from localStorage.
|
||||
|
||||
const ACCESS_TOKEN = 'auth_token'
|
||||
const REFRESH_TOKEN = 'refresh_token'
|
||||
|
||||
@@ -9,7 +6,6 @@ async function parseJsonOrThrow(res: Response) {
|
||||
try {
|
||||
return text ? JSON.parse(text) : undefined
|
||||
} catch (e) {
|
||||
// non-JSON response
|
||||
return text
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { Whiteboard } from "@/types";
|
||||
import { api } from './api'
|
||||
import type {Whiteboard} from "@/types";
|
||||
import {api} from './api'
|
||||
|
||||
export const whiteboardService = {
|
||||
async getWhiteboardHistory(): Promise<Whiteboard[]> {
|
||||
@@ -10,6 +10,14 @@ export const whiteboardService = {
|
||||
async getRecentWhiteboards(): Promise<Whiteboard[]> {
|
||||
const raw = await api.get<any[]>('/api/Whiteboard/recent')
|
||||
return raw.map(mapWhiteboard)
|
||||
},
|
||||
|
||||
async createNewWhiteboard(title: string): Promise<string> {
|
||||
return await api.post<string>('/api/Whiteboard', { title: title, maxParticipants: 10, joinPolicy: 0})
|
||||
},
|
||||
|
||||
async getWhiteboardById(id: string): Promise<Whiteboard> {
|
||||
return await api.get<any>(`/api/Whiteboard/${id}`).then(mapWhiteboard)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user