diff --git a/client/src/components/Modals/NewTicketModal.tsx b/client/src/components/Modals/NewTicketModal.tsx index cb1a5fb..bb29b1d 100644 --- a/client/src/components/Modals/NewTicketModal.tsx +++ b/client/src/components/Modals/NewTicketModal.tsx @@ -1,11 +1,21 @@ import React, { FC, useState, FormEvent } from "react"; import { useRouteMatch } from "react-router-dom"; -import { TextField, MenuItem } from "@material-ui/core"; +import { + TextField, + MenuItem, + Grid, + makeStyles, + Theme, + createStyles, +} from "@material-ui/core"; import { Modal } from "./Modal"; import { Ticket } from "../../types/Ticket"; import { Project } from "../../types/Project"; import { post } from "../../utils/http"; import { Constants } from "../../utils/Constants"; +import Category from "../../types/enums/category"; +import Impact from "../../types/enums/impact"; +import Difficulty from "../../types/enums/difficulty"; interface IProps { show: boolean; @@ -13,6 +23,12 @@ interface IProps { allProjects: Project[]; } +const useStyles = makeStyles((theme: Theme) => ({ + select: { + width: 120, + }, +})); + export const NewTicketModal: FC = ({ show, handleClose, @@ -25,6 +41,9 @@ export const NewTicketModal: FC = ({ const { url } = useRouteMatch(); const id = url.split("/")[2]; const [projectId, setProjectId] = useState(id); + const [categoryID, setCategoryID] = useState(0); + const [impactID, setImpactID] = useState(0); + const [difficultyID, setDifficultyID] = useState(0); const handleSubmit = async (e: FormEvent) => { e.preventDefault(); @@ -32,8 +51,11 @@ export const NewTicketModal: FC = ({ title: title, description: description, endingDate: new Date(endingDate).toISOString(), - creatorId: "20bf4b2a-7209-4826-96cd-29c2bc937a94", + creatorId: "20bf4b2a-7209-4826-96cd-29c2bc937a94", // get current User id projectId: parseInt(projectId), + impact: impactID, + difficulty: difficultyID, + category: categoryID, }; // const response: HttpResponse = @@ -41,6 +63,7 @@ export const NewTicketModal: FC = ({ handleClose(); }; + const classes = useStyles(); return ( = ({ action="New Ticket" handleAction={handleSubmit} > -
- ) => - setTitle(e.target.value) - } - autoFocus - /> + ) => + setTitle(e.target.value) + } + autoFocus + /> - ) => - setDescription(e.target.value) - } - multiline - /> + ) => + setDescription(e.target.value) + } + multiline + /> + ) => { + e.preventDefault(); + setProjectId(e.target.value); + }} + // helperText="Please select your currency" + variant="outlined" + margin="normal" + > + {allProjects.map((p) => ( + + {p.title} + + ))} + + + ) => + setEndingDate(e.target.value) + } + /> + + ) => { e.preventDefault(); - setProjectId(e.target.value); + setCategoryID(parseInt(e.target.value)); }} - // helperText="Please select your currency" variant="outlined" margin="normal" + className={classes.select} > - {allProjects.map((p) => ( - - {p.title} + {Category.map((c: string, i: number) => ( + + {c} ))} ) => { + e.preventDefault(); + setImpactID(parseInt(e.target.value)); }} variant="outlined" - required - value={endingDate} - onChange={(e: React.ChangeEvent) => - setEndingDate(e.target.value) - } - /> -
+ margin="normal" + > + {Impact.map((c: string, i: number) => ( + + {c} + + ))} + + + ) => { + e.preventDefault(); + setDifficultyID(parseInt(e.target.value)); + }} + variant="outlined" + margin="normal" + > + {Difficulty.map((c: string, i: number) => ( + + {c} + + ))} + +
); }; diff --git a/client/src/types/enums/category.ts b/client/src/types/enums/category.ts new file mode 100644 index 0000000..07e06d0 --- /dev/null +++ b/client/src/types/enums/category.ts @@ -0,0 +1,3 @@ +const Category: string[] = ["Product", "Tech", "Design", "Marketing", "Test"]; + +export default Category; diff --git a/client/src/types/enums/difficulty.ts b/client/src/types/enums/difficulty.ts new file mode 100644 index 0000000..746c54d --- /dev/null +++ b/client/src/types/enums/difficulty.ts @@ -0,0 +1,3 @@ +const Difficulty: string[] = ["Easy", "Medium", "Hard"]; + +export default Difficulty; diff --git a/client/src/types/enums/impact.ts b/client/src/types/enums/impact.ts new file mode 100644 index 0000000..1584183 --- /dev/null +++ b/client/src/types/enums/impact.ts @@ -0,0 +1,3 @@ +const Impact: string[] = ["High", "Medium", "Low"]; + +export default Impact;