diff --git a/client/src/components/ActivityList.tsx b/client/src/components/ActivityList.tsx index 010f727..969b7ff 100644 --- a/client/src/components/ActivityList.tsx +++ b/client/src/components/ActivityList.tsx @@ -1,18 +1,26 @@ -import React, { FC } from "react"; -import { FloatingButton } from "./FloatingButton"; +import React, { FC, useState, ChangeEvent } from "react"; import { ActivityCollection } from "./ActivityCollection"; import { Activity } from "../types/Activity"; +import { FilterBar } from "./FilterBar"; type IProps = { activities: Activity[]; }; export const ActivityList: FC = ({ activities }) => { + const [filterText, setFilterText] = useState(""); + + const handleChange: (e: ChangeEvent) => void = ( + e: ChangeEvent + ) => { + setFilterText(e.target.value); + }; + return ( <>

Activity

- +
diff --git a/client/src/components/AppFileList.tsx b/client/src/components/AppFileList.tsx index 449ec93..9f85093 100644 --- a/client/src/components/AppFileList.tsx +++ b/client/src/components/AppFileList.tsx @@ -1,21 +1,28 @@ -import React, { FC } from "react"; +import React, { FC, useState, ChangeEvent } from "react"; import { AppFile } from "../types/AppFile"; -import { FloatingButton } from "./FloatingButton"; import { FileCollection } from "./FileCollection"; -import { DropZone } from "./DropZone"; +import { InputFile } from "./InputFile"; +import { FilterBar } from "./FilterBar"; type IProps = { files: AppFile[]; }; export const FileList: FC = ({ files }) => { + const [filterText, setFilterText] = useState(""); + + const handleChange: (e: ChangeEvent) => void = ( + e: ChangeEvent + ) => { + setFilterText(e.target.value); + }; return ( <>

Files

- +
- + ); diff --git a/client/src/components/DropZone.tsx b/client/src/components/DropZone.tsx deleted file mode 100644 index 4ff5146..0000000 --- a/client/src/components/DropZone.tsx +++ /dev/null @@ -1,7 +0,0 @@ -import React, { FC } from "react"; - -type IProps = {}; - -export const DropZone: FC = () => { - return
Drag & Drop your files here.
; -}; diff --git a/client/src/components/FilterBar.tsx b/client/src/components/FilterBar.tsx new file mode 100644 index 0000000..62754c7 --- /dev/null +++ b/client/src/components/FilterBar.tsx @@ -0,0 +1,39 @@ +import React, { FC } from "react"; +import { useRouteMatch } from "react-router-dom"; + +type IProps = { + filterText: string; + handleChange: (e: React.ChangeEvent) => void; +}; + +export const FilterBar: FC = ({ filterText, handleChange }) => { + const { url } = useRouteMatch(); + const placeholder: string = url.split("/")[3]; + return ( + <> +
+
+ + + + close + +
+
+
+ + ); +}; diff --git a/client/src/components/HorizontalCard.tsx b/client/src/components/HorizontalCard.tsx index 54d611e..f9b7f2c 100644 --- a/client/src/components/HorizontalCard.tsx +++ b/client/src/components/HorizontalCard.tsx @@ -1,9 +1,10 @@ import React, { FC, MouseEvent } from "react"; import { Link } from "react-router-dom"; +import { getRemainingdays } from "../utils/methods"; interface IProps { title: string; - remainingDays?: number; + remainingDays: string; validateTicket: (event: MouseEvent) => void; archiveTicket: (event: MouseEvent) => void; } @@ -26,7 +27,7 @@ export const HorizontalCard: FC = ({ - Due {remainingDays} days + Due {getRemainingdays(remainingDays)} days
diff --git a/client/src/components/InputFile.tsx b/client/src/components/InputFile.tsx new file mode 100644 index 0000000..aa528e9 --- /dev/null +++ b/client/src/components/InputFile.tsx @@ -0,0 +1,29 @@ +import React, { FC } from "react"; + +type IProps = {}; + +export const InputFile: FC = () => { + return ( + <> +
+
+
+ cloud_upload + +
+
+ +
+
+
+ + ); +}; diff --git a/client/src/components/TabRouter.tsx b/client/src/components/TabRouter.tsx index 9d7e55f..3b3915e 100644 --- a/client/src/components/TabRouter.tsx +++ b/client/src/components/TabRouter.tsx @@ -18,7 +18,6 @@ interface IProps { export const TabRouter: FC = ({ tickets, - remainingDays, tabNames, files, activities @@ -32,7 +31,7 @@ export const TabRouter: FC = ({ - + diff --git a/client/src/components/TicketList.tsx b/client/src/components/TicketList.tsx index df56bb0..c810fcd 100644 --- a/client/src/components/TicketList.tsx +++ b/client/src/components/TicketList.tsx @@ -1,35 +1,65 @@ -import React, { FC } from "react"; +import React, { FC, useState, ChangeEvent } from "react"; import { Ticket } from "../types/Ticket"; import { FloatingButton } from "./FloatingButton"; import { HorizontalCard } from "./HorizontalCard"; +import { FilterBar } from "./FilterBar"; type TicketListProps = { tickets: Ticket[]; - remainingDays?: number; }; -export const TicketList: FC = ({ tickets, remainingDays }) => { +export const TicketList: FC = ({ tickets }) => { const archiveTicket = () => {}; const validateTicket = () => {}; + const [filterText, setFilterText] = useState(""); + const handleChange: (e: ChangeEvent) => void = ( + e: ChangeEvent + ) => { + setFilterText(e.target.value); + }; + + // const useFilter = (init: string) => { + // const [filterText, setFilterText] = useState(init); + // // const handleChange: (e: ChangeEvent) => void = ( + // // e: ChangeEvent + // // ) => { + // // setFilterText(e.target.value); + // // }; + // return { + // filterText, + // setFilterText, + // bind: { + // filterText, + // handleChange: (e: ChangeEvent) => { + // setFilterText(e.target.value); + // } + // } + // }; + // }; + // const [filterText, handleChange] = useFilter(""); + // const [filterText, handleChange] = useFilter(""); return ( <>

Tickets

- + +
    - {tickets.map((t: Ticket) => ( -
  • - -
  • - ))} + {tickets + .filter(t => t.title.includes(filterText)) + .map((t: Ticket) => ( +
  • + +
  • + ))}
diff --git a/client/src/controllers/ProjectController.tsx b/client/src/controllers/ProjectController.tsx index 86a6d64..9999fde 100644 --- a/client/src/controllers/ProjectController.tsx +++ b/client/src/controllers/ProjectController.tsx @@ -37,12 +37,16 @@ export const ProjectController: FC = () => { const tickets: Ticket[] = [ { id: 1, - title: "Ticket #1", + title: "Client objective meeting", + description: "Client objective meeting", + plannedEnding: "2020-02-17 15:51:02.787373", status: "Done" }, { id: 2, - title: "Ticket #2", + title: "Assemble Outcomes Report for client", + description: "Assemble Outcomes Report for client", + plannedEnding: "2020-02-27 15:51:02.787373", status: "To Do" } ]; diff --git a/client/src/index.css b/client/src/index.css deleted file mode 100644 index ec2585e..0000000 --- a/client/src/index.css +++ /dev/null @@ -1,13 +0,0 @@ -body { - margin: 0; - font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', - 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', - sans-serif; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; -} - -code { - font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', - monospace; -} diff --git a/client/src/index.tsx b/client/src/index.tsx index 90fb3f6..8780a3a 100644 --- a/client/src/index.tsx +++ b/client/src/index.tsx @@ -1,6 +1,5 @@ import React from "react"; import ReactDOM from "react-dom"; -import "./index.css"; import App from "./App"; import * as serviceWorker from "./serviceWorker"; diff --git a/client/src/pages/ProjectPage.tsx b/client/src/pages/ProjectPage.tsx index 9e5b833..8c49f6b 100644 --- a/client/src/pages/ProjectPage.tsx +++ b/client/src/pages/ProjectPage.tsx @@ -41,7 +41,6 @@ export const ProjectPage: FC = ({ viewModel }) => { tabNames={tabNames} tickets={tickets} files={files} - remainingDays={remainingDays} activities={activities} />
diff --git a/client/src/types/Ticket.ts b/client/src/types/Ticket.ts index a258326..7d675b1 100644 --- a/client/src/types/Ticket.ts +++ b/client/src/types/Ticket.ts @@ -1,5 +1,7 @@ export interface Ticket { id: number; title: string; + description: string; status: string; + plannedEnding: string; } diff --git a/client/src/utils/methods.ts b/client/src/utils/methods.ts new file mode 100644 index 0000000..8051548 --- /dev/null +++ b/client/src/utils/methods.ts @@ -0,0 +1,7 @@ +export const getRemainingdays: (endDate: string) => number = ( + endDate: string +) => { + let endingDate: Date = new Date(endDate); + let today: Date = new Date(); + return Math.abs(endingDate.getDate() - today.getDate()); +}; diff --git a/client/src/viewModels/ProjectVM.ts b/client/src/viewModels/ProjectVM.ts index d660db6..505e1c9 100644 --- a/client/src/viewModels/ProjectVM.ts +++ b/client/src/viewModels/ProjectVM.ts @@ -5,6 +5,7 @@ import { Project } from "../types/Project"; import { AppFile } from "../types/AppFile"; import { Activity } from "../types/Activity"; import { User } from "../types/User"; +import { getRemainingdays } from "../utils/methods"; export default class ProjectVM { public id: number; @@ -12,7 +13,6 @@ export default class ProjectVM { public description: string; public value: number; public tickets: Ticket[]; - // public avatars: string[]; public users: User[]; public ticketsTotalCount: number; public ticketsDone: number; @@ -35,7 +35,6 @@ export default class ProjectVM { this.id = project.id; this.title = project.title; this.description = project.description; - // this.avatars = project.users.map(u => u.picture); this.users = project.users; this.value = project.progression; this.tickets = project.tickets; @@ -43,12 +42,6 @@ export default class ProjectVM { this.ticketsDone = this.tickets.filter(t => t.status === "Done").length; this.files = project.files; this.activities = project.activities; - - let endingDate: Date = new Date(project.plannedEnding); - let today: Date = new Date(); - let plannedEnding: number = Math.abs( - endingDate.getDate() - today.getDate() - ); - this.remainingDays = plannedEnding; + this.remainingDays = getRemainingdays(project.plannedEnding); } }