From c5c680c4b5cb2713ecfa1d2b005814c6dfce82b2 Mon Sep 17 00:00:00 2001 From: michacurri Date: Sat, 2 Jan 2021 11:58:47 -0500 Subject: [PATCH] ternary to show either 'view workorders' or 'create new workorder' --- src/components/root/Workorder.js | 24 +++++++++++++++++++++--- src/components/root/WorkorderDisplay.js | 2 +- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/components/root/Workorder.js b/src/components/root/Workorder.js index e868db4..2fa9462 100644 --- a/src/components/root/Workorder.js +++ b/src/components/root/Workorder.js @@ -1,4 +1,4 @@ -import React, { useContext, Fragment } from "react"; +import React, { useContext, Fragment, useState } from "react"; import { UserContext } from "../../backend/authorization/UserContext"; import { ImpersonatorContext } from "../../backend/authorization/ImpersonatorContext"; import WorkorderDisplay from "./WorkorderDisplay"; @@ -7,13 +7,31 @@ import WorkorderCreate from "../admin/WorkorderCreate"; const Workorder = () => { const [currentProfile] = useContext(UserContext); const [admin] = useContext(ImpersonatorContext); + const [workView, setWorkView] = useState("display"); + + function workorderClick() { + if (workView === "display") { + setWorkView("create"); + } else { + setWorkView("display"); + } + } let content; if (!admin) { content = ( - - + {workView === "display" ? ( + + + + + ) : ( + + + + + )} ); } else { diff --git a/src/components/root/WorkorderDisplay.js b/src/components/root/WorkorderDisplay.js index b89a22d..35c18e1 100644 --- a/src/components/root/WorkorderDisplay.js +++ b/src/components/root/WorkorderDisplay.js @@ -12,7 +12,7 @@ import Paper from "@material-ui/core/Paper"; const useStyles = makeStyles({ table: { - minWidth: 650, + minWidth: 350, }, });