From 43a700d2c3b75275479758ead08de193a3d7ced3 Mon Sep 17 00:00:00 2001 From: ishak Date: Tue, 24 Jul 2018 12:51:28 +0300 Subject: [PATCH 01/20] Readme --- README.md | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 21ca1e3..040d4fb 100644 --- a/README.md +++ b/README.md @@ -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 . From d689e87ee450bc249d656b498e8aabd78879c7fb Mon Sep 17 00:00:00 2001 From: Ahmad Date: Wed, 25 Jul 2018 12:32:26 +0300 Subject: [PATCH 02/20] create Login Component, Fetch Function in helpers folder, and AppRoutes to manage the routes of the app pages --- backend/app.js | 2 + backend/controllers/index.js | 24 ++------ backend/controllers/login.js | 7 +++ backend/controllers/test.js | 3 - backend/package.json | 2 +- frontend/package-lock.json | 72 +++++++++++++++++++++++ frontend/package.json | 3 +- frontend/public/index.html | 23 -------- frontend/src/AppRoutes.js | 19 +++++++ frontend/src/components/App.js | 21 +------ frontend/src/components/Login/Login.js | 76 +++++++++++++++++++++++++ frontend/src/components/Login/style.css | 56 ++++++++++++++++++ frontend/src/helpers/fetch.js | 24 ++++++++ frontend/src/index.js | 6 +- 14 files changed, 269 insertions(+), 69 deletions(-) create mode 100644 backend/controllers/login.js delete mode 100644 backend/controllers/test.js create mode 100644 frontend/src/AppRoutes.js create mode 100644 frontend/src/components/Login/Login.js create mode 100644 frontend/src/components/Login/style.css create mode 100644 frontend/src/helpers/fetch.js diff --git a/backend/app.js b/backend/app.js index 85041b8..8b9890d 100644 --- a/backend/app.js +++ b/backend/app.js @@ -7,6 +7,8 @@ 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); diff --git a/backend/controllers/index.js b/backend/controllers/index.js index a319bbb..8c9c74e 100644 --- a/backend/controllers/index.js +++ b/backend/controllers/index.js @@ -1,24 +1,8 @@ const express = require('express'); - const router = express.Router(); +const login = require('./login'); + +router.get('/login', login.get); +router.post('/login', login.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; diff --git a/backend/controllers/login.js b/backend/controllers/login.js new file mode 100644 index 0000000..211b2da --- /dev/null +++ b/backend/controllers/login.js @@ -0,0 +1,7 @@ +exports.get = (req, res)=>{ + res.json([{a:1, n:"a"},{a:13, n:"e"},{a:12, n:"c"}]); +}; + +exports.post = (req, res)=>{ + res.send([{a:1, n:"a"},{a:13, n:"e"},{a:12, n:"c"}]); +}; diff --git a/backend/controllers/test.js b/backend/controllers/test.js deleted file mode 100644 index 3d33534..0000000 --- a/backend/controllers/test.js +++ /dev/null @@ -1,3 +0,0 @@ -exports.get= (req, res)=>{ - res.json([{a:1, n:"a"},{a:13, n:"e"},{a:12, n:"c"}]); -}; diff --git a/backend/package.json b/backend/package.json index 4477bfc..cc43443 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,5 +1,5 @@ { - "name": "GSG_Libery", + "name": "Backend", "version": "1.0.0", "description": "", "main": "index.js", diff --git a/frontend/package-lock.json b/frontend/package-lock.json index a94985c..8abf579 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -4652,6 +4652,28 @@ "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=" }, + "history": { + "version": "4.7.2", + "resolved": "https://registry.npmjs.org/history/-/history-4.7.2.tgz", + "integrity": "sha512-1zkBRWW6XweO0NBcjiphtVJVsIQ+SXF29z9DVkceeaSLVMFXHool+fdCZD4spDCfZJCILPILc3bm7Bc+HRi0nA==", + "requires": { + "invariant": "^2.2.1", + "loose-envify": "^1.2.0", + "resolve-pathname": "^2.2.0", + "value-equal": "^0.4.0", + "warning": "^3.0.0" + }, + "dependencies": { + "warning": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/warning/-/warning-3.0.0.tgz", + "integrity": "sha1-MuU3fLVy3kqwR1O9+IIcAe1gW3w=", + "requires": { + "loose-envify": "^1.0.0" + } + } + } + }, "hmac-drbg": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", @@ -4662,6 +4684,11 @@ "minimalistic-crypto-utils": "^1.0.1" } }, + "hoist-non-react-statics": { + "version": "2.5.5", + "resolved": "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-2.5.5.tgz", + "integrity": "sha512-rqcy4pJo55FTTLWt+bU8ukscqHeE/e9KWvsOW2b/a3afxQZhwkQdT1rPPCJ0rYXdj4vNcasY8zHTH+jF/qStxw==" + }, "home-or-tmp": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/home-or-tmp/-/home-or-tmp-2.0.0.tgz", @@ -8792,6 +8819,33 @@ "resolved": "https://registry.npmjs.org/react-error-overlay/-/react-error-overlay-4.0.0.tgz", "integrity": "sha512-FlsPxavEyMuR6TjVbSSywovXSEyOg6ZDj5+Z8nbsRl9EkOzAhEIcS+GLoQDC5fz/t9suhUXWmUrOBrgeUvrMxw==" }, + "react-router": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/react-router/-/react-router-4.3.1.tgz", + "integrity": "sha512-yrvL8AogDh2X42Dt9iknk4wF4V8bWREPirFfS9gLU1huk6qK41sg7Z/1S81jjTrGHxa3B8R3J6xIkDAA6CVarg==", + "requires": { + "history": "^4.7.2", + "hoist-non-react-statics": "^2.5.0", + "invariant": "^2.2.4", + "loose-envify": "^1.3.1", + "path-to-regexp": "^1.7.0", + "prop-types": "^15.6.1", + "warning": "^4.0.1" + } + }, + "react-router-dom": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-4.3.1.tgz", + "integrity": "sha512-c/MlywfxDdCp7EnB7YfPMOfMD3tOtIjrQlj/CKfNMBxdmpJP8xcz5P/UAFn3JbnQCNUxsHyVVqllF9LhgVyFCA==", + "requires": { + "history": "^4.7.2", + "invariant": "^2.2.4", + "loose-envify": "^1.3.1", + "prop-types": "^15.6.1", + "react-router": "^4.3.1", + "warning": "^4.0.1" + } + }, "react-scripts": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/react-scripts/-/react-scripts-1.1.4.tgz", @@ -9214,6 +9268,11 @@ "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-1.0.1.tgz", "integrity": "sha1-Jsv+k10a7uq7Kbw/5a6wHpPUQiY=" }, + "resolve-pathname": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/resolve-pathname/-/resolve-pathname-2.2.0.tgz", + "integrity": "sha512-bAFz9ld18RzJfddgrO2e/0S2O81710++chRMUxHjXOYKF6jTAMrUNZrEZ1PvV0zlhfjidm08iRPdTLPno1FuRg==" + }, "resolve-url": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz", @@ -10544,6 +10603,11 @@ "spdx-expression-parse": "^3.0.0" } }, + "value-equal": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/value-equal/-/value-equal-0.4.0.tgz", + "integrity": "sha512-x+cYdNnaA3CxvMaTX0INdTCN8m8aF2uY9BvEqmxuYp8bL09cs/kWVQPVGcA35fMktdOsP69IgU7wFj/61dJHEw==" + }, "vary": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", @@ -10580,6 +10644,14 @@ "makeerror": "1.0.x" } }, + "warning": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/warning/-/warning-4.0.1.tgz", + "integrity": "sha512-rAVtTNZw+cQPjvGp1ox0XC5Q2IBFyqoqh+QII4J/oguyu83Bax1apbo2eqB8bHRS+fqYUBagys6lqUoVwKSmXQ==", + "requires": { + "loose-envify": "^1.0.0" + } + }, "watch": { "version": "0.10.0", "resolved": "https://registry.npmjs.org/watch/-/watch-0.10.0.tgz", diff --git a/frontend/package.json b/frontend/package.json index fb5f366..8a608ad 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -5,6 +5,7 @@ "dependencies": { "react": "^16.4.1", "react-dom": "^16.4.1", + "react-router-dom": "^4.3.1", "react-scripts": "1.1.4" }, "scripts": { @@ -13,5 +14,5 @@ "test": "react-scripts test --env=jsdom", "eject": "react-scripts eject" }, - "proxy":"http://localhost:4001" + "proxy": "http://localhost:4001" } diff --git a/frontend/public/index.html b/frontend/public/index.html index ed0ebaf..a65853f 100644 --- a/frontend/public/index.html +++ b/frontend/public/index.html @@ -4,21 +4,8 @@ - - React App @@ -26,15 +13,5 @@ You need to enable JavaScript to run this app.
- diff --git a/frontend/src/AppRoutes.js b/frontend/src/AppRoutes.js new file mode 100644 index 0000000..6aaf3da --- /dev/null +++ b/frontend/src/AppRoutes.js @@ -0,0 +1,19 @@ +import React from 'react'; +import {BrowserRouter, Route, Switch} from 'react-router-dom' + +import App from './components/App'; +import Login from './components/Login/Login'; + + +const AppRoutes = () => ( + + + + + + + +) + + +export default AppRoutes; diff --git a/frontend/src/components/App.js b/frontend/src/components/App.js index 4b26ee7..c95afe1 100644 --- a/frontend/src/components/App.js +++ b/frontend/src/components/App.js @@ -1,36 +1,19 @@ import React, { Component } from 'react'; + + class App extends Component { state = { test: [] } componentDidMount(){ -const that = this; - var xhr = new XMLHttpRequest(); -xhr.onreadystatechange = function() { - console.log("this",that); - if (xhr.readyState === 4 && xhr.status === 200) { - const test = JSON.parse(xhr.responseText); - console.log("res",test); - that.setState({ - test - }) - - } - -}; -xhr.open("GET", "/test", true); -xhr.send(); } render() { return (

Welcome to React

- {console.log(this.state.test)} - {this.state.test.map((t)=>

{t.a}

- )}
); diff --git a/frontend/src/components/Login/Login.js b/frontend/src/components/Login/Login.js new file mode 100644 index 0000000..b58a516 --- /dev/null +++ b/frontend/src/components/Login/Login.js @@ -0,0 +1,76 @@ +import React, { Component } from 'react'; +import fetch from '../../helpers/fetch'; +import './style.css'; +class Login extends Component { + +state = { + error: undefined, + response: [] + } + + HandelLogin = (e) => { + e.preventDefault(); + const inputsValues = { + userName:e.target.userName.value, + password:e.target.password.value + } + + if(inputsValues.userName.trim() && inputsValues.password.trim()){ + e.target.userName.value = ""; + e.target.password.value = ""; + const handleFetch = { + method: 'POST', + url: '/login', + data: inputsValues, + + } + + +fetch(handleFetch, (response) => { + +response = JSON.parse(response); +this.setState(() => ( + {response: Object.assign({}, response), + error: undefined + } + ) + ) + } + ); + + } else{ + this.setState(()=>( + {error: "All fields are required"} + )); + } + +} + + +render(){ + return( +
+ +
+
+
+
true
+
+
+
true
+
+
+
+ +
+
+
+{console.log("this.state.response", this.state.response)} + {this.state.error &&

Error MSG: {this.state.error}

} +
+
+ ) +} +} + +export default Login; diff --git a/frontend/src/components/Login/style.css b/frontend/src/components/Login/style.css new file mode 100644 index 0000000..ef993c5 --- /dev/null +++ b/frontend/src/components/Login/style.css @@ -0,0 +1,56 @@ +.login-container{ + background-color:whitesmoke; + display: block; + top:0px; + padding: 5% 0%; + height: 70vh; + +} +.login-input-container{ + margin: 5%; +} + +.login-input-field{ + display: inline; + margin: auto; + width:70%; + height:30px; + -webkit-margin-after: 5%; + margin-block-end: 5%; +} +.login-input-label{ + display: inline +} +.ico{ + display: block; + width: 15%; + display: inline; + margin-right: 3px; + border-style:solid; + border-width: 0.1px; + max-height: 55px; + padding: 9.2px 5px; + border-color: lightgray; + border-radius: 5px; + +} +.login-button-parent{ + display: block; + width:-moz-available; + left: 0px; + right: 0px; + height: 100px; + +} +.login-button{ + width: -moz-available; + height: 40px; + -webkit-margin-before: 5%; + margin-block-start: 5%; + height: 90px; + border-radius: 3px; + background-color: #48A1AF; + color: white; + font-size:larger; + font-weight: bold; +} diff --git a/frontend/src/helpers/fetch.js b/frontend/src/helpers/fetch.js new file mode 100644 index 0000000..07c70c2 --- /dev/null +++ b/frontend/src/helpers/fetch.js @@ -0,0 +1,24 @@ +const fetch = (obj, cb) => { + + const xhr = new XMLHttpRequest(); +xhr.onreadystatechange = () => { + + if(xhr.readyState === 4) + if(xhr.status === 200){ + const response = xhr.responseText; + cb(response) + } + } + xhr.open(obj.method, obj.url); + if(obj.data){ + const data= JSON.stringify(obj.data); + xhr.setRequestHeader('content-type', 'application/json'); + xhr.send(data); + } else { + xhr.send(); + } + +} + + +export default fetch; diff --git a/frontend/src/index.js b/frontend/src/index.js index 9406087..ec75515 100644 --- a/frontend/src/index.js +++ b/frontend/src/index.js @@ -1,5 +1,7 @@ import React from 'react'; import ReactDOM from 'react-dom'; -import App from './components/App'; +import AppRoutes from './AppRoutes'; -ReactDOM.render(, document.getElementById('root')); + + +ReactDOM.render(, document.getElementById('root')); From 3aa1b249e997b7bf757074b9f8544a5c7e041b12 Mon Sep 17 00:00:00 2001 From: eman Date: Wed, 25 Jul 2018 13:09:53 +0300 Subject: [PATCH 03/20] signUp components --- frontend/public/index.html | 1 + frontend/src/components/App.js | 14 ++--- frontend/src/components/singup/singup.js | 51 +++++++++++++++++ frontend/src/components/singup/singupInput.js | 21 +++++++ frontend/src/components/singup/style.css | 57 +++++++++++++++++++ 5 files changed, 135 insertions(+), 9 deletions(-) create mode 100644 frontend/src/components/singup/singup.js create mode 100644 frontend/src/components/singup/singupInput.js create mode 100644 frontend/src/components/singup/style.css diff --git a/frontend/public/index.html b/frontend/public/index.html index ed0ebaf..f6d3bda 100644 --- a/frontend/public/index.html +++ b/frontend/public/index.html @@ -10,6 +10,7 @@ --> +