diff --git a/api/src/ticket/ticket.service.ts b/api/src/ticket/ticket.service.ts index 12e9304..64c80e0 100644 --- a/api/src/ticket/ticket.service.ts +++ b/api/src/ticket/ticket.service.ts @@ -171,7 +171,7 @@ export class TicketService { const query: QueryConfig = { name: 'insert_device', text: - 'INSERT INTO device(ticket_id, manufacturer, model, operating_system, operating_system_version, component) VALUES ($1, $2, $3, $4, $5 $6) RETURNING *', + 'INSERT INTO device(ticket_id, manufacturer, model, operating_system, operating_system_version, component) VALUES ($1, $2, $3, $4, $5, $6) RETURNING *', values: [ ticket_id, manufacturer, diff --git a/client/src/api/api.js b/client/src/api/api.js index 85c8536..2367339 100644 --- a/client/src/api/api.js +++ b/client/src/api/api.js @@ -1,5 +1,12 @@ import axios from "axios"; +/* +If serve static dev -> host = localhost:3000 +If concurrent dev -> host = localhost:5000 +If production -> host = 'https://lsu-it-support-demo.herokuapp.com/' +*/ +const PORT = process.env.PORT || 5000; +const HOST = process.env.HOST || `localhost:${PORT}` export default axios.create({ - baseURL: `http://localhost:3000/api/`, + baseURL: `http://${HOST}/api/`, }); diff --git a/client/src/components/form/selectOptions.js b/client/src/components/form/selectOptions.js index 2ffe608..719caa2 100644 --- a/client/src/components/form/selectOptions.js +++ b/client/src/components/form/selectOptions.js @@ -291,8 +291,9 @@ export const selectOptions = [ { name: "status", options: [ - { value: "open", text: "Open" }, - { value: "closed", text: "Closed" }, + /* Status must be OPEN or CLOSE for db */ + { value: "OPEN", text: "Open" }, + { value: "CLOSE", text: "Closed" }, ], }, ]; diff --git a/client/src/routes/admin/ManageTicket.js b/client/src/routes/admin/ManageTicket.js index 40b09f0..65a5257 100644 --- a/client/src/routes/admin/ManageTicket.js +++ b/client/src/routes/admin/ManageTicket.js @@ -143,7 +143,10 @@ const TicketForm = ( }, [dataRefresh, selectedTicket]); const internalFormSubmit = async (e, data) => { - const response = await handleFormSubmit(e, data, "/ticket"); + /* Get ticket id from state */ + const ticket_id = data.filter(x => x.name === "ticket_id").map(y => y.value)[0]; + /* set 'put' arg to true */ + const response = await handleFormSubmit(e, data, `/ticket/${ticket_id}`, true); if (response.status === 201) { dispatch({ type: "CLEAR_FORM" }); }