mirror of
https://github.com/ClaytonWWilson/CS307-Team24.git
synced 2026-03-10 21:25:04 +00:00
Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d3bfd8b5f3 | ||
|
|
16567e2373 | ||
|
|
d3a77afe43 | ||
|
|
42b73632c0 | ||
|
|
c482f56762 | ||
|
|
9525ff7d0a | ||
|
|
f602b8251f | ||
|
|
70a12dcca4 | ||
|
|
657277bcad | ||
|
|
d69828ef7f | ||
|
|
5fa4caf0a3 | ||
|
|
fd226b454e | ||
|
|
0bbc453d54 | ||
|
|
e236ceeb4b | ||
|
|
1c81ae1663 | ||
|
|
c356dd18fa | ||
|
|
ec041732d9 |
@@ -8,6 +8,7 @@
|
|||||||
},
|
},
|
||||||
"functions": {
|
"functions": {
|
||||||
"predeploy": [
|
"predeploy": [
|
||||||
|
"npm --prefix \"$RESOURCE_DIR\" run lint"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"hosting": {
|
"hosting": {
|
||||||
|
|||||||
@@ -1,20 +1,18 @@
|
|||||||
|
/* eslint-disable prefer-arrow-callback */
|
||||||
/* eslint-disable promise/always-return */
|
/* eslint-disable promise/always-return */
|
||||||
const admin = require('firebase-admin');
|
const admin = require('firebase-admin');
|
||||||
const { db } = require('../util/admin');
|
|
||||||
|
|
||||||
exports.putPost = (req, res) => {
|
exports.putPost = (req, res) => {
|
||||||
|
|
||||||
const newPost = {
|
const newPost = {
|
||||||
body: req.body.body,
|
body: req.body.body,
|
||||||
userHandle: req.userData.handle,
|
userHandle: req.user.handle,
|
||||||
userImage: req.body.userImage,
|
userImage: req.body.userImage,
|
||||||
userID: req.userData.userId,
|
userID: req.user.uid,
|
||||||
microBlogTitle: req.body.microBlogTitle,
|
microBlogTitle: req.body.microBlogTitle,
|
||||||
createdAt: new Date().toISOString(),
|
createdAt: new Date().toISOString(),
|
||||||
likeCount: 0,
|
likeCount: 0,
|
||||||
commentCount: 0,
|
commentCount: 0,
|
||||||
microBlogTopics: req.body.microBlogTopics
|
microBlogTopics: req.body.microBlogTopics
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
admin.firestore().collection('posts').add(newPost)
|
admin.firestore().collection('posts').add(newPost)
|
||||||
@@ -29,134 +27,6 @@ exports.putPost = (req, res) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
exports.getPost = (req, res) => {
|
|
||||||
let postData = {};
|
|
||||||
db.doc(`/posts/${req.params.postId}`)
|
|
||||||
.get()
|
|
||||||
.then((doc) => {
|
|
||||||
if (!doc.exists) {
|
|
||||||
return res.status(404).json({error: 'Post is not found'});
|
|
||||||
|
|
||||||
}
|
|
||||||
postData = doc.data();
|
|
||||||
postData.postId = doc.id;
|
|
||||||
return res.status(200).json(postData);
|
|
||||||
})
|
|
||||||
.catch((err) => {
|
|
||||||
console.error(err);
|
|
||||||
return res.status(500).json({error: 'Something is wrong'});
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.likePost = (req, res) => {
|
|
||||||
|
|
||||||
const likeDoc = admin.firestore().collection('likes').where('userHandle', '==', req.userData.handle)
|
|
||||||
.where('postId', '==', req.params.postId).limit(1);
|
|
||||||
|
|
||||||
const postDoc = db.doc(`/posts/${req.params.postId}`);
|
|
||||||
|
|
||||||
likeDoc.get()
|
|
||||||
.then((data) => {
|
|
||||||
if (data.empty) {
|
|
||||||
admin.firestore().collection('likes').add({
|
|
||||||
postId : req.params.postId,
|
|
||||||
userHandle: req.userData.handle
|
|
||||||
})
|
|
||||||
.then(() => {
|
|
||||||
return postDoc.update({likeCount : firebase.firestore.FieldValue.increment(1) })
|
|
||||||
})
|
|
||||||
.then(() => {
|
|
||||||
return res.status(200).json(postDoc);
|
|
||||||
})
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return res.status(400).json({error: 'Post has already been liked.'})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch((err) => {
|
|
||||||
console.error(err);
|
|
||||||
return res.status(500).json({error: 'Something is wrong'});
|
|
||||||
})
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.unlikePost = (re, res) => {
|
|
||||||
|
|
||||||
let postData;
|
|
||||||
const likeDoc = admin.firestore().collection('likes').where('userHandle', '==', req.userData.handle)
|
|
||||||
.where('postId', '==', req.params.postId).limit(1);
|
|
||||||
|
|
||||||
const postDoc = db.doc(`/posts/${req.params.postId}`);
|
|
||||||
|
|
||||||
likeDoc.get()
|
|
||||||
.then((data) => {
|
|
||||||
if (data.empty) {
|
|
||||||
return res.status(400).json({ error: 'Post cannot be unliked because it is not liked at the moment.' });
|
|
||||||
} else {
|
|
||||||
return db
|
|
||||||
.doc(`/likes/${data.docs[0].id}`)
|
|
||||||
.delete()
|
|
||||||
.then(() => {
|
|
||||||
postData.likeCount--;
|
|
||||||
return postDoc.update({ likeCount: postData.likeCount });
|
|
||||||
})
|
|
||||||
.then(() => {
|
|
||||||
res.status(200).json(postData);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch((err) => {
|
|
||||||
console.error(err);
|
|
||||||
return res.status(500).json({error: 'Something is wrong'});
|
|
||||||
})
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.quotePost = (req, res) => {
|
|
||||||
|
|
||||||
const likeDoc = admin.firestore().collection('posts').where('postId', '==', req.params.postId).limit(1);
|
|
||||||
|
|
||||||
const quotedPost = {
|
|
||||||
quotingUser : req.userData.handle,
|
|
||||||
quotedAt: new Date().toISOString(),
|
|
||||||
body: req.body.body,
|
|
||||||
|
|
||||||
}
|
|
||||||
admin.firestore().collection('posts').add(quotedPost)
|
|
||||||
.then((doc) => {
|
|
||||||
const resPost = quotedPost;
|
|
||||||
resPost.postId = doc.id;
|
|
||||||
return res.status(200).json(resPost);
|
|
||||||
}
|
|
||||||
)
|
|
||||||
.catch((err) => {
|
|
||||||
console.error(err);
|
|
||||||
return res.status(500).json({error: 'Something is wrong'});
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
exports.getallPostsforFeed = (req, res) => {
|
|
||||||
admin.firestore().collection('posts').get()
|
|
||||||
.then((data) => {
|
|
||||||
let posts = [];
|
|
||||||
|
|
||||||
data.forEach(function(doc) {
|
|
||||||
posts.push( {
|
|
||||||
microBlogs: doc.data(),
|
|
||||||
id: doc.id,
|
|
||||||
})
|
|
||||||
|
|
||||||
});
|
|
||||||
return res.status(200).json(posts);
|
|
||||||
})
|
|
||||||
.catch((err) => {
|
|
||||||
console.error(err);
|
|
||||||
return res.status(500).json({error: 'Failed to fetch all posts written by all other users.'})
|
|
||||||
})
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.getallPostsforUser = (req, res) => {
|
exports.getallPostsforUser = (req, res) => {
|
||||||
admin.firestore().collection('posts').where('userHandle', '==', req.userData.handle ).get()
|
admin.firestore().collection('posts').where('userHandle', '==', req.userData.handle ).get()
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
@@ -171,3 +41,7 @@ exports.getallPostsforUser = (req, res) => {
|
|||||||
return res.status(500).json({error: 'Failed to fetch all posts written by specific user.'})
|
return res.status(500).json({error: 'Failed to fetch all posts written by specific user.'})
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.getFilteredPosts = (req, res) => {
|
||||||
|
admin.firestore().collection('posts').where('userHandle', '==', 'new user').where('microBlogTopics', '==')
|
||||||
|
};
|
||||||
@@ -34,7 +34,6 @@ exports.getAllTopics = (req, res) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
exports.deleteTopic = (req, res) => {
|
exports.deleteTopic = (req, res) => {
|
||||||
// TODO: handle add and delete by topic id
|
|
||||||
const topic = db.doc(`/topics/${req.params.topicId}`);
|
const topic = db.doc(`/topics/${req.params.topicId}`);
|
||||||
topic.get().then((doc) => {
|
topic.get().then((doc) => {
|
||||||
if (!doc.exists) {
|
if (!doc.exists) {
|
||||||
|
|||||||
@@ -7,8 +7,6 @@ const { validateUpdateProfileInfo } = require("../util/validator");
|
|||||||
const firebase = require("firebase");
|
const firebase = require("firebase");
|
||||||
firebase.initializeApp(config);
|
firebase.initializeApp(config);
|
||||||
|
|
||||||
var handle2Email = new Map();
|
|
||||||
|
|
||||||
exports.signup = (req, res) => {
|
exports.signup = (req, res) => {
|
||||||
const newUser = {
|
const newUser = {
|
||||||
email: req.body.email,
|
email: req.body.email,
|
||||||
@@ -80,7 +78,6 @@ exports.signup = (req, res) => {
|
|||||||
userId,
|
userId,
|
||||||
followedTopics: []
|
followedTopics: []
|
||||||
};
|
};
|
||||||
handle2Email.set(userCred.handle, userCred.email);
|
|
||||||
return db.doc(`/users/${newUser.handle}`).set(userCred);
|
return db.doc(`/users/${newUser.handle}`).set(userCred);
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
@@ -98,7 +95,6 @@ exports.signup = (req, res) => {
|
|||||||
exports.login = (req, res) => {
|
exports.login = (req, res) => {
|
||||||
const user = {
|
const user = {
|
||||||
email: req.body.email,
|
email: req.body.email,
|
||||||
handle: req.body.handle,
|
|
||||||
password: req.body.password
|
password: req.body.password
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -107,25 +103,63 @@ exports.login = (req, res) => {
|
|||||||
|
|
||||||
const emailRegEx = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
const emailRegEx = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
||||||
|
|
||||||
// Email check
|
// Checks if email/username field is empty
|
||||||
if (user.email.trim() === "") {
|
if (user.email.trim() === "") {
|
||||||
errors.email = "Email must not be blank.";
|
errors.email = "Email must not be blank.";
|
||||||
}
|
}
|
||||||
else if (!user.email.match(emailRegEx)) {
|
|
||||||
user.email = handle2Email.get(user.email);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Password check
|
// Checks if password field is empty
|
||||||
if (user.password.trim() === "") {
|
if (user.password.trim() === "") {
|
||||||
errors.password = "Password must not be blank.";
|
errors.password = "Password must not be blank.";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Checking if any errors have been raised
|
// Checks if any of the above two errors were found
|
||||||
if (Object.keys(errors).length > 0) {
|
if (Object.keys(errors).length > 0) {
|
||||||
return res.status(400).json(errors);
|
return res.status(400).json(errors);
|
||||||
}
|
}
|
||||||
|
|
||||||
firebase
|
// Email/username field is username since it's not in email format
|
||||||
|
if (!user.email.match(emailRegEx)) {
|
||||||
|
var userDoc = db.collection("users").doc(`${user.email}`);
|
||||||
|
userDoc.get()
|
||||||
|
.then(function(doc) {
|
||||||
|
if (doc.exists) {
|
||||||
|
user.email = doc.data().email;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return res.status(403).json({ general: "Invalid credentials. Please try again." });
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
})
|
||||||
|
.then(function() {
|
||||||
|
firebase
|
||||||
|
.auth()
|
||||||
|
.signInWithEmailAndPassword(user.email, user.password)
|
||||||
|
.then((data) => {
|
||||||
|
return data.user.getIdToken();
|
||||||
|
})
|
||||||
|
.then((token) => {
|
||||||
|
return res.status(200).json({ token });
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.error(err);
|
||||||
|
if (err.code === "auth/user-not-found" || err.code === "auth/invalid-email" || err.code === "auth/wrong-password") {
|
||||||
|
return res.status(403).json({ general: "Invalid credentials. Please try again." });
|
||||||
|
}
|
||||||
|
return res.status(500).json({ error: err.code });
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
})
|
||||||
|
.catch(function(err) {
|
||||||
|
if(!doc.exists) {
|
||||||
|
return res.status(403).json({ general: "Invalid credentials. Please try again." });
|
||||||
|
}
|
||||||
|
return res.status(500).send(err);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// Email/username field is username
|
||||||
|
else {
|
||||||
|
firebase
|
||||||
.auth()
|
.auth()
|
||||||
.signInWithEmailAndPassword(user.email, user.password)
|
.signInWithEmailAndPassword(user.email, user.password)
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
@@ -136,49 +170,65 @@ exports.login = (req, res) => {
|
|||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
if (err.code === "auth/wrong-password" || err.code === "auth/invalid-email" || err.code === "auth/user-not-found") {
|
if (err.code === "auth/user-not-found" || err.code === "auth/invalid-email" || err.code === "auth/wrong-password") {
|
||||||
return res
|
return res
|
||||||
.status(403)
|
.status(403)
|
||||||
.json({ general: "Invalid credentials. Please try again." });
|
.json({ general: "Invalid credentials. Please try again." });
|
||||||
}
|
}
|
||||||
return res.status(500).json({ error: err.code });
|
return res.status(500).json({ error: err.code });
|
||||||
});
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//Deletes user account
|
//Deletes user account
|
||||||
exports.deleteUser = (req, res) => {
|
exports.deleteUser = (req, res) => {
|
||||||
var currentUser;
|
var currentUser;
|
||||||
|
|
||||||
firebase.auth().onAuthStateChanged(function(user) {
|
firebase.auth().onAuthStateChanged(function(user) {
|
||||||
currentUser = user;
|
currentUser = user;
|
||||||
if (currentUser) {
|
if (currentUser) {
|
||||||
/*db.collection("users").doc(`${currentUser.handle}`).delete()
|
var post_query = db.collection("posts").where("userHandle", "==", req.user.handle);
|
||||||
|
post_query.get()
|
||||||
|
.then(function(myPosts) {
|
||||||
|
myPosts.forEach(function(doc) {
|
||||||
|
doc.ref.delete();
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
})
|
||||||
.then(function() {
|
.then(function() {
|
||||||
res.status(200).send("Removed user from database.");
|
res.status(200).send("Successfully removed all user's posts from database.");
|
||||||
|
return;
|
||||||
|
})
|
||||||
|
.catch(function(err) {
|
||||||
|
res.status(500).send("Failed to remove all user's posts from database.", err);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
db.collection("users").doc(`${req.user.handle}`).delete()
|
||||||
|
.then(function() {
|
||||||
|
res.status(200).send("Sucessfully removed user from database.");
|
||||||
return;
|
return;
|
||||||
})
|
})
|
||||||
.catch(function(err) {
|
.catch(function(err) {
|
||||||
res.status(500).send("Failed to remove user from database.", err);
|
res.status(500).send("Failed to remove user from database.", err);
|
||||||
});*/
|
});
|
||||||
|
|
||||||
|
|
||||||
//let ref = db.collection('users');
|
|
||||||
//let userDoc = ref.where('userId', '==', currentUser.uid).get();
|
|
||||||
//userDoc.ref.delete();
|
|
||||||
|
|
||||||
currentUser.delete()
|
currentUser.delete()
|
||||||
.then(function() {
|
.then(function() {
|
||||||
console.log("User successfully deleted.");
|
console.log("Successfully deleted user.");
|
||||||
res.status(200).send("Deleted user.");
|
res.status(200).send("Sucessfully deleted user.");
|
||||||
return;
|
return;
|
||||||
})
|
})
|
||||||
.catch(function(err) {
|
.catch(function(err) {
|
||||||
console.log("Error deleting user.", err);
|
console.log("Failed to delete user.", err);
|
||||||
res.status(500).send("Failed to delete user.");
|
res.status(500).send("Failed to delete user.");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
console.log("Cannot get user.");
|
console.log("Failed to deleter user or cannot get user.");
|
||||||
res.status(500).send("Cannot get user.");
|
res.status(500).send("Failed to deleter user or cannot get user.");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -199,8 +249,6 @@ exports.getProfileInfo = (req, res) => {
|
|||||||
|
|
||||||
// Updates the data in the database of the user who is currently logged in
|
// Updates the data in the database of the user who is currently logged in
|
||||||
exports.updateProfileInfo = (req, res) => {
|
exports.updateProfileInfo = (req, res) => {
|
||||||
// TODO: Add functionality for adding/updating profile images
|
|
||||||
|
|
||||||
// Data validation
|
// Data validation
|
||||||
const { valid, errors, profileData } = validateUpdateProfileInfo(req);
|
const { valid, errors, profileData } = validateUpdateProfileInfo(req);
|
||||||
if (!valid) return res.status(400).json(errors);
|
if (!valid) return res.status(400).json(errors);
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ app.post("/signup", signup);
|
|||||||
app.post("/login", login);
|
app.post("/login", login);
|
||||||
|
|
||||||
//Deletes user account
|
//Deletes user account
|
||||||
app.delete("/delete", deleteUser);
|
app.delete("/delete", fbAuth, deleteUser);
|
||||||
|
|
||||||
app.get("/getUser", fbAuth, getUserDetails);
|
app.get("/getUser", fbAuth, getUserDetails);
|
||||||
|
|
||||||
@@ -44,19 +44,10 @@ app.get("/user", fbAuth, getAuthenticatedUser);
|
|||||||
/*------------------------------------------------------------------*
|
/*------------------------------------------------------------------*
|
||||||
* handlers/post.js *
|
* handlers/post.js *
|
||||||
*------------------------------------------------------------------*/
|
*------------------------------------------------------------------*/
|
||||||
const { getallPostsforUser, putPost, getPost, getallPostsforFeed, likePost, unlikePost, quotePost
|
const { getallPostsforUser, putPost
|
||||||
} = require("./handlers/post");
|
} = require("./handlers/post");
|
||||||
|
|
||||||
app.get("/getallPostsforUser", fbAuth, getallPostsforUser);
|
app.get("/getallPostsforUser", getallPostsforUser);
|
||||||
|
|
||||||
app.get("/getallPostsforFeed", fbAuth, getallPostsforFeed);
|
|
||||||
|
|
||||||
app.get("/putPost/:postId", fbAuth, getPost);
|
|
||||||
app.get("/putPost/:postId/like", fbAuth, likePost);
|
|
||||||
app.get("/putPost/:postId/unlike", fbAuth, unlikePost);
|
|
||||||
app.post("/putPost/:postId/quote", fbAuth, quotePost);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Adds one post to the database
|
// Adds one post to the database
|
||||||
app.post("/putPost", fbAuth, putPost);
|
app.post("/putPost", fbAuth, putPost);
|
||||||
|
|||||||
198
twistter-frontend/package-lock.json
generated
198
twistter-frontend/package-lock.json
generated
@@ -121,16 +121,6 @@
|
|||||||
"react-is": "^16.8.6"
|
"react-is": "^16.8.6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@restart/context": {
|
|
||||||
"version": "2.1.4",
|
|
||||||
"resolved": "https://registry.npmjs.org/@restart/context/-/context-2.1.4.tgz",
|
|
||||||
"integrity": "sha512-INJYZQJP7g+IoDUh/475NlGiTeMfwTXUEr3tmRneckHIxNolGOW9CTq83S8cxq0CgJwwcMzMJFchxvlwe7Rk8Q=="
|
|
||||||
},
|
|
||||||
"@restart/hooks": {
|
|
||||||
"version": "0.3.15",
|
|
||||||
"resolved": "https://registry.npmjs.org/@restart/hooks/-/hooks-0.3.15.tgz",
|
|
||||||
"integrity": "sha512-rVNba1A2oMzKBg16fCrrHmCf4JjOzFhT9TWR8J+Y8iOcY4zffxtP3ke7mEsakvghHZT+9//uDOPSSeuBDW41GQ=="
|
|
||||||
},
|
|
||||||
"@types/prop-types": {
|
"@types/prop-types": {
|
||||||
"version": "15.7.3",
|
"version": "15.7.3",
|
||||||
"resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.3.tgz",
|
"resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.3.tgz",
|
||||||
@@ -1429,11 +1419,6 @@
|
|||||||
"resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz",
|
||||||
"integrity": "sha1-aN/1++YMUes3cl6p4+0xDcwed24="
|
"integrity": "sha1-aN/1++YMUes3cl6p4+0xDcwed24="
|
||||||
},
|
},
|
||||||
"bootstrap": {
|
|
||||||
"version": "4.3.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-4.3.1.tgz",
|
|
||||||
"integrity": "sha512-rXqOmH1VilAt2DyPzluTi2blhk17bO7ef+zLLPlWvG494pDxcM234pJ8wTc/6R40UWizAIIMgxjvxZg5kmsbag=="
|
|
||||||
},
|
|
||||||
"brace-expansion": {
|
"brace-expansion": {
|
||||||
"version": "1.1.11",
|
"version": "1.1.11",
|
||||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
|
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
|
||||||
@@ -1719,11 +1704,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"classnames": {
|
|
||||||
"version": "2.2.6",
|
|
||||||
"resolved": "https://registry.npmjs.org/classnames/-/classnames-2.2.6.tgz",
|
|
||||||
"integrity": "sha512-JR/iSQOSt+LQIWwrwEzJ9uk0xfN3mTVYMwt1Ir5mUcSN6pU+V4zQFFaJsclJbPuAUQH+yfWef6tm7l1quW3C8Q=="
|
|
||||||
},
|
|
||||||
"clean-css": {
|
"clean-css": {
|
||||||
"version": "4.2.1",
|
"version": "4.2.1",
|
||||||
"resolved": "https://registry.npmjs.org/clean-css/-/clean-css-4.2.1.tgz",
|
"resolved": "https://registry.npmjs.org/clean-css/-/clean-css-4.2.1.tgz",
|
||||||
@@ -2248,15 +2228,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"create-react-context": {
|
|
||||||
"version": "0.3.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/create-react-context/-/create-react-context-0.3.0.tgz",
|
|
||||||
"integrity": "sha512-dNldIoSuNSvlTJ7slIKC/ZFGKexBMBrrcc+TTe1NdmROnaASuLPvqpwj9v4XS4uXZ8+YPu0sNmShX2rXI5LNsw==",
|
|
||||||
"requires": {
|
|
||||||
"gud": "^1.0.0",
|
|
||||||
"warning": "^4.0.3"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"cross-spawn": {
|
"cross-spawn": {
|
||||||
"version": "4.0.2",
|
"version": "4.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-4.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-4.0.2.tgz",
|
||||||
@@ -3121,11 +3092,6 @@
|
|||||||
"merge": "^1.2.0"
|
"merge": "^1.2.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"exenv": {
|
|
||||||
"version": "1.2.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/exenv/-/exenv-1.2.2.tgz",
|
|
||||||
"integrity": "sha1-KueOhdmJQVhnCwPUe+wfA72Ru50="
|
|
||||||
},
|
|
||||||
"exit-hook": {
|
"exit-hook": {
|
||||||
"version": "1.1.1",
|
"version": "1.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/exit-hook/-/exit-hook-1.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/exit-hook/-/exit-hook-1.1.1.tgz",
|
||||||
@@ -5324,11 +5290,6 @@
|
|||||||
"resolved": "https://registry.npmjs.org/jwt-decode/-/jwt-decode-2.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/jwt-decode/-/jwt-decode-2.2.0.tgz",
|
||||||
"integrity": "sha1-fYa9VmefWM5qhHBKZX3TkruoGnk="
|
"integrity": "sha1-fYa9VmefWM5qhHBKZX3TkruoGnk="
|
||||||
},
|
},
|
||||||
"keycode": {
|
|
||||||
"version": "2.2.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/keycode/-/keycode-2.2.0.tgz",
|
|
||||||
"integrity": "sha1-PQr1bce4uOXLqNCpfxByBO7CKwQ="
|
|
||||||
},
|
|
||||||
"kind-of": {
|
"kind-of": {
|
||||||
"version": "3.2.2",
|
"version": "3.2.2",
|
||||||
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz",
|
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz",
|
||||||
@@ -7037,25 +6998,6 @@
|
|||||||
"react-is": "^16.8.1"
|
"react-is": "^16.8.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"prop-types-extra": {
|
|
||||||
"version": "1.1.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/prop-types-extra/-/prop-types-extra-1.1.0.tgz",
|
|
||||||
"integrity": "sha512-QFyuDxvMipmIVKD2TwxLVPzMnO4e5oOf1vr3tJIomL8E7d0lr6phTHd5nkPhFIzTD1idBLLEPeylL9g+rrTzRg==",
|
|
||||||
"requires": {
|
|
||||||
"react-is": "^16.3.2",
|
|
||||||
"warning": "^3.0.0"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"warning": {
|
|
||||||
"version": "3.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/warning/-/warning-3.0.0.tgz",
|
|
||||||
"integrity": "sha1-MuU3fLVy3kqwR1O9+IIcAe1gW3w=",
|
|
||||||
"requires": {
|
|
||||||
"loose-envify": "^1.0.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"proxy-addr": {
|
"proxy-addr": {
|
||||||
"version": "2.0.5",
|
"version": "2.0.5",
|
||||||
"resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.5.tgz",
|
"resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.5.tgz",
|
||||||
@@ -7192,43 +7134,6 @@
|
|||||||
"prop-types": "^15.6.2"
|
"prop-types": "^15.6.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"react-bootstrap": {
|
|
||||||
"version": "1.0.0-beta.14",
|
|
||||||
"resolved": "https://registry.npmjs.org/react-bootstrap/-/react-bootstrap-1.0.0-beta.14.tgz",
|
|
||||||
"integrity": "sha512-UGK5f78FE8wAei1YL/oSwFlJZLqxJ/h4S8DCwHyY8hQjFCrjEW5PoEBTOOhQ6PQL6WOsZe1jkiOJG7L5TZWu+w==",
|
|
||||||
"requires": {
|
|
||||||
"@babel/runtime": "^7.4.2",
|
|
||||||
"@restart/context": "^2.1.4",
|
|
||||||
"@restart/hooks": "^0.3.11",
|
|
||||||
"@types/react": "^16.8.23",
|
|
||||||
"classnames": "^2.2.6",
|
|
||||||
"dom-helpers": "^3.4.0",
|
|
||||||
"invariant": "^2.2.4",
|
|
||||||
"keycode": "^2.2.0",
|
|
||||||
"popper.js": "^1.14.7",
|
|
||||||
"prop-types": "^15.7.2",
|
|
||||||
"prop-types-extra": "^1.1.0",
|
|
||||||
"react-overlays": "^1.2.0",
|
|
||||||
"react-transition-group": "^4.0.0",
|
|
||||||
"uncontrollable": "^7.0.0",
|
|
||||||
"warning": "^4.0.3"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"dom-helpers": {
|
|
||||||
"version": "3.4.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/dom-helpers/-/dom-helpers-3.4.0.tgz",
|
|
||||||
"integrity": "sha512-LnuPJ+dwqKDIyotW1VzmOZ5TONUN7CwkCR5hrgawTUbkBGYdeoNLZo6nNfGkCrjtE1nXXaj7iMMpDa8/d9WoIA==",
|
|
||||||
"requires": {
|
|
||||||
"@babel/runtime": "^7.1.2"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"react-context-toolbox": {
|
|
||||||
"version": "2.0.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/react-context-toolbox/-/react-context-toolbox-2.0.2.tgz",
|
|
||||||
"integrity": "sha512-tY4j0imkYC3n5ZlYSgFkaw7fmlCp3IoQQ6DxpqeNHzcD0hf+6V+/HeJxviLUZ1Rv1Yn3N3xyO2EhkkZwHn0m1A=="
|
|
||||||
},
|
|
||||||
"react-dev-utils": {
|
"react-dev-utils": {
|
||||||
"version": "0.5.2",
|
"version": "0.5.2",
|
||||||
"resolved": "https://registry.npmjs.org/react-dev-utils/-/react-dev-utils-0.5.2.tgz",
|
"resolved": "https://registry.npmjs.org/react-dev-utils/-/react-dev-utils-0.5.2.tgz",
|
||||||
@@ -7257,82 +7162,11 @@
|
|||||||
"scheduler": "^0.15.0"
|
"scheduler": "^0.15.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"react-dropdown": {
|
|
||||||
"version": "1.6.4",
|
|
||||||
"resolved": "https://registry.npmjs.org/react-dropdown/-/react-dropdown-1.6.4.tgz",
|
|
||||||
"integrity": "sha512-zTlNRZ6vzjEPsodBNgh6Xjp9IempEx9sReH3crT2Jw4S6KW2wS/BRIH3d/grYf/iXARadDRD91//uUCs9yjoLg==",
|
|
||||||
"requires": {
|
|
||||||
"classnames": "^2.2.3"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"react-is": {
|
"react-is": {
|
||||||
"version": "16.9.0",
|
"version": "16.9.0",
|
||||||
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.9.0.tgz",
|
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.9.0.tgz",
|
||||||
"integrity": "sha512-tJBzzzIgnnRfEm046qRcURvwQnZVXmuCbscxUO5RWrGTXpon2d4c8mI0D8WE6ydVIm29JiLB6+RslkIvym9Rjw=="
|
"integrity": "sha512-tJBzzzIgnnRfEm046qRcURvwQnZVXmuCbscxUO5RWrGTXpon2d4c8mI0D8WE6ydVIm29JiLB6+RslkIvym9Rjw=="
|
||||||
},
|
},
|
||||||
"react-lifecycles-compat": {
|
|
||||||
"version": "3.0.4",
|
|
||||||
"resolved": "https://registry.npmjs.org/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz",
|
|
||||||
"integrity": "sha512-fBASbA6LnOU9dOU2eW7aQ8xmYBSXUIWr+UmF9b1efZBazGNO+rcXT/icdKnYm2pTwcRylVUYwW7H1PHfLekVzA=="
|
|
||||||
},
|
|
||||||
"react-modal": {
|
|
||||||
"version": "3.11.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/react-modal/-/react-modal-3.11.1.tgz",
|
|
||||||
"integrity": "sha512-8uN744Yq0X2lbfSLxsEEc2UV3RjSRb4yDVxRQ1aGzPo86QjNOwhQSukDb8U8kR+636TRTvfMren10fgOjAy9eA==",
|
|
||||||
"requires": {
|
|
||||||
"exenv": "^1.2.0",
|
|
||||||
"prop-types": "^15.5.10",
|
|
||||||
"react-lifecycles-compat": "^3.0.0",
|
|
||||||
"warning": "^4.0.3"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"react-overlays": {
|
|
||||||
"version": "1.2.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/react-overlays/-/react-overlays-1.2.0.tgz",
|
|
||||||
"integrity": "sha512-i/FCV8wR6aRaI+Kz/dpJhOdyx+ah2tN1RhT9InPrexyC4uzf3N4bNayFTGtUeQVacj57j1Mqh1CwV60/5153Iw==",
|
|
||||||
"requires": {
|
|
||||||
"classnames": "^2.2.6",
|
|
||||||
"dom-helpers": "^3.4.0",
|
|
||||||
"prop-types": "^15.6.2",
|
|
||||||
"prop-types-extra": "^1.1.0",
|
|
||||||
"react-context-toolbox": "^2.0.2",
|
|
||||||
"react-popper": "^1.3.2",
|
|
||||||
"uncontrollable": "^6.0.0",
|
|
||||||
"warning": "^4.0.2"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"dom-helpers": {
|
|
||||||
"version": "3.4.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/dom-helpers/-/dom-helpers-3.4.0.tgz",
|
|
||||||
"integrity": "sha512-LnuPJ+dwqKDIyotW1VzmOZ5TONUN7CwkCR5hrgawTUbkBGYdeoNLZo6nNfGkCrjtE1nXXaj7iMMpDa8/d9WoIA==",
|
|
||||||
"requires": {
|
|
||||||
"@babel/runtime": "^7.1.2"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"uncontrollable": {
|
|
||||||
"version": "6.2.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/uncontrollable/-/uncontrollable-6.2.3.tgz",
|
|
||||||
"integrity": "sha512-VgOAoBU2ptCL2bfTG2Mra0I8i1u6Aq84AFonD5tmCAYSfs3hWvr2Rlw0q2ntoxXTHjcQOmZOh3FKaN+UZVyREQ==",
|
|
||||||
"requires": {
|
|
||||||
"@babel/runtime": "^7.4.5",
|
|
||||||
"invariant": "^2.2.4"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"react-popper": {
|
|
||||||
"version": "1.3.4",
|
|
||||||
"resolved": "https://registry.npmjs.org/react-popper/-/react-popper-1.3.4.tgz",
|
|
||||||
"integrity": "sha512-9AcQB29V+WrBKk6X7p0eojd1f25/oJajVdMZkywIoAV6Ag7hzE1Mhyeup2Q1QnvFRtGQFQvtqfhlEoDAPfKAVA==",
|
|
||||||
"requires": {
|
|
||||||
"@babel/runtime": "^7.1.2",
|
|
||||||
"create-react-context": "^0.3.0",
|
|
||||||
"popper.js": "^1.14.4",
|
|
||||||
"prop-types": "^15.6.1",
|
|
||||||
"typed-styles": "^0.0.7",
|
|
||||||
"warning": "^4.0.2"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"react-redux": {
|
"react-redux": {
|
||||||
"version": "7.1.1",
|
"version": "7.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/react-redux/-/react-redux-7.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/react-redux/-/react-redux-7.1.1.tgz",
|
||||||
@@ -8321,15 +8155,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"react-simple-dropdown": {
|
|
||||||
"version": "3.2.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/react-simple-dropdown/-/react-simple-dropdown-3.2.3.tgz",
|
|
||||||
"integrity": "sha512-NmyyvA0D4wph5ctzkn8U4wmblOacavJMl9gTOhQR3v8I997mc1FL1NFKkj3Mx+HNysBKRD/HI+kpxXCAgXumPw==",
|
|
||||||
"requires": {
|
|
||||||
"classnames": "^2.1.2",
|
|
||||||
"prop-types": "^15.5.8"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"react-transition-group": {
|
"react-transition-group": {
|
||||||
"version": "4.3.0",
|
"version": "4.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/react-transition-group/-/react-transition-group-4.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/react-transition-group/-/react-transition-group-4.3.0.tgz",
|
||||||
@@ -9895,11 +9720,6 @@
|
|||||||
"mime-types": "~2.1.24"
|
"mime-types": "~2.1.24"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"typed-styles": {
|
|
||||||
"version": "0.0.7",
|
|
||||||
"resolved": "https://registry.npmjs.org/typed-styles/-/typed-styles-0.0.7.tgz",
|
|
||||||
"integrity": "sha512-pzP0PWoZUhsECYjABgCGQlRGL1n7tOHsgwYv3oIiEpJwGhFTuty/YNeduxQYzXXa3Ge5BdT6sHYIQYpl4uJ+5Q=="
|
|
||||||
},
|
|
||||||
"typedarray": {
|
"typedarray": {
|
||||||
"version": "0.0.6",
|
"version": "0.0.6",
|
||||||
"resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz",
|
"resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz",
|
||||||
@@ -9941,16 +9761,6 @@
|
|||||||
"resolved": "https://registry.npmjs.org/uid-number/-/uid-number-0.0.6.tgz",
|
"resolved": "https://registry.npmjs.org/uid-number/-/uid-number-0.0.6.tgz",
|
||||||
"integrity": "sha1-DqEOgDXo61uOREnwbaHHMGY7qoE="
|
"integrity": "sha1-DqEOgDXo61uOREnwbaHHMGY7qoE="
|
||||||
},
|
},
|
||||||
"uncontrollable": {
|
|
||||||
"version": "7.0.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/uncontrollable/-/uncontrollable-7.0.2.tgz",
|
|
||||||
"integrity": "sha512-7fa8OBQ5+X4VAcp0os6BD74bCeUPQSHmr4Rqy75Me98NnlD5kNShCqqx4xWo4OmlAMiT2/YSMklLFC4FCuoGYg==",
|
|
||||||
"requires": {
|
|
||||||
"@babel/runtime": "^7.4.5",
|
|
||||||
"invariant": "^2.2.4",
|
|
||||||
"react-lifecycles-compat": "^3.0.4"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"union-value": {
|
"union-value": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.1.tgz",
|
||||||
@@ -10181,14 +9991,6 @@
|
|||||||
"makeerror": "1.0.x"
|
"makeerror": "1.0.x"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"warning": {
|
|
||||||
"version": "4.0.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/warning/-/warning-4.0.3.tgz",
|
|
||||||
"integrity": "sha512-rpJyN222KWIvHJ/F53XSZv0Zl/accqHR8et1kpaMTD/fLCRxtV8iX8czMzY7sVZupTI3zcUTg8eycS2kNF9l6w==",
|
|
||||||
"requires": {
|
|
||||||
"loose-envify": "^1.0.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"watch": {
|
"watch": {
|
||||||
"version": "0.10.0",
|
"version": "0.10.0",
|
||||||
"resolved": "https://registry.npmjs.org/watch/-/watch-0.10.0.tgz",
|
"resolved": "https://registry.npmjs.org/watch/-/watch-0.10.0.tgz",
|
||||||
|
|||||||
@@ -8,21 +8,16 @@
|
|||||||
"@material-ui/styles": "^4.5.0",
|
"@material-ui/styles": "^4.5.0",
|
||||||
"@material-ui/system": "^4.5.0",
|
"@material-ui/system": "^4.5.0",
|
||||||
"axios": "^0.19.0",
|
"axios": "^0.19.0",
|
||||||
"bootstrap": "^4.3.1",
|
|
||||||
"clsx": "^1.0.4",
|
"clsx": "^1.0.4",
|
||||||
"create-react-app": "^3.1.2",
|
"create-react-app": "^3.1.2",
|
||||||
"install": "^0.13.0",
|
"install": "^0.13.0",
|
||||||
"jwt-decode": "^2.2.0",
|
"jwt-decode": "^2.2.0",
|
||||||
"node-pre-gyp": "^0.13.0",
|
"node-pre-gyp": "^0.13.0",
|
||||||
"react": "^16.9.0",
|
"react": "^16.9.0",
|
||||||
"react-bootstrap": "^1.0.0-beta.14",
|
|
||||||
"react-dom": "^16.9.0",
|
"react-dom": "^16.9.0",
|
||||||
"react-dropdown": "^1.6.4",
|
|
||||||
"react-modal": "^3.11.1",
|
|
||||||
"react-redux": "^7.1.1",
|
"react-redux": "^7.1.1",
|
||||||
"react-router-dom": "^5.1.0",
|
"react-router-dom": "^5.1.0",
|
||||||
"react-scripts": "0.9.5",
|
"react-scripts": "0.9.5",
|
||||||
"react-simple-dropdown": "^3.2.3",
|
|
||||||
"redux": "^4.0.4",
|
"redux": "^4.0.4",
|
||||||
"redux-thunk": "^2.3.0",
|
"redux-thunk": "^2.3.0",
|
||||||
"typeface-roboto": "0.0.75"
|
"typeface-roboto": "0.0.75"
|
||||||
|
|||||||
@@ -15,14 +15,4 @@ const reducers = combineReducers({
|
|||||||
UI: uiReducer
|
UI: uiReducer
|
||||||
});
|
});
|
||||||
|
|
||||||
const store = createStore(
|
//const store = createStore(reducers, )
|
||||||
reducers,
|
|
||||||
initialState,
|
|
||||||
compose(
|
|
||||||
applyMiddleware(...middleware),
|
|
||||||
window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
|
|
||||||
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
export default store;
|
|
||||||
@@ -12,12 +12,6 @@ body {
|
|||||||
height: 200px;
|
height: 200px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.userhome{
|
|
||||||
display:flex;
|
|
||||||
flex-direction:row;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
.authButtons {
|
.authButtons {
|
||||||
border-radius: 100px;
|
border-radius: 100px;
|
||||||
box-shadow: none;
|
box-shadow: none;
|
||||||
|
|||||||
@@ -6,8 +6,6 @@ import axios from "axios";
|
|||||||
import { BrowserRouter as Router, Route, Switch } from "react-router-dom";
|
import { BrowserRouter as Router, Route, Switch } from "react-router-dom";
|
||||||
import Navbar from "./components/layout/NavBar";
|
import Navbar from "./components/layout/NavBar";
|
||||||
import jwtDecode from "jwt-decode";
|
import jwtDecode from "jwt-decode";
|
||||||
import 'bootstrap/dist/css/bootstrap.min.css';
|
|
||||||
import { Button } from 'react-bootstrap';
|
|
||||||
|
|
||||||
// Redux
|
// Redux
|
||||||
import { Provider } from "react-redux";
|
import { Provider } from "react-redux";
|
||||||
@@ -34,12 +32,11 @@ import writeMicroblog from './Writing_Microblogs.js';
|
|||||||
import editProfile from './pages/editProfile';
|
import editProfile from './pages/editProfile';
|
||||||
import userLine from './Userline.js';
|
import userLine from './Userline.js';
|
||||||
|
|
||||||
import feed from './Feed.js';
|
|
||||||
|
|
||||||
const theme = createMuiTheme(themeObject);
|
const theme = createMuiTheme(themeObject);
|
||||||
|
|
||||||
const token = localStorage.FBIdToken;
|
const token = localStorage.FBIdToken;
|
||||||
if (token) {
|
if (token) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const decodedToken = jwtDecode(token);
|
const decodedToken = jwtDecode(token);
|
||||||
if (decodedToken.exp * 1000 < Date.now()) {
|
if (decodedToken.exp * 1000 < Date.now()) {
|
||||||
@@ -74,14 +71,10 @@ class App extends Component {
|
|||||||
<AuthRoute exact path="/login" component={login} />
|
<AuthRoute exact path="/login" component={login} />
|
||||||
<Route exact path="/logout" component={logout} />
|
<Route exact path="/logout" component={logout} />
|
||||||
<Route exact path="/delete" component={Delete} />
|
<Route exact path="/delete" component={Delete} />
|
||||||
<Route exact path="/user" component={user} />
|
|
||||||
<div className="userhome">
|
|
||||||
<Route exact path="/home" component={writeMicroblog} />
|
|
||||||
<Route exact path="/home" component={feed} />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
<Route exact path="/user" component={user} />
|
||||||
|
<Route exact path="/home" component={writeMicroblog} />
|
||||||
<Route exact path="/edit" component={editProfile} />
|
<Route exact path="/edit" component={editProfile} />
|
||||||
<Route exact path="/userline" component={userLine} />
|
|
||||||
|
|
||||||
<AuthRoute exact path="/" component={home}/>
|
<AuthRoute exact path="/" component={home}/>
|
||||||
</Switch>
|
</Switch>
|
||||||
|
|||||||
@@ -1,97 +0,0 @@
|
|||||||
import React, { Component } from "react";
|
|
||||||
|
|
||||||
import axios from 'axios';
|
|
||||||
import Box from '@material-ui/core/Box';
|
|
||||||
//import {connect } from 'react-redux';
|
|
||||||
//import { likePost, unlikePost } from '../redux/actions/dataActions';
|
|
||||||
//import PropTypes from 'prop-types';
|
|
||||||
import Like from "./Like.js";
|
|
||||||
import Route from 'react-router-dom/Route';
|
|
||||||
|
|
||||||
import Quote from "./Quote.js";
|
|
||||||
|
|
||||||
class Feed extends Component {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
constructor(props) {
|
|
||||||
super(props);
|
|
||||||
this.state = {
|
|
||||||
microBlogs: [],
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
componentDidMount() {
|
|
||||||
|
|
||||||
axios.get("/getallPostsforFeed")
|
|
||||||
.then((res) => {
|
|
||||||
const post = res.data;
|
|
||||||
this.setState({microBlogs : post})
|
|
||||||
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
|
||||||
|
|
||||||
|
|
||||||
const sortedPosts = (this.state.microBlogs).sort((a,b) =>
|
|
||||||
-a.createdAt.localeCompare(b.createdAt)
|
|
||||||
)
|
|
||||||
|
|
||||||
return(
|
|
||||||
<div>
|
|
||||||
<div style={{fontsize: "13px", marginLeft: "30%", textAlign: "left", }}>
|
|
||||||
<p>Feed</p>
|
|
||||||
</div>
|
|
||||||
<Box width="25%" flex="1" height="auto" marginLeft= "30%" m={2} fontSize="13px" padding="5px" flexWrap= "wrap" flexDirection= "row" >
|
|
||||||
|
|
||||||
<div style={{flexWrap: "wrap", flex: "1", flexDirection: "row", wordBreak: "break-word", textAlign: "left"}}>
|
|
||||||
<p>
|
|
||||||
{sortedPosts.map((microBlog) => <p>Microblog Title: {microBlog.microBlogTitle}
|
|
||||||
<br></br>When post was created: {microBlog.createdAt.substring(0,10) +
|
|
||||||
" " + microBlog.createdAt.substring(11,19)}
|
|
||||||
<br></br>Who wrote the microBlog: {microBlog.userHandle}
|
|
||||||
<br></br>Body of post: {microBlog.body}
|
|
||||||
|
|
||||||
<br></br>Tagged topics: {microBlog.microBlogTopics.join("," + " ")}
|
|
||||||
<br></br><br></br><br></br>
|
|
||||||
<div className="buttons">
|
|
||||||
|
|
||||||
<Like></Like>
|
|
||||||
|
|
||||||
<span>Likes: {microBlog.likeCount}</span>
|
|
||||||
<Quote></Quote>
|
|
||||||
|
|
||||||
<br></br><br></br><br></br><br></br>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</p>)}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</Box>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* Feed.propTypes = {
|
|
||||||
likePost: PropTypes.func.isRequired,
|
|
||||||
unlikePost: PropTypes.func.isRequired,
|
|
||||||
user: PropTypes.object.isRequired,
|
|
||||||
post: PropTypes.object.isRequired
|
|
||||||
}
|
|
||||||
|
|
||||||
const mapStateToProps = state => ({
|
|
||||||
user: state.user
|
|
||||||
})
|
|
||||||
|
|
||||||
const mapActionsToProps = {
|
|
||||||
likePost,
|
|
||||||
unlikePost
|
|
||||||
}
|
|
||||||
|
|
||||||
export default connect(mapStateToProps, mapActionsToProps)(Feed); */
|
|
||||||
export default Feed;
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
import React, { Component } from "react";
|
|
||||||
import { BrowserRouter as Router } from 'react-router-dom';
|
|
||||||
import Route from 'react-router-dom/Route';
|
|
||||||
import axios from 'axios';
|
|
||||||
|
|
||||||
class Like extends Component {
|
|
||||||
|
|
||||||
constructor(props) {
|
|
||||||
super(props);
|
|
||||||
this.state = {
|
|
||||||
like : false,
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
this.handleSubmit = this.handleSubmit.bind(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
handleSubmit(){
|
|
||||||
|
|
||||||
|
|
||||||
this.setState({
|
|
||||||
like: !this.state.like
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
const postId = "AJdhYAE4diocF8UcrHDq"
|
|
||||||
|
|
||||||
if(this.state.like == false)
|
|
||||||
{
|
|
||||||
axios.get(`/putPost/${postId}/like`)
|
|
||||||
.then((res) => {
|
|
||||||
console.log(res.data);
|
|
||||||
})
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
axios.get(`/putPost/${postId}/unlike`)
|
|
||||||
.then((res) => {
|
|
||||||
console.log(res.data);
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
|
||||||
const label = this.state.like ? 'Unlike' : 'Like'
|
|
||||||
return (
|
|
||||||
<button onClick = {{backgroundColor: "lightBlue" }} onClick={this.handleSubmit}>{label}</button>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default Like;
|
|
||||||
@@ -1,78 +0,0 @@
|
|||||||
import React, { Component } from "react";
|
|
||||||
import { BrowserRouter as Router } from 'react-router-dom';
|
|
||||||
import Route from 'react-router-dom/Route';
|
|
||||||
import axios from 'axios';
|
|
||||||
import Modal from "react-modal";
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Quote extends Component {
|
|
||||||
|
|
||||||
constructor(props) {
|
|
||||||
super(props);
|
|
||||||
this.state = {
|
|
||||||
post: null
|
|
||||||
};
|
|
||||||
this.handleSubmit = this.handleSubmit.bind(this);
|
|
||||||
this.handleSubmit2 = this.handleSubmit2.bind(this);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
handleSubmit2() {
|
|
||||||
const postId = "AJdhYAE4diocF8UcrHDq";
|
|
||||||
const postNoComment = {
|
|
||||||
body : ""
|
|
||||||
}
|
|
||||||
const headers = {
|
|
||||||
headers: { 'Content-Type': 'application/json'}
|
|
||||||
}
|
|
||||||
|
|
||||||
axios.post(`/putPost/${postId}/quote`, postNoComment, headers)
|
|
||||||
.then((res) =>{
|
|
||||||
alert('Quoting was successful!')
|
|
||||||
console.log(res.data);
|
|
||||||
})
|
|
||||||
.catch((err) => {
|
|
||||||
alert('An error occured.');
|
|
||||||
console.error(err);
|
|
||||||
})
|
|
||||||
event.preventDefault();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
handleSubmit() {
|
|
||||||
const postId = "AJdhYAE4diocF8UcrHDq";
|
|
||||||
const postComment = {
|
|
||||||
body : ""
|
|
||||||
}
|
|
||||||
const headers = {
|
|
||||||
headers: { 'Content-Type': 'application/json'}
|
|
||||||
}
|
|
||||||
|
|
||||||
axios
|
|
||||||
.post(`/putPost/${postId}/quote`, postComment, headers)
|
|
||||||
.then((res) =>{
|
|
||||||
alert('Quoting was successful!')
|
|
||||||
console.log(res.data);
|
|
||||||
})
|
|
||||||
.catch((err) => {
|
|
||||||
alert('An error occured.');
|
|
||||||
console.error(err);
|
|
||||||
})
|
|
||||||
event.preventDefault();
|
|
||||||
|
|
||||||
}
|
|
||||||
render() {
|
|
||||||
return(
|
|
||||||
<div>
|
|
||||||
<button onClick={this.handleSubmit}>Quote with comment</button>
|
|
||||||
<button onClick={this.handleSubmit2}>Quote without comment</button>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default Quote
|
|
||||||
@@ -4,7 +4,6 @@ import Route from 'react-router-dom/Route';
|
|||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Writing_Microblogs extends Component {
|
class Writing_Microblogs extends Component {
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
@@ -34,7 +33,7 @@ class Writing_Microblogs extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleSubmit(event) {
|
handleSubmit(event) {
|
||||||
// alert('A title for the microblog was inputted: ' + this.state.title + '\nA microblog was posted: ' + this.state.value);
|
|
||||||
const postData = {
|
const postData = {
|
||||||
body: this.state.value,
|
body: this.state.value,
|
||||||
userImage: "bing-url",
|
userImage: "bing-url",
|
||||||
@@ -71,11 +70,8 @@ class Writing_Microblogs extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
|
||||||
<div style={{ width: "200px", height: "50px", marginTop: "180px", marginLeft: "50px" }}>
|
<div style={{ width: "200px", height: "50px", marginTop: "180px", marginLeft: "50px" }}>
|
||||||
<form>
|
<form>
|
||||||
<textarea placeholder="Enter Microblog Title" value={this.state.title} required onChange={this.handleChange} cols={30} rows={1} />
|
<textarea placeholder="Enter Microblog Title" value={this.state.title} required onChange={this.handleChange} cols={30} rows={1} />
|
||||||
@@ -100,7 +96,6 @@ class Writing_Microblogs extends Component {
|
|||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -32,12 +32,8 @@ const styles = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export class Navbar extends Component {
|
||||||
|
render() {
|
||||||
|
|
||||||
|
|
||||||
export class Navbar extends Component {
|
|
||||||
render() {
|
|
||||||
const authenticated = this.props.user.authenticated;
|
const authenticated = this.props.user.authenticated;
|
||||||
return (
|
return (
|
||||||
<AppBar>
|
<AppBar>
|
||||||
@@ -54,11 +50,9 @@ const styles = {
|
|||||||
{authenticated && <Button component={ Link } to='/logout'>
|
{authenticated && <Button component={ Link } to='/logout'>
|
||||||
Logout
|
Logout
|
||||||
</Button>}
|
</Button>}
|
||||||
{/* Commented out the delete button, because it should probably go on
|
{authenticated && <Button component={ Link } to='/delete'>
|
||||||
the profile or editProfile page instead of the NavBar */}
|
|
||||||
{/* <Button component={ Link } to='/delete'>
|
|
||||||
Delete Account
|
Delete Account
|
||||||
</Button> */}
|
</Button>}
|
||||||
</ToolBar>
|
</ToolBar>
|
||||||
</AppBar>
|
</AppBar>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -7,7 +7,8 @@ import Button from "@material-ui/core/Button";
|
|||||||
import withStyles from "@material-ui/core/styles/withStyles";
|
import withStyles from "@material-ui/core/styles/withStyles";
|
||||||
|
|
||||||
// Redux stuff
|
// Redux stuff
|
||||||
import { logoutUser } from "../redux/actions/userActions";
|
//import { logoutUser } from "../redux/actions/userActions";
|
||||||
|
import { deleteUser } from "../redux/actions/userActions";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
|
|
||||||
const styles = {
|
const styles = {
|
||||||
@@ -32,7 +33,8 @@ const styles = {
|
|||||||
export class Delete extends Component {
|
export class Delete extends Component {
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.props.logoutUser();
|
//this.props.logoutUser();
|
||||||
|
this.props.deleteUser();
|
||||||
this.props.history.push('/');
|
this.props.history.push('/');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,10 +47,12 @@ const mapStateToProps = (state) => ({
|
|||||||
user: state.user
|
user: state.user
|
||||||
});
|
});
|
||||||
|
|
||||||
const mapActionsToProps = { logoutUser };
|
//const mapActionsToProps = { logoutUser };
|
||||||
|
const mapActionsToProps = { deleteUser };
|
||||||
|
|
||||||
Delete.propTypes = {
|
Delete.propTypes = {
|
||||||
logoutUser: PropTypes.func.isRequired,
|
//logoutUser: PropTypes.func.isRequired,
|
||||||
|
deleteUser: PropTypes.func.isRequired,
|
||||||
user: PropTypes.object.isRequired,
|
user: PropTypes.object.isRequired,
|
||||||
classes: PropTypes.object.isRequired
|
classes: PropTypes.object.isRequired
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -16,13 +16,15 @@ import withStyles from "@material-ui/core/styles/withStyles";
|
|||||||
// Redux stuff
|
// Redux stuff
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { loginUser } from '../redux/actions/userActions';
|
import { loginUser } from '../redux/actions/userActions';
|
||||||
|
import { fontFamily } from '@material-ui/system';
|
||||||
|
|
||||||
|
//Theme
|
||||||
const styles = {
|
const styles = {
|
||||||
form: {
|
form: {
|
||||||
textAlign: "center"
|
textAlign: "center"
|
||||||
},
|
},
|
||||||
textField: {
|
textField: {
|
||||||
marginBottom: 30
|
marginBottom: 20
|
||||||
},
|
},
|
||||||
pageTitle: {
|
pageTitle: {
|
||||||
// marginTop: 20,
|
// marginTop: 20,
|
||||||
@@ -34,6 +36,9 @@ const styles = {
|
|||||||
},
|
},
|
||||||
progress: {
|
progress: {
|
||||||
position: "absolute"
|
position: "absolute"
|
||||||
|
},
|
||||||
|
p: {
|
||||||
|
fontFamily: "cursive",
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -104,9 +109,12 @@ export class Login extends Component {
|
|||||||
<Grid item sm />
|
<Grid item sm />
|
||||||
<Grid item sm>
|
<Grid item sm>
|
||||||
<img src={logo} className="app-logo" alt="logo" />
|
<img src={logo} className="app-logo" alt="logo" />
|
||||||
<Typography variant="h2" className={classes.pageTitle}>
|
<br></br>
|
||||||
Log in to Twistter
|
<Typography variant="p" className={classes.pageTitle} fontFamily = "Georgia, serif">
|
||||||
|
<b>Log in to Twistter</b>
|
||||||
|
<br></br>
|
||||||
</Typography>
|
</Typography>
|
||||||
|
<br></br>
|
||||||
<form noValidate onSubmit={this.handleSubmit}>
|
<form noValidate onSubmit={this.handleSubmit}>
|
||||||
<TextField
|
<TextField
|
||||||
id="email"
|
id="email"
|
||||||
|
|||||||
@@ -16,13 +16,17 @@ import withStyles from "@material-ui/core/styles/withStyles";
|
|||||||
// Redux stuff
|
// Redux stuff
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { signupUser } from '../redux/actions/userActions';
|
import { signupUser } from '../redux/actions/userActions';
|
||||||
|
import { border } from '@material-ui/system';
|
||||||
|
|
||||||
const styles = {
|
const styles = {
|
||||||
form: {
|
form: {
|
||||||
textAlign: "center"
|
textAlign: "center"
|
||||||
},
|
},
|
||||||
textField: {
|
textField: {
|
||||||
marginBottom: 30
|
marginBottom: 20,
|
||||||
|
//border: "1px solid #234",
|
||||||
|
display: "inline-block",
|
||||||
|
boxSizing: "border-box",
|
||||||
},
|
},
|
||||||
pageTitle: {
|
pageTitle: {
|
||||||
marginBottom: 40
|
marginBottom: 40
|
||||||
@@ -33,6 +37,14 @@ const styles = {
|
|||||||
},
|
},
|
||||||
progress: {
|
progress: {
|
||||||
position: "absolute"
|
position: "absolute"
|
||||||
|
},
|
||||||
|
div: {
|
||||||
|
borderRadius: "5px",
|
||||||
|
backgroundColor: "grey",
|
||||||
|
padding: "20px",
|
||||||
|
},
|
||||||
|
p: {
|
||||||
|
fontFamily: "Segoe UI",
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -92,9 +104,12 @@ export class Signup extends Component {
|
|||||||
<Grid item sm />
|
<Grid item sm />
|
||||||
<Grid item sm>
|
<Grid item sm>
|
||||||
<img src={logo} className="app-logo" alt="logo" />
|
<img src={logo} className="app-logo" alt="logo" />
|
||||||
<Typography variant="h2" className={classes.pageTitle}>
|
<br></br>
|
||||||
Create a new account
|
<Typography variant="p" className={classes.pageTitle}>
|
||||||
|
<b>Create a new account</b>
|
||||||
|
<br></br>
|
||||||
</Typography>
|
</Typography>
|
||||||
|
<br></br>
|
||||||
<form noValidate onSubmit={this.handleSubmit}>
|
<form noValidate onSubmit={this.handleSubmit}>
|
||||||
<TextField
|
<TextField
|
||||||
id="handle"
|
id="handle"
|
||||||
@@ -146,6 +161,8 @@ export class Signup extends Component {
|
|||||||
onChange={this.handleChange}
|
onChange={this.handleChange}
|
||||||
fullWidth
|
fullWidth
|
||||||
/>
|
/>
|
||||||
|
<br></br>
|
||||||
|
<br></br>
|
||||||
<Button
|
<Button
|
||||||
type="submit"
|
type="submit"
|
||||||
variant="contained"
|
variant="contained"
|
||||||
|
|||||||
@@ -6,66 +6,63 @@ import axios from 'axios';
|
|||||||
import { makeStyles, styled } from '@material-ui/core/styles';
|
import { makeStyles, styled } from '@material-ui/core/styles';
|
||||||
import Grid from '@material-ui/core/Grid';
|
import Grid from '@material-ui/core/Grid';
|
||||||
import Card from '@material-ui/core/Card';
|
import Card from '@material-ui/core/Card';
|
||||||
import CardMedia from '@material-ui/core/CardMedia';
|
|
||||||
import CardContent from '@material-ui/core/CardContent';
|
|
||||||
import Chip from '@material-ui/core/Chip';
|
import Chip from '@material-ui/core/Chip';
|
||||||
import Paper from '@material-ui/core/Paper';
|
|
||||||
import Typography from "@material-ui/core/Typography";
|
import Typography from "@material-ui/core/Typography";
|
||||||
import AddCircle from '@material-ui/icons/AddCircle';
|
import AddCircle from '@material-ui/icons/AddCircle';
|
||||||
|
import TextField from '@material-ui/core/TextField';
|
||||||
|
|
||||||
// component
|
// component
|
||||||
import Profile from '../components/profile/Profile';
|
|
||||||
import Userline from '../Userline';
|
import Userline from '../Userline';
|
||||||
import noImage from '../images/no-img.png';
|
import noImage from '../images/no-img.png';
|
||||||
|
|
||||||
|
|
||||||
const PostCard = styled(Card)({
|
|
||||||
background: 'linear-gradient(45deg, #1da1f2 90%)',
|
|
||||||
border: 3,
|
|
||||||
borderRadius: 3,
|
|
||||||
height:325,
|
|
||||||
width: 345,
|
|
||||||
padding: '0 30px',
|
|
||||||
});
|
|
||||||
|
|
||||||
const MyChip = styled(Chip)({
|
const MyChip = styled(Chip)({
|
||||||
margin: 2,
|
margin: 2,
|
||||||
color: 'primary'
|
color: 'primary'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
const styles = (theme) => ({
|
|
||||||
...theme
|
|
||||||
});
|
|
||||||
|
|
||||||
const handleDelete = () => {
|
|
||||||
alert("Delete this topic!");
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleAddCircle = () => {
|
|
||||||
alert("Add topic");
|
|
||||||
}
|
|
||||||
|
|
||||||
class user extends Component {
|
class user extends Component {
|
||||||
state = {
|
state = {
|
||||||
profile: null,
|
profile: null,
|
||||||
topics: null
|
imageUrl: null,
|
||||||
|
topics: null,
|
||||||
|
newTopic: null
|
||||||
};
|
};
|
||||||
|
|
||||||
|
handleDelete = (topic) => {
|
||||||
|
alert(`Delete topic: ${topic}!`);
|
||||||
|
}
|
||||||
|
|
||||||
|
handleAddCircle = () => {
|
||||||
|
axios.post('/putTopic', {
|
||||||
|
topic: this.state.newTopic
|
||||||
|
})
|
||||||
|
.then(function () {
|
||||||
|
location.reload();
|
||||||
|
})
|
||||||
|
.catch(function (err) {
|
||||||
|
console.log(err);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
handleChange(event) {
|
||||||
|
this.setState({
|
||||||
|
newTopic: event.target.value
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
axios
|
axios
|
||||||
.get("/user")
|
.get("/user")
|
||||||
.then(res => {
|
.then(res => {
|
||||||
console.log(res.data.credentials.handle);
|
|
||||||
this.setState({
|
this.setState({
|
||||||
profile: res.data.credentials.handle
|
profile: res.data.credentials.handle,
|
||||||
|
imageUrl: res.data.credentials.imageUrl
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.catch(err => console.log(err));
|
.catch(err => console.log(err));
|
||||||
axios
|
axios
|
||||||
.get("/getAllTopics")
|
.get("/getAllTopics")
|
||||||
.then(res => {
|
.then(res => {
|
||||||
console.log(res.data[1]);
|
|
||||||
this.setState({
|
this.setState({
|
||||||
topics: res.data
|
topics: res.data
|
||||||
})
|
})
|
||||||
@@ -83,22 +80,40 @@ class user extends Component {
|
|||||||
let topicsMarkup = this.state.topics ? (
|
let topicsMarkup = this.state.topics ? (
|
||||||
this.state.topics.map(topic => <MyChip
|
this.state.topics.map(topic => <MyChip
|
||||||
label={{topic}.topic.topic}
|
label={{topic}.topic.topic}
|
||||||
onDelete={handleDelete}/>)
|
key={{topic}.topic.topicId}
|
||||||
|
onDelete={ (topic) => this.handleDelete(topic)}/>)
|
||||||
) : (<p> loading topics...</p>);
|
) : (<p> loading topics...</p>);
|
||||||
|
|
||||||
|
let imageMarkup = this.state.imageUrl ? (
|
||||||
|
<img
|
||||||
|
src={this.state.imageUrl}
|
||||||
|
height="250"
|
||||||
|
width="250"
|
||||||
|
/>
|
||||||
|
) : (<img src={noImage}/>);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Grid container spacing={16}>
|
<Grid container spacing={16}>
|
||||||
<Grid item sm={8} xs={12}>
|
<Grid item sm={8} xs={12}>
|
||||||
<p>Post</p>
|
<p>Post</p>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid item sm={4} xs={12}>
|
<Grid item sm={4} xs={12}>
|
||||||
<img src={noImage}/>
|
{imageMarkup}
|
||||||
{profileMarkup}
|
{profileMarkup}
|
||||||
{topicsMarkup}
|
{topicsMarkup}
|
||||||
<MyChip
|
<TextField
|
||||||
icon={<AddCircle />}
|
id="newTopic"
|
||||||
|
label="new topic"
|
||||||
|
defaultValue=""
|
||||||
|
margin="normal"
|
||||||
|
variant="outlined"
|
||||||
|
value={this.state.newTopic}
|
||||||
|
onChange={ (event) => this.handleChange(event)}
|
||||||
|
/>
|
||||||
|
<AddCircle
|
||||||
|
color="primary"
|
||||||
clickable
|
clickable
|
||||||
onClick={handleAddCircle}
|
onClick={this.handleAddCircle}
|
||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
@@ -106,12 +121,4 @@ class user extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Userline.PropTypes = {
|
|
||||||
handle: PropTypes.object.isRequired
|
|
||||||
};
|
|
||||||
|
|
||||||
const mapStateToProps = (state) => ({
|
|
||||||
user: state.user
|
|
||||||
});
|
|
||||||
|
|
||||||
export default user;
|
export default user;
|
||||||
|
|||||||
Reference in New Issue
Block a user