From 167dacb51ba99201aede4b65c0b9f00e0d68a28c Mon Sep 17 00:00:00 2001 From: Dadayat <136356333+Dadayat@users.noreply.github.com> Date: Sat, 15 Jun 2024 10:03:09 +0300 Subject: [PATCH] add render board logic --- .../HeaderDashboard/HeaderDashboard.jsx | 28 ++++++++--------- .../MainDashboard/MainDashboard.jsx | 23 +++++++------- src/components/ScreensPage/ScreensPage.jsx | 31 ++++++++++++++----- 3 files changed, 50 insertions(+), 32 deletions(-) diff --git a/src/components/HeaderDashboard/HeaderDashboard.jsx b/src/components/HeaderDashboard/HeaderDashboard.jsx index c5fb905..f2963f0 100644 --- a/src/components/HeaderDashboard/HeaderDashboard.jsx +++ b/src/components/HeaderDashboard/HeaderDashboard.jsx @@ -1,16 +1,16 @@ -import css from "./HeaderDashboard.module.css" +import css from "./HeaderDashboard.module.css"; import svg from "../../img/icons.svg"; -export const HeaderDashboard = () => { - return ( -
-

Project office

- -
- ); -}; \ No newline at end of file +export const HeaderDashboard = ({ boardName }) => { + return ( +
+

{boardName}

+ +
+ ); +}; diff --git a/src/components/MainDashboard/MainDashboard.jsx b/src/components/MainDashboard/MainDashboard.jsx index 542cb34..aa5df37 100644 --- a/src/components/MainDashboard/MainDashboard.jsx +++ b/src/components/MainDashboard/MainDashboard.jsx @@ -1,16 +1,17 @@ import { AddColumnBtn } from "../AddColumnBtn/AddColumnBtn"; -import { DashboardMessage } from "../DashboardMessage/DashboardMessage"; import { TaskColumn } from "../TaskColumn/TaskColumn"; import css from "./MainDashboard.module.css"; -export const MainDashboard = () => { - return ( -
- {/* */} -
- - -
-
- ); +export const MainDashboard = ({ board }) => { + return ( +
+
+ {board.columns && board.columns.map(column => ( + + ))} + +
+
+ ); }; + diff --git a/src/components/ScreensPage/ScreensPage.jsx b/src/components/ScreensPage/ScreensPage.jsx index ef49763..e854092 100644 --- a/src/components/ScreensPage/ScreensPage.jsx +++ b/src/components/ScreensPage/ScreensPage.jsx @@ -1,12 +1,29 @@ -import { HeaderDashboard } from "../HeaderDashboard/HeaderDashboard" -import { MainDashboard } from "../MainDashboard/MainDashboard" -import css from "./ScreensPage.module.css" +import { useEffect } from "react"; +import { useDispatch, useSelector } from "react-redux"; +import { getBoards } from "../../redux/boards/operations"; +import { selectBoards, selectLoading, selectError } from "../../redux/boards/selectors"; +import { HeaderDashboard } from "../HeaderDashboard/HeaderDashboard"; +import { MainDashboard } from "../MainDashboard/MainDashboard"; +import { DashboardMessage } from "../DashboardMessage/DashboardMessage"; +import css from "./ScreensPage.module.css"; export const ScreensPage = () => { + const dispatch = useDispatch(); + const boards = useSelector(selectBoards); + const loading = useSelector(selectLoading); + const error = useSelector(selectError); + + useEffect(() => { + dispatch(getBoards()); + }, [dispatch]); + + if (loading) return

Loading...

; + if (error) return

Error loading boards

; + return (
- - + + {boards.length ? : }
- ) -} \ No newline at end of file + ); +};