mirror of
https://github.com/franjsco/tick3t
synced 2025-06-05 22:19:18 +02:00
refactor: edit dotenv
This commit is contained in:
@ -21,10 +21,11 @@ class TicketList extends Component {
|
|||||||
error: ''
|
error: ''
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.API_URL= process.env.REACT_APP_API_URL;
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
fetch(`http://localhost:3001/tickets?_limit=10`)
|
fetch(`${this.API_URL}tickets?_limit=10`)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error('Error API');
|
throw new Error('Error API');
|
||||||
@ -35,7 +36,7 @@ class TicketList extends Component {
|
|||||||
.catch(error => this.setState({ error, isLoading: false }));
|
.catch(error => this.setState({ error, isLoading: false }));
|
||||||
|
|
||||||
|
|
||||||
fetch("http://localhost:3001/categories?type=ticketStatus")
|
fetch(`${this.API_URL}categories?type=ticketStatus`)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error('Error API');
|
throw new Error('Error API');
|
||||||
@ -59,7 +60,7 @@ class TicketList extends Component {
|
|||||||
render() {
|
render() {
|
||||||
let tickets = this.state.data;
|
let tickets = this.state.data;
|
||||||
|
|
||||||
if (tickets.length > 0) {
|
if (tickets.length) {
|
||||||
tickets = tickets.map((ticket) => {
|
tickets = tickets.map((ticket) => {
|
||||||
return (
|
return (
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -16,7 +16,7 @@ import Table from '../../components/Table';
|
|||||||
import DropDown from '../../components/DropDown';
|
import DropDown from '../../components/DropDown';
|
||||||
|
|
||||||
|
|
||||||
class TicketWork extends Component {
|
class TicketManager extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
@ -32,6 +32,8 @@ class TicketWork extends Component {
|
|||||||
|
|
||||||
this.handleSubmit = this.handleSubmit.bind(this);
|
this.handleSubmit = this.handleSubmit.bind(this);
|
||||||
this.handleInputChange = this.handleInputChange.bind(this);
|
this.handleInputChange = this.handleInputChange.bind(this);
|
||||||
|
|
||||||
|
this.API_URL= process.env.REACT_APP_API_URL;
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
@ -39,7 +41,7 @@ class TicketWork extends Component {
|
|||||||
|
|
||||||
const { match: { params } } = this.props;
|
const { match: { params } } = this.props;
|
||||||
|
|
||||||
fetch(`http://localhost:3001/tickets?id=${params.ticketId}`)
|
fetch(`${this.API_URL}tickets?id=${params.ticketId}`)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error('Error API');
|
throw new Error('Error API');
|
||||||
@ -57,7 +59,7 @@ class TicketWork extends Component {
|
|||||||
.catch(error => this.setState({ error, isLoading: false }));
|
.catch(error => this.setState({ error, isLoading: false }));
|
||||||
|
|
||||||
|
|
||||||
fetch("http://localhost:3001/categories?type=ticketStatus")
|
fetch(`${this.API_URL}categories?type=ticketStatus`)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error('Error API');
|
throw new Error('Error API');
|
||||||
@ -98,7 +100,7 @@ class TicketWork extends Component {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fetch(`http://localhost:3001/tickets/${params.ticketId}`, {
|
fetch(`${this.API_URL}tickets/${params.ticketId}`, {
|
||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
@ -208,4 +210,4 @@ class TicketWork extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default TicketWork;
|
export default TicketManager;
|
@ -31,11 +31,13 @@ class CreateTicket extends Component {
|
|||||||
|
|
||||||
this.handleInputChange = this.handleInputChange.bind(this);
|
this.handleInputChange = this.handleInputChange.bind(this);
|
||||||
this.handleSubmit = this.handleSubmit.bind(this);
|
this.handleSubmit = this.handleSubmit.bind(this);
|
||||||
|
|
||||||
|
this.API_URL= process.env.REACT_APP_API_URL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
fetch("http://localhost:3001/categories?type=ticketType", {
|
fetch(`${this.API_URL}categories?type=ticketType`, {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: { 'Content-Type': 'application/json' }
|
headers: { 'Content-Type': 'application/json' }
|
||||||
})
|
})
|
||||||
@ -75,7 +77,7 @@ class CreateTicket extends Component {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fetch("http://localhost:3001/tickets", {
|
fetch(`${this.API_URL}tickets`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify(rest)
|
body: JSON.stringify(rest)
|
||||||
|
@ -13,6 +13,8 @@ class ViewTicket extends Component {
|
|||||||
error: '',
|
error: '',
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.API_URL= process.env.REACT_APP_API_URL;
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
@ -20,7 +22,7 @@ class ViewTicket extends Component {
|
|||||||
|
|
||||||
const { match: { params } } = this.props;
|
const { match: { params } } = this.props;
|
||||||
|
|
||||||
fetch(`http://localhost:3001/tickets?id=${params.ticketId}`)
|
fetch(`${this.API_URL}tickets?id=${params.ticketId}`)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error('Error API');
|
throw new Error('Error API');
|
||||||
|
Reference in New Issue
Block a user