From 08aaec54d53cc3c4fe3076d034333e9e1b4faeb3 Mon Sep 17 00:00:00 2001 From: 0x1eef <0x1eef@protonmail.com> Date: Fri, 22 Dec 2023 16:28:06 -0300 Subject: [PATCH] frontend: add trash icon to destroy an issue And remove DestroyIssueButton. --- twenty-frontend/src/css/_items.scss | 24 ++++++++++++ twenty-frontend/src/css/main.scss | 39 ++++--------------- .../src/js/components/DestroyIssueButton.tsx | 17 -------- twenty-frontend/src/js/components/Icons.tsx | 3 +- twenty-frontend/src/js/components/Issues.tsx | 37 +++++++++++------- 5 files changed, 55 insertions(+), 65 deletions(-) create mode 100644 twenty-frontend/src/css/_items.scss delete mode 100644 twenty-frontend/src/js/components/DestroyIssueButton.tsx diff --git a/twenty-frontend/src/css/_items.scss b/twenty-frontend/src/css/_items.scss new file mode 100644 index 0000000..d14a5dc --- /dev/null +++ b/twenty-frontend/src/css/_items.scss @@ -0,0 +1,24 @@ +ul.items { + margin: 0; + padding: 0; + list-style-type: none; + + li.item { + margin: 0 0 15px 0; + display: flex; + background: #f4f0ec; + border: #cfcfc4 1px solid; + border-radius: 10px; + padding: 10px; + flex-wrap: wrap; + .top, .bottom { + display: flex; + justify-content: space-between; + width: 100%; + } + .bottom { + margin: 10px 0 0 0; + font-size: small; + } + } +} diff --git a/twenty-frontend/src/css/main.scss b/twenty-frontend/src/css/main.scss index b176d84..34d93f5 100644 --- a/twenty-frontend/src/css/main.scss +++ b/twenty-frontend/src/css/main.scss @@ -2,6 +2,7 @@ @import "colors"; @import "forms"; @import "tables"; +@import "items"; *, *:before, *:after { box-sizing: border-box; @@ -34,38 +35,12 @@ body { } } - .react-mount.issues { - ul { - margin: 0; - padding: 0; - list-style-type: none; - li { - margin: 0 0 15px 0; - .item.row { - display: flex; - background: #f4f0ec; - border: #cfcfc4 1px solid; - border-radius: 10px; - padding: 10px; - flex-wrap: wrap; - .header { - .item.id { - border: 1px #cfcfc4 solid; - border-radius: 10px; - padding: 5px; - margin-right: 5px; - background: #FFF; - } - } - .footer { - display: flex; - width: 100%; - justify-content: space-between; - margin: 10px 0 0 0; - font-size: small; - } - } - } + .trash.icon { + height: 20px; + width: 20px; + cursor: pointer; + g { + fill: #d9534f; } } } diff --git a/twenty-frontend/src/js/components/DestroyIssueButton.tsx b/twenty-frontend/src/js/components/DestroyIssueButton.tsx deleted file mode 100644 index 25ebc8e..0000000 --- a/twenty-frontend/src/js/components/DestroyIssueButton.tsx +++ /dev/null @@ -1,17 +0,0 @@ -import React from "react"; -import { Issue } from "/types/schema"; -import { useDestroyIssue } from "/hooks/useDestroyIssue"; - -type Props = { - issue: Issue; - onSuccess: (issue: Issue) => unknown; -}; - -export function DestroyIssueButton({ issue, onSuccess }: Props) { - const destroy = useDestroyIssue(); - const onClick = () => { - destroy({ id: issue.id }).then(() => onSuccess(issue)); - }; - - return ; -} diff --git a/twenty-frontend/src/js/components/Icons.tsx b/twenty-frontend/src/js/components/Icons.tsx index 02fe2d0..cc407e2 100644 --- a/twenty-frontend/src/js/components/Icons.tsx +++ b/twenty-frontend/src/js/components/Icons.tsx @@ -1,6 +1,6 @@ import React from "react"; -export function TrashIcon({onClick}: {onClick: () => unknown}) { +export function TrashIcon({onClick}: {onClick?: () => unknown}) { return ( unknown}) { width="512" xmlns="http://www.w3.org/2000/svg" onClick={onClick} + className="trash icon" > diff --git a/twenty-frontend/src/js/components/Issues.tsx b/twenty-frontend/src/js/components/Issues.tsx index a9bb7be..617dfdc 100644 --- a/twenty-frontend/src/js/components/Issues.tsx +++ b/twenty-frontend/src/js/components/Issues.tsx @@ -1,33 +1,40 @@ import React from "react"; import { useIssues } from "/hooks/useIssues"; +import { useDestroyIssue } from "/hooks/useDestroyIssue"; import { TrashIcon } from "/components/Icons"; import { DateTime } from "luxon"; import { Issue } from "/types/schema"; export function Issues() { - const { issues } = useIssues(); + const { issues, setIssues } = useIssues(); + const destroyIssue = useDestroyIssue(); + const onDestroy = (issue: Issue) => { + destroyIssue({id: issue.id}) + .then(() => issues.filter((i) => i.id !== issue.id)) + .then((issues) => setIssues(issues)); + } + return (
Issues
-