diff --git a/client/package-lock.json b/client/package-lock.json index 289c4eb..0b6abc7 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -14,6 +14,7 @@ "axios": "^1.7.2", "react": "^18.2.0", "react-dom": "^18.2.0", + "react-link-preview": "^0.1.3", "react-modal": "^3.16.1", "react-router-dom": "^6.23.1", "uuid": "^10.0.0" @@ -8966,6 +8967,17 @@ "resolved": "https://registry.npmjs.org/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz", "integrity": "sha512-fBASbA6LnOU9dOU2eW7aQ8xmYBSXUIWr+UmF9b1efZBazGNO+rcXT/icdKnYm2pTwcRylVUYwW7H1PHfLekVzA==" }, + "node_modules/react-link-preview": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/react-link-preview/-/react-link-preview-0.1.3.tgz", + "integrity": "sha512-lxDUynQcuDVfqft8kqq3xuFh3U4uunsfjbNaCHPFKHM1gtwpNV94FlefF2ATFvOEZQkwbK2SO+4qbS4gmYGD2w==", + "peerDependencies": { + "react": "^15.3.0 || ^16.2.0", + "react-dom": "^15.3.0 || ^16.2.0", + "react-router": "^4.1.1", + "react-router-dom": "^4.1.1" + } + }, "node_modules/react-modal": { "version": "3.16.1", "resolved": "https://registry.npmjs.org/react-modal/-/react-modal-3.16.1.tgz", diff --git a/client/src/components/BoardComponent.tsx b/client/src/components/BoardComponent.tsx index 46262f3..2b51dd1 100644 --- a/client/src/components/BoardComponent.tsx +++ b/client/src/components/BoardComponent.tsx @@ -85,6 +85,12 @@ const BoardComponent: React.FC = () => { const sourceCards = filterCardsByColumn(source.droppableId); const destinationCards = filterCardsByColumn(destination.droppableId); + // Prevent moving any card to the position before the `newCard` + if (destination.droppableId === "Backlog" && destination.index === 0) { + console.log("Cannot move above the new card placeholder."); + destination.index = 1; + } + moveCard(sourceCards, movedCard, sourceCards.length); // just call this to remove it from the source cards it automatically filters it out movedCard.column = columns.find( (col) => col.title === destination.droppableId @@ -112,70 +118,76 @@ const BoardComponent: React.FC = () => {
{columns.map((col) => ( - - {(provided, _) => ( -
-

- {col.title} -

-
    - {selectedBoard! - .cards!.filter((card) => card.column === col.key) - .sort((a, b) => a.order - b.order) - .map((card) => - card.id === "0" ? ( -
  • setSelectedCard(card)} - > -

    - {card.cardName} -

    - {card.details.timeEstimate && - card.details.timeEstimate > 0 ? ( -

    {card.details.timeEstimate} minutes

    - ) : ( - "" - )} -
  • - ) : ( - - {(provided, _) => ( -
  • setSelectedCard(card)} - > -

    - {card.cardName} -

    - {card.details.timeEstimate && - card.details.timeEstimate > 0 ? ( -

    {card.details.timeEstimate} minutes

    - ) : ( - "" - )} -
  • - )} -
    - ) - )} - {provided.placeholder} -
-
- )} -
+
+

+ {col.title} +

+ + {(provided, _) => ( +
+
    + {selectedBoard! + .cards!.filter((card) => card.column === col.key) + .sort((a, b) => a.order - b.order) + .map((card) => + card.id === "0" ? ( +
  • setSelectedCard(card)} + > +

    + {card.cardName} +

    + {card.details.timeEstimate && + card.details.timeEstimate > 0 ? ( +

    {card.details.timeEstimate} minutes

    + ) : ( + "" + )} +
  • + ) : ( + + {(provided, _) => ( +
  • setSelectedCard(card)} + > +

    + {card.cardName} +

    + {card.details.timeEstimate && + card.details.timeEstimate > 0 ? ( +

    + {card.details.timeEstimate} minutes +

    + ) : ( + "" + )} +
  • + )} +
    + ) + )} + {provided.placeholder} +
+
+ )} +
+
))}
diff --git a/client/src/components/CardDetails.tsx b/client/src/components/CardDetails.tsx index 1b203d5..236bd09 100644 --- a/client/src/components/CardDetails.tsx +++ b/client/src/components/CardDetails.tsx @@ -1,10 +1,11 @@ import React, { useState, ChangeEvent } from "react"; -import { Card, ChecklistEntry, Columns } from "../types"; +import { Card, ChecklistEntry } from "../types"; import useKeyPress from "../hooks/useKeyPress"; import CreateCardComponent from "./CreateCardComponent"; import { useBoard } from "../context/BoardContext"; +import CheckboxItem from "./CheckboxItem"; const CardDetails: React.FC = () => { const { selectedCard, setSelectedCard, handleUpdateCard, handleDeleteCard } = @@ -75,29 +76,6 @@ const CardDetails: React.FC = () => { setIsConfirmingDelete(false); }; - const toggleCheck = (index: number) => { - if (!selectedCard || !selectedCard.details.checklist) return; - if (selectedCard.column !== Columns.inProgress) return; - - setChecklistItems((prevItems) => { - const updatedChecklist = prevItems.map((item, idx) => { - return idx === index ? { ...item, checked: !item.checked } : item; - }); - - const newSelectedCard = { - ...selectedCard, - details: { - ...selectedCard.details, - checklist: updatedChecklist, - }, - }; - - handleUpdateCard(newSelectedCard); - - return updatedChecklist; - }); - }; - // Use custom hook to handle ESC key useKeyPress("Escape", () => setSelectedCard(null)); @@ -113,19 +91,17 @@ const CardDetails: React.FC = () => { onChange={(e: ChangeEvent) => setCardName(e.target.value) } - className="rounded mb-2 w-full text-lg font-bold bg-white" + className="rounded mb-2 pl-2 w-full text-lg font-bold bg-white" /> -