Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

making chat component and fix style issues relate to issue #7 #28

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 42 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,42 @@
Care And Share App
# Care And Share App
###### *The* network for carers to access information, resources, and the support they need to thrive as carers.
![](https://i0.wp.com/evangelbc.org/ev2/wp-content/uploads/2017/11/Care-and-Share.jpg?resize=768%2C432&ssl=1)

## Problem Statment:
The problem is located in three points:

* Lack of support for carers.
* Giving carers a way to connect and support each other.
* Digitize the "My Book" book.

#### Our solution:
Creating CAS(Care And Share) App to Improve Information sharing within the carers network
and find a place where allows the carers to communicate to each other.

## user Stories:

- carers can sign up and login.
- carers can browse and search other 'anonymised' carers.
- carers can request to connect.
- carers can see requests and accept.
- carers can see who they have connected with.
- carers can send messages to their connections.

### Database Schema:
the App database structure for represent the App tables and the relations between them.
![DB](https://user-images.githubusercontent.com/28482863/43066526-94a0ff94-8e6d-11e8-8050-f6c38ed43c2f.jpg)
#### Prototype: :link:
There is the link of the App prototype on figma [Here ](https://www.figma.com/proto/GDGWmaT7HSHTJBY1b7tmfsL5/My-Book?node-id=0%3A1&scaling=scale-down)

# Technology Stack:

- Express.js
- React.js
- postgresql
- CSS3

# How to start the program locally:
- `npm run`
- `npm test (run tests) `

Team members: Ishak, Eman, Ahmad-A and Ahmad_M .
8 changes: 2 additions & 6 deletions backend/app.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
const express = require('express');
const bodyParser = require('body-parser');
const controllers = require('./controllers');
const compression = require('compression');


const app = express();
const path = require('path');



app.use(bodyParser.json());
app.use(bodyParser.urlencoded());
app.set('port', process.env.PORT || 4001);
app.use(compression());
app.use(express.static(path.join(__dirname, '..', 'public')));
app.use(controllers);

Expand Down
8 changes: 8 additions & 0 deletions backend/controllers/carers.js
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)
})
};
26 changes: 6 additions & 20 deletions backend/controllers/index.js
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;
12 changes: 12 additions & 0 deletions backend/controllers/login.js
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})
})
};
3 changes: 0 additions & 3 deletions backend/controllers/test.js

This file was deleted.

50 changes: 50 additions & 0 deletions backend/database/build.sql
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','a7m4d.m.sh@gmail.com', '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','farah@gmail.com', '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','abdallah@gmail.com', '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','eman@gmail.com', '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;
19 changes: 19 additions & 0 deletions backend/database/queries/select.js
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};
Loading