From 217bcf08a6a07096c5681ee98a733d7e003ad0c3 Mon Sep 17 00:00:00 2001 From: Kayne Ruse Date: Wed, 3 Feb 2021 12:22:39 +1100 Subject: [PATCH] Added news editor --- README.md | 7 +- client/components/pages/admin.jsx | 2 + client/components/panels/news-editor.jsx | 110 ++++ client/components/panels/news-feed.jsx | 4 +- client/components/panels/news-publisher.jsx | 2 + package-lock.json | 614 ++++++++++++++++++-- package.json | 1 + 7 files changed, 671 insertions(+), 69 deletions(-) create mode 100644 client/components/panels/news-editor.jsx diff --git a/README.md b/README.md index 3176c64..daae09e 100644 --- a/README.md +++ b/README.md @@ -40,17 +40,16 @@ TODO: more info. - Administration Panel - ~~Exclusive to admin accounts~~ - inspect aggregate user data -- News blog system (microservice) +- ~~News blog system (microservice)~~ - ~~build the microservice to provide the news feed~~ - ~~access an external news feed~~ - - admin panel for publishing and editing news - - "created at" and "updated at" in the response + - ~~admin panel for publishing and editing news~~ + - ~~"created at" and "updated at" in the response~~ - Chat system (microservice) - Based on usernames - Chat logs - Direct Messages & rooms - admin panel banning/unbanning (currently borked) -- Achievements? - Privacy policy & data collection notice # Email settings diff --git a/client/components/pages/admin.jsx b/client/components/pages/admin.jsx index c011d5a..936708b 100644 --- a/client/components/pages/admin.jsx +++ b/client/components/pages/admin.jsx @@ -4,6 +4,7 @@ import { useCookies } from 'react-cookie'; //import BannedEmails from '../panels/banned-emails'; import NewsPublisher from '../panels/news-publisher'; +import NewsEditor from '../panels/news-editor'; const Admin = props => { const [cookies, setCookie] = useCookies(); @@ -17,6 +18,7 @@ const Admin = props => {

Administration

+
); }; diff --git a/client/components/panels/news-editor.jsx b/client/components/panels/news-editor.jsx new file mode 100644 index 0000000..2bd699d --- /dev/null +++ b/client/components/panels/news-editor.jsx @@ -0,0 +1,110 @@ +import React, { useState } from 'react'; +import Select from 'react-dropdown-select'; + +//DOCS: props.uri is the address of a live news-server +//DOCS: props.newsKey is the key of the live news-server +const NewsEditor = props => { + let titleElement, authorElement, bodyElement; + const [articles, setArticles] = useState(null); + const [index, setIndex] = useState(null); + + if (!articles) { + fetch(`${props.uri}/titles?limit=999`, { method: 'GET' }) + .then(a => { + if (!a.ok) { + throw `Network error ${a.status}: ${a.statusText} ${a.url}`; + } + return a.json(); + }) + .then(a => setArticles(a)) + .catch(e => console.error(e)) + ; + } + + return ( +
+

News Editor

+
+ + titleElement = e } /> +
+ +
+ + authorElement = e } /> +
+ +
+ +