Skip to content

Commit 3bfd787

Browse files
author
DimaGalchenko
committed
* FE&BE: Implement list deleting
1 parent a68e7f5 commit 3bfd787

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

client/src/components/column/column.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ type Props = {
1818
listName: string;
1919
cards: Card[];
2020
index: number;
21+
onDelete: (id: string) => void;
2122
};
2223

23-
export const Column = ({ listId, listName, cards, index }: Props) => {
24+
export const Column = ({ listId, listName, cards, index, onDelete }: Props) => {
2425
return (
2526
<Draggable draggableId={listId} index={index}>
2627
{(provided: DraggableProvided, snapshot: DraggableStateSnapshot) => (
@@ -43,7 +44,7 @@ export const Column = ({ listId, listName, cards, index }: Props) => {
4344
isBold
4445
/>
4546
<Splitter />
46-
<DeleteButton color="#FFF0" onClick={() => {}} />
47+
<DeleteButton color="#FFF0" onClick={() => onDelete(listId)} />
4748
</Header>
4849
<CardsList listId={listId} listType="CARD" cards={cards} />
4950
<Footer onCreateCard={() => {}} />

client/src/pages/Workspace.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ export const Workspace = () => {
6868
socket.emit(ListEvent.CREATE, name);
6969
}
7070

71+
const onDeleteList = (listId: string) => {
72+
socket.emit(ListEvent.DELETE, listId)
73+
}
74+
7175
return (
7276
<React.Fragment>
7377
<DragDropContext onDragEnd={onDragEnd}>
@@ -85,6 +89,7 @@ export const Workspace = () => {
8589
listName={list.name}
8690
cards={list.cards}
8791
listId={list.id}
92+
onDelete={onDeleteList}
8893
/>
8994
))}
9095
{provided.placeholder}

server/src/handlers/list.handler.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class ListHandler extends SocketHandler {
99
socket.on(ListEvent.CREATE, this.createList.bind(this));
1010
socket.on(ListEvent.GET, this.getLists.bind(this));
1111
socket.on(ListEvent.REORDER, this.reorderLists.bind(this));
12+
socket.on(ListEvent.DELETE, this.deleteList.bind(this));
1213
}
1314

1415
private getLists(callback: (cards: List[]) => void): void {
@@ -32,6 +33,12 @@ class ListHandler extends SocketHandler {
3233
this.db.setData(lists.concat(newList));
3334
this.updateLists();
3435
}
36+
37+
private deleteList(id: string): void {
38+
const lists = this.db.getData();
39+
this.db.setData(lists.filter((list) => list.id !== id));
40+
this.updateLists();
41+
}
3542
}
3643

3744
export { ListHandler };

0 commit comments

Comments
 (0)