Skip to content

Commit

Permalink
minor prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
tuckner committed Dec 16, 2023
1 parent 5d896af commit 44429c2
Show file tree
Hide file tree
Showing 8 changed files with 343 additions and 185 deletions.
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,17 @@
"@types/react": "^18.0.21",
"@types/react-dom": "^18.0.6",
"@typescript-eslint/eslint-plugin": "^6.7.3",
"@typescript-eslint/parser": "^6.7.3",
"@typescript-eslint/parser": "^5.0.1",
"@vitejs/plugin-react": "^2.1.0",
"autoprefixer": "^10.4.12",
"cypress": "^13.2.0",
"eslint": "^8.50.0",
"eslint": "^8.7.0",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"postcss": "^8.4.16",
"prettier": "3.1.1",
"tailwindcss": "^3.1.8",
"typescript": "^4.9.5",
"typescript": "^4.4.4",
"vite": "^3.1.0",
"vite-plugin-eslint": "^1.8.1",
"vite-tsconfig-paths": "^3.5.1"
Expand Down
20 changes: 16 additions & 4 deletions src/components/Board/AddBoard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ interface Props {
function AddBoard({ handleClose, active }: Props) {
const dispatch = useDispatch();
const data = useSelector(appData);
const board :IBoard[] = data.board;
const board: IBoard[] = data.board;
const toast = useToast();

const TaskSchema = Yup.object().shape({
Expand Down Expand Up @@ -59,7 +59,19 @@ function AddBoard({ handleClose, active }: Props) {
initialValues={
active
? { id: active.id, name: active.name, columns: active.columns }
: { id: uuidv4(), name: "", columns: [{"id": uuidv4(), "name": "Alert Handling", tasks: []}, {"id": uuidv4(), "name": "Issue Tracking", tasks: []}, {"id": uuidv4(), "name": "Enrichment", tasks: []}, {"id": uuidv4(), "name": "User Interaction", tasks: []}, {"id": uuidv4(), "name": "Response", tasks: []}, {"id": uuidv4(), "name": "Continuity", tasks: []}, {"id": uuidv4(), "name": "Procedural", tasks: []}] }
: {
id: uuidv4(),
name: "",
columns: [
{ id: uuidv4(), name: "Alert Handling", tasks: [] },
{ id: uuidv4(), name: "Issue Tracking", tasks: [] },
{ id: uuidv4(), name: "Enrichment", tasks: [] },
{ id: uuidv4(), name: "User Interaction", tasks: [] },
{ id: uuidv4(), name: "Response", tasks: [] },
{ id: uuidv4(), name: "Continuity", tasks: [] },
{ id: uuidv4(), name: "Procedural", tasks: [] },
],
}
}
validationSchema={TaskSchema}
validateOnChange={false}
Expand Down Expand Up @@ -93,7 +105,7 @@ function AddBoard({ handleClose, active }: Props) {
/>
))}
<button
aria-label="Add column"
aria-label="Add column"
className="bg-white mt-3 font-bold text-sm text-primary p-2 w-full rounded-full"
type="button"
onClick={() => {
Expand Down Expand Up @@ -122,7 +134,7 @@ function AddBoard({ handleClose, active }: Props) {
</div>

<button
aria-label="Board"
aria-label="Board"
className="bg-primary p-2 w-full text-sm rounded-full"
type="submit"
>
Expand Down
18 changes: 9 additions & 9 deletions src/components/Board/AddTask.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,16 @@ export default function AddTask({ handleClose, tasks }: Props) {
)?.name
);


const TaskSchema = Yup.object().shape({
name: Yup.string().required("Required"),
description: Yup.string(),
category: Yup.string().required("Required"),
subtasks: Yup.array()
.of(
Yup.object().shape({
title: Yup.string(),
isCompleted: Yup.boolean(),
})
),
subtasks: Yup.array().of(
Yup.object().shape({
title: Yup.string(),
isCompleted: Yup.boolean(),
})
),
});

const addTaskHandler = (values: ITask) => {
Expand Down Expand Up @@ -80,7 +78,9 @@ export default function AddTask({ handleClose, tasks }: Props) {

return (
<div>
<h1 className="font-bold pb-2 px-4">{tasks ? "Edit" : "Add new"} capability</h1>
<h1 className="font-bold pb-2 px-4">
{tasks ? "Edit" : "Add new"} capability
</h1>
<div className="overflow-y-auto h-[25rem] px-4">
<Formik
initialValues={
Expand Down
13 changes: 6 additions & 7 deletions src/components/Board/TaskDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export default function TaskDetails({
</div>
</div>
<div className="text-xs text-gray my-2">
<p>ID: A{tasks.id}</p>
<p>ID: A{tasks.id}</p>
</div>
<div>
<p className="text-sm my-4">
Expand All @@ -103,10 +103,11 @@ export default function TaskDetails({
</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) => (
<Linkify as="p" options={linkoptions}>
{tasks.techniques &&
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>
Expand All @@ -121,9 +122,7 @@ export default function TaskDetails({
key={index}
className="dark:bg-secondary-dark bg-offwhite flex items-center gap-x-4 rounded-sm p-3 mt-2"
>
<p>
{subtask.title}
</p>
<p>{subtask.title}</p>
</div>
);
})}
Expand Down
43 changes: 24 additions & 19 deletions src/components/Board/TaskItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,30 @@ export default function TaskItem({ tasks, index }: Props) {
{tasks.subtasks.length} workflows
</p>
<div className="pt-2 text-xs text-gray content-end font-bold">
{" "}
<div className="flex justify-end">
<BsCircleFill
className=""
onClick={handleOpenModal}
style={{
color: tasks.subtasks.length === 1 ? "#e6e22e" : tasks.subtasks.length >= 2 ? "#238823" : "#e64747"
}}
/>
</div>
</div>
</div>
);
}}
</Draggable>
{/* <Icon type="board" /> */}
<Modal open={isOpen} handleClose={() => setIsOpen(false)}>
<TaskDetails
subtasks={tasks.subtasks}
{" "}
<div className="flex justify-end">
<BsCircleFill
className=""
onClick={handleOpenModal}
style={{
color:
tasks.subtasks.length === 1
? "#e6e22e"
: tasks.subtasks.length >= 2
? "#238823"
: "#e64747",
}}
/>
</div>
</div>
</div>
);
}}
</Draggable>
{/* <Icon type="board" /> */}
<Modal open={isOpen} handleClose={() => setIsOpen(false)}>
<TaskDetails
subtasks={tasks.subtasks}
tasks={tasks}
handleClose={() => setIsOpen(false)}
index={index}
Expand Down
60 changes: 30 additions & 30 deletions src/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ export default function Header() {
const editBoard = () => {
setOpenBoard(true);
setOpenMenu(false);

};
const handleOpenMenu = ()=> setOpenMenu(false)
const handleOpenMenu = () => setOpenMenu(false);
const isMobile = useMediaQuery({ query: "(min-width: 700px)" });
return (
<>
Expand Down Expand Up @@ -71,18 +70,21 @@ export default function Header() {
)}

<div className="flex items-center">
<div className="pr-4"></div>
<div className="flex items-center">
<label htmlFor="Search" className="sr-only"> Search </label>
<input
type="text"
id="Search"
placeholder="Filter..."
onChange={(e) => handleFilterChange(e.target.value)}
className="w-full rounded-md border-gray-200 py-2.5 pl-3 pe-10 shadow-sm sm:text-sm"
/>
</div>
<div className="pr-4"></div>
<div className="pr-4"></div>
<div className="flex items-center">
<label htmlFor="Search" className="sr-only">
{" "}
Search{" "}
</label>
<input
type="text"
id="Search"
placeholder="Filter..."
onChange={(e) => handleFilterChange(e.target.value)}
className="w-full rounded-md border-gray-200 py-2.5 pl-3 pe-10 shadow-sm sm:text-sm"
/>
</div>
<div className="pr-4"></div>
<button
aria-label="Add capability"
onClick={() => setIsOpen(true)}
Expand All @@ -96,23 +98,21 @@ export default function Header() {
<span className="py-8"> + Add capability</span>
)}
</button>
<div className="pr-4"></div>
<div className="pr-4">
</div>
<div className="pr-4">
<button
aria-label="Export"
onClick={() => exportConfig()}
className={`rounded-full bg-primary text-sm font-bold text-white ${
!isMobile ? "w-[40px]" : "w-32"
} h-[40px]`}
>
{!isMobile ? (
<IoIosAdd className="inline-flex" />
) : (
<span className="py-8">Export</span>
)}
</button>

<button
aria-label="Export"
onClick={() => exportConfig()}
className={`rounded-full bg-primary text-sm font-bold text-white ${
!isMobile ? "w-[40px]" : "w-32"
} h-[40px]`}
>
{!isMobile ? (
<IoIosAdd className="inline-flex" />
) : (
<span className="py-8">Export</span>
)}
</button>
</div>
<div>
<BiDotsVerticalRounded
Expand Down
12 changes: 6 additions & 6 deletions src/utilis/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ export const exportConfig = () => {
try {
const boardData = localStorage.getItem("boarddata");
if (boardData) {
const raw = JSON.parse(boardData).board
const data = {"schema": 1, "config": raw}
data.config.active = 0
const acmexport = JSON.stringify(data, null, 2)
const raw = JSON.parse(boardData).board;
const data = { schema: 1, config: raw };
data.config.active = 0;
const acmexport = JSON.stringify(data, null, 2);
const blob = new Blob([acmexport], { type: "application/json" });
const url = URL.createObjectURL(blob);
const link = document.createElement("a");
Expand Down Expand Up @@ -87,11 +87,11 @@ export const saveState = (state: any) => {
const serializesState = JSON.stringify(state);
localStorage.setItem("boarddata", serializesState);
} catch (err) {
return err
return err;
}
};

export const checkDuplicatedBoard = (values: IBoard, board: IBoard[]) => {
export const checkDuplicatedBoard = (values: IBoard, board: IBoard[]) => {
return board.some((el: IBoard) => el.name === values.name);
};

Expand Down
Loading

0 comments on commit 44429c2

Please sign in to comment.