cleaner code...

This commit is contained in:
Luke Berndt
2021-01-24 22:16:20 -05:00
parent 4892fd7c71
commit 7c11c520cd
7 changed files with 5 additions and 53 deletions

View File

@@ -1,26 +1,13 @@
import React, { Component } from "react";
import ReactDOM from "react-dom";
import {
Container,
Header,
Dropdown,
Divider,
TextArea,
Form,
Grid,
Segment,
Input,
Button,
Message,
Checkbox,
Icon
} from "semantic-ui-react";
// ----------------------------------------------------
const checkInputMessagestyle = {
color: "red"
};
// ----------------------------------------------------
class SystemForm extends Component {
constructor(props) {
@@ -94,7 +81,7 @@ class SystemForm extends Component {
this.setState({ nameError: false });
}
if (this.state.shortName.length == 0 || this.state.shortName.length > 10) {
if (this.state.shortName.length === 0 || this.state.shortName.length > 10) {
this.setState({ shortNameError: true });
checkInputMessages.push(
"Short Name for the system has to be 4-10 charecters"
@@ -416,7 +403,7 @@ class SystemForm extends Component {
<div style={floatStyle}>
<Button type="submit" size="large" floated="right" value="Login">
{isEditing != true ? "Create" : "Update"}
{isEditing !== true ? "Create" : "Update"}
</Button>
</div>
</Form>

View File

@@ -16,7 +16,6 @@ class UpdateSystem extends Component {
}
componentDidMount() {
const { dispatch } = this.props
this.props.fetchSystems()
}

View File

@@ -18,15 +18,6 @@ function fetchError(data) {
data };
}
function makeUserRequest(method, data, api) {
// returns a Promise
return axios({
method: method,
url: api,
data: data
});
}
export function changeUrl(url) {
return dispatch => {
dispatch(push(url));
@@ -39,7 +30,7 @@ export function fetch(shortName) {
dispatch(beginFetch());
return axios
.get(process.env.REACT_APP_BACKEND_SERVER + "/" + shortName + "/errors")
.get(process.env.REACT_APP_BACKEND_SERVER + "/" + shortName + "/errors", {withCredentials: true})
.then(response => {
if (response.data) {
var data ={

View File

@@ -138,7 +138,7 @@ export function fetchErrors(shortName) {
dispatch(beginFetchError());
return axios
.get(process.env.REACT_APP_BACKEND_SERVER + "/" + shortName + "/systems")
.get(process.env.REACT_APP_BACKEND_SERVER + "/" + shortName + "/systems", {withCredentials: true})
.then(response => {
if (response.data) {
dispatch(fetchErrorsSuccess(shortName, response.data));

View File

@@ -1,16 +1,5 @@
import React, { Component } from "react";
import ReactDOM from "react-dom";
import { Link } from 'react-router-dom'
import {
Container,
Header,
Form,
Grid,
Segment,
Input,
Button,
Message,
Icon,
Table
} from "semantic-ui-react";
@@ -20,11 +9,6 @@ import {
// ----------------------------------------------------
class ListTalkgroups extends Component {
constructor(props) {
super(props);
}
//https://stackoverflow.com/questions/36559661/how-can-i-dispatch-from-child-components-in-react-redux
//https://stackoverflow.com/questions/42597602/react-onclick-pass-event-with-parameter

View File

@@ -26,15 +26,6 @@ function beginExportTalkgroup() {
return { type: types.EXPORT_TALKGROUP };
}
function exportTalkgroupSuccess() {
return { type: types.EXPORT_SUCCESS_TALKGROUP };
}
function exportTalkgroupError() {
return { type: types.EXPORT_ERROR_TALKGROUP };
}
function beginFetchTalkgroup() {
return { type: types.FETCH_TALKGROUP };
}