Skip to content

Commit eaa21a2

Browse files
committed
Code refactor
1 parent d065cdd commit eaa21a2

File tree

10 files changed

+30
-231
lines changed

10 files changed

+30
-231
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
HOST = 0.0.0.0
22
PORT = 4848
3-
REACT_APP_API_SERVER = 192.168.0.134
3+
REACT_APP_API_SERVER = 192.168.0.118
44
REACT_APP_API_SERVER_PORT = 280
5-
REACT_APP_FLASK_SERVER = 192.168.0.134
5+
REACT_APP_API_CONTEXT = /
6+
REACT_APP_FLASK_SERVER = 192.168.0.118
67
REACT_APP_FLASK_SERVER_PORT = 5000
78
GITHUB_SECRET = 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

Track 4_ReactJS_Web Development/Project/Frontend/hrc-dashboard/src/utils/api/HighradiusWinterInternship.postman_collection.json

-210
This file was deleted.

Track 4_ReactJS_Web Development/Project/Frontend/hrc-dashboard/src/utils/api/advancedSearch.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { post } from 'axios';
22

3-
const { REACT_APP_API_SERVER, REACT_APP_API_SERVER_PORT } = process.env;
3+
const { REACT_APP_API_SERVER, REACT_APP_API_SERVER_PORT, REACT_APP_API_CONTEXT } = process.env;
44

55
const advancedSearch = async (payload) => {
66
const URL = `http://${REACT_APP_API_SERVER || '192.168.0.134'}:${
77
REACT_APP_API_SERVER_PORT || '280'
8-
}/RESTDatabase_war_exploded/advancedSearch`;
8+
}${REACT_APP_API_CONTEXT||'/RESTDatabase_war_exploded'}/advancedSearch`;
99

1010
try {
1111
/* const payload = {
@@ -34,7 +34,7 @@ const advancedSearch = async (payload) => {
3434
const { status, data } = await post(
3535
`http://${REACT_APP_API_SERVER || '192.168.0.134'}:${
3636
REACT_APP_API_SERVER_PORT || '280'
37-
}/RESTDatabase_war_exploded/getrows?start=${start}&limit=${limit}`,
37+
}${REACT_APP_API_CONTEXT||'/RESTDatabase_war_exploded'}/getrows?start=${start}&limit=${limit}`,
3838
);
3939
if (status === 200) {
4040
data[data.length - 3] = { ...data[data.length - 3], start, limit };

Track 4_ReactJS_Web Development/Project/Frontend/hrc-dashboard/src/utils/api/getAnalyticsData.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { post } from 'axios';
22

33
const getAnalyticsData = async (payload) => {
4-
const { REACT_APP_API_SERVER, REACT_APP_API_SERVER_PORT } = process.env;
4+
const { REACT_APP_API_SERVER, REACT_APP_API_SERVER_PORT, REACT_APP_API_CONTEXT } = process.env;
55
/* const payload = {
66
clear_date: ['2019-01-01', '2020-12-31'],
77
due_in_date: ['2019-01-01', '2020-12-31'],
@@ -11,9 +11,9 @@ const getAnalyticsData = async (payload) => {
1111

1212
try {
1313
const { status, data } = await post(
14-
`http://${REACT_APP_API_SERVER || '192.168.0.134'}:${
15-
REACT_APP_API_SERVER_PORT || '280'
16-
}/RESTDatabase_war_exploded/getanalytics`,
14+
`http://${REACT_APP_API_SERVER || '192.168.0.134'}:${REACT_APP_API_SERVER_PORT || '280'}${
15+
REACT_APP_API_CONTEXT || '/RESTDatabase_war_exploded'
16+
}/getanalytics`,
1717
JSON.stringify(payload),
1818
);
1919

Track 4_ReactJS_Web Development/Project/Frontend/hrc-dashboard/src/utils/api/getBusinesses.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
import { get } from 'axios';
22

33
const doPost = async () => {
4+
const { REACT_APP_API_SERVER, REACT_APP_API_SERVER_PORT, REACT_APP_API_CONTEXT } = process.env;
5+
46
try {
57
const { status, data } = await get(
6-
'http://192.168.0.134:280/RESTDatabase_war_exploded/getbusinesses',
8+
`http://${REACT_APP_API_SERVER || '192.168.0.134'}:${REACT_APP_API_SERVER_PORT || '280'}${
9+
REACT_APP_API_CONTEXT || '/RESTDatabase_war_exploded'
10+
}/getbusinesses`,
711
);
812
if (status === 200) {
913
console.log('[API /getBusinesses] Response: 200 ');

Track 4_ReactJS_Web Development/Project/Frontend/hrc-dashboard/src/utils/api/getCustomers.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
import { get } from 'axios';
22

33
const doGet = async () => {
4+
const { REACT_APP_API_SERVER, REACT_APP_API_SERVER_PORT, REACT_APP_API_CONTEXT } = process.env;
5+
46
try {
57
const { status, data } = await get(
6-
'http://192.168.0.134:280/RESTDatabase_war_exploded/getcustomers',
8+
`http://${REACT_APP_API_SERVER || '192.168.0.134'}:${
9+
REACT_APP_API_SERVER_PORT || '280'
10+
}${REACT_APP_API_CONTEXT||'/RESTDatabase_war_exploded'}/getcustomers`,
711
);
812
if (status === 200) {
913
console.log('[API /getCustomers] Response: 200 ');

Track 4_ReactJS_Web Development/Project/Frontend/hrc-dashboard/src/utils/api/getRows.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { post } from 'axios';
22

33
const doPost = async ({ start = 0, limit = 10 }) => {
4-
const { REACT_APP_API_SERVER, REACT_APP_API_SERVER_PORT } = process.env;
4+
const { REACT_APP_API_SERVER, REACT_APP_API_SERVER_PORT, REACT_APP_API_CONTEXT } = process.env;
55

66
try {
77
const { status, data } = await post(
8-
`http://${REACT_APP_API_SERVER || '192.168.0.134'}:${
9-
REACT_APP_API_SERVER_PORT || '280'
10-
}/RESTDatabase_war_exploded/getrows?start=${start}&limit=${limit}`,
8+
`http://${REACT_APP_API_SERVER || '192.168.0.134'}:${REACT_APP_API_SERVER_PORT || '280'}${
9+
REACT_APP_API_CONTEXT || '/RESTDatabase_war_exploded'
10+
}/getrows?start=${start}&limit=${limit}`,
1111
);
1212
if (status === 200) {
1313
data[data.length - 3] = { ...data[data.length - 3], start, limit };

Track 4_ReactJS_Web Development/Project/Frontend/hrc-dashboard/src/utils/api/handleAddForm.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { post } from 'axios';
22
// This file is concerned with posting the addform to the server.
3-
const { REACT_APP_API_SERVER, REACT_APP_API_SERVER_PORT } = process.env;
3+
const { REACT_APP_API_SERVER, REACT_APP_API_SERVER_PORT, REACT_APP_API_CONTEXT } = process.env;
44

55
const doSubmit = async (body) => {
66
const URL = `http://${REACT_APP_API_SERVER || '192.168.0.134'}:${
77
REACT_APP_API_SERVER_PORT || '280'
8-
}/RESTDatabase_war_exploded/addRow`;
8+
}${REACT_APP_API_CONTEXT || '/RESTDatabase_war_exploded'}/addRow`;
99

1010
try {
1111
// Pass json body to axios post method.

Track 4_ReactJS_Web Development/Project/Frontend/hrc-dashboard/src/utils/api/handleDeleteRows.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import axios from 'axios';
22
// This file is concerned with DELETE the deleteForm to the server.
3-
const { REACT_APP_API_SERVER, REACT_APP_API_SERVER_PORT } = process.env;
3+
const { REACT_APP_API_SERVER, REACT_APP_API_SERVER_PORT, REACT_APP_API_CONTEXT } = process.env;
44

55
const doDelete = async (selectedIndices) => {
66
const URL = `http://${REACT_APP_API_SERVER || '192.168.0.134'}:${
77
REACT_APP_API_SERVER_PORT || '280'
8-
}/RESTDatabase_war_exploded/deleteRow`;
8+
}${REACT_APP_API_CONTEXT || '/RESTDatabase_war_exploded'}/deleteRow`;
99

1010
// Loop through selectedIndices and append comma ',' to each index.
1111
const selectedIndicesString = selectedIndices.reduce((curr, next) => `${curr + next},`, '');

Track 4_ReactJS_Web Development/Project/Frontend/hrc-dashboard/src/utils/api/handleEditForm.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { post } from 'axios';
22
// This file is concerned with posting the editform to the server.
3-
const { REACT_APP_API_SERVER, REACT_APP_API_SERVER_PORT } = process.env;
3+
const { REACT_APP_API_SERVER, REACT_APP_API_SERVER_PORT, REACT_APP_API_CONTEXT } = process.env;
44

55
const doSubmit = async (params, body) => {
66
const URL = `http://${REACT_APP_API_SERVER || '192.168.0.134'}:${
77
REACT_APP_API_SERVER_PORT || '280'
8-
}/RESTDatabase_war_exploded/editRow`;
8+
}${REACT_APP_API_CONTEXT || '/RESTDatabase_war_exploded'}/editRow`;
99
console.log(JSON.stringify(body));
1010
try {
1111
// Post data to the server with params

0 commit comments

Comments
 (0)