-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from FACG4/carers
Carers
- Loading branch information
Showing
31 changed files
with
1,226 additions
and
2,680 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const { selectAllCarers } = require('../database/queries/select'); | ||
|
||
exports.post = (req, res,)=>{ | ||
selectAllCarers(null, (err, results)=>{ | ||
if (err) console.log("error", err); | ||
res.send(results) | ||
}) | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,10 @@ | ||
const express = require('express'); | ||
|
||
const router = express.Router(); | ||
const carers = require('./carers'); | ||
const login = require('./login'); | ||
|
||
router.post('/login', login.post) | ||
router.post('/carers', carers.post) | ||
|
||
|
||
const test = require('./test'); | ||
// const login = require('./login.js'); | ||
// const GSG_Library = require('./GSG_Library'); | ||
// const deletee = require('./deletee'); | ||
// const home = require('./home'); | ||
// const addnewbook = require('./addnewbook'); | ||
// const waitinglist = require('./waitinglist'); | ||
// | ||
router.get('/test', test.get); | ||
// router.post('/addToWaitingList', home.post); | ||
// router.get('/waitinglist',waitinglist.get); | ||
// router.get('/admin', login.get); | ||
// router.get('/dashboard', dashboard.get); | ||
// router.get('/GSG_Library', GSG_Library.get); | ||
// router.post('/search', GSG_Library.post); | ||
// router.get('/delete/:id', deletee.delete1); | ||
// router.post('/deletebookfromsearch',deletee.delete2); | ||
// router.get('/addnewbook', addnewbook.get); | ||
// router.post('/addnewbook', addnewbook.post); | ||
module.exports = router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const { selectAllCarers } = require('../database/queries/select'); | ||
|
||
exports.post = (req, res)=>{ | ||
selectAllCarers(req.body.userName, (err, results)=>{ | ||
if (err) return res.send({msg: 'error in database', status: 0}); | ||
if (!results.length) return res.send({msg: 'Sorry .. User not found', status: 3}); | ||
if (req.body.password == results[0].password) { | ||
return res.send({msg: 'Login Success', status: 1}) | ||
} | ||
return res.send({msg: 'Sorry .. Password is wrong', status: 2}) | ||
}) | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
BEGIN; | ||
DROP TABLE IF EXISTS users, connections, discussions CASCADE; | ||
CREATE TYPE roles AS ENUM ('user'); | ||
CREATE TYPE states AS ENUM ('approved', 'pending', 'decline'); | ||
|
||
CREATE TABLE "users" ( | ||
"id" serial NOT NULL, | ||
"full_name" varchar(30) NOT NULL, | ||
"user_name" varchar(30) NOT NULL UNIQUE, | ||
"email" varchar(30) NOT NULL UNIQUE, | ||
"password" varchar(30) NOT NULL, | ||
"user_role" roles NOT NULL, | ||
"age" int NOT NULL, | ||
"sitution" varchar(300) NOT NULL, | ||
"location" varchar(30) NOT NULL, | ||
"offer" varchar(300) NOT NULL, | ||
"looking" varchar(300) NOT NULL, | ||
CONSTRAINT users_pk PRIMARY KEY ("id") | ||
); | ||
|
||
CREATE TABLE "connections" ( | ||
"id" serial NOT NULL, | ||
"first_user_id" int NOT NULL, | ||
"second_user_id" int NOT NULL, | ||
"relation_state" states NOT NULL, | ||
"date_created" DATE NOT NULL, | ||
CONSTRAINT connections_pk PRIMARY KEY ("id") | ||
); | ||
|
||
CREATE TABLE "discussions" ( | ||
"massage_id" serial NOT NULL, | ||
"massage_body" varchar(1000) NOT NULL, | ||
"sender_id" int NOT NULL, | ||
"receiver_id" int NOT NULL, | ||
CONSTRAINT discussions_pk PRIMARY KEY ("massage_id") | ||
); | ||
|
||
ALTER TABLE "connections" ADD CONSTRAINT "connections_fk0" FOREIGN KEY ("first_user_id") REFERENCES "users"("id"); | ||
ALTER TABLE "connections" ADD CONSTRAINT "connections_fk1" FOREIGN KEY ("second_user_id") REFERENCES "users"("id"); | ||
ALTER TABLE "discussions" ADD CONSTRAINT "discussions_fk0" FOREIGN KEY ("sender_id") REFERENCES "users"("id"); | ||
ALTER TABLE "discussions" ADD CONSTRAINT "discussions_fk1" FOREIGN KEY ("receiver_id") REFERENCES "users"("id"); | ||
|
||
|
||
INSERT INTO users (full_name, user_name, email, password, user_role, age, sitution, location, offer, looking) VALUES | ||
('Ahmad Shatat','ahmad','[email protected]', '123', 'user', '30', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut massa tellus, aliquet quis pulvinar ornare.', 'London', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut massa tellus, aliquet quis pulvinar ornare.', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut massa tellus, aliquet quis pulvinar ornare.'), | ||
('Farah Zaqout','farah','[email protected]', '123', 'user', '25', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut massa tellus, aliquet quis pulvinar ornare.', 'Gaza', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut massa tellus, aliquet quis pulvinar ornare.', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut massa tellus, aliquet quis pulvinar ornare.'), | ||
('Abdallah Azmi','abdallah','[email protected]', '123', 'user', '35', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut massa tellus, aliquet quis pulvinar ornare.', 'Cairo', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut massa tellus, aliquet quis pulvinar ornare.', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut massa tellus, aliquet quis pulvinar ornare.'), | ||
('Eman Khaled','eman','[email protected]', '123', 'user', '39', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut massa tellus, aliquet quis pulvinar ornare.', 'Washington', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut massa tellus, aliquet quis pulvinar ornare.', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut massa tellus, aliquet quis pulvinar ornare.'); | ||
|
||
COMMIT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const db = require('./../db_connection'); | ||
|
||
const selectAllCarers = (data, cb) => { | ||
let sql = 'SELECT * from users'; | ||
|
||
if (data) { | ||
sql = { | ||
text: 'select * from users where user_name = $1', | ||
values: [data] | ||
}; | ||
|
||
} | ||
db.query(sql, (err, results) => { | ||
if (err) return cb(err); | ||
return cb(null,results.rows); | ||
}); | ||
}; | ||
|
||
module.exports = {selectAllCarers}; |
Oops, something went wrong.