Skip to content

Commit dabbd42

Browse files
Added docker support for mysql, react-ui and common-data-service
1 parent 1f808f0 commit dabbd42

File tree

13 files changed

+43
-35
lines changed

13 files changed

+43
-35
lines changed

client/Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Base Package
2+
FROM node:14
3+
4+
MAINTAINER Ujjaval Desai
5+
6+
# Create app directory
7+
WORKDIR /usr/src/app
8+
9+
# Install app dependencies
10+
# A wildcard is used to ensure both package.json AND package-lock.json are copied
11+
# where available (npm@5+)
12+
COPY package*.json ./
13+
14+
RUN npm install
15+
16+
# Bundle app source
17+
COPY . .
18+
19+
# Initiate npm start
20+
CMD [ "npm", "start" ]

client/public/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
Only files inside the `public` folder can be referenced from the HTML.
2323
2424
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
25-
work correctly both with client-side routing and a non-root public URL.
25+
work correctly both with react-ui-side routing and a non-root public URL.
2626
Learn how to configure a non-root public URL by running `npm run build`.
2727
-->
2828
<title>React App</title>

client/src/components/routes/checkout/paymentButton.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, {Component, useEffect, useState} from 'react'
1+
import React, {Component} from 'react'
22
import StripeCheckout from 'react-stripe-checkout';
33
import {Button, Grid} from "@material-ui/core";
44
import {connect} from "react-redux";
@@ -12,7 +12,6 @@ class PaymentButton extends Component {
1212
constructor(props) {
1313
super(props);
1414
this.state = {
15-
grandTotal: null,
1615
paymentBtnClicked: false
1716
}
1817
}

client/src/components/routes/home/home.js

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,30 @@ const Home = props => {
2727
// eslint-disable-next-line
2828
}, [homePageDataReducer]);
2929

30+
// we will be showing spinner till we get the data via API
3031
if (homeAPIData.isLoading) {
3132
log.info("[Home]: loading")
3233
return <Spinner/>
3334
} else {
34-
if (homeAPIData.hasOwnProperty("data")) {
35-
if (Object.entries(homeAPIData.data).length !== HOME_PAGE_API_OBJECT_LEN) {
3635

37-
log.info(`[Home]: homeAPIData.data length didn't matched` +
38-
`actual length = ${Object.entries(homeAPIData.data).length},` +
39-
`expected length = ${HOME_PAGE_API_OBJECT_LEN}`)
36+
// check if we got the data from the API
37+
if (homeAPIData.hasOwnProperty("data")
38+
&& Object.entries(homeAPIData.data).length !== HOME_PAGE_API_OBJECT_LEN) {
4039

41-
return <BadRequest/>
42-
}
43-
} else {
44-
if (homeAPIData.hasOwnProperty('statusCode')) {
45-
log.info(`[Home]: homeAPIData.statusCode = ${homeAPIData.statusCode}`)
46-
return <HTTPError statusCode={homeAPIData.statusCode}/>
47-
}
40+
log.info(`[Home]: homeAPIData.data length didn't matched` +
41+
`actual length = ${Object.entries(homeAPIData.data).length},` +
42+
`expected length = ${HOME_PAGE_API_OBJECT_LEN}`)
43+
44+
// if we can't get the data then the front end
45+
// didn't use the API correctly.
46+
return <BadRequest/>
47+
48+
// if statusCode exist in the object then
49+
// we are sure that something went wrong at server side while
50+
// fetching the API
51+
} else if (homeAPIData.hasOwnProperty('statusCode')) {
52+
log.info(`[Home]: homeAPIData.statusCode = ${homeAPIData.statusCode}`)
53+
return <HTTPError statusCode={homeAPIData.statusCode}/>
4854
}
4955
}
5056

client/src/components/routes/home/homeMenuIcons.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,16 @@ import {Link} from "react-router-dom";
44
import log from 'loglevel';
55
import {MAX_PRODUCTS_PER_PAGE} from "../../../constants/constants";
66
import {useSelector} from "react-redux";
7-
import {BadRequest} from "../../ui/error/badRequest";
87

98
const HomeMenuIcons = () => {
109
const homeAPIData = useSelector(state => state.homePageDataReducer)
1110

1211
const renderImageList = (imageList) => {
1312

14-
if(!imageList) {
15-
log.info(`[HomeMenuIcons]: imageList is null`)
16-
return <BadRequest/>
17-
}
18-
1913
// filter out images which are related to home icons.
2014
imageList = imageList.filter(image => image.filePath.search("icon") !== -1)
2115

16+
// map the image path and link
2217
return imageList.map(info => {
2318
return (
2419
<Grid key={info.id} item sm={2}>

client/src/components/routes/home/topCategoriesAndBrands.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import React from 'react';
2-
import {Grid, Box, Typography} from "@material-ui/core";
2+
import {Grid} from "@material-ui/core";
33
import {Link} from "react-router-dom";
44
import log from 'loglevel';
55
import {MAX_PRODUCTS_PER_PAGE} from "../../../constants/constants";
66
import {useSelector} from "react-redux";
7-
import Hidden from "@material-ui/core/Hidden";
8-
import {BadRequest} from "../../ui/error/badRequest";
97

108
const queryType = {
119
brand: 1,
@@ -16,10 +14,6 @@ const TopCategoriesAndBrands = () => {
1614
const homeAPIData = useSelector(state => state.homePageDataReducer)
1715

1816
const renderImageList = (imageList, filterQueryType) => {
19-
if(!imageList) {
20-
log.info(`[TopCategoriesAndBrands]: imageList is null`)
21-
return <BadRequest/>
22-
}
2317

2418
return imageList.map(info => {
2519

docker-compose.yml

Whitespace-only changes.

mysql-db/user.sql

Whitespace-only changes.

server/common-data-service/Dockerfile

Whitespace-only changes.

server/common-data-service/src/main/java/com/ujjaval/ecommerce/commondataservice/service/CommonDataServiceImpl.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,6 @@ public ProductInfo findAddressById(Integer id) {
9797
return productInfo;
9898
}
9999

100-
public String getCurrentHostUrl() throws UnknownHostException {
101-
return String.format("%s:%s", InetAddress.getLocalHost().getHostAddress(),
102-
environment.getProperty("local.server.port"));
103-
}
104-
105100
public void save() {
106101
// AddressInfo addressInfo1 = new AddressInfo("2600 bay area blvd.", "Apt. 304", "77058", "Tx", "USA");
107102
// ContactInfo contactInfo = new ContactInfo("[email protected]", "534636453", "345345353", null);
@@ -132,8 +127,7 @@ public void save() {
132127
}
133128

134129
public String appendHostUrl(String path) throws UnknownHostException {
135-
String currentHostUrl = getCurrentHostUrl();
136-
return String.format("http://%s/web-images/%s", currentHostUrl, path);
130+
return String.format("http://localhost:%s/web-images/%s", environment.getProperty("local.server.port"), path);
137131
}
138132

139133
public MainScreenResponse getHomeScreenData() throws UnknownHostException {

0 commit comments

Comments
 (0)