added being able to assign sessions to projects via the sessions modal

This commit is contained in:
Storme-bit
2026-04-13 20:36:42 -07:00
parent e3f6b9a9db
commit 649ed2b350
8 changed files with 163 additions and 121 deletions

View File

@@ -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();
}