Skip to content

Commit 540bf1d

Browse files
committed
added option to hard delete from bin
1 parent 8d4fca0 commit 540bf1d

2 files changed

Lines changed: 30 additions & 6 deletions

File tree

β€Žfrontend/src/feature/quote/dialog/recycle-bin.dialog.tsxβ€Ž

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,13 @@ import type { CardView, Quote, QuoteFormData, SortOption } from "@/model/index.m
2929
import { cardViewOptions, useCardViewStore } from "@/store/use-card-view.store";
3030
import { themeModes, type ThemeMode } from '@/hook/use-dark-or-light-theme.hook'
3131
import { showInfo, useShowCardInfo, type ShowInfo } from "@/store/use-card-info.store";
32-
import { ArrowLeftIcon, CircleArrowDown, CircleCheckBig, Copy, Images, LoaderCircle, Save, Share, Settings, Link2Icon, SquareArrowOutUpRight, ArrowUpRight, TrashIcon, CircleArrowLeft, RotateCcw } from "lucide-react";
32+
import { ArrowLeftIcon, CircleArrowDown, CircleCheckBig, Copy, Images, LoaderCircle, Save, Share, Settings, Link2Icon, SquareArrowOutUpRight, ArrowUpRight, TrashIcon, CircleArrowLeft, RotateCcw, Trash2Icon } from "lucide-react";
3333
import { Link } from "@tanstack/react-router";
3434
import { cn } from "@/lib/utils";
3535
import { useGetAllDeletedQuoteDetails } from "@/api-hook/use-get-all-delete-quote-details.hook";
3636
import { sanitizeHTML } from "@/helper/sanitize-html";
3737
import { useUpdateQuoteDetails } from "@/api-hook/use-update-quote-details.hook";
38+
import { deleteQuoteWithLinks } from "@/db/quote_tags.db";
3839

3940
interface Props {
4041

@@ -56,6 +57,13 @@ function RecycleBinComponent(props: Props) {
5657
refetch()
5758
}
5859

60+
const handleHardDelete = async (quote: Quote) => {
61+
if (!quote.id) return
62+
await await deleteQuoteWithLinks(quote.id)
63+
refetch()
64+
}
65+
66+
5967
return (
6068
<Dialog open={open} onOpenChange={setOpen}
6169

@@ -86,15 +94,16 @@ function RecycleBinComponent(props: Props) {
8694
<div
8795
className=" overflow-y-auto rounded-xl h-40 min-h-0 flex flex-col gap-1 border-2 p-2">
8896
{data?.map((quote, i) => (
89-
<div className="flex justify-between border-2 rounded-lg p-2">
97+
<div key={'bin' + quote.id}
98+
className="flex justify-between border-2 rounded-lg p-2">
9099
<div
91-
key={'bin' + quote.id}
100+
92101
className=" "
93102
dangerouslySetInnerHTML={{
94103
__html: sanitizeHTML(quote?.text!)
95104
}}
96105
/>
97-
<div>
106+
<div className="flex items-center gap-2">
98107
<Button
99108
className={cn("hover:text-primary focus:text-primary active:text-primary",)}
100109
variant={"outline"}
@@ -107,6 +116,18 @@ function RecycleBinComponent(props: Props) {
107116
>
108117
<RotateCcw />
109118
</Button>
119+
<Button
120+
className={cn("hover:text-primary focus:text-primary active:text-primary",)}
121+
variant={"outline"}
122+
onClick={(e) => {
123+
e.preventDefault()
124+
handleHardDelete(quote)
125+
}}
126+
aria-label={"Delete note"}
127+
size={"sm"}
128+
>
129+
<Trash2Icon />
130+
</Button>
110131
</div>
111132
</div>
112133

β€Žfrontend/src/feature/quote/dialog/setting.dialog.tsxβ€Ž

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ function SettingComponent(props: Props) {
149149

150150
<Separator className="bg-border" />
151151

152-
<div className={cn("flex flex-col gap-1", )}>
152+
<div className={cn("flex flex-col gap-1",)}>
153153
<p className={cn("text-muted-foreground ", fontClassXxs)}>Card Style</p>
154154
<div className="flex justify-between items-center text-xs">
155155
Show Info
@@ -252,7 +252,10 @@ function SettingComponent(props: Props) {
252252

253253
<Separator className="bg-border" />
254254
<div className=" w-full text-center text-sm">
255-
Made with πŸ’™ by Pritam Debnath
255+
<a href="https://pridebnath.github.io/portfolio-v2/" target="_blank"
256+
className="hover:underline focus:underline active:underline">
257+
Made with πŸ’™ by Pritam Debnath
258+
</a>
256259
</div>
257260
</DialogContent>
258261
</Dialog>

0 commit comments

Comments
Β (0)