Skip to content

Commit

Permalink
techniques
Browse files Browse the repository at this point in the history
  • Loading branch information
tuckner committed Dec 19, 2023
1 parent 420695a commit 093a962
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 17 deletions.
9 changes: 6 additions & 3 deletions src/components/Board/AddTask.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import { appData, addTask, editTask, deleteTask } from "redux/boardSlice";
import { useDispatch, useSelector } from "react-redux";
import { checkDuplicatedTask } from "utilis";
import { useToast } from "@chakra-ui/react";
import { v4 as uuidv4 } from "uuid";

const generateRandomNumber = (): string => {
return String(Math.floor(Math.random() * (9999 - 9000 + 1)) + 9000);
};

interface Props {
handleClose: () => void;
Expand Down Expand Up @@ -94,7 +97,7 @@ export default function AddTask({ handleClose, tasks }: Props) {
subtasks: tasks.subtasks,
}
: {
id: uuidv4().slice(5),
id: generateRandomNumber(),
name: "",
description: "",
category: selectedColumn,
Expand Down Expand Up @@ -149,7 +152,7 @@ export default function AddTask({ handleClose, tasks }: Props) {
type="button"
onClick={() => {
arrayHelpers.push({
id: uuidv4().slice(5),
id: generateRandomNumber(),
title: "",
isCompleted: false,
});
Expand Down
23 changes: 14 additions & 9 deletions src/components/Board/TaskDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,20 @@ export default function TaskDetails({
{tasks.description ? tasks.description : "No description"}
</Linkify>
</p>
<p className=" text-sm font-bold mb-2 ">Techniques:</p>
<p className="text-sm my-3">
<Linkify as="p" options={linkoptions}>
{tasks.techniques &&
tasks.techniques.map((technique: string, index: number) => (
<li key={index}>{technique}</li>
))}
</Linkify>
</p>
{tasks.techniques && tasks.techniques.length > 0 && (
<>
<p className="text-sm font-bold mb-2">Techniques:</p>
<p className="text-sm my-3">
<Linkify as="p" options={linkoptions}>
{tasks.techniques.map(
(technique: string, index: number) => (
<li key={index}>{technique}</li>
)
)}
</Linkify>
</p>
</>
)}
<p className=" text-sm font-bold mb-2 ">{`Workflows: ${tasks.subtasks.length}`}</p>
<div
className={`overflow-y-auto px-4 ${
Expand Down
4 changes: 1 addition & 3 deletions src/components/Board/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import { addTask, appData, deleteTask } from "redux/boardSlice";
import { Droppable, DragDropContext } from "@hello-pangea/dnd";
// import { randomColor } from "utilis";

import { v4 as uuidv4 } from "uuid";

export default function Index() {
const data = useSelector(appData);
const dispatch = useDispatch();
Expand All @@ -36,7 +34,7 @@ export default function Index() {
dispatch(deleteTask(sourceTask));
const updatedTasks = {
...sourceTask,
id: uuidv4().slice(5),
id: sourceTask?.id,
status: result.destination.droppableId,
};
const position = result.destination.index;
Expand Down
4 changes: 2 additions & 2 deletions src/components/SelectBox/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { BiChevronUp, BiChevronDown } from "react-icons/bi";
import { IBoard, IColumn, ITask } from "types";
import { addTask, appData, deleteTask } from "redux/boardSlice";
import { useDispatch, useSelector } from "react-redux";
import { v4 as uuidv4 } from "uuid";

interface Props {
selectedColumn: string;
setSelectedColumn: Dispatch<SetStateAction<string>>;
Expand All @@ -25,7 +25,7 @@ export default function Index({ selectedColumn, setSelectedColumn, tasks }: Prop
if (tasks && 'status' in tasks && tasks.status !== title) {
const updatedTasks = {
...tasks,
id: uuidv4().slice(5),
id: tasks.id,
status: title,
};
dispatch(addTask({ updatedTasks, position: 0 }));
Expand Down

0 comments on commit 093a962

Please sign in to comment.