From ca60daa296fe2f50f1853a0bced25108c501d0f0 Mon Sep 17 00:00:00 2001 From: Kerboul Date: Wed, 15 Jan 2025 08:32:57 +0100 Subject: [PATCH] =?UTF-8?q?Ajout=20du=20champ=20'status'=20lors=20de=20la?= =?UTF-8?q?=20cr=C3=A9ation=20d'un=20projet=20et=20suppression=20de=20la?= =?UTF-8?q?=20v=C3=A9rification=20du=20Project=20ID=20dans=20la=20route=20?= =?UTF-8?q?POST=20/projects?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routes/api.js | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/routes/api.js b/routes/api.js index cd1409e..8586602 100644 --- a/routes/api.js +++ b/routes/api.js @@ -201,8 +201,8 @@ router.post('/projects', async (req, res) => { } try { - const query = 'INSERT INTO public.projects (name, description) VALUES ($1, $2) RETURNING id'; - const result = await db.query(query, [name, description]); + const query = `INSERT INTO public.projects (name, description, status) VALUES ('${name}', '${description}', 0) RETURNING id`; + const result = await db.query(query); const projectId = result.rows[0].id; fileUtils.createProjectDirectory(projectId); @@ -211,18 +211,6 @@ router.post('/projects', async (req, res) => { console.error('Error creating project:', error); res.status(500).json({ error: 'Internal server error' }); } - const { projectId } = req.body; - if (!projectId) { - return res.status(400).json({ error: 'Project ID is required' }); - } - - try { - fileUtils.createProjectDirectory(projectId); - res.status(201).json({ message: 'Project directory created successfully' }); - } catch (error) { - console.error('Error creating project directory:', error); - res.status(500).json({ error: 'Internal server error' }); - } }); /**