mirror of
https://github.com/rjNemo/ticket_manager
synced 2026-06-12 03:36:39 +00:00
[UI] updated TicketCard to display ticket Info
This commit is contained in:
parent
1f2e1ff2bc
commit
5e057d1c72
2 changed files with 91 additions and 25 deletions
|
|
@ -1,36 +1,103 @@
|
||||||
import React, { FC, MouseEvent } from "react";
|
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 CategoryIcon from "@material-ui/icons/Category";
|
||||||
|
import PriorityHighIcon from "@material-ui/icons/PriorityHigh";
|
||||||
|
import SpeedIcon from "@material-ui/icons/Speed";
|
||||||
import { HorizontalCard } from "./HorizontalCard";
|
import { HorizontalCard } from "./HorizontalCard";
|
||||||
import { Button, Typography } from "@material-ui/core";
|
import { Ticket } from "../../types/Ticket";
|
||||||
import { getRemainingdays } from "../../utils/methods";
|
import { getRemainingdays } from "../../utils/methods";
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
title?: string;
|
ticket?: Ticket;
|
||||||
remainingDays?: string;
|
|
||||||
validateTicket?: (event: MouseEvent) => void;
|
validateTicket?: (event: MouseEvent) => void;
|
||||||
link?: string;
|
link?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const TicketCard: FC<IProps> = ({
|
const useStyles = makeStyles((theme: Theme) =>
|
||||||
title,
|
createStyles({
|
||||||
remainingDays,
|
root: {
|
||||||
link = "#",
|
display: "flex",
|
||||||
validateTicket,
|
justifyContent: "center",
|
||||||
}) => {
|
flexWrap: "wrap",
|
||||||
|
listStyle: "none",
|
||||||
|
padding: theme.spacing(0.5),
|
||||||
|
margin: 0,
|
||||||
|
marginTop: 20,
|
||||||
|
marginBottom: 20,
|
||||||
|
},
|
||||||
|
chip: {
|
||||||
|
margin: theme.spacing(0.5),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
const TicketCard: FC<IProps> = ({ link = "#", validateTicket, ticket }) => {
|
||||||
|
const ChipsArray: FC = () => {
|
||||||
|
const classes = useStyles();
|
||||||
|
const chipData = [
|
||||||
|
// { label: "status", value: ticket?.status },
|
||||||
|
{ label: "category", value: ticket?.category },
|
||||||
|
{ label: "impact", value: ticket?.impact },
|
||||||
|
{ label: "difficulty", value: ticket?.difficulty },
|
||||||
|
];
|
||||||
|
|
||||||
|
return (
|
||||||
|
// <Paper component="ul" className={classes.root}>
|
||||||
|
<Grid component="ul" className={classes.root}>
|
||||||
|
{chipData.map((data, i: number) => {
|
||||||
|
let icon = <CategoryIcon />;
|
||||||
|
let color:
|
||||||
|
| "inherit"
|
||||||
|
| "default"
|
||||||
|
| "primary"
|
||||||
|
| "secondary"
|
||||||
|
| undefined;
|
||||||
|
|
||||||
|
if (data.label === "impact") {
|
||||||
|
color = "primary";
|
||||||
|
icon = <PriorityHighIcon />;
|
||||||
|
}
|
||||||
|
if (data.label === "difficulty") {
|
||||||
|
color = "secondary";
|
||||||
|
icon = <SpeedIcon />;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<li key={i}>
|
||||||
|
<Chip
|
||||||
|
icon={icon}
|
||||||
|
color={color}
|
||||||
|
label={data.value}
|
||||||
|
className={classes.chip}
|
||||||
|
/>
|
||||||
|
</li>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</Grid>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const Content: FC = () => {
|
const Content: FC = () => {
|
||||||
return (
|
return (
|
||||||
<Typography variant="body2" component="p">
|
<Grid container justify="space-between" alignItems="center">
|
||||||
<span>
|
<ChipsArray />
|
||||||
Due in{" "}
|
<Typography variant="body2" component="p">
|
||||||
{remainingDays ? (
|
<span>
|
||||||
getRemainingdays(remainingDays)
|
Due in{" "}
|
||||||
) : (
|
{ticket?.endingDate ? (
|
||||||
<span>
|
getRemainingdays(ticket?.endingDate)
|
||||||
<del>Too much</del> 0
|
) : (
|
||||||
</span>
|
<span>
|
||||||
)}{" "}
|
<del>Too much</del> 0
|
||||||
days
|
</span>
|
||||||
</span>
|
)}{" "}
|
||||||
</Typography>
|
days
|
||||||
|
</span>
|
||||||
|
</Typography>
|
||||||
|
</Grid>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -46,7 +113,7 @@ const TicketCard: FC<IProps> = ({
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<HorizontalCard
|
<HorizontalCard
|
||||||
title={title}
|
title={ticket?.title}
|
||||||
link={link}
|
link={link}
|
||||||
content={<Content />}
|
content={<Content />}
|
||||||
actions={<Action />}
|
actions={<Action />}
|
||||||
|
|
|
||||||
|
|
@ -106,8 +106,7 @@ export const TicketList: FC<TicketListProps> = ({
|
||||||
filteredTickets.map((t: Ticket) => (
|
filteredTickets.map((t: Ticket) => (
|
||||||
<TicketCard
|
<TicketCard
|
||||||
key={t.id}
|
key={t.id}
|
||||||
title={t.title}
|
ticket={t}
|
||||||
remainingDays={t.endingDate}
|
|
||||||
link={`/tickets/${t.id}`}
|
link={`/tickets/${t.id}`}
|
||||||
validateTicket={async (e: MouseEvent) => {
|
validateTicket={async (e: MouseEvent) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue