From 8a3e1d96d5228d1da00b7ed84bc89b85487c575e Mon Sep 17 00:00:00 2001 From: Ruidy Nemausat Date: Sat, 18 Apr 2020 11:18:06 +0200 Subject: [PATCH] Extracted TicketChipsArray in own component. Used on ticketPage --- client/src/components/Cards/TicketCard.tsx | 81 +++------------ .../src/components/Cards/TicketChipsArray.tsx | 77 +++++++++++++++ client/src/pages/TicketPage.tsx | 99 +++++++++++-------- 3 files changed, 147 insertions(+), 110 deletions(-) create mode 100644 client/src/components/Cards/TicketChipsArray.tsx diff --git a/client/src/components/Cards/TicketCard.tsx b/client/src/components/Cards/TicketCard.tsx index af5a36d..dcd1090 100644 --- a/client/src/components/Cards/TicketCard.tsx +++ b/client/src/components/Cards/TicketCard.tsx @@ -3,12 +3,11 @@ 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 { Ticket } from "../../types/Ticket"; import { getRemainingdays } from "../../utils/methods"; +import TicketChipsArray from "./TicketChipsArray"; interface IProps { ticket?: Ticket; @@ -16,74 +15,20 @@ interface IProps { link?: string; } -const useStyles = makeStyles((theme: Theme) => - createStyles({ - root: { - display: "flex", - 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 = ({ 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 ( - // - - {chipData.map((data, i: number) => { - let icon = ; - let color: - | "inherit" - | "default" - | "primary" - | "secondary" - | undefined; - - if (data.label === "impact") { - color = "primary"; - icon = ; - } - if (data.label === "difficulty") { - color = "secondary"; - icon = ; - } - - return ( -
  • - -
  • - ); - })} -
    - ); - }; - +const TicketCard: FC = ({ + link = "#", + validateTicket, + ticket = {} as Ticket, +}) => { const Content: FC = () => { return ( - + Due in{" "} diff --git a/client/src/components/Cards/TicketChipsArray.tsx b/client/src/components/Cards/TicketChipsArray.tsx new file mode 100644 index 0000000..92b57f9 --- /dev/null +++ b/client/src/components/Cards/TicketChipsArray.tsx @@ -0,0 +1,77 @@ +import React, { FC } from "react"; +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({ + root: { + display: "flex", + justifyContent: "space-between", + flexWrap: "wrap", + listStyle: "none", + padding: theme.spacing(0.5), + margin: 0, + marginTop: 20, + marginBottom: 20, + }, + chip: { + margin: theme.spacing(0.5), + }, + }) +); + +interface IProps { + status: string; + category: string; + impact: string; + difficulty: string; +} +const TicketChipsArray: FC = ({ + status, + category, + impact, + difficulty, +}) => { + const classes = useStyles(); + const chipData = [ + // { label: "status", value: status }, + { label: "category", value: category }, + { label: "impact", value: impact }, + { label: "difficulty", value: difficulty }, + ]; + + return ( + // + + {chipData.map((data, i: number) => { + let icon = ; + let color: "inherit" | "default" | "primary" | "secondary" | undefined; + + if (data.label === "impact") { + color = "primary"; + icon = ; + } + if (data.label === "difficulty") { + color = "secondary"; + icon = ; + } + + return ( +
  • + +
  • + ); + })} +
    + ); +}; + +export default TicketChipsArray; diff --git a/client/src/pages/TicketPage.tsx b/client/src/pages/TicketPage.tsx index 29a5d7a..cf6a5b2 100644 --- a/client/src/pages/TicketPage.tsx +++ b/client/src/pages/TicketPage.tsx @@ -7,14 +7,14 @@ 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 { Header } from "../components/Header"; -import { AvatarList } from "../components/Avatars/AvatarList"; -import { TicketVM } from "../VM/TicketVM"; -import { getRemainingdays } from "../utils/methods"; - import { makeStyles, Theme, Grid, Typography } from "@material-ui/core"; import { Timer } from "@material-ui/icons"; import PageLayout from "../layouts/PageLayout"; +import { TicketVM } from "../VM/TicketVM"; +import { Header } from "../components/Header"; +import { AvatarList } from "../components/Avatars/AvatarList"; +import TicketChipsArray from "../components/Cards/TicketChipsArray"; +import { getRemainingdays } from "../utils/methods"; interface IProps { viewModel: TicketVM; @@ -23,10 +23,15 @@ interface IProps { const useStyles = makeStyles((theme: Theme) => ({ root: { margin: theme.spacing(1), - flexGrow: 1, + // flexGrow: 1, }, table: { - minWidth: 650, + margin: "auto", + maxWidth: 650, + alignItems: "center", + }, + subtitle: { + marginTop: 20, }, })); @@ -54,8 +59,12 @@ export const TicketPage: FC = ({ viewModel }) => {
    - - In project: {" "} + + Project: {project.title} @@ -65,8 +74,14 @@ export const TicketPage: FC = ({ viewModel }) => {
    -
    - + {/* */} + = ({ viewModel }) => { ); }; -interface InfoProps { - status: string; - category: string; - impact: string; - difficulty: string; -} +// interface InfoProps { +// status: string; +// category: string; +// impact: string; +// difficulty: string; +// } -const InfoTable: FC = (info: InfoProps) => { - const classes = useStyles(); +// const InfoTable: FC = (info: InfoProps) => { +// const classes = useStyles(); - return ( - - - - - Status - Category - Impact - Difficulty - - - - - {info.status} - {info.category} - {info.impact} - {info.difficulty} - - -
    -
    - ); -}; +// return ( +// +// +// +// +// Status +// Category +// Impact +// Difficulty +// +// +// +// +// {info.status} +// {info.category} +// {info.impact} +// {info.difficulty} +// +// +//
    +//
    +// ); +// };