= ({
-
diff --git a/client/src/components/NewTicketModal.tsx b/client/src/components/NewTicketModal.tsx
index bce42ac..60d6a86 100644
--- a/client/src/components/NewTicketModal.tsx
+++ b/client/src/components/NewTicketModal.tsx
@@ -5,16 +5,23 @@ import { post } from "../utils/http";
import { Constants } from "../utils/Constants";
import { HttpResponse } from "../types/HttpResponse";
import { NewTicketForm } from "./NewTicketForm";
+import { Project } from "../types/Project";
interface IProps {
show: boolean;
handleClose(): void;
+ allProjects: Project[];
}
-export const NewTicketModal: FC = ({ show, handleClose }) => {
+export const NewTicketModal: FC = ({
+ show,
+ handleClose,
+ allProjects
+}) => {
const [title, setTitle] = useState("");
const [description, setDescription] = useState("");
const [endingDate, setEndingDate] = useState("");
+ const [projectId, setProjectId] = useState("0");
const handleSubmit: (event: FormEvent) => void = async (
e: FormEvent
@@ -25,7 +32,7 @@ export const NewTicketModal: FC = ({ show, handleClose }) => {
description: description,
endingDate: new Date(endingDate).toISOString(),
creatorId: "20bf4b2a-7209-4826-96cd-29c2bc937a94",
- projectId: 1
+ projectId: parseInt(projectId)
};
// console.log(newTicket);
const response: HttpResponse = await post(
@@ -63,6 +70,9 @@ export const NewTicketModal: FC = ({ show, handleClose }) => {
setDescription={setDescription}
endingDate={endingDate}
setEndingDate={setEndingDate}
+ allProjects={allProjects}
+ projectId={projectId}
+ setProjectId={setProjectId}
/>
diff --git a/client/src/components/NewTicketTabRouter.tsx b/client/src/components/NewTicketTabRouter.tsx
index 200651d..0b68000 100644
--- a/client/src/components/NewTicketTabRouter.tsx
+++ b/client/src/components/NewTicketTabRouter.tsx
@@ -1,7 +1,6 @@
import React, { FC } from "react";
import { useRouteMatch } from "react-router-dom";
import { TabRouterHeader } from "./TabRouterHeader";
-import { NewTicketForm } from "./NewTicketForm";
interface IProps {
tabNames: string[];
@@ -28,14 +27,14 @@ export const NewTicketTabRouter: FC = ({
-
+ /> */}
>
);
diff --git a/client/src/components/TabRouter.tsx b/client/src/components/TabRouter.tsx
index 54c2142..8ecfaba 100644
--- a/client/src/components/TabRouter.tsx
+++ b/client/src/components/TabRouter.tsx
@@ -7,6 +7,7 @@ import { FileList } from "./AppFileList";
import { Ticket } from "../types/Ticket";
import { AppFile } from "../types/AppFile";
import { Activity } from "../types/Activity";
+import { Project } from "../types/Project";
interface IProps {
tickets: Ticket[];
@@ -14,13 +15,15 @@ interface IProps {
tabNames: string[];
files: AppFile[];
activities: Activity[];
+ allProjects: Project[];
}
export const TabRouter: FC = ({
tickets,
tabNames,
files,
- activities
+ activities,
+ allProjects
}) => {
const { url } = useRouteMatch();
@@ -32,7 +35,7 @@ export const TabRouter: FC = ({
-
+
diff --git a/client/src/components/TicketList.tsx b/client/src/components/TicketList.tsx
index 929850e..677af17 100644
--- a/client/src/components/TicketList.tsx
+++ b/client/src/components/TicketList.tsx
@@ -7,12 +7,14 @@ import { HttpResponse } from "../types/HttpResponse";
import { put } from "../utils/http";
import { Constants } from "../utils/Constants";
import { NewTicketModal } from "./NewTicketModal";
+import { Project } from "../types/Project";
type TicketListProps = {
tickets: Ticket[];
+ allProjects: Project[];
};
-export const TicketList: FC = ({ tickets }) => {
+export const TicketList: FC = ({ tickets, allProjects }) => {
const [filterText, setFilterText] = useState("");
const clearFilterText: (e: MouseEvent) => void = (e: MouseEvent) => {
setFilterText("");
@@ -42,6 +44,7 @@ export const TicketList: FC = ({ tickets }) => {
setShowNew(false);
}}
show={showNew}
+ allProjects={allProjects}
/>
Tickets
= ({ tickets, tabNames, projects }) => {
- {/*
-
- */}
+
+
+
>
);
diff --git a/client/src/controllers/ProjectController.tsx b/client/src/controllers/ProjectController.tsx
index 0252cd5..3d30d04 100644
--- a/client/src/controllers/ProjectController.tsx
+++ b/client/src/controllers/ProjectController.tsx
@@ -13,6 +13,7 @@ import { User } from "../types/User";
export const ProjectController: FC = () => {
const [project, setProject] = useState({} as Project);
const [allUsers, setAllUsers] = useState([]);
+ const [allProjects, setAllProjects] = useState([]);
const [isLoading, setIsLoading] = useState(true);
const [hasError, setHasError] = useState(false);
const [error, setError] = useState("");
@@ -48,10 +49,25 @@ export const ProjectController: FC = () => {
}
}
+ async function httpGetAllProjects(): Promise {
+ try {
+ const response: HttpResponse = await get(
+ `${Constants.projectsURI}`
+ );
+ if (response.parsedBody !== undefined) {
+ setAllProjects((response.parsedBody as unknown) as Project[]);
+ }
+ } catch (ex) {
+ setHasError(true);
+ setError(ex);
+ }
+ }
+
useEffect(() => {
if (id !== undefined) {
httpGetProjects(id);
httpGetAllUsers();
+ httpGetAllProjects();
} else {
setHasError(true);
setError("Bad Request");
@@ -61,6 +77,6 @@ export const ProjectController: FC = () => {
if (hasError) {
return ;
}
- const viewModel = new ProjectVM(project, allUsers);
+ const viewModel = new ProjectVM(project, allUsers, allProjects);
return isLoading ? : ;
};
diff --git a/client/src/pages/ProjectPage.tsx b/client/src/pages/ProjectPage.tsx
index f7b0219..464d0e4 100644
--- a/client/src/pages/ProjectPage.tsx
+++ b/client/src/pages/ProjectPage.tsx
@@ -13,6 +13,7 @@ interface IProps {
export const ProjectPage: FC = ({ viewModel }) => {
const {
+ // id,
title,
description,
users,
@@ -23,7 +24,8 @@ export const ProjectPage: FC = ({ viewModel }) => {
ticketsTotalCount,
remainingDays,
files,
- activities
+ activities,
+ allProjects
} = viewModel;
const tabNames: string[] = ["Tickets", "Files"]; //, "Activity"];
@@ -59,6 +61,7 @@ export const ProjectPage: FC = ({ viewModel }) => {
tickets={tickets}
files={files}
activities={activities}
+ allProjects={allProjects}
/>
diff --git a/client/src/pages/UserPage.tsx b/client/src/pages/UserPage.tsx
index 6641aad..2b908af 100644
--- a/client/src/pages/UserPage.tsx
+++ b/client/src/pages/UserPage.tsx
@@ -23,10 +23,6 @@ export const UserPage: FC = ({ viewModel }) => {
tickets={tickets}
/>
- {/* //
- //
- //
- // */}
);
};