Skip to content

Commit c2d7e45

Browse files
committed
1. var changed to let
2. Send the selected service provider from front end 3. node-backend renamed to server
1 parent 1d5cc5e commit c2d7e45

26 files changed

Lines changed: 237 additions & 195 deletions

.DS_Store

-2 KB
Binary file not shown.

.vscode/settings.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
{
2-
"editor.formatOnSave": true
3-
}
4-
2+
"editor.formatOnSave": true
3+
}

node-backend/helpers/listcompute.js

Lines changed: 0 additions & 7 deletions
This file was deleted.

node-backend/routes/getservices.js

Lines changed: 0 additions & 83 deletions
This file was deleted.

react-frontend/src/HomePage/HomePage.js

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,32 +18,15 @@ class HomePage extends React.Component {
1818

1919
componentDidMount() {
2020
this.state.user = localStorage.getItem("user");
21-
this.props.dispatch(userActions.getAll());
21+
this.props.dispatch(userActions.getAll(this.state.selectedService));
2222
}
2323

2424
handleDeleteUser(id) {
2525
return e => this.props.dispatch(userActions.delete(id));
2626
}
2727

2828
render() {
29-
// if(!this.props.users.loading){
30-
// console.log("loaded here")
31-
// const items= this.props.users["item"]
32-
// tableItems = items.map(item => (
33-
// <Table.Row key={item.id}>
34-
// <Table.Cell>{item.serviceId}</Table.Cell>
35-
// <Table.Cell>{item.name}</Table.Cell>
36-
// <Table.Cell>{item.type}</Table.Cell>
37-
// </Table.Row>
38-
// ));
39-
// }
4029
const { selectedService } = this.state;
41-
console.log("HOME RENDER METHOD", this.props.users);
42-
// if(this.props.users === {}){
43-
// console.log("\n\n\n Empty");
44-
// } else {
45-
// console.log("\n\n\n\ has data", this.props.users);
46-
// }
4730
return (
4831
<div style={{ margin: 20 }}>
4932
<div class="ui center aligned page grid">

react-frontend/src/_actions/user.actions.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@ function register(user) {
6868
}
6969
}
7070

71-
function getAll() {
71+
function getAll(serviceProvider) {
7272
return dispatch => {
7373
dispatch(request());
7474

75-
userService.getAll().then(res => {
75+
userService.getAll(serviceProvider).then(res => {
7676
if (res.success) {
7777
dispatch(success(res.data));
7878
} else {

react-frontend/src/_helpers/auth-header.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
export function authHeader() {
22
// return authorization header with jwt token
3-
let user = JSON.parse(localStorage.getItem("user"));
3+
let token = localStorage.getItem("access_token");
44

5-
if (user && user.token) {
6-
return { Authorization: "Bearer " + user.token };
5+
if (token) {
6+
return { token };
77
} else {
88
return {};
99
}

react-frontend/src/_reducers/authentication.reducer.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { userConstants } from "../_constants/user.constants";
22

3-
localStorage.clear();
43
let user = JSON.parse(localStorage.getItem("user"));
54
const initialState = user ? { loggedIn: true, user } : {};
65

react-frontend/src/_services/user.services.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,19 @@ function login(username, password) {
3131

3232
function logout() {
3333
// remove user from local storage to log user out
34+
console.log("some how logout was called");
3435
localStorage.removeItem("user");
3536
}
3637

37-
function getAll() {
38+
function getAll(serviceProvider) {
3839
const requestOptions = {
3940
method: "GET",
4041
headers: authHeader()
4142
};
42-
return fetch(`http://localhost:4000/home`, requestOptions)
43+
return fetch(
44+
`http://localhost:4000/home/?serviceProvider=${serviceProvider}`,
45+
requestOptions
46+
)
4347
.then(handleResponse)
4448
.then(data => {
4549
console.log("AAAA", data);

react-frontend/webpack.config.js

Lines changed: 60 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,65 @@
1-
var HtmlWebpackPlugin = require('html-webpack-plugin');
2-
var path = require('path');
3-
var APP_DIR = path.resolve(__dirname, 'src');
4-
const ExtractTextPlugin = require('extract-text-webpack-plugin');
5-
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
1+
let HtmlWebpackPlugin = require("html-webpack-plugin");
2+
let path = require("path");
3+
let APP_DIR = path.resolve(__dirname, "src");
4+
const ExtractTextPlugin = require("extract-text-webpack-plugin");
5+
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
66

77
module.exports = {
8-
entry: APP_DIR + '/index.js',
9-
mode: 'development',
10-
resolve: {
11-
extensions: ['.js', '.jsx']
12-
},
13-
module: {
14-
rules: [
15-
{
16-
test: /\.jsx?$/,
17-
loader: 'babel-loader'
18-
},
19-
{
20-
test: /\.css$/,
21-
use: [
22-
{
23-
loader: MiniCssExtractPlugin.loader,
24-
options: {
25-
// you can specify a publicPath here
26-
// by default it uses publicPath in webpackOptions.output
27-
publicPath: '../',
28-
hmr: process.env.NODE_ENV === 'development',
29-
},
30-
},
31-
'css-loader',
32-
],
33-
},
34-
{
35-
test: /\.(png|jpe?g|gif)$/,
36-
use: [
37-
{
38-
loader: 'file-loader',
39-
options: {},
40-
},
41-
],
42-
},
8+
entry: APP_DIR + "/index.js",
9+
mode: "development",
10+
resolve: {
11+
extensions: [".js", ".jsx"]
12+
},
13+
module: {
14+
rules: [
15+
{
16+
test: /\.jsx?$/,
17+
loader: "babel-loader"
18+
},
19+
{
20+
test: /\.css$/,
21+
use: [
22+
{
23+
loader: MiniCssExtractPlugin.loader,
24+
options: {
25+
// you can specify a publicPath here
26+
// by default it uses publicPath in webpackOptions.output
27+
publicPath: "../",
28+
hmr: process.env.NODE_ENV === "development"
29+
}
30+
},
31+
"css-loader"
4332
]
44-
},
45-
plugins: [new HtmlWebpackPlugin({
46-
template: './src/index.html'
33+
},
34+
{
35+
test: /\.(png|jpe?g|gif)$/,
36+
use: [
37+
{
38+
loader: "file-loader",
39+
options: {}
40+
}
41+
]
42+
}
43+
]
44+
},
45+
plugins: [
46+
new HtmlWebpackPlugin({
47+
template: "./src/index.html"
4748
}),
4849
new MiniCssExtractPlugin({
49-
// Options similar to the same options in webpackOptions.output
50-
// both options are optional
51-
filename: '[name].css',
52-
chunkFilename: '[id].css',
53-
}),
54-
],
55-
devServer: {
56-
historyApiFallback: true
57-
},
58-
externals: {
59-
// global app config object
60-
config: JSON.stringify({
61-
apiUrl: 'http://localhost:4000'
62-
})
63-
}
64-
}
50+
// Options similar to the same options in webpackOptions.output
51+
// both options are optional
52+
filename: "[name].css",
53+
chunkFilename: "[id].css"
54+
})
55+
],
56+
devServer: {
57+
historyApiFallback: true
58+
},
59+
externals: {
60+
// global app config object
61+
config: JSON.stringify({
62+
apiUrl: "http://localhost:4000"
63+
})
64+
}
65+
};

0 commit comments

Comments
 (0)