Skip to content

Commit a8f5743

Browse files
committed
feat: Add category deletion functionality in Kanban board
1 parent b6e16fa commit a8f5743

4 files changed

Lines changed: 44 additions & 15 deletions

File tree

src/components/kanban/KanbanBoard.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,26 @@ export default function KanbanBoard({ projectId }: KanbanBoardProps) {
401401
}
402402
};
403403

404+
const handleDeleteCategory = async (categoryId: string) => {
405+
if (!projectId) {
406+
setError('No project selected');
407+
return;
408+
}
409+
410+
try {
411+
setLoading(true);
412+
await categoriesApi.deleteCategory(categoryId);
413+
414+
// Remove column from state
415+
setColumns(cols => cols.filter(col => col.id !== categoryId));
416+
} catch (e: unknown) {
417+
const msg = (e as Error)?.message || 'Failed to delete category';
418+
setError(msg);
419+
} finally {
420+
setLoading(false);
421+
}
422+
};
423+
404424
const handleTaskClick = async (task: Task) => {
405425
console.log('Task clicked:', task);
406426
setSelectedTask(task);
@@ -480,6 +500,7 @@ export default function KanbanBoard({ projectId }: KanbanBoardProps) {
480500
column={column}
481501
onAddTask={handleAddTask}
482502
onTaskClick={handleTaskClick}
503+
onDeleteColumn={handleDeleteCategory}
483504
/>
484505
))}
485506
<div className={styles.kanbanAddColumn}>

src/components/kanban/KanbanColumn.tsx

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useDroppable } from '@dnd-kit/core';
22
import { SortableContext, verticalListSortingStrategy } from '@dnd-kit/sortable';
33
import { Button, Text } from '@fluentui/react-components';
4-
import { Add20Regular } from '@fluentui/react-icons';
4+
import { Add20Regular, Delete20Regular } from '@fluentui/react-icons';
55
import { mainLayoutStyles } from '../styles/Styles';
66
import KanbanCard, { type Task } from './KanbanCard';
77

@@ -15,9 +15,10 @@ interface KanbanColumnProps {
1515
column: Column;
1616
onAddTask?: (columnId: string) => void;
1717
onTaskClick?: (task: Task) => void;
18+
onDeleteColumn?: (columnId: string) => void;
1819
}
1920

20-
export default function KanbanColumn({ column, onAddTask, onTaskClick }: KanbanColumnProps) {
21+
export default function KanbanColumn({ column, onAddTask, onTaskClick, onDeleteColumn }: KanbanColumnProps) {
2122
const styles = mainLayoutStyles();
2223
const { setNodeRef, isOver } = useDroppable({
2324
id: column.id,
@@ -34,14 +35,24 @@ export default function KanbanColumn({ column, onAddTask, onTaskClick }: KanbanC
3435
<Text className={styles.kanbanColumnTitle}>
3536
{column.title} ({column.tasks.length})
3637
</Text>
37-
{onAddTask && (
38-
<Button
39-
appearance="transparent"
40-
icon={<Add20Regular />}
41-
size="small"
42-
onClick={() => onAddTask(column.id)}
43-
/>
44-
)}
38+
<div style={{ display: 'flex', gap: '4px' }}>
39+
{onAddTask && (
40+
<Button
41+
appearance="transparent"
42+
icon={<Add20Regular />}
43+
size="small"
44+
onClick={() => onAddTask(column.id)}
45+
/>
46+
)}
47+
{onDeleteColumn && (
48+
<Button
49+
appearance="transparent"
50+
icon={<Delete20Regular />}
51+
size="small"
52+
onClick={() => onDeleteColumn(column.id)}
53+
/>
54+
)}
55+
</div>
4556
</div>
4657

4758
<SortableContext items={taskIds} strategy={verticalListSortingStrategy}>

src/pages/project/KanbanPage.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,8 @@ export default function KanbanPage() {
2828
.finally(() => setLoadingProject(false));
2929
}, [decodedName]);
3030

31-
const title = decodedName || 'Project';
32-
3331
return (
3432
<Card className={`${styles.artifCard} ${styles.layoutPadding} ${styles.flexColFit} ${styles.gap}`}>
35-
<h1 className={styles.pageTitle}>{title} - Kanban</h1>
3633
{projectError && (
3734
<div style={{ color: tokens.colorPaletteRedForeground3 }}>{projectError}</div>
3835
)}

src/pages/project/ProjectPage.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
Dropdown,
2121
Option,
2222
} from '@fluentui/react-components';
23-
import { AddCircle20Regular, ChevronDown12Regular } from '@fluentui/react-icons';
23+
import { AddCircle20Regular } from '@fluentui/react-icons';
2424
import { useParams, useNavigate, useOutletContext } from 'react-router-dom';
2525
import { projectsApi, type Project } from '../../components/apis/projects';
2626
import { usersApi } from '../../components/apis/users';
@@ -411,7 +411,7 @@ export default function ProjectPage() {
411411
{/* Permission access not shown */}
412412
<TableCell>
413413
<div className={styles.personaRow} style={{ gap: tokens.spacingHorizontalXXS }}>
414-
<ChevronDown12Regular />
414+
415415
<span>{formatDate(member.joinedAt)}</span>
416416
</div>
417417
</TableCell>

0 commit comments

Comments
 (0)