1
0
mirror of https://github.com/franjsco/tick3t synced 2025-06-05 22:19:18 +02:00

improvement: ViewTicket

This commit is contained in:
frab1t
2019-07-03 10:30:49 +02:00
parent 3c5ed86e60
commit 07f20983d5

View File

@@ -1,6 +1,8 @@
import React, { Component } from 'react';
import { Link } from 'react-router-dom';
import { config } from '../../config';
import Card from '../../components/Card';
import Table from '../../components/Table';
@@ -14,7 +16,6 @@ class ViewTicket extends Component {
isLoading: false,
};
this.API_URL= process.env.REACT_APP_API_URL;
}
componentDidMount() {
@@ -22,7 +23,7 @@ class ViewTicket extends Component {
const { match: { params } } = this.props;
fetch(`${this.API_URL}tickets?id=${params.ticketId}`)
fetch(`${config.baseURL}tickets/${params.ticketId}`)
.then(response => {
if (!response.ok) {
throw new Error('Error API');
@@ -31,13 +32,13 @@ class ViewTicket extends Component {
return response.json();
})
.then(json => {
if (!json.length) {
console.log()
if (!json.success) {
throw new Error('Ticket Not found');
}
this.setState({
data: json[0],
data: json.data,
isLoading: false
})
})