added being able to assign sessions to projects via the sessions modal
This commit is contained in:
@@ -143,7 +143,7 @@ export async function fetchModels() {
|
||||
if(!res.ok) throw new Error(`Failted to fetch models: ${res.status}`);
|
||||
return res.json();
|
||||
}
|
||||
|
||||
/*
|
||||
export async function renameSession(sessionId, name) {
|
||||
const res = await fetch(`${BASE_URL}/sessions/${sessionId}`, {
|
||||
method: 'PATCH',
|
||||
@@ -153,6 +153,20 @@ export async function renameSession(sessionId, name) {
|
||||
if (!res.ok) throw new Error(`Failed to rename session: ${res.status}`);
|
||||
return res.json();
|
||||
}
|
||||
*/
|
||||
export async function updateSession(sessionId, { name, projectId } = {}) {
|
||||
const res = await fetch(`${BASE_URL}/sessions/${sessionId}`, {
|
||||
method: 'PATCH',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ name, projectId }),
|
||||
});
|
||||
if (!res.ok) throw new Error(`Failed to update session: ${res.status}`);
|
||||
return res.json();
|
||||
}
|
||||
|
||||
export async function renameSession(sessionId, name) {
|
||||
return updateSession(sessionId, {name})
|
||||
}
|
||||
|
||||
export async function deleteSession(sessionId) {
|
||||
const res = await fetch(`${BASE_URL}/sessions/${sessionId}`, {
|
||||
@@ -190,4 +204,14 @@ export async function updateProject(id, { name, description, colour, icon }) {
|
||||
export async function deleteProject(id) {
|
||||
const res = await fetch(`${BASE_URL}/projects/${id}`, { method: 'DELETE' });
|
||||
if (!res.ok) throw new Error(`Failed to delete project: ${res.status}`);
|
||||
}
|
||||
|
||||
export async function updateSessionProject(sessionId, projectId) {
|
||||
const res = await fetch(`${BASE_URL}/sessions/${sessionId}`, {
|
||||
method: 'PATCH',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ projectId }),
|
||||
});
|
||||
if (!res.ok) throw new Error(`Failed to update session project: ${res.status}`);
|
||||
return res.json();
|
||||
}
|
||||
Reference in New Issue
Block a user