Written by {article.author}, {
+ article.edits > 0 ?
+ Last Updated {dateFormat(articles.updatedAt, 'fullDate')} ({`${article.edits} edit${article.edits > 1 ? 's': ''}`}) :
+ Published {dateFormat(articles.createdAt, 'fullDate')}
+ }
+
{article.body}
+
+ );
+ })}
+
+ );
+};
+
+export default NewsFeed;
\ No newline at end of file
diff --git a/front-ends/react/news-publisher.jsx b/front-ends/react/news-publisher.jsx
new file mode 100644
index 0000000..9bb1969
--- /dev/null
+++ b/front-ends/react/news-publisher.jsx
@@ -0,0 +1,70 @@
+import React from 'react';
+
+//DOCS: props.uri is the address of a live news-server
+//DOCS: props.newsKey is the key of the live news-server
+const NewsPublisher = props => {
+ let titleElement, authorElement, bodyElement;
+
+ return (
+
+
News Publisher
+
+
+ );
+};
+
+const handleSubmit = async (title, author, body, uri, newsKey) => {
+ title = title.trim();
+ author = author.trim();
+ body = body.trim();
+ uri = uri.trim();
+ newsKey = newsKey.trim();
+
+ //fetch POST json data
+ const raw = await fetch(
+ uri,
+ {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ 'Access-Control-Allow-Origin': '*'
+ },
+ body: JSON.stringify({ title: title, author: author, body: body, key: newsKey })
+ }
+ );
+
+ if (raw.ok) {
+ const result = await raw.json();
+
+ if (result.ok) {
+ alert(`Published article index ${result.index}`);
+ } else {
+ alert(result.error);
+ }
+ } else {
+ alert(raw.statusText);
+ }
+};
+
+export default NewsPublisher;
\ No newline at end of file