Skip to content

Commit 40f5126

Browse files
author
gondzo
committed
Merge remote-tracking branch 'remotes/origin/dev' into issue-logout-callback
2 parents 171b4ee + f5d94cb commit 40f5126

File tree

22 files changed

+751
-215
lines changed

22 files changed

+751
-215
lines changed

.env.example

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
REACT_APP_API_BASE_PATH=https://kb-dsp-server.herokuapp.com
2-
REACT_APP_SOCKET_URL=https://kb-dsp-server.herokuapp.com
3-
REACT_APP_AUTH0_CLIEND_ID=3CGKzjS2nVSqHxHHE64RhvvKY6e0TYpK
4-
REACT_APP_AUTH0_DOMAIN=dronetest.auth0.com
5-
REACT_APP_GOOGLE_API_KEY=AIzaSyCR3jfBdv9prCBYBOf-fPUDhjPP4K05YjE
1+
GOOGLE_API_KEY=AIzaSyCrL-O319wNJK8kk8J_JAYsWgu6yo5YsDI
2+
REACT_APP_API_BASE_PATH=http://localhost:3500
3+
REACT_APP_AUTH0_CLIENT_ID=h7p6V93Shau3SSvqGrl6V4xrATlkrVGm
4+
REACT_APP_AUTH0_CLIENT_DOMAIN=dronetest.auth0.com
5+
REACT_APP_SOCKET_URL=http://localhost:3500

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,24 @@ See Guild https://github.com/lorenwest/node-config/wiki/Configuration-Files
2424
|`REACT_APP_AUTH0_DOMAIN`| The React app auth0 domain`|
2525

2626
Environment variables will be loaded from the .env file during build. Create the .env file based on the provided env.example
27+
### Auth0 setup
28+
- Create an account on auth0.
29+
- Click on clients in left side menu, it will redirect you to client page. Click on CREATE CLIENT button
30+
to create a new client.
31+
- Copy the client id and client domain and export them as environment variables.
32+
- Add `http://localhost:3000` as Allowed callback url's in client settings.
33+
34+
### Add social connections
35+
36+
### Facebook social connection
37+
- To add facebook social connection to auth0, you have to create a facebook app.
38+
Go to facebook [developers](https://developers.facebook.com/apps) and create a new app.
39+
- Copy the app secret and app id to auth0 social connections facebook tab.
40+
- You have to setup the oauth2 callback in app oauth settings.
41+
- For more information visit auth0 [docs](https://auth0.com/docs/connections/social/facebook)
42+
43+
### Google social connection
44+
- For more information on how to connect google oauth2 client, visit official [docs](https://auth0.com/docs/connections/social/google)
2745

2846
## Install dependencies
2947
`npm i`

config/default.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-disable import/no-commonjs */
22
/**
3-
* Main config file
3+
* Main config file for the server which is hosting the reat app
44
*/
55
module.exports = {
66
// below env variables are NOT visible in frontend

src/api/User.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,30 +40,33 @@ class UserApi {
4040
});
4141
}
4242

43-
register(name, email, password) {
43+
register(firstName, lastName, email, password) {
4444
const url = `${this.basePath}/api/v1/register`;
4545
return reqwest({
4646
url,
4747
method: 'post',
4848
type: 'json',
4949
contentType: 'application/json',
5050
data: JSON.stringify({
51-
firstName: name,
52-
lastName: name,
51+
firstName,
52+
lastName,
5353
email,
5454
phone: '1',
5555
password,
5656
})});
5757
}
5858

59-
registerSocialUser(name, email) {
59+
registerSocialUser(name, email, token) {
6060
const url = `${this.basePath}/api/v1/login/social`;
6161

6262
return reqwest({
6363
url,
6464
method: 'post',
6565
type: 'json',
6666
contentType: 'application/json',
67+
headers: {
68+
Authorization: `Bearer ${token}`,
69+
},
6770
data: JSON.stringify({
6871
name,
6972
email,

src/components/AdminHeader/AdminHeader.jsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import React from 'react';
22
import CSSModules from 'react-css-modules';
33
import {Link} from 'react-router';
44
import styles from './AdminHeader.scss';
5+
import Dropdown from '../Dropdown';
6+
import Notification from '../Notification';
57

68
export const AdminHeader = () => (
79
<nav styleName="admin-header">
@@ -19,6 +21,19 @@ export const AdminHeader = () => (
1921
</li>
2022
</ul>
2123
</li>
24+
<li key="notification" styleName="notifications" />
25+
<li key="welcome" >
26+
<Dropdown title={<span>Welcome,<br />Admin</span>}>
27+
<ul>
28+
<li>
29+
<a href="javascript:">Profile</a>
30+
</li>
31+
<li>
32+
<a href="javascript:">Logout</a>
33+
</li>
34+
</ul>
35+
</Dropdown>
36+
</li>
2237
</ul>
2338
</nav>
2439
);

src/components/AdminHeader/AdminHeader.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,8 @@
1010
composes: pages from '../Header/Header.scss'
1111
}
1212

13+
.notifications {
14+
composes: notifications from '../Header/Header.scss'
15+
}
16+
1317

src/components/Header/Header.jsx

Lines changed: 63 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import styles from './Header.scss';
1010

1111
export const Header = ({
1212
location, selectedCategory, categories, user, notifications,
13-
routes, handleNotification, toggleNotif, loggedUser,
13+
routes, handleNotification, doLogout, toggleNotif, loggedUser,
1414
}) => (
1515

1616
<nav styleName="header">
@@ -20,65 +20,75 @@ export const Header = ({
2020
</li>
2121
{
2222
(() => {
23-
const currentRoute = routes[routes.length - 1].name;
24-
if (currentRoute === 'ServiceRequest'
25-
|| currentRoute === 'Home'
26-
|| currentRoute === 'MyRequestStatus'
27-
|| currentRoute === 'StatusDetail') {
23+
if (user.role == 'consumer') {
2824
return (
29-
[(<li key="location" styleName="location">
30-
<i />
31-
{location}
32-
</li>),
33-
(<li key="search" styleName="search">
34-
<SearchInput placeholder="Type your search here..." />
35-
</li>),
36-
]
25+
<li styleName="pages">
26+
<ul>
27+
<li>
28+
<Link to="/home" activeClassName="active">Home</Link>
29+
</li>
30+
<li>
31+
<Link to="/my-request-status" activeClassName="active">My Requests</Link>
32+
</li>
33+
<li>
34+
<Link to="/browse-provider" activeClassName="active">Browse Services</Link>
35+
</li>
36+
<li><Link to="javascript:;" activeClassName="active">Analytics</Link></li>
37+
<li><Link to="/drones-map" activeClassName="active">Drone Traffic</Link></li>
38+
<li><Link to="/mission-planner" activeClassName="active">MissionPlanner</Link></li>
39+
</ul>
40+
</li>
41+
);
42+
} else if (user.role == 'provider') {
43+
return (
44+
<li styleName="pages">
45+
<ul>
46+
<li>
47+
<Link to="/dashboard" activeClassName="active">Dashboard</Link>
48+
</li>
49+
<li>
50+
<Link to="/my-request" activeClassName="active">Requests</Link>
51+
</li>
52+
<li>
53+
<Link to="/my-drone" activeClassName="active">My Drones</Link>
54+
</li>
55+
<li>
56+
<Link to="/my-services" activeClassName="active">My Services</Link>
57+
</li>
58+
<li><Link to="javascript:;" activeClassName="active">Analytics</Link></li>
59+
<li><Link to="/drones-map" activeClassName="active">Drone Traffic</Link></li>
60+
<li><Link to="/mission-planner" activeClassName="active">MissionPlanner</Link></li>
61+
</ul>
62+
</li>
3763
);
3864
}
39-
return (
40-
<li styleName="pages">
41-
<ul>
42-
<li>
43-
<Link to="/dashboard" activeClassName="active">Dashboard</Link>
44-
</li>
45-
<li>
46-
<Link to="/my-request" activeClassName="active">Requests</Link>
47-
</li>
48-
<li>
49-
<Link to="/my-drone" activeClassName="active">My Drones</Link>
50-
</li>
51-
<li>
52-
<Link to="/my-services" activeClassName="active">My Services</Link>
53-
</li>
54-
<li><Link to="javascript:;" activeClassName="active">Analytics</Link></li>
55-
<li className={currentRoute === 'DroneMap' ? 'active' : null}>
56-
<Link to="/drones-map" activeClassName="active">Drone Traffic</Link></li>
57-
<li className={currentRoute === 'MissionPlanner' ? 'active' : null}>
58-
<Link to="/mission-planner" activeClassName="active">MissionPlanner</Link></li>
59-
</ul>
60-
</li>
61-
);
6265
})()
6366
}
6467
{
6568
(() => {
6669
if (!loggedUser) {
6770
return (
6871
[
69-
(<li key="category">
70-
<Dropdown title={selectedCategory}>
71-
<ul>
72-
{categories.map((item, i) => <li key={i}><a href="javascript:">{item.name}</a></li>)}
73-
</ul>
74-
</Dropdown>
75-
</li>),
76-
(<li key="login" styleName="login">
77-
<LogInModalContainer />
78-
</li>),
79-
(<li key="signup" styleName="login">
80-
<SignupModalContainer />
81-
</li>),
72+
(<li key="location" styleName="location">
73+
<i />
74+
{location}
75+
</li>),
76+
(<li key="search" styleName="search">
77+
<SearchInput placeholder="Type your search here..." />
78+
</li>),
79+
(<li key="category">
80+
<Dropdown title={selectedCategory}>
81+
<ul>
82+
{categories.map((item, i) => <li key={i}><a href="javascript:">{item.name}</a></li>)}
83+
</ul>
84+
</Dropdown>
85+
</li>),
86+
(<li key="login" styleName="login">
87+
<LogInModalContainer />
88+
</li>),
89+
(<li key="signup" styleName="login">
90+
<SignupModalContainer />
91+
</li>),
8292
]
8393
);
8494
}
@@ -91,21 +101,14 @@ export const Header = ({
91101
handleNotification={handleNotification}
92102
/>}
93103
</li>),
94-
(<li key="category">
95-
<Dropdown title={selectedCategory}>
96-
<ul>
97-
{categories.map((item, i) => <li key={i}><a href="javascript:">{item.name}</a></li>)}
98-
</ul>
99-
</Dropdown>
100-
</li>),
101104
(<li key="welcome" styleName="user">
102-
<Dropdown title={<span>Welcome,<br />{user.name}e</span>}>
105+
<Dropdown title={<span>Welcome,<br />{user.name}</span>}>
103106
<ul>
104107
<li>
105108
<a href="javascript:">Profile</a>
106109
</li>
107110
<li>
108-
<a href="javascript:">Logout</a>
111+
<a href="javascript:" onClick={doLogout()}>Logout</a>
109112
</li>
110113
</ul>
111114
</Dropdown>
@@ -127,6 +130,7 @@ Header.propTypes = {
127130
notifications: PropTypes.array.isRequired,
128131
user: PropTypes.object.isRequired,
129132
handleNotification: PropTypes.func,
133+
doLogout: PropTypes.func.isRequired,
130134
toggleNotif: PropTypes.bool,
131135
loggedUser: PropTypes.bool,
132136
};

src/components/TextField/TextField.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
width: 100%;
33
border: 1px solid #ebebeb;
44

5+
input[type="password"],
56
input[type="text"] {
67
width: 100%;
78
padding: 0 10px;

src/config/index.js

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,16 @@
1+
/* eslint-disable import/no-commonjs */
12
/**
2-
* Copyright (c) 2016 Topcoder Inc, All rights reserved.
3+
* Main config file for the react app
34
*/
4-
5-
/**
6-
* Webapp configuration
7-
*
8-
* @author TCSCODER
9-
* @version 1.0.0
10-
*/
11-
12-
const config = {
5+
module.exports = {
136
api: {
147
basePath: process.env.REACT_APP_API_BASE_PATH || 'http://localhost:3500',
158
},
169
socket: {
1710
url: process.env.REACT_APP_SOCKET_URL || 'http://localhost:3500',
1811
},
19-
AUTH0_CLIEND_ID: process.env.REACT_APP_AUTH0_CLIEND_ID || '3CGKzjS2nVSqHxHHE64RhvvKY6e0TYpK',
20-
AUTH0_DOMAIN: process.env.REACT_APP_AUTH0_DOMAIN || 'dronetest.auth0.com',
21-
};
12+
AUTH0_CLIENT_ID: process.env.REACT_APP_AUTH0_CLIENT_ID || 'h7p6V93Shau3SSvqGrl6V4xrATlkrVGm',
13+
AUTH0_CLIENT_DOMAIN: process.env.REACT_APP_AUTH0_CLIENT_DOMAIN || 'spanhawk.auth0.com',
14+
AUTH0_CALLBACK: 'http://localhost:3000',
2215

23-
export default config;
16+
};

src/containers/HeaderContainer.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import Header from 'components/Header';
22
import {asyncConnect} from 'redux-connect';
3-
import {toggleNotification, loginAction} from '../store/modules/global';
3+
import {actions, toggleNotification, loginAction, logoutAction, logout} from '../store/modules/global';
44

55
const resolve = [{
66
promise: () => Promise.resolve(),
77
}];
88

9-
const mapState = (state) => state.global;
9+
const mapState = (state) => ({...state.global, doLogout: logout});
1010

1111
const mapDispatchToProps = (dispatch) => ({
1212
handleNotification: (value) => {
@@ -15,5 +15,5 @@ const mapDispatchToProps = (dispatch) => ({
1515
handleLogin: (userObj) => dispatch(loginAction(userObj)),
1616
});
1717

18-
export default asyncConnect(resolve, mapState, mapDispatchToProps)(Header);
18+
export default asyncConnect(resolve, mapState, {...actions, logoutAction})(Header);
1919

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy