diff options
author | Alexander Neonxp Kiryukhin <i@neonxp.ru> | 2024-10-29 01:21:05 +0300 |
---|---|---|
committer | Alexander Neonxp Kiryukhin <i@neonxp.ru> | 2024-10-29 01:21:05 +0300 |
commit | fd4e0c3112d69061d495dfcf79f6ef62e3c6d5e6 (patch) | |
tree | fa55d6e879e3c6d85601d5c2486837f323ffd81d /web/src/pages | |
parent | b26bd10926447ed59cbf263aef087bb7c04f35eb (diff) |
Diffstat (limited to 'web/src/pages')
-rw-r--r-- | web/src/pages/echo.js | 22 | ||||
-rw-r--r-- | web/src/pages/list.js | 21 |
2 files changed, 43 insertions, 0 deletions
diff --git a/web/src/pages/echo.js b/web/src/pages/echo.js new file mode 100644 index 0000000..6ba7e67 --- /dev/null +++ b/web/src/pages/echo.js @@ -0,0 +1,22 @@ +import React from "react"; +import { useLoaderData, useParams } from "react-router"; +import Message from "../components/message"; + +const Echo = () => { + const {echo, messages} = useLoaderData(); + const params = useParams(); + if (!echo) { + return (<article aria-busy="true">Загрузка списка сообщений</article>) + } + return ( + <> + <h1>{echo.name}</h1> + <p>Сообщений: {echo.count}</p> + {messages.map((message) => ( + <Message key={message.id} message={message} /> + ))} + </> + ); +}; + +export default Echo; diff --git a/web/src/pages/list.js b/web/src/pages/list.js new file mode 100644 index 0000000..a806622 --- /dev/null +++ b/web/src/pages/list.js @@ -0,0 +1,21 @@ +import React from "react"; +import { useLoaderData } from "react-router"; +import { Link } from "react-router-dom"; + +const List = () => { + const list = useLoaderData(); + + return list + .sort((e1, e2) => e2.count - e1.count) + .map((e) => ( + <article key={e.name}> + <header> + <Link to={`/e/${e.name}`}>{e.name}</Link> + [{e.count}] + </header> + {e.description} + </article> + )); +}; + +export default List; |