From 73830344ed7c07f4e01b2698901936c9dafa9f05 Mon Sep 17 00:00:00 2001 From: Ruidy Nemausat Date: Wed, 4 Mar 2020 16:47:36 +0100 Subject: [PATCH] handled project selector in newticketform --- client/src/components/NewTicketModal.tsx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/client/src/components/NewTicketModal.tsx b/client/src/components/NewTicketModal.tsx index 60d6a86..03c7ccd 100644 --- a/client/src/components/NewTicketModal.tsx +++ b/client/src/components/NewTicketModal.tsx @@ -1,11 +1,12 @@ -import React, { FC, useState, useEffect, FormEvent } from "react"; +import React, { FC, useState, FormEvent } from "react"; +import { useParams, useRouteMatch } from "react-router-dom"; import { Modal } from "./Modal"; +import { NewTicketForm } from "./NewTicketForm"; import { Ticket } from "../types/Ticket"; +import { Project } from "../types/Project"; 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; @@ -21,7 +22,10 @@ export const NewTicketModal: FC = ({ const [title, setTitle] = useState(""); const [description, setDescription] = useState(""); const [endingDate, setEndingDate] = useState(""); - const [projectId, setProjectId] = useState("0"); + + const { url } = useRouteMatch(); + const id = url.split("/")[2]; + const [projectId, setProjectId] = useState(id); const handleSubmit: (event: FormEvent) => void = async ( e: FormEvent @@ -43,7 +47,6 @@ export const NewTicketModal: FC = ({ handleClose(); }; - useEffect(() => {}); return (