Skip to content

Commit

Permalink
Merge pull request #21 from cdalton713/backend
Browse files Browse the repository at this point in the history
Backend
  • Loading branch information
alxford45 authored Nov 29, 2020
2 parents d4ae709 + 9fc19b3 commit a5ac230
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion api/src/ticket/ticket.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 8 additions & 1 deletion client/src/api/api.js
Original file line number Diff line number Diff line change
@@ -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/`,
});
5 changes: 3 additions & 2 deletions client/src/components/form/selectOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
],
},
];
5 changes: 4 additions & 1 deletion client/src/routes/admin/ManageTicket.js
Original file line number Diff line number Diff line change
Expand Up @@ -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" });
}
Expand Down

0 comments on commit a5ac230

Please sign in to comment.