mirror of
https://github.com/rjNemo/ticket_manager
synced 2026-06-06 00:36:39 +00:00
NewProjectModal can add new project
This commit is contained in:
parent
1368859860
commit
3e94c311e5
7 changed files with 11 additions and 151 deletions
BIN
app.db
BIN
app.db
Binary file not shown.
|
|
@ -1,13 +1,9 @@
|
|||
import React, { FC, MouseEvent } from "react";
|
||||
import { Button, Typography, Grid } from "@material-ui/core";
|
||||
import { createStyles, makeStyles, Theme } from "@material-ui/core/styles";
|
||||
import Chip from "@material-ui/core/Chip";
|
||||
import Paper from "@material-ui/core/Paper";
|
||||
|
||||
import { HorizontalCard } from "./HorizontalCard";
|
||||
import TicketChipsArray from "./TicketChipsArray";
|
||||
import { Ticket } from "../../types/Ticket";
|
||||
import { getRemainingdays } from "../../utils/methods";
|
||||
import TicketChipsArray from "./TicketChipsArray";
|
||||
|
||||
interface IProps {
|
||||
ticket?: Ticket;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ import { Grid, Chip, makeStyles, Theme, createStyles } from "@material-ui/core";
|
|||
import CategoryIcon from "@material-ui/icons/Category";
|
||||
import PriorityHighIcon from "@material-ui/icons/PriorityHigh";
|
||||
import SpeedIcon from "@material-ui/icons/Speed";
|
||||
import { Ticket } from "../../types/Ticket";
|
||||
|
||||
const useStyles = makeStyles((theme: Theme) =>
|
||||
createStyles({
|
||||
|
|
|
|||
|
|
@ -1,21 +1,10 @@
|
|||
import React, { FC, useState, FormEvent } from "react";
|
||||
import { useRouteMatch } from "react-router-dom";
|
||||
import {
|
||||
TextField,
|
||||
MenuItem,
|
||||
Grid,
|
||||
makeStyles,
|
||||
Theme,
|
||||
createStyles,
|
||||
} from "@material-ui/core";
|
||||
import { TextField } from "@material-ui/core";
|
||||
import { Modal } from "./Modal";
|
||||
import { Ticket } from "../../types/Ticket";
|
||||
import { Project } from "../../types/Project";
|
||||
import { User } from "../../types/User";
|
||||
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;
|
||||
|
|
@ -23,53 +12,30 @@ interface IProps {
|
|||
allUsers: User[];
|
||||
}
|
||||
|
||||
const useStyles = makeStyles((theme: Theme) => ({
|
||||
select: {
|
||||
width: 120,
|
||||
},
|
||||
}));
|
||||
|
||||
export const NewProjectModal: FC<IProps> = ({
|
||||
show,
|
||||
handleClose,
|
||||
allUsers,
|
||||
}) => {
|
||||
export const NewProjectModal: FC<IProps> = ({ show, handleClose }) => {
|
||||
const [title, setTitle] = useState("");
|
||||
const [description, setDescription] = useState("");
|
||||
const [endingDate, setEndingDate] = useState("");
|
||||
|
||||
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();
|
||||
let newTicket = {
|
||||
let newProject = {
|
||||
title: title,
|
||||
description: description,
|
||||
endingDate: new Date(endingDate).toISOString(),
|
||||
creatorId: "20bf4b2a-7209-4826-96cd-29c2bc937a94", // get current User id
|
||||
projectId: parseInt(projectId),
|
||||
impact: impactID,
|
||||
difficulty: difficultyID,
|
||||
category: categoryID,
|
||||
managerId: "cd179eb7-3a54-4060-b22c-3e947bdffcbc", // get current User id
|
||||
};
|
||||
|
||||
// const response: HttpResponse<Ticket> =
|
||||
await post<Ticket>(`${Constants.ticketsURI}`, newTicket);
|
||||
await post<Project>(`${Constants.projectsURI}`, newProject);
|
||||
handleClose();
|
||||
};
|
||||
|
||||
const classes = useStyles();
|
||||
return (
|
||||
<Modal
|
||||
name="New Ticket"
|
||||
name="New Project"
|
||||
show={show}
|
||||
handleClose={handleClose}
|
||||
action="New Ticket"
|
||||
action="New Project"
|
||||
handleAction={handleSubmit}
|
||||
>
|
||||
<TextField
|
||||
|
|
@ -102,29 +68,6 @@ export const NewProjectModal: FC<IProps> = ({
|
|||
multiline
|
||||
/>
|
||||
|
||||
<TextField
|
||||
id="project"
|
||||
name="project"
|
||||
select
|
||||
fullWidth
|
||||
required
|
||||
label="Project"
|
||||
value={projectId}
|
||||
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
e.preventDefault();
|
||||
setProjectId(e.target.value);
|
||||
}}
|
||||
// helperText="Please select your currency"
|
||||
variant="outlined"
|
||||
margin="normal"
|
||||
>
|
||||
{allUsers.map((p) => (
|
||||
<MenuItem key={p.id} value={p.id}>
|
||||
{p}
|
||||
</MenuItem>
|
||||
))}
|
||||
</TextField>
|
||||
|
||||
<TextField
|
||||
id="date"
|
||||
name="date"
|
||||
|
|
@ -132,8 +75,6 @@ export const NewProjectModal: FC<IProps> = ({
|
|||
type="date"
|
||||
margin="normal"
|
||||
fullWidth
|
||||
// defaultValue={new Date().toISOString()}
|
||||
// className={classes.textField}
|
||||
InputLabelProps={{
|
||||
shrink: true,
|
||||
}}
|
||||
|
|
@ -144,71 +85,6 @@ export const NewProjectModal: FC<IProps> = ({
|
|||
setEndingDate(e.target.value)
|
||||
}
|
||||
/>
|
||||
|
||||
<Grid container justify="space-between">
|
||||
<TextField
|
||||
id="category"
|
||||
name="category"
|
||||
select
|
||||
label="Category"
|
||||
value={categoryID}
|
||||
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
e.preventDefault();
|
||||
setCategoryID(parseInt(e.target.value));
|
||||
}}
|
||||
variant="outlined"
|
||||
margin="normal"
|
||||
className={classes.select}
|
||||
>
|
||||
{Category.map((c: string, i: number) => (
|
||||
<MenuItem key={i} value={i}>
|
||||
{c}
|
||||
</MenuItem>
|
||||
))}
|
||||
</TextField>
|
||||
|
||||
<TextField
|
||||
className={classes.select}
|
||||
id="impact"
|
||||
name="impact"
|
||||
select
|
||||
label="Impact"
|
||||
value={impactID}
|
||||
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
e.preventDefault();
|
||||
setImpactID(parseInt(e.target.value));
|
||||
}}
|
||||
variant="outlined"
|
||||
margin="normal"
|
||||
>
|
||||
{Impact.map((c: string, i: number) => (
|
||||
<MenuItem key={i} value={i}>
|
||||
{c}
|
||||
</MenuItem>
|
||||
))}
|
||||
</TextField>
|
||||
|
||||
<TextField
|
||||
className={classes.select}
|
||||
id="difficulty"
|
||||
name="difficulty"
|
||||
select
|
||||
label="Difficulty"
|
||||
value={difficultyID}
|
||||
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
e.preventDefault();
|
||||
setDifficultyID(parseInt(e.target.value));
|
||||
}}
|
||||
variant="outlined"
|
||||
margin="normal"
|
||||
>
|
||||
{Difficulty.map((c: string, i: number) => (
|
||||
<MenuItem key={i} value={i}>
|
||||
{c}
|
||||
</MenuItem>
|
||||
))}
|
||||
</TextField>
|
||||
</Grid>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import {
|
|||
Grid,
|
||||
makeStyles,
|
||||
Theme,
|
||||
createStyles,
|
||||
} from "@material-ui/core";
|
||||
import { Modal } from "./Modal";
|
||||
import { Ticket } from "../../types/Ticket";
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ const useStyles = makeStyles((theme: Theme) => ({
|
|||
backgroundColor: "#E9ECEF",
|
||||
borderRadius: "20px",
|
||||
},
|
||||
topbar: { borderTopLeftRadius: "10px", borderTopRightRadius: "10px" },
|
||||
}));
|
||||
|
||||
interface IProps {
|
||||
|
|
@ -77,11 +78,7 @@ export const UserTabPanel: FC<IProps> = ({
|
|||
|
||||
return (
|
||||
<div className={classes.root}>
|
||||
<AppBar
|
||||
position="static"
|
||||
color="inherit"
|
||||
style={{ borderTopLeftRadius: "10px", borderTopRightRadius: "10px" }}
|
||||
>
|
||||
<AppBar position="static" color="inherit" className={classes.topbar}>
|
||||
<Tabs
|
||||
value={value}
|
||||
onChange={handleChange}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,5 @@
|
|||
import React, { FC } from "react";
|
||||
import { Link } from "react-router-dom";
|
||||
import Table from "@material-ui/core/Table";
|
||||
import TableBody from "@material-ui/core/TableBody";
|
||||
import TableCell from "@material-ui/core/TableCell";
|
||||
import TableContainer from "@material-ui/core/TableContainer";
|
||||
import TableHead from "@material-ui/core/TableHead";
|
||||
import TableRow from "@material-ui/core/TableRow";
|
||||
import Paper from "@material-ui/core/Paper";
|
||||
import { makeStyles, Theme, Grid, Typography } from "@material-ui/core";
|
||||
import { Timer } from "@material-ui/icons";
|
||||
import PageLayout from "../layouts/PageLayout";
|
||||
|
|
|
|||
Loading…
Reference in a new issue