diff --git a/client/components/pages/admin.jsx b/client/components/pages/admin.jsx
index e91ef95..c011d5a 100644
--- a/client/components/pages/admin.jsx
+++ b/client/components/pages/admin.jsx
@@ -16,7 +16,7 @@ const Admin = props => {
return (
Administration
-
+
);
};
diff --git a/client/components/pages/homepage.jsx b/client/components/pages/homepage.jsx
index b8af805..fb1112c 100644
--- a/client/components/pages/homepage.jsx
+++ b/client/components/pages/homepage.jsx
@@ -7,7 +7,7 @@ const HomePage = props => {
return (
This is the MERN template homepage.
-
+
);
};
diff --git a/client/components/panels/news-publisher.jsx b/client/components/panels/news-publisher.jsx
index 1fcc701..d16fa66 100644
--- a/client/components/panels/news-publisher.jsx
+++ b/client/components/panels/news-publisher.jsx
@@ -1,5 +1,68 @@
+import React from 'react';
+
const NewsPublisher = props => {
- return null;
+ let titleElement, authorElement, bodyElement;
+
+ return (
+
+ );
+};
+
+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
diff --git a/webpack.config.js b/webpack.config.js
index f9fc297..6ea4f2f 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -1,4 +1,5 @@
//plugins
+const { DefinePlugin } = require('webpack');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
@@ -39,11 +40,17 @@ module.exports = ({ production, analyzer }) => {
]
},
plugins: [
+ new DefinePlugin({
+ 'process.env': {
+ 'NEWS_URI': '"http://dev-news.eggtrainer.com:3100/news"',
+ 'NEWS_KEY': '"key"',
+ }
+ }),
new CleanWebpackPlugin({
cleanOnceBeforeBuildPatterns: ['*', '!content*']
}),
new HtmlWebpackPlugin({
- template: "./client/template.html",
+ template: './client/template.html',
minify: {
collapseWhitespace: production,
removeComments: production,