From 95f82866400c2eb046724ef59f2510170fa8eb78 Mon Sep 17 00:00:00 2001 From: ctc-devops <90984711+ctc-devops@users.noreply.github.com> Date: Mon, 26 Feb 2024 12:04:32 -0800 Subject: [PATCH 1/2] Create a pull trequest for branch 52-add-names-to-accounts From 0b8f8a9cff08704b69b5932623d8317a11d458f6 Mon Sep 17 00:00:00 2001 From: Cheryl Chen Date: Mon, 26 Feb 2024 13:39:52 -0800 Subject: [PATCH 2/2] added first and last name to db and create user route --- routes/users.js | 6 +++--- server/schema/users.sql | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/routes/users.js b/routes/users.js index 9f2b5cd..7f2ce2a 100644 --- a/routes/users.js +++ b/routes/users.js @@ -37,10 +37,10 @@ userRouter.get('/:uid', async (req, res) => { userRouter.post('/create', async (req, res) => { try { - const { id, email, type, approved, approvedOn } = req.body; + const { id, email, type, approved, approvedOn, firstName, lastName } = req.body; await db.query( - `INSERT INTO users (id, email, "type", approved, approved_on) VALUES ($1, $2, $3, $4, $5);`, - [id, email, type, approved, approvedOn], + `INSERT INTO users (id, email, "type", approved, approved_on, first_name, last_name) VALUES ($1, $2, $3, $4, $5, $6, $7);`, + [id, email, type, approved, approvedOn, firstName, lastName], ); res.status(201).json({ id, diff --git a/server/schema/users.sql b/server/schema/users.sql index 785246f..e45297a 100644 --- a/server/schema/users.sql +++ b/server/schema/users.sql @@ -8,4 +8,6 @@ CREATE TABLE users ( type account_type NOT NULL, approved BOOLEAN NOT NULL, approved_on DATE NOT NULL, + first_name VARCHAR(50) NOT NULL, + last_name VARCHAR(50) NOT NULL ); \ No newline at end of file