saving project notes
This commit is contained in:
@@ -132,11 +132,15 @@ export async function createProject({ name, description, colour, icon, isolated
|
|||||||
return res.json();
|
return res.json();
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function updateProject(id, { name, description, colour, icon, isolated }) {
|
export async function updateProject(id, fields = {}) {
|
||||||
|
// Convert isolated boolean to integer if present
|
||||||
|
const body = { ...fields };
|
||||||
|
if (body.isolated !== undefined) body.isolated = body.isolated ? 1 : 0;
|
||||||
|
|
||||||
const res = await fetch(`${BASE_URL}/projects/${id}`, {
|
const res = await fetch(`${BASE_URL}/projects/${id}`, {
|
||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify({ name, description, colour, icon, isolated: isolated ? 1 : 0}),
|
body: JSON.stringify(body),
|
||||||
});
|
});
|
||||||
if (!res.ok) throw new Error(`Failed to update project: ${res.status}`);
|
if (!res.ok) throw new Error(`Failed to update project: ${res.status}`);
|
||||||
return res.json();
|
return res.json();
|
||||||
|
|||||||
@@ -100,11 +100,11 @@ async function getProjects() {
|
|||||||
return res.json();
|
return res.json();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function updateProject(id, { name, description, colour, icon }) {
|
async function updateProject(id, fields = {}) {
|
||||||
const res = await fetch(`${BASE_URL}/projects/${id}`, {
|
const res = await fetch(`${BASE_URL}/projects/${id}`, {
|
||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify({ name, description, colour, icon })
|
body: JSON.stringify(fields)
|
||||||
});
|
});
|
||||||
if (!res.ok) throw new Error(`Failed to update project: ${res.status}`);
|
if (!res.ok) throw new Error(`Failed to update project: ${res.status}`);
|
||||||
return res.json();
|
return res.json();
|
||||||
|
|||||||
Reference in New Issue
Block a user