+ );
}
\ No newline at end of file
diff --git a/bfrontend/src/Components/Notification.js b/bfrontend/src/Components/Notification.js
new file mode 100644
index 0000000..2b8de06
--- /dev/null
+++ b/bfrontend/src/Components/Notification.js
@@ -0,0 +1,7 @@
+export default function Notification({ text }) {
+ return (
+
+
{ text }
+
+ );
+}
\ No newline at end of file
diff --git a/bfrontend/src/Components/Root.js b/bfrontend/src/Components/Root.js
new file mode 100644
index 0000000..dd1f267
--- /dev/null
+++ b/bfrontend/src/Components/Root.js
@@ -0,0 +1,21 @@
+import { useHistory } from 'react-router-dom';
+
+export default function Root(props) {
+ const history = useHistory();
+
+ if (props.user) {
+ return (
+
+
Welcome, { props.user.username }
+
+ );
+ } else {
+ return (
+
+
Welcome, - nevermind, you aren't logged in
+
+
+ );
+ }
+
+}
\ No newline at end of file
diff --git a/bfrontend/src/Config.js b/bfrontend/src/Config.js
index 44d7617..1c373a8 100644
--- a/bfrontend/src/Config.js
+++ b/bfrontend/src/Config.js
@@ -1,5 +1,5 @@
const config = {
- apiUrl: 'http://localhost:3002'
+ apiUrl: 'http://localhost:3000'
};
export default config;
\ No newline at end of file
diff --git a/bfrontend/src/Errors.js b/bfrontend/src/Errors.js
new file mode 100644
index 0000000..c6c81a2
--- /dev/null
+++ b/bfrontend/src/Errors.js
@@ -0,0 +1,113 @@
+const getLoginMessageFromError = (json) => {
+ switch (json.message) {
+ case 'ERROR_REQUEST_LOGIN_INVALID': {
+ return 'Invalid username or password.';
+ }
+
+ case 'ERROR_ACCESS_DENIED': {
+ return 'You are not allowed to perform this action.'
+ }
+
+ default: {
+ return 'Unknown error. Something went wrong.'
+ }
+ }
+}
+
+const getSignupMessageFromError = (json) => {
+ switch (json.message) {
+ case 'ERROR_REQUEST_INVALID_DATA': {
+
+ switch (json.errors[0].param) {
+ case 'username': {
+ return 'Invalid username. Username must be between 3 and 32 characters long, and be alphanumeric.';
+ }
+ case 'password': {
+ return 'Invalid password. Password must be at least 8 characters long and at most 128 characters.';
+ }
+ case 'email': {
+ return 'Invalid email.';
+ }
+ case 'specialCode': {
+ return 'Invalid special code.';
+ }
+
+ default: {
+ return 'Invalid value sent to server. Something went wrong.';
+ }
+ }
+
+ }
+
+ case 'ERROR_ACCESS_DENIED': {
+ return 'You are not allowed to perform this action.'
+ }
+
+ case 'ERROR_REQUEST_USERNAME_EXISTS': {
+ return 'That username is taken.';
+ }
+
+ default: {
+ return 'Unknown error. Something went wrong.'
+ }
+ }
+};
+
+const getCreatePostError = (json) => {
+ switch (json.message) {
+ case 'ERROR_REQUEST_INVALID_DATA': {
+ switch (json.errors[0].param) {
+ case 'title': {
+ return 'Invalid title. Must be between 3 and 32 characters.';
+ }
+ case 'body': {
+ return 'Invalid content. Must be between 3 and 1000 characters';
+ }
+ case 'category': {
+ return 'Invalid category. Something went wrong.';
+ }
+ default: {
+ return 'Invalid value sent to server. Something went wrong.';
+ }
+ }
+ }
+
+ case 'ERROR_CATEGORY_NOT_FOUND': {
+ return 'The category you tried to post to no longer exists.';
+ }
+
+ case 'ERROR_ACCESS_DENIED': {
+ return 'You are not allowed to perform this action.'
+ }
+
+ default: {
+ return 'Unknown error. Something went wrong.';
+ }
+ }
+};
+
+const getCreateCategoryError = (json) => {
+ switch (json.message) {
+ case 'ERROR_REQUEST_INVALID_DATA': {
+ switch (json.errors[0].param) {
+ case 'title': {
+ return 'Invalid title. Title must be between 3 and 32 characters.';
+ }
+
+ default: {
+ return 'Invalid value sent to server. Something went wrong.'
+ }
+ }
+ }
+
+ case 'ERROR_ACCESS_DENIED': {
+ return 'You are not allowed to perform this action.'
+ }
+
+ default: {
+ return 'Unknown error. Something went wrong.';
+ }
+ }
+};
+
+module.exports = { getLoginMessageFromError, getSignupMessageFromError, getCreatePostError, getCreateCategoryError }
\ No newline at end of file
diff --git a/bfrontend/src/index.js b/bfrontend/src/index.js
index bb73391..5711482 100644
--- a/bfrontend/src/index.js
+++ b/bfrontend/src/index.js
@@ -1,11 +1,16 @@
-import React from 'react';
-import ReactDOM from 'react-dom';
+import store from './store';
import './index.css';
import App from './Components/App';
+import React from 'react';
+import ReactDOM from 'react-dom';
+import { Provider } from 'react-redux';
+
ReactDOM.render(
-
+
+
+ ,
document.getElementById('root')
);
\ No newline at end of file
diff --git a/bfrontend/src/store.js b/bfrontend/src/store.js
new file mode 100644
index 0000000..885e684
--- /dev/null
+++ b/bfrontend/src/store.js
@@ -0,0 +1,20 @@
+import { createStore } from 'redux';
+
+const reducer = (state, payload) => {
+ switch (payload.type) {
+ case 'authenticator/updatelocaluserobject': {
+ return {
+ ...state,
+ user: payload.user
+ }
+ }
+
+ default: {
+ return state;
+ }
+ }
+};
+
+const store = createStore(reducer, window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__());
+
+export default store;
\ No newline at end of file