feat: allow deleting keywords from the All Keywords view

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
le king fu 2026-02-22 07:29:29 -05:00
parent 3f4e1516a3
commit 2436f78023
3 changed files with 19 additions and 1 deletions

View file

@ -2,6 +2,9 @@
## [Unreleased] ## [Unreleased]
### Added
- Delete keywords from the "All Keywords" view
## [0.3.8] ## [0.3.8]
### Added ### Added

View file

@ -1,6 +1,6 @@
import { useState, useEffect } from "react"; import { useState, useEffect } from "react";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { Search } from "lucide-react"; import { Search, X } from "lucide-react";
import { import {
getAllKeywordsWithCategory, getAllKeywordsWithCategory,
type KeywordWithCategory, type KeywordWithCategory,
@ -15,10 +15,12 @@ function normalize(str: string): string {
interface AllKeywordsPanelProps { interface AllKeywordsPanelProps {
onSelectCategory: (id: number) => void; onSelectCategory: (id: number) => void;
onRemove: (id: number) => void;
} }
export default function AllKeywordsPanel({ export default function AllKeywordsPanel({
onSelectCategory, onSelectCategory,
onRemove,
}: AllKeywordsPanelProps) { }: AllKeywordsPanelProps) {
const { t } = useTranslation(); const { t } = useTranslation();
const [keywords, setKeywords] = useState<KeywordWithCategory[]>([]); const [keywords, setKeywords] = useState<KeywordWithCategory[]>([]);
@ -89,6 +91,7 @@ export default function AllKeywordsPanel({
</th> </th>
<th className="pb-2 font-medium">{t("categories.priority")}</th> <th className="pb-2 font-medium">{t("categories.priority")}</th>
<th className="pb-2 font-medium">{t("transactions.category")}</th> <th className="pb-2 font-medium">{t("transactions.category")}</th>
<th className="pb-2 w-8"></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -111,6 +114,17 @@ export default function AllKeywordsPanel({
{k.category_name} {k.category_name}
</button> </button>
</td> </td>
<td className="py-2">
<button
onClick={() => {
onRemove(k.id);
setKeywords((prev) => prev.filter((kw) => kw.id !== k.id));
}}
className="p-1 text-[var(--muted-foreground)] hover:text-[var(--negative)] transition-colors"
>
<X size={14} />
</button>
</td>
</tr> </tr>
))} ))}
</tbody> </tbody>

View file

@ -87,6 +87,7 @@ export default function CategoriesPage() {
setShowAllKeywords(false); setShowAllKeywords(false);
selectCategory(id); selectCategory(id);
}} }}
onRemove={removeKeyword}
/> />
) : ( ) : (
<div className="flex gap-6" style={{ minHeight: "calc(100vh - 180px)" }}> <div className="flex gap-6" style={{ minHeight: "calc(100vh - 180px)" }}>