From ea91f9dad81dac0b975a8aacc65d5d1c2b070122 Mon Sep 17 00:00:00 2001 From: DeDxYk594 Date: Mon, 25 Nov 2024 19:06:01 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D1=8B=20=D0=BA=D0=BD=D0=BE=D0=BF=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/KanbanCard.tsx | 22 ++++----- src/components/KanbanColumn.tsx | 4 +- src/containers/CardDetails.tsx | 82 +++++++++++++++++++++++---------- 3 files changed, 70 insertions(+), 38 deletions(-) diff --git a/src/components/KanbanCard.tsx b/src/components/KanbanCard.tsx index 186d10a..060a21d 100644 --- a/src/components/KanbanCard.tsx +++ b/src/components/KanbanCard.tsx @@ -13,11 +13,9 @@ import { setCardDetailsStore } from '@/stores/cardDetailsStore'; import { Card } from '@/types/card'; interface KanbanCardProps extends ComponentProps { - text: string; - cardId: number; + card: Card; columnId: number; columnIdx: number; - coverImageUrl?: string; } interface EditableProps extends ComponentProps { @@ -70,6 +68,7 @@ const Editable = (props: EditableProps) => { export const KanbanCard = (props: KanbanCardProps) => { const activeBoard = useActiveBoardStore() as ActiveBoard; + const card = props.card; const [isInput, setIsInput] = useState(false); let timer: number; const editCallback = () => { @@ -83,10 +82,10 @@ export const KanbanCard = (props: KanbanCardProps) => {
{ - deleteCard(props.cardId).then(() => { + deleteCard(card.id).then(() => { activeBoard.columns.forEach((column) => { column.cards = column.cards.filter((card) => { - return card.id !== props.cardId; + return card.id !== card.id; }); }); setActiveBoardStore(activeBoard); @@ -96,14 +95,14 @@ export const KanbanCard = (props: KanbanCardProps) => {
)} - {props.coverImageUrl !== undefined ? ( - + {card.coverImageUrl !== undefined ? ( + ) : undefined} {isInput ? ( { activeBoard.columns[props.columnIdx].cards = activeBoard.columns[ props.columnIdx @@ -127,16 +126,17 @@ export const KanbanCard = (props: KanbanCardProps) => { ON_click={() => { clearTimeout(timer); timer = setTimeout(() => { - getCardDetails(props.cardId).then((val) => { + getCardDetails(card.id).then((val) => { setCardDetailsStore(val); console.log(val); }); }, 300); }} > - {props.text} + {card.title} )} + {} ); }; diff --git a/src/components/KanbanColumn.tsx b/src/components/KanbanColumn.tsx index e3b6f5d..8a6075c 100644 --- a/src/components/KanbanColumn.tsx +++ b/src/components/KanbanColumn.tsx @@ -96,11 +96,9 @@ export const KanbanColumn = (props: KanbanColumnProps) => { return ( ); })} diff --git a/src/containers/CardDetails.tsx b/src/containers/CardDetails.tsx index 8677637..cc5297b 100644 --- a/src/containers/CardDetails.tsx +++ b/src/containers/CardDetails.tsx @@ -184,6 +184,37 @@ export const CardDetailsContainer = (props: ComponentProps) => { const [newComment, setNewComment] = useState(''); const [newCheckListField, setNewCheckListField] = useState(''); const [newAssigned, setNewAssigned] = useState(''); + + const addCLF = () => { + addCheckListField(cardDetails.card.id, newCheckListField).then((clf) => { + if (clf !== undefined) { + setNewCheckListField(''); + cardDetails.checkList.push(clf); + setCardDetailsStore(cardDetails); + } + }); + }; + + const addComm = () => { + createComment(cardDetails.card.id, newComment).then((comment) => { + if (comment !== undefined) { + setNewComment(''); + cardDetails.comments.push(comment); + setCardDetailsStore(cardDetails); + } + }); + }; + + const addAssigned = () => { + assignUser(cardDetails.card.id, newAssigned).then((u) => { + if (u !== undefined) { + setNewAssigned(''); + cardDetails.assignedUsers.push(u); + setCardDetailsStore(cardDetails); + } + }); + }; + return (
@@ -199,27 +230,29 @@ export const CardDetailsContainer = (props: ComponentProps) => { { - addCheckListField(cardDetails.card.id, text).then((clf) => { - if (clf !== undefined) { - cardDetails.checkList.push(clf); - setCardDetailsStore(cardDetails); - } - }); + onEnter={addCLF} + onChanged={(newText) => { + setNewCheckListField(newText); }} /> +
);