Skip to content

Commit

Permalink
post from admin setup. assignment/work all that left
Browse files Browse the repository at this point in the history
  • Loading branch information
cdalton713 committed Nov 29, 2020
1 parent f356db6 commit e4086a8
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 35 deletions.
19 changes: 7 additions & 12 deletions client/src/components/form/ManageTicketForm/adminView.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,14 @@ import {
EuiTitle,
} from "@elastic/eui";
import React, { useState } from "react";
import { MyTextField } from "../MyTextField";
import { MySelectField } from "../MySelectField";
import { addToast } from "../../toast";
import { DEBUG } from "../../app/app";
import { errorMessages } from "./fields";
import {
handleDateChange,
handleFormFieldBlur,
handleFormFieldChange,
} from "./handlers";
import { selectOptions } from "../selectOptions";
import { MyDatePicker } from "../MyDatePicker";
import { TicketAssignmentTable } from "../../table/AssignedToTable";
import { AddTechnicianPopover } from "../../popover/TechnicianPopover";
import { TimeLogTable } from "../../table/TimeLogTable";

var _ = require("lodash");
Expand All @@ -44,7 +38,7 @@ export const AdminView = (
<MySelectField
data={data}
name={"core_issue"}
selectOptions={selectOptions}
selectOptions={selectOptions.find((o) => o.name === "core_issue")}
handleBlur={(e) => handleFormFieldBlur(e, data, dispatch)}
handleChange={(e) => handleFormFieldChange(e, data, dispatch)}
/>
Expand All @@ -53,7 +47,7 @@ export const AdminView = (
<MySelectField
data={data}
name={"component"}
selectOptions={selectOptions}
selectOptions={selectOptions.find((o) => o.name === "component")}
handleBlur={(e) => handleFormFieldBlur(e, data, dispatch)}
handleChange={(e) => handleFormFieldChange(e, data, dispatch)}
/>
Expand All @@ -67,20 +61,21 @@ export const AdminView = (
<EuiFlexGroup style={{ maxWidth: 1000 }}>
<EuiFlexItem style={{ maxWidth: 1000 }}>
<EuiFormRow
label={_.find(data, ["name", "description"]).label}
label={_.find(data, ["name", "notes"]).label}
error={[
_.find(errorMessages, [
"error_type",
_.find(data, ["name", "description"]).error_type,
_.find(data, ["name", "notes"]).error_type,
]).error_message,
]}
isInvalid={_.find(data, ["name", "description"]).error}
isInvalid={_.find(data, ["name", "notes"]).error}
>
<EuiTextArea
placeholder={"Ticket notes..."}
name={_.find(data, ["name", "notes"]).name}
onChange={(e) => handleFormFieldChange(e, data, dispatch)}
onBlur={(e) => handleFormFieldBlur(e, data, dispatch)}
value={_.find(data, ["name", "description"]).value}
/>
</EuiFormRow>
</EuiFlexItem>
Expand Down Expand Up @@ -149,7 +144,7 @@ export const AdminView = (
<MySelectField
handleChange={(e) => handleFormFieldChange(e, data, dispatch)}
handleBlur={(e) => handleFormFieldBlur(e, data, dispatch)}
selectOptions={selectOptions}
selectOptions={selectOptions.find((o) => o.name === "status")}
data={data}
name={"status"}
/>
Expand Down
1 change: 1 addition & 0 deletions client/src/components/form/ManageTicketForm/userView.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ export const UserView = ({ data, dispatch }, ...props) => {
name={_.find(data, ["name", "description"]).name}
onChange={(e) => handleFormFieldChange(e, data, dispatch)}
onBlur={(e) => handleFormFieldBlur(e, data, dispatch)}
value={_.find(data, ["name", "description"]).value}
/>
</EuiFormRow>
</EuiFlexItem>
Expand Down
21 changes: 9 additions & 12 deletions client/src/components/table/TicketsTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,6 @@ import { AdminTicketFlyout } from "../flyout/flyout";
import { dataFetchReducer } from "../../api/reducers";
import { ErrorCallout } from "../callout/Callout";

const userTest = [
{
id: "1",
firstName: "john",
lastName: "doe",
github: "johndoe",
dateOfBirth: Date.now(),
nationality: "NL",
online: true,
},
];

export const TicketsTable = (
{ handleTicketSelection, tickets, isLoading },
...props
Expand Down Expand Up @@ -54,6 +42,15 @@ export const TicketsTable = (
{
field: "problem_category",
name: "Problem Category",
render: (problem_category) => {
String.prototype.toProperCase = function () {
return this.replace(/\w\S*/g, function (txt) {
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
});
};

return problem_category.replace("_", " ").toProperCase();
},
},
{
field: "status",
Expand Down
12 changes: 1 addition & 11 deletions client/src/routes/admin/ManageTicket.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ const TicketForm = ({ setSelectedTicket, selectedTicket }, ...props) => {
};

try {
dispatch({ type: "CLEAR_FORM" });
const result = await axios.get("/ticket/" + selectedTicket.ticket_id);
const userResult = await axios.get("/user/" + selectedTicket.lsu_id);
let final = [];
for (const [key, value] of Object.entries(result.data)) {
console.log(`${key}: ${value}`);
Expand All @@ -91,16 +91,6 @@ const TicketForm = ({ setSelectedTicket, selectedTicket }, ...props) => {
});
}

for (const [key, value] of Object.entries(userResult.data)) {
console.log(`${key}: ${value}`);
final.push({
name: key,
value: value,
error: false,
error_type: "none",
label: key.replace("_", " ").toProperCase(),
});
}
const union = _.unionBy(final, fields, "name");
dispatch({
type: "FETCH_TICKET_SUCCESS",
Expand Down

0 comments on commit e4086a8

Please sign in to comment.