Skip to content

Commit

Permalink
Added names to accounts (#55)
Browse files Browse the repository at this point in the history
* Create a pull trequest for branch 52-add-names-to-accounts

* added first and last name to db and create user route

---------

Co-authored-by: Cheryl Chen <[email protected]>
  • Loading branch information
ctc-devops and Cheryl Chen authored Mar 5, 2024
1 parent fcf8a14 commit 5d962dc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 3 additions & 3 deletions routes/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions server/schema/users.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
);

0 comments on commit 5d962dc

Please sign in to comment.