Skip to content

Commit

Permalink
Code refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
nooobcoder committed Apr 11, 2022
1 parent d065cdd commit eaa21a2
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 231 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
HOST = 0.0.0.0
PORT = 4848
REACT_APP_API_SERVER = 192.168.0.134
REACT_APP_API_SERVER = 192.168.0.118
REACT_APP_API_SERVER_PORT = 280
REACT_APP_FLASK_SERVER = 192.168.0.134
REACT_APP_API_CONTEXT = /
REACT_APP_FLASK_SERVER = 192.168.0.118
REACT_APP_FLASK_SERVER_PORT = 5000
GITHUB_SECRET = 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

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { post } from 'axios';

const { REACT_APP_API_SERVER, REACT_APP_API_SERVER_PORT } = process.env;
const { REACT_APP_API_SERVER, REACT_APP_API_SERVER_PORT, REACT_APP_API_CONTEXT } = process.env;

const advancedSearch = async (payload) => {
const URL = `http://${REACT_APP_API_SERVER || '192.168.0.134'}:${
REACT_APP_API_SERVER_PORT || '280'
}/RESTDatabase_war_exploded/advancedSearch`;
}${REACT_APP_API_CONTEXT||'/RESTDatabase_war_exploded'}/advancedSearch`;

try {
/* const payload = {
Expand Down Expand Up @@ -34,7 +34,7 @@ const advancedSearch = async (payload) => {
const { status, data } = await post(
`http://${REACT_APP_API_SERVER || '192.168.0.134'}:${
REACT_APP_API_SERVER_PORT || '280'
}/RESTDatabase_war_exploded/getrows?start=${start}&limit=${limit}`,
}${REACT_APP_API_CONTEXT||'/RESTDatabase_war_exploded'}/getrows?start=${start}&limit=${limit}`,
);
if (status === 200) {
data[data.length - 3] = { ...data[data.length - 3], start, limit };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { post } from 'axios';

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

try {
const { status, data } = await post(
`http://${REACT_APP_API_SERVER || '192.168.0.134'}:${
REACT_APP_API_SERVER_PORT || '280'
}/RESTDatabase_war_exploded/getanalytics`,
`http://${REACT_APP_API_SERVER || '192.168.0.134'}:${REACT_APP_API_SERVER_PORT || '280'}${
REACT_APP_API_CONTEXT || '/RESTDatabase_war_exploded'
}/getanalytics`,
JSON.stringify(payload),
);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { get } from 'axios';

const doPost = async () => {
const { REACT_APP_API_SERVER, REACT_APP_API_SERVER_PORT, REACT_APP_API_CONTEXT } = process.env;

try {
const { status, data } = await get(
'http://192.168.0.134:280/RESTDatabase_war_exploded/getbusinesses',
`http://${REACT_APP_API_SERVER || '192.168.0.134'}:${REACT_APP_API_SERVER_PORT || '280'}${
REACT_APP_API_CONTEXT || '/RESTDatabase_war_exploded'
}/getbusinesses`,
);
if (status === 200) {
console.log('[API /getBusinesses] Response: 200 ');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { get } from 'axios';

const doGet = async () => {
const { REACT_APP_API_SERVER, REACT_APP_API_SERVER_PORT, REACT_APP_API_CONTEXT } = process.env;

try {
const { status, data } = await get(
'http://192.168.0.134:280/RESTDatabase_war_exploded/getcustomers',
`http://${REACT_APP_API_SERVER || '192.168.0.134'}:${
REACT_APP_API_SERVER_PORT || '280'
}${REACT_APP_API_CONTEXT||'/RESTDatabase_war_exploded'}/getcustomers`,
);
if (status === 200) {
console.log('[API /getCustomers] Response: 200 ');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { post } from 'axios';

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

try {
const { status, data } = await post(
`http://${REACT_APP_API_SERVER || '192.168.0.134'}:${
REACT_APP_API_SERVER_PORT || '280'
}/RESTDatabase_war_exploded/getrows?start=${start}&limit=${limit}`,
`http://${REACT_APP_API_SERVER || '192.168.0.134'}:${REACT_APP_API_SERVER_PORT || '280'}${
REACT_APP_API_CONTEXT || '/RESTDatabase_war_exploded'
}/getrows?start=${start}&limit=${limit}`,
);
if (status === 200) {
data[data.length - 3] = { ...data[data.length - 3], start, limit };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { post } from 'axios';
// This file is concerned with posting the addform to the server.
const { REACT_APP_API_SERVER, REACT_APP_API_SERVER_PORT } = process.env;
const { REACT_APP_API_SERVER, REACT_APP_API_SERVER_PORT, REACT_APP_API_CONTEXT } = process.env;

const doSubmit = async (body) => {
const URL = `http://${REACT_APP_API_SERVER || '192.168.0.134'}:${
REACT_APP_API_SERVER_PORT || '280'
}/RESTDatabase_war_exploded/addRow`;
}${REACT_APP_API_CONTEXT || '/RESTDatabase_war_exploded'}/addRow`;

try {
// Pass json body to axios post method.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import axios from 'axios';
// This file is concerned with DELETE the deleteForm to the server.
const { REACT_APP_API_SERVER, REACT_APP_API_SERVER_PORT } = process.env;
const { REACT_APP_API_SERVER, REACT_APP_API_SERVER_PORT, REACT_APP_API_CONTEXT } = process.env;

const doDelete = async (selectedIndices) => {
const URL = `http://${REACT_APP_API_SERVER || '192.168.0.134'}:${
REACT_APP_API_SERVER_PORT || '280'
}/RESTDatabase_war_exploded/deleteRow`;
}${REACT_APP_API_CONTEXT || '/RESTDatabase_war_exploded'}/deleteRow`;

// Loop through selectedIndices and append comma ',' to each index.
const selectedIndicesString = selectedIndices.reduce((curr, next) => `${curr + next},`, '');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { post } from 'axios';
// This file is concerned with posting the editform to the server.
const { REACT_APP_API_SERVER, REACT_APP_API_SERVER_PORT } = process.env;
const { REACT_APP_API_SERVER, REACT_APP_API_SERVER_PORT, REACT_APP_API_CONTEXT } = process.env;

const doSubmit = async (params, body) => {
const URL = `http://${REACT_APP_API_SERVER || '192.168.0.134'}:${
REACT_APP_API_SERVER_PORT || '280'
}/RESTDatabase_war_exploded/editRow`;
}${REACT_APP_API_CONTEXT || '/RESTDatabase_war_exploded'}/editRow`;
console.log(JSON.stringify(body));
try {
// Post data to the server with params
Expand Down

0 comments on commit eaa21a2

Please sign in to comment.