Add
@@ -30,29 +76,39 @@ export const AddTechnicianPopover = () => {
);
return (
-
-
-
-
- handleFormFieldChange(e, data, setData)}
- handleBlur={(e) => handleFormFieldBlur(e, data, setData)}
- />
-
-
-
- Add
-
-
-
-
-
+ <>
+ {state.isLoading === true ? null : (
+
+
+
+
+ {
+ handleFormFieldChange(e, state.data, dispatch);
+ }}
+ handleBlur={(e) =>
+ handleFormFieldBlur(e, state.data, dispatch)
+ }
+ />
+
+
+
+ internalFormSubmit(e, state.data)}>
+ Add
+
+
+
+
+
+
+ )}
+ >
);
};
diff --git a/client/src/components/table/assignedTo.js b/client/src/components/table/TicketAssignmentTable.js
similarity index 55%
rename from client/src/components/table/assignedTo.js
rename to client/src/components/table/TicketAssignmentTable.js
index 48af5cb..cd5b103 100644
--- a/client/src/components/table/assignedTo.js
+++ b/client/src/components/table/TicketAssignmentTable.js
@@ -3,28 +3,7 @@ import React from "react";
import { EuiBasicTable, EuiLink, EuiHealth, EuiButton } from "@elastic/eui";
import { AdminTicketFlyout } from "../flyout/flyout";
-const userTest = [
- {
- id: "1",
- firstName: "john",
- lastName: "doe",
- },
-];
-/*
-Example user object:
-
-
-
-Example country object:
-
-{
- code: 'NL',
- name: 'Netherlands',
- flag: '🇳🇱'
-}
-*/
-
-export const TicketAssignmentTable = ({ handleTicketSelection }, ...props) => {
+export const TicketAssignmentTable = ({ items, isLoading }, ...props) => {
const deleteUser = (user) => {};
const actions = [
@@ -41,18 +20,12 @@ export const TicketAssignmentTable = ({ handleTicketSelection }, ...props) => {
const columns = [
{
- field: "firstName",
+ field: "first_name",
name: "First Name",
- sortable: true,
- "data-test-subj": "firstNameCell",
},
{
- field: "lastName",
+ field: "last_name",
name: "Last Name",
- truncateText: true,
- mobileOptions: {
- show: false,
- },
},
{
name: "Actions",
@@ -60,16 +33,14 @@ export const TicketAssignmentTable = ({ handleTicketSelection }, ...props) => {
},
];
- const items = userTest.filter((user, index) => index < 10);
-
const getRowProps = (item) => {
const { id } = item;
return {
"data-test-subj": `row-${id}`,
className: "customRowClass",
- onClick: (e) => {
- handleTicketSelection(e, id);
- },
+ // onClick: (e) => {
+ // handleTicketSelection(e, id);
+ // },
};
};
@@ -84,12 +55,17 @@ export const TicketAssignmentTable = ({ handleTicketSelection }, ...props) => {
};
return (
-
+
+ {isLoading === true ? null : (
+
+ )}
+
);
};
diff --git a/client/src/components/table/TicketsTable.js b/client/src/components/table/TicketsTable.js
new file mode 100644
index 0000000..35aa608
--- /dev/null
+++ b/client/src/components/table/TicketsTable.js
@@ -0,0 +1,111 @@
+import React, { useEffect, useState, useReducer } from "react";
+import axios from "../../api/api";
+import { EuiBasicTable, EuiLink, EuiHealth, EuiButton } from "@elastic/eui";
+import { AdminTicketFlyout } from "../flyout/flyout";
+import { dataFetchReducer } from "../../api/reducers";
+import { ErrorCallout } from "../callout/Callout";
+
+export const TicketsTable = (
+ { handleTicketSelection, tickets, isLoading },
+ ...props
+) => {
+ const columns = [
+ {
+ field: "first_name",
+ name: "First Name",
+ sortable: true,
+ "data-test-subj": "firstNameCell",
+ mobileOptions: {
+ render: (item) => (
+
+ {item.firstName}{" "}
+
+ {item.lastName}
+
+
+ ),
+ header: false,
+ truncateText: false,
+ enlarge: true,
+ fullWidth: true,
+ },
+ },
+ {
+ field: "last_name",
+ name: "Last Name",
+ truncateText: true,
+ },
+ {
+ field: "lsu_id",
+ name: "LSU ID",
+ },
+ {
+ 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",
+ name: "Status",
+ render: (status) => {
+ const color =
+ status === "OPEN"
+ ? "danger"
+ : status === "IN PROGRESS"
+ ? "primary"
+ : "success";
+ const label =
+ status === "OPEN"
+ ? "Open"
+ : status === "IN PROGRESS"
+ ? "In Progress"
+ : "Closed";
+ return {label};
+ },
+ },
+ ];
+
+ const getRowProps = (item) => {
+ const { lsu_id } = item;
+ return {
+ "data-test-subj": `row-${lsu_id}`,
+ className: "customRowClass",
+ onClick: (e) => {
+ handleTicketSelection(e, item);
+ },
+ };
+ };
+
+ const getCellProps = (item, column) => {
+ const { id } = item;
+ const { field } = column;
+ return {
+ className: "customCellClass",
+ "data-test-subj": `cell-${id}-${field}`,
+ textOnly: true,
+ };
+ };
+
+ return (
+
+ {isLoading === true ? null : (
+
+ )}
+
+ );
+};
diff --git a/client/src/components/table/TimeLogTable.js b/client/src/components/table/WorkLogTable.js
similarity index 56%
rename from client/src/components/table/TimeLogTable.js
rename to client/src/components/table/WorkLogTable.js
index 71d6e97..8114742 100644
--- a/client/src/components/table/TimeLogTable.js
+++ b/client/src/components/table/WorkLogTable.js
@@ -2,29 +2,9 @@ import React from "react";
import { EuiBasicTable, EuiLink, EuiHealth, EuiButton } from "@elastic/eui";
import { AdminTicketFlyout } from "../flyout/flyout";
+import moment from "moment";
-const userTest = [
- {
- id: "1",
- start_datetime: "john",
- end_datetime: "doe",
- },
-];
-/*
-Example user object:
-
-
-
-Example country object:
-
-{
- code: 'NL',
- name: 'Netherlands',
- flag: '🇳🇱'
-}
-*/
-
-export const TimeLogTable = ({ handleTicketSelection }, ...props) => {
+export const WorkLogTable = ({ items, isLoading }, ...props) => {
const deleteUser = (user) => {};
const actions = [
@@ -40,18 +20,26 @@ export const TimeLogTable = ({ handleTicketSelection }, ...props) => {
];
const columns = [
+ {
+ field: "first_name",
+ name: "First Name",
+ },
+ {
+ field: "last_name",
+ name: "Last Name",
+ },
{
field: "start_datetime",
name: "Start Datetime",
- sortable: true,
- "data-test-subj": "firstNameCell",
+ render: (start_datetime) => {
+ return moment(start_datetime).format("MMMM Do YYYY, h:mm a");
+ },
},
{
field: "end_datetime",
name: "End Datetime",
- truncateText: true,
- mobileOptions: {
- show: false,
+ render: (end_datetime) => {
+ return moment(end_datetime).format("MMMM Do YYYY, h:mm a");
},
},
{
@@ -60,16 +48,14 @@ export const TimeLogTable = ({ handleTicketSelection }, ...props) => {
},
];
- const items = userTest.filter((user, index) => index < 10);
-
const getRowProps = (item) => {
const { id } = item;
return {
"data-test-subj": `row-${id}`,
className: "customRowClass",
- onClick: (e) => {
- handleTicketSelection(e, id);
- },
+ // onClick: (e) => {
+ // handleTicketSelection(e, id);
+ // },
};
};
@@ -84,12 +70,17 @@ export const TimeLogTable = ({ handleTicketSelection }, ...props) => {
};
return (
-
+
+ {isLoading === true ? null : (
+
+ )}
+
);
};
diff --git a/client/src/components/table/openTickets.js b/client/src/components/table/openTickets.js
deleted file mode 100644
index 5710389..0000000
--- a/client/src/components/table/openTickets.js
+++ /dev/null
@@ -1,114 +0,0 @@
-import React from "react";
-
-import { EuiBasicTable, EuiLink, EuiHealth, EuiButton } from "@elastic/eui";
-import { AdminTicketFlyout } from "../flyout/flyout";
-
-const userTest = [
- {
- id: "1",
- firstName: "john",
- lastName: "doe",
- github: "johndoe",
- dateOfBirth: Date.now(),
- nationality: "NL",
- online: true,
- },
-];
-/*
-Example user object:
-
-
-
-Example country object:
-
-{
- code: 'NL',
- name: 'Netherlands',
- flag: '🇳🇱'
-}
-*/
-
-export const TicketsTable = ({ handleTicketSelection }, ...props) => {
- const columns = [
- {
- field: "firstName",
- name: "First Name",
- sortable: true,
- "data-test-subj": "firstNameCell",
- mobileOptions: {
- render: (item) => (
-
- {item.firstName}{" "}
-
- {item.lastName}
-
-
- ),
- header: false,
- truncateText: false,
- enlarge: true,
- fullWidth: true,
- },
- },
- {
- field: "lastName",
- name: "Last Name",
- truncateText: true,
- render: (name) => (
-
- {name}
-
- ),
- mobileOptions: {
- show: false,
- },
- },
- {
- field: "github",
- name: "Github",
- },
- {
- field: "online",
- name: "Online",
- dataType: "boolean",
- render: (online) => {
- const color = online ? "success" : "danger";
- const label = online ? "Online" : "Offline";
- return {label};
- },
- },
- ];
-
- const items = userTest.filter((user, index) => index < 10);
-
- const getRowProps = (item) => {
- const { id } = item;
- return {
- "data-test-subj": `row-${id}`,
- className: "customRowClass",
- onClick: (e) => {
- handleTicketSelection(e, id);
- },
- };
- };
-
- const getCellProps = (item, column) => {
- const { id } = item;
- const { field } = column;
- return {
- className: "customCellClass",
- "data-test-subj": `cell-${id}-${field}`,
- textOnly: true,
- };
- };
-
- return (
-
- );
-};
diff --git a/client/src/routes/admin/ManageTicket.js b/client/src/routes/admin/ManageTicket.js
index d8b282c..40b09f0 100644
--- a/client/src/routes/admin/ManageTicket.js
+++ b/client/src/routes/admin/ManageTicket.js
@@ -1,4 +1,4 @@
-import React, { useState, useEffect } from "react";
+import React, { useState, useEffect, useReducer } from "react";
import {
EuiPage,
@@ -21,52 +21,195 @@ import {
EuiCode,
} from "@elastic/eui";
import { NavBar } from "../../components/navbar/navbar";
-import { TicketsTable } from "../../components/table/openTickets";
+import { TicketsTable } from "../../components/table/TicketsTable";
import { AdminTicketFlyout } from "../../components/flyout/flyout";
import { UserView } from "../../components/form/ManageTicketForm/userView";
import { handleFormSubmit } from "../../components/form/ManageTicketForm/handlers";
import { AdminView } from "../../components/form/ManageTicketForm/adminView";
import { Debug } from "../../components/debug/debug";
import axios from "../../api/api";
-import { fields } from "../../components/form/ManageTicketForm/fields";
+import {
+ fields,
+ workLogFields,
+} from "../../components/form/ManageTicketForm/fields";
+import { dataFetchReducer } from "../../api/reducers";
+import { MyStat } from "./Stats";
+import { personFields } from "../../components/form/person/fields";
+
var _ = require("lodash");
-const TicketForm = ({ data, setData }, ...props) => {
+const TicketForm = (
+ { technician, setSelectedTicket, selectedTicket },
+ ...props
+) => {
+ const [state, dispatch] = useReducer(dataFetchReducer, {
+ isLoading: false,
+ isError: false,
+ data: fields,
+ workLogData: null,
+ workLogLoading: true,
+ assignLog: null,
+ assignLogLoading: true,
+ });
+
+ const [workRefresh, setWorkRefresh] = useState(false);
+ const [assignmentRefresh, setAssignmentRefresh] = useState(false);
+ const [dataRefresh, setDataRefresh] = useState(false);
+
+ useEffect(() => {
+ const fetchWorkLog = async (selectedTicket) => {
+ try {
+ const result = await axios.get(
+ "/work/ticket/" + selectedTicket.ticket_id
+ );
+ const userResult = await axios.get("/user/admin");
+ let final = [];
+
+ for (let i = 0; i < result.data.length; i++) {
+ final.push({
+ ...result.data[i],
+ ...userResult.data.find(
+ (itmInner) => itmInner.lsu_id === result.data[i].lsu_id
+ ),
+ });
+ }
+ dispatch({ type: "FETCH_WORK_LOG_SUCCESS", payload: final });
+ } catch (error) {
+ console.log(error);
+ }
+ };
+ if (selectedTicket != null) {
+ fetchWorkLog(selectedTicket);
+ }
+ }, [workRefresh, selectedTicket]);
+
+ useEffect(() => {
+ const fetchAssignLog = async (selectedTicket) => {
+ try {
+ const result = await axios.get(
+ "/assign/ticket/" + selectedTicket.ticket_id
+ );
+
+ const userResult = await axios.get("/user/admin");
+ const final = userResult.data.filter((o) =>
+ result.data.find(({ lsu_id }) => o.lsu_id === lsu_id)
+ );
+
+ dispatch({ type: "FETCH_ASSIGN_LOG_SUCCESS", payload: final });
+ } catch (error) {
+ console.log(error);
+ }
+ };
+ if (selectedTicket != null) {
+ fetchAssignLog(selectedTicket);
+ }
+ }, [assignmentRefresh, selectedTicket]);
+
+ useEffect(() => {
+ const fetchData = async (selectedTicket) => {
+ String.prototype.toProperCase = function () {
+ return this.replace(/\w\S*/g, function (txt) {
+ return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
+ });
+ };
+
+ try {
+ dispatch({ type: "CLEAR_FORM" });
+ const result = await axios.get("/ticket/" + selectedTicket.ticket_id);
+ let final = [];
+ for (const [key, value] of Object.entries(result.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",
+ payload: union,
+ });
+ } catch (error) {
+ console.log(error);
+ }
+ };
+ if (selectedTicket != null) {
+ fetchData(selectedTicket);
+ }
+ }, [dataRefresh, selectedTicket]);
+
+ const internalFormSubmit = async (e, data) => {
+ const response = await handleFormSubmit(e, data, "/ticket");
+ if (response.status === 201) {
+ dispatch({ type: "CLEAR_FORM" });
+ }
+ };
return (
<>
Customer Information
-
-
+ {state.isLoading ? null : (
+ <>
+
+
+ >
+ )}
+
handleFormSubmit(e, data)}
+ onClick={(e) => internalFormSubmit(e, state.data)}
>
Submit
-
+
>
);
};
-export const ManageTicket = (props) => {
- const [isLoadingStat, setStatLoading] = useState(false);
- const [selectedTicket, setSelectedTicket] = useState(false);
+export const ManageTicket = ({ technician }, ...props) => {
+ const [selectedTicket, setSelectedTicket] = useState(null);
+ const [tickets, setTickets] = useState(null);
+ const [isTicketsLoading, setIsTicketsLoading] = useState(true);
- const [data, setData] = useState(fields);
+ useEffect(() => {
+ const fetchData = async () => {
+ try {
+ const result = await axios.get("ticket");
+ setTickets(result.data);
+ setIsTicketsLoading(false);
+ } catch (error) {
+ console.log(error);
+ }
+ };
+
+ fetchData();
+ }, []);
- // TODO: get request for open and closed tickets. /api/ticket
- // useEffect(async () => {
- // const result = await axios.get();
- // });
const handleTicketSelection = (e, id) => {
setSelectedTicket(id);
};
@@ -74,53 +217,70 @@ export const ManageTicket = (props) => {
return (
<>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ {isTicketsLoading === true ? null : (
+
+
+
+
+
+
+
+
+
+
+
+ )}
All Tickets
- Temp Table until DB is setup
-
+
- {selectedTicket === false
+ {selectedTicket === null
? "Create New Ticket"
- : "Edit ____'s Ticket"}
+ : "Edit " + selectedTicket.first_name + "'s Ticket"}
-
+ {selectedTicket == null ? (
+ "Please select ticket."
+ ) : (
+
+ )}
>
);
diff --git a/client/src/routes/admin/NewTechnicianFlyout.js b/client/src/routes/admin/NewTechnicianFlyout.js
index e8b5199..5232360 100644
--- a/client/src/routes/admin/NewTechnicianFlyout.js
+++ b/client/src/routes/admin/NewTechnicianFlyout.js
@@ -1,4 +1,4 @@
-import React, { useState } from "react";
+import React, { useEffect, useReducer, useState } from "react";
import {
EuiFlyout,
@@ -16,16 +16,28 @@ import { NewTechnicianForm } from "../../components/form/ManageTechnicianForm/Ne
import { personFields } from "../../components/form/person/fields";
import { handleFormSubmit } from "../../components/form/ManageTicketForm/handlers";
import { Debug } from "../../components/debug/debug";
+import { dataFetchReducer } from "../../api/reducers";
export const NewTechnicianFlyout = (
{ isFlyoutVisible, setIsFlyoutVisible },
...props
) => {
const closeFlyout = () => setIsFlyoutVisible(false);
- const [data, setData] = useState(personFields);
+
+ const [state, dispatch] = useReducer(dataFetchReducer, {
+ isLoading: false,
+ isError: false,
+ data: personFields,
+ });
const showFlyout = () => setIsFlyoutVisible(true);
+ const internalFormSubmit = (e, data) => {
+ if (handleFormSubmit(e, data, "/user") != null) {
+ setIsFlyoutVisible(false);
+ }
+ };
+
if (isFlyoutVisible) {
return (
-
-
- New Technician
-
-
-
-
-
-
-
- handleFormSubmit(e, data)}
- >
- Save
-
-
-
-
-
+ {state.isLoading ? null : (
+ <>
+
+
+ New Technician
+
+
+
+
+
+
+
+ {
+ internalFormSubmit(e, state.data);
+ }}
+ >
+ Save
+
+
+
+
+
+ >
+ )}
);
} else {
diff --git a/client/src/routes/admin/SelectTechnician.js b/client/src/routes/admin/SelectTechnician.js
index 42f0d54..cef0910 100644
--- a/client/src/routes/admin/SelectTechnician.js
+++ b/client/src/routes/admin/SelectTechnician.js
@@ -1,4 +1,4 @@
-import React, { useState } from "react";
+import React, { useEffect, useReducer, useState } from "react";
import {
EuiButton,
@@ -15,6 +15,7 @@ import {
} from "@elastic/eui";
import { MySelectField } from "../../components/form/MySelectField";
import {
+ handleDateChange,
handleFormFieldBlur,
handleFormFieldChange,
} from "../../components/form/ManageTicketForm/handlers";
@@ -22,69 +23,115 @@ import { NewTechnicianFlyout } from "./NewTechnicianFlyout";
import { Debug } from "../../components/debug/debug";
import {
fields,
- selectOptions,
+ selectTechnicianOptions_default,
} from "../../components/form/ManageTechnicianForm/fields";
+import axios from "../../api/api.js";
+import { dataFetchReducer } from "../../api/reducers";
+import { addToast } from "../../components/toast";
var _ = require("lodash");
-export const SelectTechnician = ({ setTechnician }, ...props) => {
- const [data, setData] = useState(fields);
+export const SelectTechnician = ({ technician, setTechnician }, ...props) => {
const [isFlyoutVisible, setIsFlyoutVisible] = useState(false);
+ const [state, dispatch] = useReducer(dataFetchReducer, {
+ isLoading: false,
+ isError: false,
+ data: fields,
+ selectTechnicianOptions: selectTechnicianOptions_default,
+ });
+
+ useEffect(() => {
+ const fetchData = async () => {
+ try {
+ const result = await axios.get("/user/admin");
+ const final = {
+ name: "technician",
+ options: result.data.map((o) => ({
+ ...o,
+ value: o.lsu_id,
+ text: o.first_name + " " + o.last_name,
+ })),
+ };
+ dispatch({ type: "FETCH_TECHNICIANS_SUCCESS", payload: final });
+ } catch (error) {
+ dispatch({ type: "FETCH_FAILURE" });
+ }
+ };
+
+ fetchData();
+ }, []);
+
const handleFormSubmit = (e, data) => {
+ e.preventDefault();
const errors = _.find(data, ["error", true]);
if (errors === undefined) {
- console.log(data);
- setTechnician(data);
+ if (data[0].value === "") {
+ addToast({
+ title: "Select technician to continue",
+ color: "danger",
+ });
+ } else {
+ console.log(data);
+ setTechnician(data);
+ }
}
};
return (
-
-
-
-
-
- Choose Technician
-
-
-
-
-
- handleFormFieldChange(e, data, setData)}
- handleBlur={(e) => handleFormFieldBlur(e, data, setData)}
- />
-
-
-
- setIsFlyoutVisible(true)}
- >
- New
-
-
-
- handleFormSubmit(e, data)}
- >
- Select
-
-
-
-
-
-
-
-
-
+ <>
+ {state.isLoading ? null : (
+
+
+
+
+
+ Choose Technician
+
+
+
+
+
+ {
+ handleFormFieldChange(e, state.data, dispatch);
+ }}
+ handleBlur={(e) =>
+ handleFormFieldBlur(e, state.data, dispatch)
+ }
+ />
+
+
+
+ setIsFlyoutVisible(true)}
+ >
+ New
+
+
+
+ handleFormSubmit(e, state.data)}
+ >
+ Select
+
+
+
+
+
+
+
+
+
+ )}
+ >
);
};
diff --git a/client/src/routes/admin/Stats.js b/client/src/routes/admin/Stats.js
new file mode 100644
index 0000000..53f4599
--- /dev/null
+++ b/client/src/routes/admin/Stats.js
@@ -0,0 +1,37 @@
+import { EuiIcon, EuiPanel, EuiStat } from "@elastic/eui";
+import React, { useEffect, useState, useReducer } from "react";
+import { dataFetchReducer } from "../../api/reducers";
+import axios from "../../api/api";
+import { ErrorCallout } from "../../components/callout/Callout";
+
+export const MyStat = (
+ { data, color, icon, description, filter, isLoading },
+ ...props
+) => {
+ const [items, setItems] = useState(null);
+
+ useEffect(() => {
+ if (data != null) {
+ const i = data.filter((o) => o.status === filter).length;
+ setItems(i);
+ }
+ }, [data]);
+
+ return (
+ <>
+
+ {isLoading ? null : (
+
+
+
+ )}
+
+ >
+ );
+};
diff --git a/client/src/routes/admin/admin.js b/client/src/routes/admin/admin.js
index 8976cea..fc86871 100644
--- a/client/src/routes/admin/admin.js
+++ b/client/src/routes/admin/admin.js
@@ -21,12 +21,6 @@ import {
EuiCode,
} from "@elastic/eui";
import { NavBar } from "../../components/navbar/navbar";
-import { TicketsTable } from "../../components/table/openTickets";
-import { AdminTicketFlyout } from "../../components/flyout/flyout";
-import { UserView } from "../../components/form/ManageTicketForm/userView";
-import { fields } from "../../components/form/ManageTicketForm/fields";
-import { handleFormSubmit } from "../../components/form/ManageTicketForm/handlers";
-import { AdminView } from "../../components/form/ManageTicketForm/adminView";
import { SelectTechnician } from "./SelectTechnician";
import { ManageTicket } from "./ManageTicket";
@@ -43,9 +37,12 @@ export const AdminRoute = (props) => {
{technician === false ? (
-
+
) : (
-
+
)}
diff --git a/client/src/routes/user/user.js b/client/src/routes/user/user.js
index e030eff..4b42475 100644
--- a/client/src/routes/user/user.js
+++ b/client/src/routes/user/user.js
@@ -1,4 +1,4 @@
-import React, { useState } from "react";
+import React, { useEffect, useReducer, useState } from "react";
import {
EuiPage,
@@ -31,12 +31,25 @@ import { UserView } from "../../components/form/ManageTicketForm/userView";
import { fields } from "../../components/form/ManageTicketForm/fields";
import { handleFormSubmit } from "../../components/form/ManageTicketForm/handlers";
import { Debug } from "../../components/debug/debug";
+import { dataFetchReducer } from "../../api/reducers";
+import { selectTechnicianOptions_default } from "../../components/form/ManageTechnicianForm/fields";
var _ = require("lodash");
export const UserRoute = (props) => {
- const [data, setData] = useState(fields);
+ const [state, dispatch] = useReducer(dataFetchReducer, {
+ isLoading: false,
+ isError: false,
+ data: fields,
+ });
+ const internalFormSubmit = async (e, data) => {
+ data.find((o) => o.name === "component").value = "N/A";
+ const response = await handleFormSubmit(e, data, "/ticket");
+ if (response.status === 201) {
+ // dispatch({ type: "CLEAR_FORM" });
+ }
+ };
return (
<>
@@ -50,32 +63,25 @@ export const UserRoute = (props) => {
- {/**/}
- {/* */}
- {/* */}
- {/* Submit Ticket
*/}
- {/* */}
- {/* */}
- {/**/}
My Information
-
+
handleFormSubmit(e, data)}
+ onClick={(e) => internalFormSubmit(e, state.data)}
>
Submit
-
+