From e4086a8e856ac17d7a148687b9c7b34ba26930ca Mon Sep 17 00:00:00 2001 From: Christian Dalton Date: Sat, 28 Nov 2020 20:31:43 -0600 Subject: [PATCH] post from admin setup. assignment/work all that left --- .../form/ManageTicketForm/adminView.js | 19 +++++++---------- .../form/ManageTicketForm/userView.js | 1 + client/src/components/table/TicketsTable.js | 21 ++++++++----------- client/src/routes/admin/ManageTicket.js | 12 +---------- 4 files changed, 18 insertions(+), 35 deletions(-) diff --git a/client/src/components/form/ManageTicketForm/adminView.js b/client/src/components/form/ManageTicketForm/adminView.js index 5fa7f01..d6d8b24 100644 --- a/client/src/components/form/ManageTicketForm/adminView.js +++ b/client/src/components/form/ManageTicketForm/adminView.js @@ -11,10 +11,7 @@ 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, @@ -22,9 +19,6 @@ import { 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"); @@ -44,7 +38,7 @@ export const AdminView = ( o.name === "core_issue")} handleBlur={(e) => handleFormFieldBlur(e, data, dispatch)} handleChange={(e) => handleFormFieldChange(e, data, dispatch)} /> @@ -53,7 +47,7 @@ export const AdminView = ( o.name === "component")} handleBlur={(e) => handleFormFieldBlur(e, data, dispatch)} handleChange={(e) => handleFormFieldChange(e, data, dispatch)} /> @@ -67,20 +61,21 @@ export const AdminView = ( handleFormFieldChange(e, data, dispatch)} onBlur={(e) => handleFormFieldBlur(e, data, dispatch)} + value={_.find(data, ["name", "description"]).value} /> @@ -149,7 +144,7 @@ export const AdminView = ( handleFormFieldChange(e, data, dispatch)} handleBlur={(e) => handleFormFieldBlur(e, data, dispatch)} - selectOptions={selectOptions} + selectOptions={selectOptions.find((o) => o.name === "status")} data={data} name={"status"} /> diff --git a/client/src/components/form/ManageTicketForm/userView.js b/client/src/components/form/ManageTicketForm/userView.js index f424f45..9a5e884 100644 --- a/client/src/components/form/ManageTicketForm/userView.js +++ b/client/src/components/form/ManageTicketForm/userView.js @@ -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} /> diff --git a/client/src/components/table/TicketsTable.js b/client/src/components/table/TicketsTable.js index b5c78cd..f698741 100644 --- a/client/src/components/table/TicketsTable.js +++ b/client/src/components/table/TicketsTable.js @@ -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 @@ -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", diff --git a/client/src/routes/admin/ManageTicket.js b/client/src/routes/admin/ManageTicket.js index e64818a..bc9637b 100644 --- a/client/src/routes/admin/ManageTicket.js +++ b/client/src/routes/admin/ManageTicket.js @@ -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}`); @@ -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",