diff --git a/client/src/VM/ProjectVM.ts b/client/src/VM/ProjectVM.ts index 2a974ce..87faecc 100644 --- a/client/src/VM/ProjectVM.ts +++ b/client/src/VM/ProjectVM.ts @@ -6,7 +6,7 @@ import { User } from "../types/User"; import { getRemainingdays } from "../utils/methods"; export default class ProjectVM { - public id: number; + // public id: number; public title: string; public description: string; public creationDate: string; @@ -24,7 +24,7 @@ export default class ProjectVM { public remainingDays: number; public constructor(project: Project, allUsers: User[]) { - this.id = project.id; + // this.id = project.id; this.title = project.title; this.description = project.description; this.creationDate = project.creationDate; diff --git a/client/src/VM/UserVM.ts b/client/src/VM/UserVM.ts index 821ee4f..175da9a 100644 --- a/client/src/VM/UserVM.ts +++ b/client/src/VM/UserVM.ts @@ -1,5 +1,19 @@ -export class UserVM { - public Id?: number; +import { Project } from "../types/Project"; +import { Ticket } from "../types/Ticket"; +import { User } from "../types/User"; - public constructor() {} +export class UserVM { + public fullName: string; + public presentation: string; + public picture: string; + public projects: Project[]; + public tickets: Ticket[]; + + public constructor(user: User) { + this.fullName = user.fullName; + this.presentation = user.presentation; + this.picture = user.picture; + this.projects = user.projects; + this.tickets = user.tickets; + } } diff --git a/client/src/components/ActivityCollection.tsx b/client/src/components/ActivityCollection.tsx index f85ad8d..c347cc2 100644 --- a/client/src/components/ActivityCollection.tsx +++ b/client/src/components/ActivityCollection.tsx @@ -1,6 +1,5 @@ import React, { FC } from "react"; import { Activity } from "../types/Activity"; -import { act } from "react-dom/test-utils"; type IProps = { activities: Activity[]; diff --git a/client/src/components/Avatar.tsx b/client/src/components/Avatar.tsx new file mode 100644 index 0000000..37c45c4 --- /dev/null +++ b/client/src/components/Avatar.tsx @@ -0,0 +1,12 @@ +import React, { FC } from "react"; + +interface IProps { + picture: string; +} +export const Avatar: FC = ({ picture }) => { + return ( + <> + + + ); +}; diff --git a/client/src/components/ProjectList.tsx b/client/src/components/ProjectList.tsx new file mode 100644 index 0000000..03d45eb --- /dev/null +++ b/client/src/components/ProjectList.tsx @@ -0,0 +1,85 @@ +import React, { FC, useState, ChangeEvent, MouseEvent } from "react"; +import { Ticket } from "../types/Ticket"; +import { FloatingButton } from "./FloatingButton"; +import { HorizontalCard } from "./HorizontalCard"; +import { FilterBar } from "./FilterBar"; +import { put } from "../utils/http"; +import { HttpResponse } from "../types/HttpResponse"; +import { Constants } from "../utils/Constants"; +import { NewTicketModal } from "./NewTicketModal"; +import { Project } from "../types/Project"; + +type IProps = { + projects: Project[]; +}; + +export const ProjectList: FC = ({ projects }) => { + const [filterText, setFilterText] = useState(""); + const clearFilterText: (e: MouseEvent) => void = (e: MouseEvent) => { + setFilterText(""); + }; + // const archiveTicket = () => {}; + + const onClick: (e: MouseEvent) => void = (e: MouseEvent) => { + e.preventDefault(); + setShowNew(true); + }; + const handleChange: (e: ChangeEvent) => void = ( + e: ChangeEvent + ) => { + setFilterText(e.target.value); + }; + + const [showNew, setShowNew] = useState(false); + let filteredTickets = projects.filter( + t => + t.status !== "Done" && + t.title.toLowerCase().includes(filterText.toLowerCase()) + ); + return ( + <> +
+ { + setShowNew(false); + }} + show={showNew} + /> +

Projects

+ + +
+
+
    + {filteredTickets.length === 0 ? ( + + ) : ( + filteredTickets.map((t: Ticket) => ( + { + e.preventDefault(); + await put>( + `${Constants.ticketsURI}/${t.id}/closed`, + {} + ); + }} + // archiveTicket={archiveTicket} + /> + )) + )} +
+
+ + ); +}; diff --git a/client/src/components/TicketList.tsx b/client/src/components/TicketList.tsx index 4b551e7..cbedf39 100644 --- a/client/src/components/TicketList.tsx +++ b/client/src/components/TicketList.tsx @@ -65,7 +65,7 @@ export const TicketList: FC = ({ tickets }) => { { e.preventDefault(); await put>( diff --git a/client/src/components/UserHeader.tsx b/client/src/components/UserHeader.tsx new file mode 100644 index 0000000..3242e63 --- /dev/null +++ b/client/src/components/UserHeader.tsx @@ -0,0 +1,21 @@ +import React, { FC } from "react"; +import { Header } from "../components/Header"; +import { Avatar } from "../components/Avatar"; + +interface IProps { + fullName: string; + presentation: string; + picture: string; +} +export const UserHeader: FC = ({ fullName, presentation, picture }) => { + return ( +
+
+ +
+
+
+
+
+ ); +}; diff --git a/client/src/components/UserTabRouter.tsx b/client/src/components/UserTabRouter.tsx new file mode 100644 index 0000000..5646630 --- /dev/null +++ b/client/src/components/UserTabRouter.tsx @@ -0,0 +1,38 @@ +import React, { FC } from "react"; +import { TabRouterHeader } from "./TabRouterHeader"; +import { TicketList } from "./TicketList"; + +import { Ticket } from "../types/Ticket"; + +import { Route, useRouteMatch, Redirect } from "react-router-dom"; + +import { Project } from "../types/Project"; +import { ProjectList } from "./ProjectList"; + +interface IProps { + tabNames: string[]; + tickets: Ticket[]; + projects: Project[]; +} + +export const UserTabRouter: FC = ({ tickets, tabNames, projects }) => { + const { url } = useRouteMatch(); + + return ( + <> +
+ + + + + + + + + + + +
+ + ); +}; diff --git a/client/src/components/UsersModal.tsx b/client/src/components/UsersModal.tsx index ee13f25..d5d4878 100644 --- a/client/src/components/UsersModal.tsx +++ b/client/src/components/UsersModal.tsx @@ -3,12 +3,10 @@ import { Modal } from "./Modal"; import { AvatarList } from "./AvatarList"; import { User } from "../types/User"; import { FilterBar } from "./FilterBar"; -import { HttpResponse } from "../types/HttpResponse"; -import { get, put, patch } from "../utils/http"; +import { patch } from "../utils/http"; import { Constants } from "../utils/Constants"; import { UsersModalEntry } from "./UsersModalEntry"; import { useParams } from "react-router-dom"; -import _ from "underscore"; interface IProps { show: boolean; diff --git a/client/src/components/UsersModalEntry.tsx b/client/src/components/UsersModalEntry.tsx index 301439a..e35501f 100644 --- a/client/src/components/UsersModalEntry.tsx +++ b/client/src/components/UsersModalEntry.tsx @@ -1,6 +1,5 @@ import React, { FC } from "react"; import { User } from "../types/User"; -import _ from "underscore"; interface IProps { setMembers: React.Dispatch>; diff --git a/client/src/controllers/UserController.tsx b/client/src/controllers/UserController.tsx index a023b5e..c25ed62 100644 --- a/client/src/controllers/UserController.tsx +++ b/client/src/controllers/UserController.tsx @@ -1,6 +1,62 @@ -import React, { FC } from "react"; +import React, { FC, useState, useEffect } from "react"; import { UserPage } from "../pages/UserPage"; +import { UserVM } from "../VM/UserVM"; +import { User } from "../types/User"; +import { AppFile } from "../types/AppFile"; +import { Activity } from "../types/Activity"; +import { Ticket } from "../types/Ticket"; +import { Preloader } from "../components/Preloader"; export const UserController: FC = () => { - return ; + const [isLoading, setIsLoading] = useState(true); + + const user: User = { + id: "resldsm,dgd", + firstName: "David", + lastName: "Whittaker", + fullName: "David Whittaker", + presentation: "Interface designer and front-end developer", + creationDate: new Date().toDateString(), + email: "dw@mail.au", + phone: "0998765432", + picture: require("../images/user_1.jpg"), + projects: [ + { + id: 1, + title: "Project Title", + description: "What is it about", + progression: 25, + creationDate: new Date().toDateString(), + endingDate: "2020-02-17 15:51:02.787373", + status: "Todo", + manager: {} as User, + users: [] as User[], + tickets: [] as Ticket[], + files: [] as AppFile[], + activities: [] as Activity[] + } + ], + tickets: [ + { + id: 1, + title: "Client objective meeting", + description: "Client objective meeting", + endingDate: "2020-02-17 15:51:02.787373", + status: "Done" + }, + { + id: 2, + title: "Assemble Outcomes Report for client", + description: "Assemble Outcomes Report for client", + endingDate: "2020-02-27 15:51:02.787373", + status: "To Do" + } + ], + activities: [] + }; + useEffect(() => { + setTimeout(() => setIsLoading(false), 1000); + }); + const viewModel = new UserVM(user); + return isLoading ? : ; }; diff --git a/client/src/pages/UserPage.tsx b/client/src/pages/UserPage.tsx index a2a1ad0..6641aad 100644 --- a/client/src/pages/UserPage.tsx +++ b/client/src/pages/UserPage.tsx @@ -1,12 +1,32 @@ import React, { FC } from "react"; -import { Header } from "../components/Header"; +import { UserVM } from "../VM/UserVM"; +import { UserHeader } from "../components/UserHeader"; +import { UserTabRouter } from "../components/UserTabRouter"; -export const UserPage: FC = () => { +interface IProps { + viewModel: UserVM; +} +export const UserPage: FC = ({ viewModel }) => { + const { fullName, presentation, picture, projects, tickets } = viewModel; + const tabNames: string[] = ["Projects", "Tickets"]; return ( -
- // +
+
+ + +
+ {/* // // // - // + // */} +
); }; diff --git a/client/src/types/Ticket.ts b/client/src/types/Ticket.ts index 7d675b1..8ec3a71 100644 --- a/client/src/types/Ticket.ts +++ b/client/src/types/Ticket.ts @@ -3,5 +3,5 @@ export interface Ticket { title: string; description: string; status: string; - plannedEnding: string; + endingDate: string; } diff --git a/client/src/types/User.ts b/client/src/types/User.ts index 94b6732..7cdfb58 100644 --- a/client/src/types/User.ts +++ b/client/src/types/User.ts @@ -10,7 +10,7 @@ export interface User { presentation: string; email: string; phone: string; - createdAt: string; + creationDate: string; picture: string; activities: Activity[]; projects: Project[]; diff --git a/client/src/utils/router.tsx b/client/src/utils/router.tsx index c99ab2b..6b88795 100644 --- a/client/src/utils/router.tsx +++ b/client/src/utils/router.tsx @@ -12,7 +12,7 @@ import * as creacteHistory from "history"; import { ProjectController } from "../controllers/ProjectController"; import { NotFoundPage } from "../pages/NotFoundPage"; import { TestPage } from "../pages/TestPage"; -// import { UserController } from "../controllers/UserController"; +import { UserController } from "../controllers/UserController"; // import { TicketController } from "../controllers/TicketController"; export const history = creacteHistory.createBrowserHistory(); @@ -28,24 +28,20 @@ export const AppRouter = () => { {/* - + */} - */} + {/* - */} + */} - - {/* - - */}