generated from TetiZ/vite-react-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a4e4f64
commit 5419eee
Showing
15 changed files
with
121 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,22 @@ | ||
import { useState, useEffect } from "react"; | ||
import CreateBoardBtn from "../CreateBoardBtn/CreateBoardBtn"; | ||
import Board from "../Board/Board"; | ||
|
||
import css from "./BoardList.module.css"; | ||
import bgData from "../../assets/bg.json"; | ||
import { useSelector } from "react-redux"; | ||
import { selectBoards } from "../../redux/boards/selectors.js"; | ||
|
||
export default function BoardList() { | ||
const [boards, setBoards] = useState([]); | ||
|
||
useEffect(() => { | ||
const storedBoards = JSON.parse(localStorage.getItem("boardData")) || []; | ||
setBoards(storedBoards); | ||
}, []); | ||
|
||
const getBgById = (id) => { | ||
const { | ||
id: _, | ||
mini, | ||
mini2x, | ||
...bgs | ||
} = bgData.find((item) => item.id === id) || {}; | ||
return bgs; | ||
}; | ||
const boards = useSelector(selectBoards); | ||
|
||
return ( | ||
<> | ||
<h3 className={css.title}>My boards</h3> | ||
|
||
<CreateBoardBtn /> | ||
|
||
<ul className={css.list}> | ||
{boards.map((board, index) => { | ||
const bg = getBgById(board.background); | ||
return ( | ||
<Board | ||
key={index} | ||
title={board.title} | ||
icon={board.icon} | ||
background={bg} | ||
/> | ||
); | ||
})} | ||
</ul> | ||
<div className={css.list}> | ||
{boards.map((board) => ( | ||
<Board key={board._id} board={board} /> | ||
))} | ||
</div> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.