mirror of
https://github.com/franjsco/tick3t
synced 2025-06-05 22:19:18 +02:00
refactoring: remove unused State
This commit is contained in:
@@ -30,7 +30,6 @@ class TicketManager extends Component {
|
|||||||
note: '',
|
note: '',
|
||||||
error: '',
|
error: '',
|
||||||
updated: false,
|
updated: false,
|
||||||
isLoading: false,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.handleSubmit = this.handleSubmit.bind(this);
|
this.handleSubmit = this.handleSubmit.bind(this);
|
||||||
@@ -39,35 +38,15 @@ class TicketManager extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.setState({ isLoading: true });
|
|
||||||
|
|
||||||
const { match: { params } } = this.props;
|
const { match: { params } } = this.props;
|
||||||
/*
|
|
||||||
fetch(`${config.baseURL}tickets/${params.ticketId}`)
|
|
||||||
.then(response => {
|
|
||||||
if (!response.ok) {
|
|
||||||
throw new Error('Error API');
|
|
||||||
}
|
|
||||||
|
|
||||||
return response.json();
|
|
||||||
})
|
|
||||||
.then(json => {
|
|
||||||
if (!json.data) {
|
|
||||||
throw new Error('Ticket Not found');
|
|
||||||
}
|
|
||||||
|
|
||||||
this.setState({ data: json.data, isLoading: false })
|
|
||||||
})
|
|
||||||
.catch(error => this.setState({ error, isLoading: false }));
|
|
||||||
*/
|
|
||||||
|
|
||||||
viewTicket(params.ticketId)
|
viewTicket(params.ticketId)
|
||||||
.then((json) => this.setState({ data: json.data, isLoading: false }))
|
.then((json) => this.setState({ data: json.data}))
|
||||||
.catch(error => this.setState({ error, isLoading: false }));
|
.catch(error => this.setState({ error }));
|
||||||
|
|
||||||
getAllTicketStatus()
|
getAllTicketStatus()
|
||||||
.then((json) => this.setState({ categories: json.data }))
|
.then((json) => this.setState({ categories: json.data }))
|
||||||
.catch(error => this.setState({ error, isLoading: false }));
|
.catch(error => this.setState({ error }));
|
||||||
}
|
}
|
||||||
|
|
||||||
handleInputChange(event) {
|
handleInputChange(event) {
|
||||||
@@ -108,7 +87,7 @@ class TicketManager extends Component {
|
|||||||
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { data, updated, isLoading, error } = this.state;
|
const { data, updated, error } = this.state;
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
return (
|
return (
|
||||||
@@ -118,9 +97,6 @@ class TicketManager extends Component {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isLoading) {
|
|
||||||
return '' // add spinner
|
|
||||||
}
|
|
||||||
|
|
||||||
if (updated) {
|
if (updated) {
|
||||||
return (
|
return (
|
||||||
|
Reference in New Issue
Block a user