mirror of
https://github.com/rjNemo/ticket_manager
synced 2026-06-12 11:46:40 +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 React, { FC, MouseEvent } from "react";
|
||||||
import { Button, Typography, Grid } from "@material-ui/core";
|
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 { HorizontalCard } from "./HorizontalCard";
|
||||||
|
import TicketChipsArray from "./TicketChipsArray";
|
||||||
import { Ticket } from "../../types/Ticket";
|
import { Ticket } from "../../types/Ticket";
|
||||||
import { getRemainingdays } from "../../utils/methods";
|
import { getRemainingdays } from "../../utils/methods";
|
||||||
import TicketChipsArray from "./TicketChipsArray";
|
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
ticket?: Ticket;
|
ticket?: Ticket;
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ import { Grid, Chip, makeStyles, Theme, createStyles } from "@material-ui/core";
|
||||||
import CategoryIcon from "@material-ui/icons/Category";
|
import CategoryIcon from "@material-ui/icons/Category";
|
||||||
import PriorityHighIcon from "@material-ui/icons/PriorityHigh";
|
import PriorityHighIcon from "@material-ui/icons/PriorityHigh";
|
||||||
import SpeedIcon from "@material-ui/icons/Speed";
|
import SpeedIcon from "@material-ui/icons/Speed";
|
||||||
import { Ticket } from "../../types/Ticket";
|
|
||||||
|
|
||||||
const useStyles = makeStyles((theme: Theme) =>
|
const useStyles = makeStyles((theme: Theme) =>
|
||||||
createStyles({
|
createStyles({
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,10 @@
|
||||||
import React, { FC, useState, FormEvent } from "react";
|
import React, { FC, useState, FormEvent } from "react";
|
||||||
import { useRouteMatch } from "react-router-dom";
|
import { TextField } from "@material-ui/core";
|
||||||
import {
|
|
||||||
TextField,
|
|
||||||
MenuItem,
|
|
||||||
Grid,
|
|
||||||
makeStyles,
|
|
||||||
Theme,
|
|
||||||
createStyles,
|
|
||||||
} from "@material-ui/core";
|
|
||||||
import { Modal } from "./Modal";
|
import { Modal } from "./Modal";
|
||||||
import { Ticket } from "../../types/Ticket";
|
import { Project } from "../../types/Project";
|
||||||
import { User } from "../../types/User";
|
import { User } from "../../types/User";
|
||||||
import { post } from "../../utils/http";
|
import { post } from "../../utils/http";
|
||||||
import { Constants } from "../../utils/Constants";
|
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 {
|
interface IProps {
|
||||||
show: boolean;
|
show: boolean;
|
||||||
|
|
@ -23,53 +12,30 @@ interface IProps {
|
||||||
allUsers: User[];
|
allUsers: User[];
|
||||||
}
|
}
|
||||||
|
|
||||||
const useStyles = makeStyles((theme: Theme) => ({
|
export const NewProjectModal: FC<IProps> = ({ show, handleClose }) => {
|
||||||
select: {
|
|
||||||
width: 120,
|
|
||||||
},
|
|
||||||
}));
|
|
||||||
|
|
||||||
export const NewProjectModal: FC<IProps> = ({
|
|
||||||
show,
|
|
||||||
handleClose,
|
|
||||||
allUsers,
|
|
||||||
}) => {
|
|
||||||
const [title, setTitle] = useState("");
|
const [title, setTitle] = useState("");
|
||||||
const [description, setDescription] = useState("");
|
const [description, setDescription] = useState("");
|
||||||
const [endingDate, setEndingDate] = 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) => {
|
const handleSubmit = async (e: FormEvent) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
let newTicket = {
|
let newProject = {
|
||||||
title: title,
|
title: title,
|
||||||
description: description,
|
description: description,
|
||||||
endingDate: new Date(endingDate).toISOString(),
|
endingDate: new Date(endingDate).toISOString(),
|
||||||
creatorId: "20bf4b2a-7209-4826-96cd-29c2bc937a94", // get current User id
|
managerId: "cd179eb7-3a54-4060-b22c-3e947bdffcbc", // get current User id
|
||||||
projectId: parseInt(projectId),
|
|
||||||
impact: impactID,
|
|
||||||
difficulty: difficultyID,
|
|
||||||
category: categoryID,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// const response: HttpResponse<Ticket> =
|
await post<Project>(`${Constants.projectsURI}`, newProject);
|
||||||
await post<Ticket>(`${Constants.ticketsURI}`, newTicket);
|
|
||||||
handleClose();
|
handleClose();
|
||||||
};
|
};
|
||||||
|
|
||||||
const classes = useStyles();
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
name="New Ticket"
|
name="New Project"
|
||||||
show={show}
|
show={show}
|
||||||
handleClose={handleClose}
|
handleClose={handleClose}
|
||||||
action="New Ticket"
|
action="New Project"
|
||||||
handleAction={handleSubmit}
|
handleAction={handleSubmit}
|
||||||
>
|
>
|
||||||
<TextField
|
<TextField
|
||||||
|
|
@ -102,29 +68,6 @@ export const NewProjectModal: FC<IProps> = ({
|
||||||
multiline
|
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
|
<TextField
|
||||||
id="date"
|
id="date"
|
||||||
name="date"
|
name="date"
|
||||||
|
|
@ -132,8 +75,6 @@ export const NewProjectModal: FC<IProps> = ({
|
||||||
type="date"
|
type="date"
|
||||||
margin="normal"
|
margin="normal"
|
||||||
fullWidth
|
fullWidth
|
||||||
// defaultValue={new Date().toISOString()}
|
|
||||||
// className={classes.textField}
|
|
||||||
InputLabelProps={{
|
InputLabelProps={{
|
||||||
shrink: true,
|
shrink: true,
|
||||||
}}
|
}}
|
||||||
|
|
@ -144,71 +85,6 @@ export const NewProjectModal: FC<IProps> = ({
|
||||||
setEndingDate(e.target.value)
|
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>
|
</Modal>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ import {
|
||||||
Grid,
|
Grid,
|
||||||
makeStyles,
|
makeStyles,
|
||||||
Theme,
|
Theme,
|
||||||
createStyles,
|
|
||||||
} from "@material-ui/core";
|
} from "@material-ui/core";
|
||||||
import { Modal } from "./Modal";
|
import { Modal } from "./Modal";
|
||||||
import { Ticket } from "../../types/Ticket";
|
import { Ticket } from "../../types/Ticket";
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,7 @@ const useStyles = makeStyles((theme: Theme) => ({
|
||||||
backgroundColor: "#E9ECEF",
|
backgroundColor: "#E9ECEF",
|
||||||
borderRadius: "20px",
|
borderRadius: "20px",
|
||||||
},
|
},
|
||||||
|
topbar: { borderTopLeftRadius: "10px", borderTopRightRadius: "10px" },
|
||||||
}));
|
}));
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
|
|
@ -77,11 +78,7 @@ export const UserTabPanel: FC<IProps> = ({
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classes.root}>
|
<div className={classes.root}>
|
||||||
<AppBar
|
<AppBar position="static" color="inherit" className={classes.topbar}>
|
||||||
position="static"
|
|
||||||
color="inherit"
|
|
||||||
style={{ borderTopLeftRadius: "10px", borderTopRightRadius: "10px" }}
|
|
||||||
>
|
|
||||||
<Tabs
|
<Tabs
|
||||||
value={value}
|
value={value}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,5 @@
|
||||||
import React, { FC } from "react";
|
import React, { FC } from "react";
|
||||||
import { Link } from "react-router-dom";
|
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 { makeStyles, Theme, Grid, Typography } from "@material-ui/core";
|
||||||
import { Timer } from "@material-ui/icons";
|
import { Timer } from "@material-ui/icons";
|
||||||
import PageLayout from "../layouts/PageLayout";
|
import PageLayout from "../layouts/PageLayout";
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue