mirror of
https://github.com/rjNemo/ticket_manager
synced 2026-06-12 11:46:40 +00:00
HorizontalCard is a Layout; Created ProjectCard and TicketCard
This commit is contained in:
parent
4ff69d18b7
commit
382150fffa
5 changed files with 112 additions and 47 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
import React, { FC, MouseEvent } from "react";
|
import React, { FC, MouseEvent, ReactNode } from "react";
|
||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
import { makeStyles } from "@material-ui/core/styles";
|
import { makeStyles } from "@material-ui/core/styles";
|
||||||
import Card from "@material-ui/core/Card";
|
import Card from "@material-ui/core/Card";
|
||||||
|
|
@ -10,33 +10,22 @@ import { getRemainingdays } from "../utils/methods";
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
title?: string;
|
title?: string;
|
||||||
remainingDays?: string;
|
|
||||||
validateTicket?: (event: MouseEvent) => void;
|
|
||||||
link?: string;
|
link?: string;
|
||||||
|
content: ReactNode;
|
||||||
|
actions?: ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
const useStyles = makeStyles({
|
const useStyles = makeStyles({
|
||||||
root: {
|
root: {
|
||||||
minWidth: 275
|
minWidth: 275,
|
||||||
},
|
},
|
||||||
bullet: {
|
|
||||||
display: "inline-block",
|
|
||||||
margin: "0 2px",
|
|
||||||
transform: "scale(0.8)"
|
|
||||||
},
|
|
||||||
title: {
|
|
||||||
fontSize: 14
|
|
||||||
},
|
|
||||||
pos: {
|
|
||||||
marginBottom: 12
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export const HorizontalCard: FC<IProps> = ({
|
export const HorizontalCard: FC<IProps> = ({
|
||||||
title,
|
title,
|
||||||
remainingDays,
|
|
||||||
link = "#",
|
link = "#",
|
||||||
validateTicket
|
content,
|
||||||
|
actions,
|
||||||
}) => {
|
}) => {
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
|
|
||||||
|
|
@ -48,26 +37,9 @@ export const HorizontalCard: FC<IProps> = ({
|
||||||
<b>{title ?? "Nothing to do"}</b>
|
<b>{title ?? "Nothing to do"}</b>
|
||||||
</Link>
|
</Link>
|
||||||
</Typography>
|
</Typography>
|
||||||
|
{content}
|
||||||
<Typography variant="body2" component="p">
|
|
||||||
<span>
|
|
||||||
Due{" "}
|
|
||||||
{remainingDays ? (
|
|
||||||
getRemainingdays(remainingDays)
|
|
||||||
) : (
|
|
||||||
<span>
|
|
||||||
<del>Too much</del> 0
|
|
||||||
</span>
|
|
||||||
)}{" "}
|
|
||||||
days
|
|
||||||
</span>
|
|
||||||
</Typography>
|
|
||||||
</CardContent>
|
</CardContent>
|
||||||
<CardActions>
|
<CardActions>{actions}</CardActions>
|
||||||
<Button size="small" onClick={validateTicket}>
|
|
||||||
Mark as done
|
|
||||||
</Button>
|
|
||||||
</CardActions>
|
|
||||||
</Card>
|
</Card>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
34
client/src/components/ProjectCard.tsx
Normal file
34
client/src/components/ProjectCard.tsx
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
import React, { FC, MouseEvent } from "react";
|
||||||
|
import { HorizontalCard } from "./HorizontalCard";
|
||||||
|
import { Typography } from "@material-ui/core";
|
||||||
|
import { getRemainingdays } from "../utils/methods";
|
||||||
|
|
||||||
|
interface IProps {
|
||||||
|
title?: string;
|
||||||
|
remainingDays?: string;
|
||||||
|
link?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const ProjectCard: FC<IProps> = ({ title, remainingDays, link = "#" }) => {
|
||||||
|
const Content: FC = () => {
|
||||||
|
return (
|
||||||
|
<Typography variant="body2" component="p">
|
||||||
|
<span>
|
||||||
|
Due{" "}
|
||||||
|
{remainingDays ? (
|
||||||
|
getRemainingdays(remainingDays)
|
||||||
|
) : (
|
||||||
|
<span>
|
||||||
|
<del>Too much</del> 0
|
||||||
|
</span>
|
||||||
|
)}{" "}
|
||||||
|
days
|
||||||
|
</span>
|
||||||
|
</Typography>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
return <HorizontalCard title={title} link={link} content={<Content />} />;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ProjectCard;
|
||||||
|
|
@ -13,6 +13,7 @@ import { HttpResponse } from "../types/HttpResponse";
|
||||||
import { Project } from "../types/Project";
|
import { Project } from "../types/Project";
|
||||||
import { put } from "../utils/http";
|
import { put } from "../utils/http";
|
||||||
import { Constants } from "../utils/Constants";
|
import { Constants } from "../utils/Constants";
|
||||||
|
import ProjectCard from "./ProjectCard";
|
||||||
|
|
||||||
const useStyles = makeStyles((theme: Theme) =>
|
const useStyles = makeStyles((theme: Theme) =>
|
||||||
createStyles({
|
createStyles({
|
||||||
|
|
@ -65,21 +66,21 @@ export const ProjectList: FC<IProps> = ({ projects }) => {
|
||||||
<Grid item xs={12}>
|
<Grid item xs={12}>
|
||||||
<div className="col s12 grey lighten-1">
|
<div className="col s12 grey lighten-1">
|
||||||
{filteredTickets.length === 0 ? (
|
{filteredTickets.length === 0 ? (
|
||||||
<HorizontalCard />
|
<ProjectCard />
|
||||||
) : (
|
) : (
|
||||||
filteredTickets.map((t: Project) => (
|
filteredTickets.map((t: Project) => (
|
||||||
<HorizontalCard
|
<ProjectCard
|
||||||
key={t.id}
|
key={t.id}
|
||||||
title={t.title}
|
title={t.title}
|
||||||
remainingDays={t.endingDate}
|
remainingDays={t.endingDate}
|
||||||
link={`/projects/${t.id}`}
|
link={`/projects/${t.id}`}
|
||||||
validateTicket={async (e: MouseEvent) => {
|
// validateTicket={async (e: MouseEvent) => {
|
||||||
e.preventDefault();
|
// e.preventDefault();
|
||||||
await put<HttpResponse<Ticket>>(
|
// await put<HttpResponse<Ticket>>(
|
||||||
`${Constants.ticketsURI}/${t.id}/closed`,
|
// `${Constants.ticketsURI}/${t.id}/closed`,
|
||||||
{}
|
// {}
|
||||||
);
|
// );
|
||||||
}}
|
// }}
|
||||||
/>
|
/>
|
||||||
))
|
))
|
||||||
)}
|
)}
|
||||||
|
|
|
||||||
57
client/src/components/TicketCard.tsx
Normal file
57
client/src/components/TicketCard.tsx
Normal file
|
|
@ -0,0 +1,57 @@
|
||||||
|
import React, { FC, MouseEvent } from "react";
|
||||||
|
import { HorizontalCard } from "./HorizontalCard";
|
||||||
|
import { Button, Typography } from "@material-ui/core";
|
||||||
|
import { getRemainingdays } from "../utils/methods";
|
||||||
|
|
||||||
|
interface IProps {
|
||||||
|
title?: string;
|
||||||
|
remainingDays?: string;
|
||||||
|
validateTicket?: (event: MouseEvent) => void;
|
||||||
|
link?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const TicketCard: FC<IProps> = ({
|
||||||
|
title,
|
||||||
|
remainingDays,
|
||||||
|
link = "#",
|
||||||
|
validateTicket,
|
||||||
|
}) => {
|
||||||
|
const Content: FC = () => {
|
||||||
|
return (
|
||||||
|
<Typography variant="body2" component="p">
|
||||||
|
<span>
|
||||||
|
Due{" "}
|
||||||
|
{remainingDays ? (
|
||||||
|
getRemainingdays(remainingDays)
|
||||||
|
) : (
|
||||||
|
<span>
|
||||||
|
<del>Too much</del> 0
|
||||||
|
</span>
|
||||||
|
)}{" "}
|
||||||
|
days
|
||||||
|
</span>
|
||||||
|
</Typography>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const Action = () => {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Button size="small" onClick={validateTicket}>
|
||||||
|
Mark as done
|
||||||
|
</Button>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<HorizontalCard
|
||||||
|
title={title}
|
||||||
|
link={link}
|
||||||
|
content={<Content />}
|
||||||
|
actions={<Action />}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default TicketCard;
|
||||||
|
|
@ -15,6 +15,7 @@ import { NewTicketModal } from "./NewTicketModal";
|
||||||
import { Project } from "../types/Project";
|
import { Project } from "../types/Project";
|
||||||
import { put } from "../utils/http";
|
import { put } from "../utils/http";
|
||||||
import { Constants } from "../utils/Constants";
|
import { Constants } from "../utils/Constants";
|
||||||
|
import TicketCard from "./TicketCard";
|
||||||
|
|
||||||
const useStyles = makeStyles((theme: Theme) =>
|
const useStyles = makeStyles((theme: Theme) =>
|
||||||
createStyles({
|
createStyles({
|
||||||
|
|
@ -101,10 +102,10 @@ export const TicketList: FC<TicketListProps> = ({
|
||||||
<Grid item xs={12}>
|
<Grid item xs={12}>
|
||||||
<div className="col s12 grey lighten-1">
|
<div className="col s12 grey lighten-1">
|
||||||
{filteredTickets.length === 0 ? (
|
{filteredTickets.length === 0 ? (
|
||||||
<HorizontalCard />
|
<TicketCard />
|
||||||
) : (
|
) : (
|
||||||
filteredTickets.map((t: Ticket) => (
|
filteredTickets.map((t: Ticket) => (
|
||||||
<HorizontalCard
|
<TicketCard
|
||||||
key={t.id}
|
key={t.id}
|
||||||
title={t.title}
|
title={t.title}
|
||||||
remainingDays={t.endingDate}
|
remainingDays={t.endingDate}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue