From d6d46f2850d3497f25fd37dea3fcaa607eb890c1 Mon Sep 17 00:00:00 2001 From: Ruidy Nemausat Date: Sun, 23 Feb 2020 22:06:18 +0100 Subject: [PATCH] added manage user layout to project page --- .gitignore | 1 + README.md | 25 +++++----- client/src/components/FilterBar.tsx | 2 +- client/src/components/Modal.tsx | 31 +++++++----- client/src/components/UsersModal.tsx | 73 ++++++++++++++++++++++++++++ client/src/pages/ProjectPage.tsx | 21 ++++++-- client/src/utils/router.tsx | 5 ++ 7 files changed, 129 insertions(+), 29 deletions(-) create mode 100644 client/src/components/UsersModal.tsx diff --git a/.gitignore b/.gitignore index 38ee8ff..01d8a9f 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,5 @@ app.db* .DS_Store app.db client/node_modules +client/src/pages/TestPage.tsx Scripts/ diff --git a/README.md b/README.md index 817f04a..01870bc 100644 --- a/README.md +++ b/README.md @@ -33,15 +33,16 @@ ## TO DO -- Write API tests using Postman: request + test, environment variables, mock server -- Annotate API request in controllers -- Annotate Properties in Models -- Write backend tests -- Have a Look at typeahead component -- Ensure Tickets Edits belong to Project Edits -- Ensure Tickets Files belong to Project Files -- Async model methods ? -- update assignments automatically from context -- use PATCH instead of PUT -- logging -- check useRef, useReducer, dispatch +- [ ] Write API tests using Postman: request + test, environment variables, mock server +- [ ] Annotate API request in controllers +- [ ] Annotate Properties in Models +- [ ] Write backend tests +- [ ] Have a Look at typeahead component +- [ ] Ensure Tickets Edits belong to Project Edits +- [ ] Ensure Tickets Files belong to Project Files +- [ ] Async model methods ? +- [ ] update assignments automatically from context +- [ ] use PATCH instead of PUT +- [ ] logging +- [ ] check useRef, useReducer, dispatch +- [ ] error page redirect when offline. diff --git a/client/src/components/FilterBar.tsx b/client/src/components/FilterBar.tsx index a99b24e..fc9cb9c 100644 --- a/client/src/components/FilterBar.tsx +++ b/client/src/components/FilterBar.tsx @@ -13,7 +13,7 @@ export const FilterBar: FC = ({ clearFilterText }) => { const { url } = useRouteMatch(); - const placeholder: string = url.split("/")[3]; + const placeholder: string = url.split("/")[3] || "users"; return ( <>
diff --git a/client/src/components/Modal.tsx b/client/src/components/Modal.tsx index 714f860..d826e40 100644 --- a/client/src/components/Modal.tsx +++ b/client/src/components/Modal.tsx @@ -1,17 +1,24 @@ -import React, { FC } from "react"; +import React, { FC, useState, CSSProperties } from "react"; -export const Modal: FC = () => { +interface IProps { + handleClose: () => void; + show: boolean; +} +export const Modal: FC = ({ handleClose, show, children }) => { + const showHideStyle: CSSProperties = show + ? { display: "block", zIndex: 10 } + : { display: "none", zIndex: 10 }; return ( -
-
-

Modal Header

-

A bunch of text

-
- +
+
{children}
+ {/*
+ +
*/}
); }; diff --git a/client/src/components/UsersModal.tsx b/client/src/components/UsersModal.tsx new file mode 100644 index 0000000..24ab07a --- /dev/null +++ b/client/src/components/UsersModal.tsx @@ -0,0 +1,73 @@ +import React, { FC, useState, ChangeEvent } from "react"; +import { Modal } from "./Modal"; +import { AvatarList } from "./AvatarList"; +import { User } from "../types/User"; +import { FilterBar } from "./FilterBar"; + +interface IProps { + show: boolean; + handleClose: () => void; + users: User[]; +} + +export const UsersModal: FC = ({ show, handleClose, users }) => { + const [filterText, setFilterText] = useState(""); + const handleChange: (e: ChangeEvent) => void = ( + e: ChangeEvent + ) => { + setFilterText(e.target.value); + }; + return ( + +
+
+

Manage users

+
+
+ + close + +
+
+
+ + setFilterText("")} + handleChange={handleChange} + /> +
+
+
    + {users.map((u: User) => ( +
  • +
    + false} + // checked + /> + + {u.fullName} + {u.fullName} + +
    +
  • + ))} +
+
+
+ ); +}; diff --git a/client/src/pages/ProjectPage.tsx b/client/src/pages/ProjectPage.tsx index f0f03fd..43528c7 100644 --- a/client/src/pages/ProjectPage.tsx +++ b/client/src/pages/ProjectPage.tsx @@ -1,15 +1,16 @@ -import React, { FC } from "react"; +import React, { FC, useState } from "react"; +import ProjectVM from "../VM/ProjectVM"; import { Header } from "../components/Header"; import { AvatarList } from "../components/AvatarList"; import { ProgressBar } from "../components/ProgressBar"; -import ProjectVM from "../VM/ProjectVM"; import { TabRouter } from "../components/TabRouter"; import { FloatingButton } from "../components/FloatingButton"; -import { Modal } from "../components/Modal"; +import { UsersModal } from "../components/UsersModal"; interface IProps { viewModel: ProjectVM; } + export const ProjectPage: FC = ({ viewModel }) => { const { title, @@ -23,7 +24,9 @@ export const ProjectPage: FC = ({ viewModel }) => { files, activities } = viewModel; + const tabNames: string[] = ["Tickets", "Files", "Activity"]; + const [showModal, setShowModal] = useState(false); return (
@@ -31,7 +34,17 @@ export const ProjectPage: FC = ({ viewModel }) => {
- + setShowModal(true)} + /> + setShowModal(false)} + />
{
+ + + + {/*