refactor: edit dotenv

This commit is contained in:
frab1t 2019-05-18 18:56:40 +02:00
parent cd22fd6a77
commit 7461424cc2
4 changed files with 18 additions and 11 deletions

View File

@ -21,10 +21,11 @@ class TicketList extends Component {
error: ''
};
this.API_URL= process.env.REACT_APP_API_URL;
}
componentDidMount() {
fetch(`http://localhost:3001/tickets?_limit=10`)
fetch(`${this.API_URL}tickets?_limit=10`)
.then(response => {
if (!response.ok) {
throw new Error('Error API');
@ -35,7 +36,7 @@ class TicketList extends Component {
.catch(error => this.setState({ error, isLoading: false }));
fetch("http://localhost:3001/categories?type=ticketStatus")
fetch(`${this.API_URL}categories?type=ticketStatus`)
.then((response) => {
if (!response.ok) {
throw new Error('Error API');
@ -59,7 +60,7 @@ class TicketList extends Component {
render() {
let tickets = this.state.data;
if (tickets.length > 0) {
if (tickets.length) {
tickets = tickets.map((ticket) => {
return (
<tr>

View File

@ -16,7 +16,7 @@ import Table from '../../components/Table';
import DropDown from '../../components/DropDown';
class TicketWork extends Component {
class TicketManager extends Component {
constructor(props) {
super(props);
@ -32,6 +32,8 @@ class TicketWork extends Component {
this.handleSubmit = this.handleSubmit.bind(this);
this.handleInputChange = this.handleInputChange.bind(this);
this.API_URL= process.env.REACT_APP_API_URL;
}
componentDidMount() {
@ -39,7 +41,7 @@ class TicketWork extends Component {
const { match: { params } } = this.props;
fetch(`http://localhost:3001/tickets?id=${params.ticketId}`)
fetch(`${this.API_URL}tickets?id=${params.ticketId}`)
.then(response => {
if (!response.ok) {
throw new Error('Error API');
@ -57,7 +59,7 @@ class TicketWork extends Component {
.catch(error => this.setState({ error, isLoading: false }));
fetch("http://localhost:3001/categories?type=ticketStatus")
fetch(`${this.API_URL}categories?type=ticketStatus`)
.then((response) => {
if (!response.ok) {
throw new Error('Error API');
@ -98,7 +100,7 @@ class TicketWork extends Component {
return;
}
fetch(`http://localhost:3001/tickets/${params.ticketId}`, {
fetch(`${this.API_URL}tickets/${params.ticketId}`, {
method: 'PATCH',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
@ -208,4 +210,4 @@ class TicketWork extends Component {
}
}
export default TicketWork;
export default TicketManager;

View File

@ -31,11 +31,13 @@ class CreateTicket extends Component {
this.handleInputChange = this.handleInputChange.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
this.API_URL= process.env.REACT_APP_API_URL;
}
componentDidMount() {
fetch("http://localhost:3001/categories?type=ticketType", {
fetch(`${this.API_URL}categories?type=ticketType`, {
method: 'GET',
headers: { 'Content-Type': 'application/json' }
})
@ -75,7 +77,7 @@ class CreateTicket extends Component {
return;
}
fetch("http://localhost:3001/tickets", {
fetch(`${this.API_URL}tickets`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(rest)

View File

@ -13,6 +13,8 @@ class ViewTicket extends Component {
error: '',
isLoading: false,
};
this.API_URL= process.env.REACT_APP_API_URL;
}
componentDidMount() {
@ -20,7 +22,7 @@ class ViewTicket extends Component {
const { match: { params } } = this.props;
fetch(`http://localhost:3001/tickets?id=${params.ticketId}`)
fetch(`${this.API_URL}tickets?id=${params.ticketId}`)
.then(response => {
if (!response.ok) {
throw new Error('Error API');