mirror of
https://github.com/ClaytonWWilson/CS307-Team24.git
synced 2026-03-10 13:15:05 +00:00
Compare commits
281 Commits
shobhit
...
980028b032
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
980028b032 | ||
|
|
bde1930b48 | ||
|
|
b9cbd610a9 | ||
| daabbf80f6 | |||
| f9acefaafb | |||
| 948eff32c2 | |||
| 6de219505a | |||
| 7132a2ab45 | |||
| 5474543af4 | |||
| 6f77d03e2d | |||
| da6e7436ea | |||
| e7afac9a19 | |||
|
|
9449d3544b | ||
| 4f2e07756d | |||
|
|
f2cf7542a8 | ||
| ff7677bfb3 | |||
| 978af53a74 | |||
| a0a522f1d2 | |||
|
|
988c807af2 | ||
|
|
01b449d01d | ||
| f30a9ae27c | |||
| a459e6581e | |||
|
|
b769ab930a | ||
|
|
116f97bf64 | ||
|
|
a4efc15d58 | ||
|
|
39613584e7 | ||
| a1f9a4bef3 | |||
| c85eeccd4c | |||
|
|
bb50e0fa5d | ||
|
|
f111553827 | ||
|
|
5e935f3508 | ||
|
|
80a2e1894c | ||
| 8acd29e842 | |||
| b402c96864 | |||
|
|
76792148cd | ||
|
|
a92681451f | ||
|
|
e3522876d7 | ||
|
|
c7859e0f0a | ||
|
|
aad9dc0273 | ||
|
|
30df98343e | ||
| 719294f0ed | |||
| fc9994d42e | |||
|
|
de72bd9223 | ||
| b85bee7cba | |||
| 76330fd234 | |||
| b007666317 | |||
| a0d2532c22 | |||
| 739b1cc92a | |||
| 57087a5ea3 | |||
|
|
3424a7d34f | ||
| 1aff5ba99b | |||
|
|
2bcf6bfcb3 | ||
|
|
bae2947003 | ||
|
|
96423cee8a | ||
| f9a45ffe07 | |||
|
|
17c7e989ef | ||
|
|
efecf3b02a | ||
|
|
8b4c32b81f | ||
|
|
323cb5bcee | ||
|
|
4a4733f593 | ||
|
|
35cec7abf3 | ||
|
|
6989091fb1 | ||
|
|
699ea23750 | ||
| 0bcfdcdd6c | |||
| 4e5b100968 | |||
| 374c4d45b0 | |||
| 7efed257f2 | |||
| 99ffbe52a4 | |||
|
|
856cb8630e | ||
| 0776728e73 | |||
| 77a3ba9f69 | |||
| 7a0a5725b7 | |||
| 79051f2243 | |||
| 94db3f451d | |||
| fd1718a1f4 | |||
| 7fd976d4cb | |||
| 72d099e05e | |||
|
|
f3fcd5ee8d | ||
|
|
7141bf9000 | ||
| ebca5192e0 | |||
|
|
acecf704dc | ||
|
|
56e836451d | ||
| 1747a29c2e | |||
| 041e53c36f | |||
| 2d426840c0 | |||
| 5b5e785142 | |||
| a4cce0b75e | |||
| 825c126c6c | |||
| 49a4d55f1e | |||
| b4f4dec9ca | |||
| f0c4a2974f | |||
| c26ff21b20 | |||
| 3092fabfd2 | |||
| 1a6aae6545 | |||
| 4abaa13b09 | |||
| 09a3ccd12d | |||
| f7058a520d | |||
| 1a02b53d0f | |||
| e4ea325fb8 | |||
|
|
6e32b25861 | ||
|
|
684ccd1a85 | ||
|
|
f0ddaa30b1 | ||
| 8244631d4d | |||
| 4d97afcb09 | |||
| 88064c55a3 | |||
| 7c7256acbd | |||
| cff0fd4e05 | |||
|
|
e218708e0a | ||
|
|
445c8b39de | ||
|
|
6e8b7f410a | ||
|
|
07a8f0b7bb | ||
|
|
54cd1c44a7 | ||
|
|
ca7f793d4c | ||
|
|
a36212c23d | ||
|
|
b83eb0c897 | ||
| fee2225745 | |||
| 0d8850c45d | |||
| f7ef0cb333 | |||
| 731e01c552 | |||
|
|
0c9778949a | ||
|
|
1a2af4e9bb | ||
|
|
c34f06f130 | ||
| 3814377817 | |||
|
|
9fff6ed81c | ||
| 445687cc54 | |||
| 331509da7f | |||
|
|
64cc9bd156 | ||
|
|
6a78d74930 | ||
|
|
4e817c9647 | ||
|
|
7976110e2b | ||
|
|
3da2449050 | ||
|
|
607ea3fd55 | ||
|
|
e8110d643f | ||
| e06cc614cb | |||
| 709df1492d | |||
|
|
c3091cc10a | ||
|
|
81749c19ce | ||
|
|
1ccc195036 | ||
|
|
0aaa9014b9 | ||
| 3d9266778d | |||
|
|
2de3da928a | ||
| 297619cacb | |||
|
|
42c53fdbc4 | ||
|
|
c8aa1fd050 | ||
| a59c2feb4a | |||
| 0f1cfe0393 | |||
|
|
c6022dbc38 | ||
|
|
1d26eb97ad | ||
| 63e917f54c | |||
| 2f5ec1c5ac | |||
| 19f8f70bf2 | |||
| 02197ee940 | |||
| 5507247a7f | |||
| 5560b6e13c | |||
| 19d78596b5 | |||
| 9372a092ad | |||
| 7a6ac8499c | |||
| 6149e15b35 | |||
| 80670d054e | |||
| 947e5b01a4 | |||
| 7cc8a3f11f | |||
| 7476833f0a | |||
| a2ed627f2b | |||
| bbbfc4b750 | |||
| 38df4ef087 | |||
| 2bd1c08c2c | |||
|
|
6924af58a7 | ||
| 903ea35662 | |||
| e644498108 | |||
| 97bc9c4fb1 | |||
|
|
f2dac314e5 | ||
| b01aa92f96 | |||
|
|
d3bfd8b5f3 | ||
| d6876eab0b | |||
| f4bedea2c7 | |||
| d4ea00d2e9 | |||
| acd33d6a96 | |||
| 3fa4cd7033 | |||
| ab07d45205 | |||
| f1e4362205 | |||
| 1e4b2d16ef | |||
| e8e69cec31 | |||
|
|
ae89e3d63b | ||
|
|
f60c045483 | ||
|
|
1842eef2f8 | ||
| 56323801aa | |||
| ce984df437 | |||
| 112988c8fb | |||
| 325d37f0de | |||
|
|
35e5cf8e9d | ||
|
|
649b9b4a69 | ||
|
|
e73b2d02f3 | ||
|
|
50bc73870b | ||
| ca1d86acf1 | |||
|
|
da14700987 | ||
|
|
26afabe709 | ||
|
|
a61c296ddf | ||
|
|
1337071bec | ||
|
|
cd19364efc | ||
| 3c31db9bf5 | |||
|
|
8438ce27cf | ||
|
|
6db14e3868 | ||
| c96c77cd9f | |||
|
|
16567e2373 | ||
|
|
d3a77afe43 | ||
| fb6c1e3d98 | |||
|
|
42b73632c0 | ||
| 3d875e2bde | |||
|
|
b20408c144 | ||
|
|
c482f56762 | ||
|
|
9525ff7d0a | ||
|
|
f602b8251f | ||
|
|
70a12dcca4 | ||
| 3001ec0b38 | |||
| e8a403f575 | |||
|
|
657277bcad | ||
|
|
d69828ef7f | ||
| 44d3450b10 | |||
|
|
5fa4caf0a3 | ||
|
|
fd226b454e | ||
|
|
97998a8f09 | ||
|
|
13a1401759 | ||
|
|
0bbc453d54 | ||
|
|
e236ceeb4b | ||
|
|
1c81ae1663 | ||
|
|
c356dd18fa | ||
|
|
19780a1395 | ||
|
|
981795b288 | ||
|
|
ec041732d9 | ||
|
|
eb3766edb2 | ||
|
|
d9f6fb5d8e | ||
| b31a571b29 | |||
| 60f83da514 | |||
| 41bcc78c3a | |||
| f82f9984c6 | |||
|
|
6335690046 | ||
|
|
9d1f987ac1 | ||
|
|
b255006f7a | ||
|
|
f13580c727 | ||
|
|
4ec560de75 | ||
|
|
65ac1c7384 | ||
|
|
340d3537a6 | ||
|
|
de44f1eb89 | ||
|
|
5405d96150 | ||
| 0e6af081fa | |||
|
|
021e25de86 | ||
|
|
de38339cad | ||
|
|
a498b4748f | ||
|
|
4200c05ca1 | ||
|
|
6e9a86e5ce | ||
|
|
97650f6539 | ||
|
|
4aa029c649 | ||
| 1b3ac4d05a | |||
| 64c10cd172 | |||
|
|
37cce6c828 | ||
|
|
bcaf0920a6 | ||
|
|
b16c3eb50f | ||
|
|
79d23af3fc | ||
|
|
52bd8eed64 | ||
|
|
ac28b3e19e | ||
|
|
570866ff40 | ||
|
|
bdad36957c | ||
|
|
e524bc2811 | ||
|
|
714e6a4e07 | ||
|
|
cdbf0fcdc6 | ||
|
|
8f5020f881 | ||
|
|
eea2f56b49 | ||
| de4018a6d2 | |||
|
|
b17fb1f3f0 | ||
|
|
45f88861c8 | ||
|
|
ad853923c8 | ||
|
|
bc0b2549b4 | ||
|
|
e984afff74 | ||
|
|
1b66f18dd5 | ||
|
|
dede04aa8e | ||
|
|
bb0343ab30 | ||
|
|
7b8e40c7b0 | ||
| c5942a6634 | |||
| e062ffbb41 | |||
|
|
cb4885cadf | ||
|
|
d2032eef75 |
@@ -1,2 +1,2 @@
|
||||
# CS307-Team24
|
||||
CS307 Team 24 Twistter website.
|
||||
CS307 Team 24 Twistter website
|
||||
|
||||
@@ -1,43 +1,543 @@
|
||||
/* eslint-disable prefer-arrow-callback */
|
||||
/* eslint-disable promise/always-return */
|
||||
const admin = require('firebase-admin');
|
||||
const { admin, db } = require("../util/admin");
|
||||
|
||||
|
||||
exports.putPost = (req, res) => {
|
||||
const newPost = {
|
||||
body: req.body.body,
|
||||
userHandle: req.user.handle,
|
||||
userImage: req.body.userImage,
|
||||
userID: req.user.uid,
|
||||
microBlogTitle: req.body.microBlogTitle,
|
||||
createdAt: new Date().toISOString(),
|
||||
likeCount: 0,
|
||||
commentCount: 0,
|
||||
microBlogTopics: req.body.microBlogTopics,
|
||||
quoteBody: null
|
||||
};
|
||||
|
||||
const newPost = {
|
||||
body: req.body.body,
|
||||
userHandle: req.body.userHandle,
|
||||
userImage: req.body.userImage,
|
||||
microBlogTitle: req.body.microBlogTitle,
|
||||
createdAt: new Date().toISOString(),
|
||||
likeCount: 0,
|
||||
commentCount: 0,
|
||||
microBlogTopics: req.body.microBlogTopics
|
||||
|
||||
};
|
||||
admin
|
||||
.firestore()
|
||||
.collection("posts")
|
||||
.add(newPost)
|
||||
.then(doc => {
|
||||
doc.update({ postId: doc.id });
|
||||
const resPost = newPost;
|
||||
resPost.postId = doc.id;
|
||||
return res.status(200).json(resPost);
|
||||
})
|
||||
.catch(err => {
|
||||
console.error(err);
|
||||
return res.status(500).json({ error: "something went wrong" });
|
||||
});
|
||||
};
|
||||
|
||||
admin.firestore().collection('posts').add(newPost)
|
||||
.then((doc) => {
|
||||
const resPost = newPost;
|
||||
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.deletePost = (req, res) => {
|
||||
let posts = db.collection("posts")
|
||||
.where("userHandle", "==", req.user.handle)
|
||||
.get()
|
||||
.then((query) => {
|
||||
query.forEach((snap) => {
|
||||
snap.ref.delete();
|
||||
});
|
||||
return;
|
||||
})
|
||||
};
|
||||
|
||||
exports.getallPostsforUser = (req, res) => {
|
||||
var post_query = admin
|
||||
.firestore()
|
||||
.collection("posts")
|
||||
.where("userHandle", "==", req.user.handle);
|
||||
|
||||
admin.firestore().collection('posts').where('userHandle', '==', 'new user' ).get()
|
||||
.then((data) => {
|
||||
let posts = [];
|
||||
data.forEach(function(doc) {
|
||||
posts.push(doc.data());
|
||||
});
|
||||
return res.status(200).json(posts);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error(err);
|
||||
return res.status(500).json({error: 'Failed to fetch all posts written by specific user.'})
|
||||
})
|
||||
}
|
||||
post_query
|
||||
.get()
|
||||
.then(function(myPosts) {
|
||||
let posts = [];
|
||||
myPosts.forEach(function(doc) {
|
||||
posts.push(doc.data());
|
||||
});
|
||||
posts.sort((a, b) => -a.createdAt.localeCompare(b.createdAt));
|
||||
return res.status(200).json(posts);
|
||||
})
|
||||
|
||||
.then(function() {
|
||||
return res
|
||||
.status(200)
|
||||
.json("Successfully retrieved all user's posts from database.");
|
||||
})
|
||||
.catch(function(err) {
|
||||
return res
|
||||
.status(500)
|
||||
.json({message: "Failed to retrieve user's posts from database.", error: err});
|
||||
});
|
||||
};
|
||||
|
||||
exports.hidePost = (req, res) => {
|
||||
/* db
|
||||
.collection("posts")
|
||||
.doc(${req.params.postId}) */
|
||||
const postId = req.body.postId;
|
||||
db.doc(`/posts/${postId}`)
|
||||
.update({
|
||||
hidden: true
|
||||
})
|
||||
.then(() => {
|
||||
return res.status(200).json({message: "ok"});
|
||||
})
|
||||
.catch((error) => {
|
||||
return res.status(500).json(error);
|
||||
})
|
||||
};
|
||||
|
||||
exports.getallPosts = (req, res) => {
|
||||
let posts = [];
|
||||
let users = {};
|
||||
|
||||
// Get all the posts
|
||||
var postsPromise = new Promise((resolve, reject) => {
|
||||
db.collection("posts")
|
||||
.get()
|
||||
.then(allPosts => {
|
||||
allPosts.forEach(post => {
|
||||
posts.push(post.data());
|
||||
});
|
||||
posts.sort((a, b) => -a.createdAt.localeCompare(b.createdAt));
|
||||
resolve();
|
||||
})
|
||||
.catch(error => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
|
||||
// Get all users
|
||||
var usersPromise = new Promise((resolve, reject) => {
|
||||
db.collection("users")
|
||||
.get()
|
||||
.then(allUsers => {
|
||||
allUsers.forEach(user => {
|
||||
users[user.data().handle] = user.data();
|
||||
});
|
||||
resolve();
|
||||
})
|
||||
.catch(error => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
|
||||
// Wait for the two promises
|
||||
Promise.all([postsPromise, usersPromise])
|
||||
.then(() => {
|
||||
let newPosts = [];
|
||||
// Add the image url of the person who made the post to all of the post objects
|
||||
posts.forEach(post => {
|
||||
post.profileImage = users[post.userHandle].imageUrl
|
||||
? users[post.userHandle].imageUrl
|
||||
: null;
|
||||
newPosts.push(post);
|
||||
});
|
||||
return res.status(200).json(newPosts);
|
||||
})
|
||||
.catch(error => {
|
||||
return res.status(500).json({ error });
|
||||
});
|
||||
};
|
||||
|
||||
exports.getAlert = (req, res) => {
|
||||
var post_query = admin
|
||||
.firestore()
|
||||
.collection("posts")
|
||||
.where("microBlogTitle", "==", "Alert");
|
||||
|
||||
post_query
|
||||
.get()
|
||||
.then(function(myPosts) {
|
||||
let posts = [];
|
||||
myPosts.forEach(function(doc) {
|
||||
posts.push(doc.data());
|
||||
});
|
||||
posts.sort((a, b) => -a.createdAt.localeCompare(b.createdAt));
|
||||
return res.status(200).json(posts);
|
||||
})
|
||||
.then(function() {
|
||||
return res
|
||||
.status(200)
|
||||
.json("Successfully retrieved all user's posts from database.");
|
||||
})
|
||||
.catch(function(err) {
|
||||
return res
|
||||
.status(500)
|
||||
.json("Failed to retrieve user's posts from database.", err);
|
||||
});
|
||||
};
|
||||
|
||||
exports.getOtherUsersPosts = (req, res) => {
|
||||
var post_query = admin
|
||||
.firestore()
|
||||
.collection("posts")
|
||||
.where("userHandle", "==", req.body.handle);
|
||||
|
||||
// post_query += admin
|
||||
// .firestore()
|
||||
// .collection("posts")
|
||||
// .where("microBlogTitle", "==", "Alert").where("userHandle", "==", "Admin");
|
||||
|
||||
post_query
|
||||
.get()
|
||||
.then(function(myPosts) {
|
||||
let posts = [];
|
||||
myPosts.forEach(function(doc) {
|
||||
posts.push(doc.data());
|
||||
});
|
||||
posts.sort((a, b) => -a.createdAt.localeCompare(b.createdAt));
|
||||
return res.status(200).json(posts);
|
||||
})
|
||||
.then(function() {
|
||||
return res
|
||||
.status(200)
|
||||
.json("Successfully retrieved all user's posts from database.");
|
||||
})
|
||||
.catch(function(err) {
|
||||
return res
|
||||
.status(500)
|
||||
.json("Failed to retrieve user's posts from database.", err);
|
||||
});
|
||||
};
|
||||
|
||||
exports.quoteWithPost = (req, res) => {
|
||||
let quoteData;
|
||||
const quoteDoc = admin
|
||||
.firestore()
|
||||
.collection("quote")
|
||||
.where("userHandle", "==", req.user.handle)
|
||||
.where("quoteId", "==", req.params.postId)
|
||||
.limit(1);
|
||||
|
||||
const postDoc = db.doc(`/posts/${req.params.postId}`);
|
||||
|
||||
postDoc
|
||||
.get()
|
||||
.then(doc => {
|
||||
if (doc.exists) {
|
||||
quoteData = doc.data();
|
||||
return quoteDoc.get();
|
||||
} else {
|
||||
return res.status(404).json({ error: "Post not found" });
|
||||
}
|
||||
})
|
||||
.then(data => {
|
||||
if (data.empty) {
|
||||
return admin
|
||||
.firestore()
|
||||
.collection("quote")
|
||||
.add({
|
||||
quoteId: req.params.postId,
|
||||
userHandle: req.user.handle,
|
||||
quoteBody: req.body.quoteBody
|
||||
})
|
||||
.then(() => {
|
||||
const post = {
|
||||
body: quoteData.body,
|
||||
userHandle: req.user.handle,
|
||||
quoteBody: req.body.quoteBody,
|
||||
createdAt: new Date().toISOString(),
|
||||
userImage: req.body.userImage,
|
||||
likeCount: 0,
|
||||
commentCount: 0,
|
||||
userID: req.user.uid,
|
||||
microBlogTitle: quoteData.microBlogTitle,
|
||||
microBlogTopics: quoteData.microBlogTopics,
|
||||
quoteId: req.params.postId
|
||||
};
|
||||
return admin
|
||||
.firestore()
|
||||
.collection("posts")
|
||||
.add(post)
|
||||
.then(doc => {
|
||||
doc.update({ postId: doc.id });
|
||||
const resPost = post;
|
||||
resPost.postId = doc.id;
|
||||
return res.status(200).json(resPost);
|
||||
});
|
||||
});
|
||||
} else {
|
||||
return res.status(400).json({ error: "Post has already been quoted." });
|
||||
}
|
||||
})
|
||||
|
||||
.catch(err => {
|
||||
return res.status(500).json({ error: err });
|
||||
});
|
||||
};
|
||||
|
||||
exports.quoteWithoutPost = (req, res) => {
|
||||
let quoteData;
|
||||
const quoteDoc = admin
|
||||
.firestore()
|
||||
.collection("quote")
|
||||
.where("userHandle", "==", req.user.handle)
|
||||
.where("quoteId", "==", req.params.postId)
|
||||
.limit(1);
|
||||
|
||||
const postDoc = db.doc(`/posts/${req.params.postId}`);
|
||||
|
||||
postDoc
|
||||
.get()
|
||||
.then(doc => {
|
||||
if (doc.exists) {
|
||||
quoteData = doc.data();
|
||||
return quoteDoc.get();
|
||||
} else {
|
||||
return res.status(404).json({ error: "Post not found" });
|
||||
}
|
||||
})
|
||||
.then(data => {
|
||||
if (data.empty) {
|
||||
return admin
|
||||
.firestore()
|
||||
.collection("quote")
|
||||
.add({
|
||||
quoteId: req.params.postId,
|
||||
userHandle: req.user.handle,
|
||||
quoteBody: null
|
||||
})
|
||||
.then(() => {
|
||||
const post = {
|
||||
userHandle: req.user.handle,
|
||||
body: quoteData.body,
|
||||
quoteBody: null,
|
||||
createdAt: new Date().toISOString(),
|
||||
likeCount: 0,
|
||||
commentCount: 0,
|
||||
userID: req.user.uid,
|
||||
userImage: req.body.userImage,
|
||||
microBlogTitle: quoteData.microBlogTitle,
|
||||
microBlogTopics: quoteData.microBlogTopics,
|
||||
quoteId: req.params.postId
|
||||
};
|
||||
return admin
|
||||
.firestore()
|
||||
.collection("posts")
|
||||
.add(post)
|
||||
.then(doc => {
|
||||
doc.update({ postId: doc.id });
|
||||
const resPost = post;
|
||||
resPost.postId = doc.id;
|
||||
return res.status(200).json(resPost);
|
||||
});
|
||||
});
|
||||
} else {
|
||||
return res.status(400).json({ error: "Post has already been quoted." });
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
// return res.status(500).json({ error: "Something is wrong" });
|
||||
return res.status(500).json({ error: err });
|
||||
});
|
||||
};
|
||||
|
||||
exports.checkforLikePost = (req, res) => {
|
||||
const likedPostDoc = admin
|
||||
.firestore()
|
||||
.collection("likes")
|
||||
.where("userHandle", "==", req.user.handle)
|
||||
.where("postId", "==", req.params.postId)
|
||||
.limit(1);
|
||||
let result;
|
||||
|
||||
likedPostDoc
|
||||
.get()
|
||||
.then(data => {
|
||||
if (data.empty) {
|
||||
result = false;
|
||||
return res.status(200).json(result);
|
||||
} else {
|
||||
result = true;
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
return res.status(500).json({ error: err });
|
||||
});
|
||||
};
|
||||
|
||||
exports.likePost = (req, res) => {
|
||||
const postId = req.params.postId;
|
||||
let likedPostDoc;
|
||||
db.doc(`/users/${req.userData.handle}`)
|
||||
.get()
|
||||
.then(userDoc => {
|
||||
let likes = userDoc.data().likes;
|
||||
if (likes === undefined || likes === null) {
|
||||
likes = [];
|
||||
}
|
||||
|
||||
if (likes.includes(postId)) {
|
||||
return res
|
||||
.status(400)
|
||||
.json({ error: "This user has already liked this post" });
|
||||
}
|
||||
|
||||
likes.push(postId);
|
||||
|
||||
return userDoc.ref.update({ likes });
|
||||
})
|
||||
.then(() => {
|
||||
return db.doc(`/posts/${postId}`).get();
|
||||
})
|
||||
.then(postDoc => {
|
||||
let postData = postDoc.data();
|
||||
postData.likeCount++;
|
||||
likedPostDoc = postData;
|
||||
return postDoc.ref.update({ likeCount: postData.likeCount });
|
||||
})
|
||||
.then(() => {
|
||||
return res.status(201).json(likedPostDoc);
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
return res.status(500).json({ error: err });
|
||||
});
|
||||
|
||||
// let postData;
|
||||
// const likeDoc = admin.firestore().collection('likes').where('userHandle', '==', req.user.handle)
|
||||
// .where('postId', '==', req.params.postId).limit(1);
|
||||
|
||||
// const postDoc = db.doc(`/posts/${req.params.postId}`);
|
||||
|
||||
// postDoc.get()
|
||||
// .then((doc) => {
|
||||
// if(doc.exists) {
|
||||
// postData = doc.data();
|
||||
// return likeDoc.get();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return res.status(404).json({error: 'Post not found'});
|
||||
// }
|
||||
// })
|
||||
// .then((data) => {
|
||||
// if (data.empty) {
|
||||
// return admin.firestore().collection('likes').add({
|
||||
// postId : req.params.postId,
|
||||
// userHandle: req.user.handle
|
||||
|
||||
// })
|
||||
// .then(() => {
|
||||
// postData.likeCount++;
|
||||
// return postDoc.update({likeCount : postData.likeCount})
|
||||
// })
|
||||
// .then(() => {
|
||||
// return res.status(200).json(postData);
|
||||
// })
|
||||
// }
|
||||
// })
|
||||
// .catch((err) => {
|
||||
// return res.status(500).json({error: 'Something is wrong'});
|
||||
// })
|
||||
};
|
||||
|
||||
exports.unlikePost = (req, res) => {
|
||||
const postId = req.params.postId;
|
||||
let likedPostDoc;
|
||||
db.doc(`/users/${req.userData.handle}`)
|
||||
.get()
|
||||
.then(userDoc => {
|
||||
let likes = userDoc.data().likes;
|
||||
if (likes === undefined || likes === null) {
|
||||
likes = [];
|
||||
}
|
||||
|
||||
if (!likes.includes(postId)) {
|
||||
return res
|
||||
.status(400)
|
||||
.json({ error: "This user hasn't liked this post yet" });
|
||||
}
|
||||
|
||||
let i;
|
||||
for (i = 0; i < likes.length; i++) {
|
||||
if (likes[i] === postId) {
|
||||
likes.splice(i, 1);
|
||||
}
|
||||
}
|
||||
|
||||
return userDoc.ref.update({ likes });
|
||||
})
|
||||
.then(() => {
|
||||
return db.doc(`/posts/${postId}`).get();
|
||||
})
|
||||
.then(postDoc => {
|
||||
let postData = postDoc.data();
|
||||
postData.likeCount--;
|
||||
likedPostDoc = postData;
|
||||
return postDoc.ref.update({ likeCount: postData.likeCount });
|
||||
})
|
||||
.then(() => {
|
||||
return res.status(201).json(likedPostDoc);
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
return res.status(500).json({ error: err });
|
||||
});
|
||||
|
||||
// let postData;
|
||||
// const likeDoc = admin.firestore().collection('likes').where('userHandle', '==', req.user.handle)
|
||||
// .where('postId', '==', req.params.postId).limit(1);
|
||||
|
||||
// const postDoc = db.doc(`/posts/${req.params.postId}`);
|
||||
|
||||
// postDoc.get()
|
||||
// .then((doc) => {
|
||||
// if(doc.exists) {
|
||||
// postData = doc.data();
|
||||
// return likeDoc.get();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return res.status(404).json({error: 'Post not found'});
|
||||
// }
|
||||
// })
|
||||
// .then((data) => {
|
||||
// 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.getLikes = (req, res) => {
|
||||
db.doc(`/users/${req.userData.handle}`)
|
||||
.get()
|
||||
.then(doc => {
|
||||
let likes = doc.data().likes;
|
||||
if (likes === undefined || likes === null) {
|
||||
likes = [];
|
||||
}
|
||||
return res.status(200).json({ likes });
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
return res.status(500).json({ error: err });
|
||||
});
|
||||
};
|
||||
|
||||
exports.getFilteredPosts = (req, res) => {
|
||||
admin
|
||||
.firestore()
|
||||
.collection("posts")
|
||||
.where("userHandle", "==", "new user")
|
||||
.where("microBlogTopics", "==");
|
||||
};
|
||||
|
||||
128
functions/handlers/topic.js
Normal file
128
functions/handlers/topic.js
Normal file
@@ -0,0 +1,128 @@
|
||||
const { admin, db } = require("../util/admin");
|
||||
exports.putTopic = (req, res) => {
|
||||
let new_following = [];
|
||||
let userRef = db.doc(`/users/${req.userData.handle}`);
|
||||
userRef
|
||||
.get()
|
||||
.then(doc => {
|
||||
new_following = doc.data().followedTopics;
|
||||
new_following.push(req.body.following);
|
||||
|
||||
// add stuff
|
||||
userRef
|
||||
.set({ followedTopics: new_following }, { merge: true })
|
||||
.then(doc => {
|
||||
return res
|
||||
.status(201)
|
||||
.json({ message: `Following ${req.body.following}` });
|
||||
})
|
||||
.catch(err => {
|
||||
return res.status(500).json({ err });
|
||||
});
|
||||
return res.status(200).json({ message: "OK" });
|
||||
})
|
||||
.catch(err => {
|
||||
return res.status(500).json({ err });
|
||||
});
|
||||
};
|
||||
|
||||
exports.putNewTopic = (req, res) => {
|
||||
let new_following = [];
|
||||
let userRef = db.doc(`/users/${req.userData.handle}`);
|
||||
userRef
|
||||
.get()
|
||||
.then(doc => {
|
||||
let topics = [];
|
||||
new_following = doc.data().following;
|
||||
// new_following.push(req.body.following);
|
||||
new_following.forEach(follow => {
|
||||
if (follow.handle === req.body.handle) {
|
||||
// topics = follow.topics;
|
||||
follow.topics.push(req.body.topic);
|
||||
}
|
||||
});
|
||||
// return res.status(201).json({ new_following });
|
||||
|
||||
// add stuff
|
||||
userRef
|
||||
.set({ following: new_following }, { merge: true })
|
||||
.then(doc => {
|
||||
return res
|
||||
.status(201)
|
||||
.json({ message: `Following ${req.body.topic}` });
|
||||
})
|
||||
.catch(err => {
|
||||
return res.status(500).json({ err });
|
||||
});
|
||||
return res.status(200).json({ message: "OK" });
|
||||
})
|
||||
.catch(err => {
|
||||
return res.status(500).json({ err });
|
||||
});
|
||||
};
|
||||
|
||||
exports.getAllTopics = (req, res) => {
|
||||
admin
|
||||
.firestore()
|
||||
.collection("topics")
|
||||
.get()
|
||||
.then(data => {
|
||||
let topics = [];
|
||||
data.forEach(function(doc) {
|
||||
topics.push({
|
||||
topic: doc.data().topic,
|
||||
id: doc.id
|
||||
});
|
||||
});
|
||||
return res.status(200).json(topics);
|
||||
})
|
||||
.catch(err => {
|
||||
console.error(err);
|
||||
return res.status(500).json({ error: "Failed to fetch all topics." });
|
||||
});
|
||||
};
|
||||
|
||||
exports.deleteTopic = (req, res) => {
|
||||
let new_following = [];
|
||||
let userRef = db.doc(`/users/${req.userData.handle}`);
|
||||
userRef
|
||||
.get()
|
||||
.then(doc => {
|
||||
new_following = doc.data().followedTopics;
|
||||
// remove username from array
|
||||
new_following.forEach(function(follower, index) {
|
||||
if (follower === `${req.body.unfollow}`) {
|
||||
new_following.splice(index, 1);
|
||||
}
|
||||
});
|
||||
|
||||
// update database
|
||||
userRef
|
||||
.set({ followedTopics: new_following }, { merge: true })
|
||||
.then(doc => {
|
||||
return res
|
||||
.status(202)
|
||||
.json({ message: `Successfully unfollow ${req.body.unfollow}` });
|
||||
})
|
||||
.catch(err => {
|
||||
return res.status(500).json({ err });
|
||||
});
|
||||
return res.status(200).json({ message: "ok" });
|
||||
})
|
||||
.catch(err => {
|
||||
return res.status(500).json({ err });
|
||||
});
|
||||
};
|
||||
|
||||
exports.getUserTopics = (req, res) => {
|
||||
let data = [];
|
||||
db.doc(`/users/${req.body.handle}`)
|
||||
.get()
|
||||
.then(doc => {
|
||||
data = doc.data().followedTopics;
|
||||
return res.status(200).json({ data });
|
||||
})
|
||||
.catch(err => {
|
||||
return res.status(500).json({ err });
|
||||
});
|
||||
};
|
||||
File diff suppressed because it is too large
Load Diff
@@ -11,11 +11,25 @@ app.use(cors());
|
||||
*------------------------------------------------------------------*/
|
||||
const {
|
||||
getAuthenticatedUser,
|
||||
getDirectMessages,
|
||||
sendDirectMessage,
|
||||
createDirectMessage,
|
||||
checkDirectMessagesEnabled,
|
||||
toggleDirectMessages,
|
||||
getAllHandles,
|
||||
getUserDetails,
|
||||
getProfileInfo,
|
||||
login,
|
||||
signup,
|
||||
updateProfileInfo
|
||||
deleteUser,
|
||||
updateProfileInfo,
|
||||
uploadProfileImage,
|
||||
verifyUser,
|
||||
unverifyUser,
|
||||
getUserHandles,
|
||||
addSubscription,
|
||||
getSubs,
|
||||
removeSub
|
||||
} = require("./handlers/users");
|
||||
|
||||
// Adds a user to the database and registers them in firebase with
|
||||
@@ -27,7 +41,31 @@ app.post("/signup", signup);
|
||||
// and password
|
||||
app.post("/login", login);
|
||||
|
||||
app.get("/getUser/:handle", getUserDetails);
|
||||
//Deletes user account
|
||||
app.delete("/delete", fbAuth, deleteUser);
|
||||
|
||||
// Returns all direct messages that the user is participating in
|
||||
app.get("/dms", fbAuth, getDirectMessages);
|
||||
|
||||
// Send a message in a DM from one user to another
|
||||
app.post("/dms/send", fbAuth, sendDirectMessage);
|
||||
|
||||
// Create a new DM between two users
|
||||
app.post("/dms/new", fbAuth, createDirectMessage);
|
||||
|
||||
// Checks if the user provided has DMs enabled or not
|
||||
app.post("/dms/enabled", checkDirectMessagesEnabled);
|
||||
|
||||
// Used to toggle DMs on or off for the current user
|
||||
app.post("/dms/toggle", fbAuth, toggleDirectMessages);
|
||||
|
||||
app.get("/getUser", fbAuth, getUserDetails);
|
||||
|
||||
app.post("/getUserDetails", fbAuth, getUserDetails);
|
||||
|
||||
// Returns a list of all usernames
|
||||
// Used for searching
|
||||
app.get("/getAllHandles", fbAuth, getAllHandles);
|
||||
|
||||
// Returns all profile data of the currently logged in user
|
||||
app.get("/getProfileInfo", fbAuth, getProfileInfo);
|
||||
@@ -35,16 +73,98 @@ app.get("/getProfileInfo", fbAuth, getProfileInfo);
|
||||
// Updates the currently logged in user's profile information
|
||||
app.post("/updateProfileInfo", fbAuth, updateProfileInfo);
|
||||
|
||||
// Returns all user data for the logged in user.
|
||||
// Used when setting the state in Redux.
|
||||
app.get("/user", fbAuth, getAuthenticatedUser);
|
||||
|
||||
// Uploads a profile image
|
||||
app.post("/user/image", fbAuth, uploadProfileImage);
|
||||
|
||||
// Verifies the user sent to the request
|
||||
// Must be run by the Admin user
|
||||
app.post("/verifyUser", fbAuth, verifyUser);
|
||||
|
||||
// Unverifies the user sent to the request
|
||||
// Must be run by admin
|
||||
app.post("/unverifyUser", fbAuth, unverifyUser);
|
||||
|
||||
// get user handles with search phase
|
||||
app.post("/getUserHandles", fbAuth, getUserHandles);
|
||||
|
||||
// get user's subscription
|
||||
app.get("/getSubs", fbAuth, getSubs);
|
||||
|
||||
// add user to another user's "following" data field
|
||||
app.post("/addSubscription", fbAuth, addSubscription);
|
||||
|
||||
// remove one subscription
|
||||
app.post("/removeSub", fbAuth, removeSub);
|
||||
|
||||
/*------------------------------------------------------------------*
|
||||
* handlers/post.js *
|
||||
*------------------------------------------------------------------*/
|
||||
const { getallPostsforUser, putPost } = require("./handlers/post");
|
||||
|
||||
app.get("/getallPostsforUser", getallPostsforUser);
|
||||
|
||||
const {
|
||||
getallPostsforUser,
|
||||
getallPosts,
|
||||
putPost,
|
||||
hidePost,
|
||||
likePost,
|
||||
unlikePost,
|
||||
getLikes,
|
||||
quoteWithPost,
|
||||
quoteWithoutPost,
|
||||
checkforLikePost,
|
||||
getOtherUsersPosts,
|
||||
getAlert
|
||||
} = require("./handlers/post");
|
||||
|
||||
app.get("/getallPostsforUser", fbAuth, getallPostsforUser);
|
||||
|
||||
app.get("/getallPosts", getallPosts);
|
||||
|
||||
//Hides Post
|
||||
app.post("/hidePost", fbAuth, hidePost);
|
||||
|
||||
// Adds one post to the database
|
||||
app.post("/putPost", fbAuth, putPost);
|
||||
|
||||
app.get("/likes", fbAuth, getLikes);
|
||||
app.get("/like/:postId", fbAuth, likePost);
|
||||
app.get("/unlike/:postId", fbAuth, unlikePost);
|
||||
app.get("/checkforLikePost/:postId", fbAuth, checkforLikePost);
|
||||
|
||||
app.post("/quoteWithPost/:postId", fbAuth, quoteWithPost);
|
||||
app.post("/quoteWithoutPost/:postId", fbAuth, quoteWithoutPost);
|
||||
|
||||
app.post("/getOtherUsersPosts", fbAuth, getOtherUsersPosts);
|
||||
|
||||
app.get("/getAlert", fbAuth, getAlert);
|
||||
|
||||
/*------------------------------------------------------------------*
|
||||
* handlers/topic.js *
|
||||
*------------------------------------------------------------------*/
|
||||
const {
|
||||
putTopic,
|
||||
getAllTopics,
|
||||
deleteTopic,
|
||||
getUserTopics,
|
||||
putNewTopic
|
||||
} = require("./handlers/topic");
|
||||
|
||||
// add topic to database
|
||||
app.post("/putTopic", fbAuth, putTopic);
|
||||
|
||||
// get all topics from database
|
||||
app.get("/getAllTopics", fbAuth, getAllTopics);
|
||||
|
||||
// delete a specific topic
|
||||
app.post("/deleteTopic", fbAuth, deleteTopic);
|
||||
|
||||
// get topic for this user
|
||||
app.post("/getUserTopics", fbAuth, getUserTopics);
|
||||
|
||||
app.post("/putNewTopic", fbAuth, putNewTopic);
|
||||
|
||||
exports.api = functions.https.onRequest(app);
|
||||
|
||||
251
functions/package-lock.json
generated
251
functions/package-lock.json
generated
@@ -34,21 +34,6 @@
|
||||
"dom-storage": "2.1.0",
|
||||
"tslib": "1.10.0",
|
||||
"xmlhttprequest": "1.8.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@firebase/logger": {
|
||||
"version": "0.1.25",
|
||||
"resolved": "https://registry.npmjs.org/@firebase/logger/-/logger-0.1.25.tgz",
|
||||
"integrity": "sha512-/lRhuepVcCCnQ2jcO5Hr08SYdmZDTQU9fdPdzg+qXJ9k/QnIrD2RbswXQcL6mmae3uPpX7fFXQAoScJ9pzp50w=="
|
||||
},
|
||||
"@firebase/util": {
|
||||
"version": "0.2.28",
|
||||
"resolved": "https://registry.npmjs.org/@firebase/util/-/util-0.2.28.tgz",
|
||||
"integrity": "sha512-ZQMAWtXj8y5kvB6izs0aTM/jG+WO8HpqhXA/EwD6LckJ+1P5LnAhaLZt1zR4HpuCE+jeP5I32Id5RJ/aifFs6A==",
|
||||
"requires": {
|
||||
"tslib": "1.10.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"@firebase/app-types": {
|
||||
@@ -70,15 +55,9 @@
|
||||
"integrity": "sha512-foQHhvyB0RR+mb/+wmHXd/VOU+D8fruFEW1k79Q9wzyTPpovMBa1Mcns5fwEWBhUfi8bmoEtaGB8RSAHnTFzTg=="
|
||||
},
|
||||
"@firebase/database": {
|
||||
<<<<<<< HEAD
|
||||
"version": "0.5.3",
|
||||
"resolved": "https://registry.npmjs.org/@firebase/database/-/database-0.5.3.tgz",
|
||||
"integrity": "sha512-LnXKRE1AmjlS+iRF7j8vx+Ni8x85CmLP5u5Pw5rDKhKLn2eTR1tJKD937mUeeGEtDHwR1rrrkLYOqRR2cSG3hQ==",
|
||||
=======
|
||||
"version": "0.5.4",
|
||||
"resolved": "https://registry.npmjs.org/@firebase/database/-/database-0.5.4.tgz",
|
||||
"integrity": "sha512-Hz1Bi3fzIcNNocE4EhvvwoEQGurG2BGssWD3/6a2bzty+K1e57SLea2Ied8QYNBUU1zt/4McHfa3Y71EQIyn/w==",
|
||||
>>>>>>> 7969d3b10bc35a9078834c5ee2ba8c8fd60d338f
|
||||
"requires": {
|
||||
"@firebase/database-types": "0.4.3",
|
||||
"@firebase/logger": "0.1.25",
|
||||
@@ -113,11 +92,7 @@
|
||||
"@firebase/firestore": {
|
||||
"version": "1.5.3",
|
||||
"resolved": "https://registry.npmjs.org/@firebase/firestore/-/firestore-1.5.3.tgz",
|
||||
<<<<<<< HEAD
|
||||
"integrity": "sha512-CPYLvkGZBKE47oQC9a0q13UMVRj3LvnSbB1nOerktE3CGRHKy44LxDumamN8Kj067hV/80mKK9FdbeUufwO/Rg==",
|
||||
=======
|
||||
"integrity": "sha512-O/yAbXpitOA6g627cUl0/FHYlkTy1EiEKMKOlnlMOJF2fH+nLVZREXjsrCC7N2tIvTn7yYwfpZ4zpSNvrhwiTA==",
|
||||
>>>>>>> 7969d3b10bc35a9078834c5ee2ba8c8fd60d338f
|
||||
"requires": {
|
||||
"@firebase/firestore-types": "1.5.0",
|
||||
"@firebase/logger": "0.1.25",
|
||||
@@ -126,21 +101,6 @@
|
||||
"@grpc/proto-loader": "^0.5.0",
|
||||
"grpc": "1.23.3",
|
||||
"tslib": "1.10.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@firebase/logger": {
|
||||
"version": "0.1.25",
|
||||
"resolved": "https://registry.npmjs.org/@firebase/logger/-/logger-0.1.25.tgz",
|
||||
"integrity": "sha512-/lRhuepVcCCnQ2jcO5Hr08SYdmZDTQU9fdPdzg+qXJ9k/QnIrD2RbswXQcL6mmae3uPpX7fFXQAoScJ9pzp50w=="
|
||||
},
|
||||
"@firebase/util": {
|
||||
"version": "0.2.28",
|
||||
"resolved": "https://registry.npmjs.org/@firebase/util/-/util-0.2.28.tgz",
|
||||
"integrity": "sha512-ZQMAWtXj8y5kvB6izs0aTM/jG+WO8HpqhXA/EwD6LckJ+1P5LnAhaLZt1zR4HpuCE+jeP5I32Id5RJ/aifFs6A==",
|
||||
"requires": {
|
||||
"tslib": "1.10.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"@firebase/firestore-types": {
|
||||
@@ -173,16 +133,6 @@
|
||||
"@firebase/util": "0.2.28",
|
||||
"idb": "3.0.2",
|
||||
"tslib": "1.10.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@firebase/util": {
|
||||
"version": "0.2.28",
|
||||
"resolved": "https://registry.npmjs.org/@firebase/util/-/util-0.2.28.tgz",
|
||||
"integrity": "sha512-ZQMAWtXj8y5kvB6izs0aTM/jG+WO8HpqhXA/EwD6LckJ+1P5LnAhaLZt1zR4HpuCE+jeP5I32Id5RJ/aifFs6A==",
|
||||
"requires": {
|
||||
"tslib": "1.10.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"@firebase/installations-types": {
|
||||
@@ -190,6 +140,11 @@
|
||||
"resolved": "https://registry.npmjs.org/@firebase/installations-types/-/installations-types-0.1.2.tgz",
|
||||
"integrity": "sha512-fQaWIW8hyX1XUN7+FCSPjvM1agFjGidVuF4Sxi7aFwfyh5t+4fD2VpM4wCQbWmodnx4fZLvsuQd9mkxxU+lGYQ=="
|
||||
},
|
||||
"@firebase/logger": {
|
||||
"version": "0.1.25",
|
||||
"resolved": "https://registry.npmjs.org/@firebase/logger/-/logger-0.1.25.tgz",
|
||||
"integrity": "sha512-/lRhuepVcCCnQ2jcO5Hr08SYdmZDTQU9fdPdzg+qXJ9k/QnIrD2RbswXQcL6mmae3uPpX7fFXQAoScJ9pzp50w=="
|
||||
},
|
||||
"@firebase/messaging": {
|
||||
"version": "0.4.11",
|
||||
"resolved": "https://registry.npmjs.org/@firebase/messaging/-/messaging-0.4.11.tgz",
|
||||
@@ -198,16 +153,6 @@
|
||||
"@firebase/messaging-types": "0.3.2",
|
||||
"@firebase/util": "0.2.28",
|
||||
"tslib": "1.10.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@firebase/util": {
|
||||
"version": "0.2.28",
|
||||
"resolved": "https://registry.npmjs.org/@firebase/util/-/util-0.2.28.tgz",
|
||||
"integrity": "sha512-ZQMAWtXj8y5kvB6izs0aTM/jG+WO8HpqhXA/EwD6LckJ+1P5LnAhaLZt1zR4HpuCE+jeP5I32Id5RJ/aifFs6A==",
|
||||
"requires": {
|
||||
"tslib": "1.10.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"@firebase/messaging-types": {
|
||||
@@ -225,21 +170,6 @@
|
||||
"@firebase/performance-types": "0.0.3",
|
||||
"@firebase/util": "0.2.28",
|
||||
"tslib": "1.10.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@firebase/logger": {
|
||||
"version": "0.1.25",
|
||||
"resolved": "https://registry.npmjs.org/@firebase/logger/-/logger-0.1.25.tgz",
|
||||
"integrity": "sha512-/lRhuepVcCCnQ2jcO5Hr08SYdmZDTQU9fdPdzg+qXJ9k/QnIrD2RbswXQcL6mmae3uPpX7fFXQAoScJ9pzp50w=="
|
||||
},
|
||||
"@firebase/util": {
|
||||
"version": "0.2.28",
|
||||
"resolved": "https://registry.npmjs.org/@firebase/util/-/util-0.2.28.tgz",
|
||||
"integrity": "sha512-ZQMAWtXj8y5kvB6izs0aTM/jG+WO8HpqhXA/EwD6LckJ+1P5LnAhaLZt1zR4HpuCE+jeP5I32Id5RJ/aifFs6A==",
|
||||
"requires": {
|
||||
"tslib": "1.10.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"@firebase/performance-types": {
|
||||
@@ -272,16 +202,6 @@
|
||||
"@firebase/storage-types": "0.3.3",
|
||||
"@firebase/util": "0.2.28",
|
||||
"tslib": "1.10.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@firebase/util": {
|
||||
"version": "0.2.28",
|
||||
"resolved": "https://registry.npmjs.org/@firebase/util/-/util-0.2.28.tgz",
|
||||
"integrity": "sha512-ZQMAWtXj8y5kvB6izs0aTM/jG+WO8HpqhXA/EwD6LckJ+1P5LnAhaLZt1zR4HpuCE+jeP5I32Id5RJ/aifFs6A==",
|
||||
"requires": {
|
||||
"tslib": "1.10.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"@firebase/storage-types": {
|
||||
@@ -289,6 +209,14 @@
|
||||
"resolved": "https://registry.npmjs.org/@firebase/storage-types/-/storage-types-0.3.3.tgz",
|
||||
"integrity": "sha512-fUp4kpbxwDiWs/aIBJqBvXgFHZvgoND2JA0gJYSEsXtWtVwfgzY/710plErgZDeQKopX5eOR1sHskZkQUy0U6w=="
|
||||
},
|
||||
"@firebase/util": {
|
||||
"version": "0.2.28",
|
||||
"resolved": "https://registry.npmjs.org/@firebase/util/-/util-0.2.28.tgz",
|
||||
"integrity": "sha512-ZQMAWtXj8y5kvB6izs0aTM/jG+WO8HpqhXA/EwD6LckJ+1P5LnAhaLZt1zR4HpuCE+jeP5I32Id5RJ/aifFs6A==",
|
||||
"requires": {
|
||||
"tslib": "1.10.0"
|
||||
}
|
||||
},
|
||||
"@firebase/webchannel-wrapper": {
|
||||
"version": "0.2.26",
|
||||
"resolved": "https://registry.npmjs.org/@firebase/webchannel-wrapper/-/webchannel-wrapper-0.2.26.tgz",
|
||||
@@ -608,10 +536,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"ansi-regex": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz",
|
||||
"integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=",
|
||||
"dev": true
|
||||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz",
|
||||
"integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg=="
|
||||
},
|
||||
"ansi-styles": {
|
||||
"version": "3.2.1",
|
||||
@@ -830,28 +757,28 @@
|
||||
"integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=",
|
||||
"requires": {
|
||||
"number-is-nan": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"string-width": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz",
|
||||
"integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=",
|
||||
"requires": {
|
||||
"code-point-at": "^1.0.0",
|
||||
"is-fullwidth-code-point": "^1.0.0",
|
||||
"strip-ansi": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"strip-ansi": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz",
|
||||
"integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=",
|
||||
"requires": {
|
||||
"ansi-regex": "^2.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"string-width": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz",
|
||||
"integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=",
|
||||
"requires": {
|
||||
"code-point-at": "^1.0.0",
|
||||
"is-fullwidth-code-point": "^1.0.0",
|
||||
"strip-ansi": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"strip-ansi": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz",
|
||||
"integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=",
|
||||
"requires": {
|
||||
"ansi-regex": "^2.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"code-point-at": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz",
|
||||
@@ -1190,15 +1117,9 @@
|
||||
}
|
||||
},
|
||||
"end-of-stream": {
|
||||
<<<<<<< HEAD
|
||||
"version": "1.4.1",
|
||||
"resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.1.tgz",
|
||||
"integrity": "sha512-1MkrZNvWTKCaigbn+W15elq2BB/L22nqrSY5DKlo3X6+vclJm8Bb5djXJBmEX6fS3+zCh/F4VBK5Z2KxJt4s2Q==",
|
||||
=======
|
||||
"version": "1.4.3",
|
||||
"resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.3.tgz",
|
||||
"integrity": "sha512-cbNhPFS6MlYlWTGncSiDYbdqKhwWFy7kNeb1YSOG6K65i/wPTkLVCJQj0hXA4j0m5Da+hBWnqopEnu1FFelisQ==",
|
||||
>>>>>>> 7969d3b10bc35a9078834c5ee2ba8c8fd60d338f
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"once": "^1.4.0"
|
||||
@@ -1280,6 +1201,12 @@
|
||||
"text-table": "^0.2.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"ansi-regex": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz",
|
||||
"integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=",
|
||||
"dev": true
|
||||
},
|
||||
"debug": {
|
||||
"version": "4.1.1",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
|
||||
@@ -1294,6 +1221,15 @@
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz",
|
||||
"integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==",
|
||||
"dev": true
|
||||
},
|
||||
"strip-ansi": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz",
|
||||
"integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ansi-regex": "^3.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -1556,33 +1492,6 @@
|
||||
"@firebase/polyfill": "0.3.22",
|
||||
"@firebase/storage": "0.3.12",
|
||||
"@firebase/util": "0.2.28"
|
||||
},
|
||||
"dependencies": {
|
||||
"@firebase/database": {
|
||||
"version": "0.5.4",
|
||||
"resolved": "https://registry.npmjs.org/@firebase/database/-/database-0.5.4.tgz",
|
||||
"integrity": "sha512-Hz1Bi3fzIcNNocE4EhvvwoEQGurG2BGssWD3/6a2bzty+K1e57SLea2Ied8QYNBUU1zt/4McHfa3Y71EQIyn/w==",
|
||||
"requires": {
|
||||
"@firebase/database-types": "0.4.3",
|
||||
"@firebase/logger": "0.1.25",
|
||||
"@firebase/util": "0.2.28",
|
||||
"faye-websocket": "0.11.3",
|
||||
"tslib": "1.10.0"
|
||||
}
|
||||
},
|
||||
"@firebase/logger": {
|
||||
"version": "0.1.25",
|
||||
"resolved": "https://registry.npmjs.org/@firebase/logger/-/logger-0.1.25.tgz",
|
||||
"integrity": "sha512-/lRhuepVcCCnQ2jcO5Hr08SYdmZDTQU9fdPdzg+qXJ9k/QnIrD2RbswXQcL6mmae3uPpX7fFXQAoScJ9pzp50w=="
|
||||
},
|
||||
"@firebase/util": {
|
||||
"version": "0.2.28",
|
||||
"resolved": "https://registry.npmjs.org/@firebase/util/-/util-0.2.28.tgz",
|
||||
"integrity": "sha512-ZQMAWtXj8y5kvB6izs0aTM/jG+WO8HpqhXA/EwD6LckJ+1P5LnAhaLZt1zR4HpuCE+jeP5I32Id5RJ/aifFs6A==",
|
||||
"requires": {
|
||||
"tslib": "1.10.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"firebase-admin": {
|
||||
@@ -1710,8 +1619,7 @@
|
||||
"functional-red-black-tree": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz",
|
||||
"integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=",
|
||||
"optional": true
|
||||
"integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc="
|
||||
},
|
||||
"gaxios": {
|
||||
"version": "2.0.1",
|
||||
@@ -2259,15 +2167,9 @@
|
||||
}
|
||||
},
|
||||
"gtoken": {
|
||||
<<<<<<< HEAD
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/gtoken/-/gtoken-4.0.0.tgz",
|
||||
"integrity": "sha512-XaRCfHJxhj06LmnWNBzVTAr85NfAErq0W1oabkdqwbq3uL/QTB1kyvGog361Uu2FMG/8e3115sIy/97Rnd4GjQ==",
|
||||
=======
|
||||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npmjs.org/gtoken/-/gtoken-4.1.0.tgz",
|
||||
"integrity": "sha512-wqyn2gf5buzEZN4QNmmiiW2i2JkEdZnL7Z/9p44RtZqgt4077m4khRgAYNuu8cBwHWCc6MsP6eDUn/KkF6jFIw==",
|
||||
>>>>>>> 7969d3b10bc35a9078834c5ee2ba8c8fd60d338f
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"gaxios": "^2.0.0",
|
||||
@@ -2441,8 +2343,7 @@
|
||||
"imurmurhash": {
|
||||
"version": "0.1.4",
|
||||
"resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz",
|
||||
"integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=",
|
||||
"optional": true
|
||||
"integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o="
|
||||
},
|
||||
"inflight": {
|
||||
"version": "1.0.6",
|
||||
@@ -2457,8 +2358,7 @@
|
||||
"inherits": {
|
||||
"version": "2.0.4",
|
||||
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
|
||||
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
|
||||
"optional": true
|
||||
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
|
||||
},
|
||||
"inquirer": {
|
||||
"version": "6.5.2",
|
||||
@@ -2528,10 +2428,8 @@
|
||||
"is-fullwidth-code-point": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz",
|
||||
"integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=",
|
||||
"requires": {
|
||||
"number-is-nan": "^1.0.0"
|
||||
}
|
||||
"integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=",
|
||||
"dev": true
|
||||
},
|
||||
"is-obj": {
|
||||
"version": "2.0.0",
|
||||
@@ -2929,7 +2827,6 @@
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
|
||||
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"wrappy": "1"
|
||||
}
|
||||
@@ -3374,8 +3271,7 @@
|
||||
"signal-exit": {
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz",
|
||||
"integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=",
|
||||
"optional": true
|
||||
"integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0="
|
||||
},
|
||||
"slice-ansi": {
|
||||
"version": "2.1.0",
|
||||
@@ -3428,11 +3324,28 @@
|
||||
"string-width": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz",
|
||||
"integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=",
|
||||
"integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"code-point-at": "^1.0.0",
|
||||
"is-fullwidth-code-point": "^2.0.0",
|
||||
"strip-ansi": "^4.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"ansi-regex": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz",
|
||||
"integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=",
|
||||
"dev": true
|
||||
},
|
||||
"strip-ansi": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz",
|
||||
"integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ansi-regex": "^3.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"string_decoder": {
|
||||
@@ -3442,12 +3355,11 @@
|
||||
"optional": true
|
||||
},
|
||||
"strip-ansi": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz",
|
||||
"integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=",
|
||||
"dev": true,
|
||||
"version": "5.2.0",
|
||||
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz",
|
||||
"integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==",
|
||||
"requires": {
|
||||
"ansi-regex": "^3.0.0"
|
||||
"ansi-regex": "^4.1.0"
|
||||
}
|
||||
},
|
||||
"strip-json-comments": {
|
||||
@@ -3755,8 +3667,7 @@
|
||||
"wrappy": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
||||
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=",
|
||||
"optional": true
|
||||
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
|
||||
},
|
||||
"write": {
|
||||
"version": "1.0.3",
|
||||
|
||||
@@ -14,9 +14,11 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"axios": "^0.19.0",
|
||||
"busboy": "^0.3.1",
|
||||
"firebase": "^6.6.2",
|
||||
"firebase-admin": "^8.6.0",
|
||||
"firebase-functions": "^3.1.0"
|
||||
"firebase-functions": "^3.1.0",
|
||||
"strip-ansi": "^5.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "^5.12.0",
|
||||
|
||||
@@ -4,12 +4,12 @@ const { admin, db } = require('./admin');
|
||||
// The function will only execute if the user is logged in, or rather, they have
|
||||
// a valid token
|
||||
module.exports = (req, res, next) => {
|
||||
console.log(req);
|
||||
console.log(req.body);
|
||||
console.log(req.headers);
|
||||
console.log(req.headers.authorization);
|
||||
console.log(JSON.stringify(req.body));
|
||||
console.log(JSON.stringify(req.header));
|
||||
// console.log(req);
|
||||
// console.log(req.body);
|
||||
// console.log(req.headers);
|
||||
// console.log(req.headers.authorization);
|
||||
// console.log(JSON.stringify(req.body));
|
||||
// console.log(JSON.stringify(req.header));
|
||||
|
||||
let idToken;
|
||||
|
||||
@@ -32,6 +32,7 @@ module.exports = (req, res, next) => {
|
||||
.then((data) => {
|
||||
req.user.handle = data.docs[0].data().handle; // Save username
|
||||
req.user.imageUrl = data.docs[0].data().imageUrl;
|
||||
req.userData = data.docs[0].data(); // Stores all user data from the database
|
||||
return next();
|
||||
})
|
||||
.catch((err) => {
|
||||
|
||||
@@ -9,23 +9,39 @@ const isEmpty = (str) => {
|
||||
else return false;
|
||||
};
|
||||
|
||||
exports.validateUpdateProfileInfo = (data) => {
|
||||
exports.validateUpdateProfileInfo = (req) => {
|
||||
const newData = req.body;
|
||||
// const oldData = req.userData;
|
||||
let errors = {};
|
||||
let profileData = {};
|
||||
let profileData = req.userData;
|
||||
|
||||
// ?: Should users be able to change their handles and emails?
|
||||
|
||||
// Only adds the key to the database if the values are not empty
|
||||
if (!isEmpty(data.firstName)) profileData.firstName = data.firstName.trim();
|
||||
if (!isEmpty(data.lastName)) profileData.lastName = data.lastName.trim();
|
||||
if (!isEmpty(data.bio)) profileData.bio = data.bio.trim();
|
||||
// Deletes any unused keys so that they aren't stored in the database
|
||||
if (newData.firstName) {
|
||||
profileData.firstName = newData.firstName.toString().trim();
|
||||
} else {
|
||||
delete profileData.firstName;
|
||||
}
|
||||
|
||||
if (isEmpty(data.email)) {
|
||||
if (newData.lastName) {
|
||||
profileData.lastName = newData.lastName.toString().trim();
|
||||
} else {
|
||||
delete profileData.lastName;
|
||||
}
|
||||
|
||||
if (newData.bio) {
|
||||
profileData.bio = newData.bio.toString().trim();
|
||||
} else {
|
||||
delete profileData.bio;
|
||||
}
|
||||
|
||||
if (isEmpty(newData.email)) {
|
||||
errors.email = "Must not be empty.";
|
||||
} else if (!isEmail(data.email)) {
|
||||
} else if (!isEmail(newData.email)) {
|
||||
errors.email = "Must be a valid email.";
|
||||
} else {
|
||||
profileData.email = data.email;
|
||||
profileData.email = newData.email;
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
37
package-lock.json
generated
37
package-lock.json
generated
@@ -16,6 +16,15 @@
|
||||
"resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
|
||||
"integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI="
|
||||
},
|
||||
"axios": {
|
||||
"version": "0.19.0",
|
||||
"resolved": "https://registry.npmjs.org/axios/-/axios-0.19.0.tgz",
|
||||
"integrity": "sha512-1uvKqKQta3KBxIz14F2v06AEHZ/dIoeKfbTRkK1E5oqjDnuEerLmYTgJB5AiQZHJcljpg1TuRzdjDR06qNk0DQ==",
|
||||
"requires": {
|
||||
"follow-redirects": "1.5.10",
|
||||
"is-buffer": "^2.0.2"
|
||||
}
|
||||
},
|
||||
"body-parser": {
|
||||
"version": "1.19.0",
|
||||
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz",
|
||||
@@ -164,6 +173,24 @@
|
||||
"unpipe": "~1.0.0"
|
||||
}
|
||||
},
|
||||
"follow-redirects": {
|
||||
"version": "1.5.10",
|
||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.10.tgz",
|
||||
"integrity": "sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ==",
|
||||
"requires": {
|
||||
"debug": "=3.1.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"debug": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
|
||||
"integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
|
||||
"requires": {
|
||||
"ms": "2.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"forwarded": {
|
||||
"version": "0.1.2",
|
||||
"resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz",
|
||||
@@ -204,6 +231,16 @@
|
||||
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.0.tgz",
|
||||
"integrity": "sha512-M4Sjn6N/+O6/IXSJseKqHoFc+5FdGJ22sXqnjTpdZweHK64MzEPAyQZyEU3R/KRv2GLoa7nNtg/C2Ev6m7z+eA=="
|
||||
},
|
||||
"is-buffer": {
|
||||
"version": "2.0.4",
|
||||
"resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.4.tgz",
|
||||
"integrity": "sha512-Kq1rokWXOPXWuaMAqZiJW4XxsmD9zGx9q4aePabbn3qCRGedtH7Cm+zV8WETitMfu1wdh+Rvd6w5egwSngUX2A=="
|
||||
},
|
||||
"jwt-decode": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/jwt-decode/-/jwt-decode-2.2.0.tgz",
|
||||
"integrity": "sha1-fYa9VmefWM5qhHBKZX3TkruoGnk="
|
||||
},
|
||||
"media-typer": {
|
||||
"version": "0.3.0",
|
||||
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
{
|
||||
"type": "service_account",
|
||||
"project_id": "twistter-e4649",
|
||||
"private_key_id": "1e57494429e4fd7d17f6fc28524e14b8e5227596",
|
||||
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCyRdMZwXrpf3HB\nsVrGZVoPt+S+ahkT4SCCEWV/Q4O4hVyW277Rs0p7k5ZkZfkhcVVBUqKGMgW/Esvz\npx0VIgpg3gg308kMRmC3MGzYbodjynVyDHatyAZhhUi9cg0N2K9+vSsW5eSmWROe\nfVvB8hvr6m5xGVdJFA7DV4/0vm2cfy+Q/FlFb6vFmQTZtPZzGFf5BKoNMe7pMxey\n4zspAIZgRmxWDbAqqzX0PYk/WbXFgH/wn2X25S+ArHhoay2Hms65/NbWCV6mpFUJ\nYqzrlCn/WcwXGAm7tjmu00yD+bARabImh8R7+PSBaHMQ+SGdri2snIXWsvB/xi9/\nSNFqzHynAgMBAAECggEAVty/zapg1bnTt0FPziBfIA6FpaPzoSSN3uJUFozSdwuA\nAD+E/A9EiO7yFew71egvVrtJVmK0OxQRDSDNglkKPoWg8na+XL1D7a5qMpC0ZlKl\nJBNfljBCr6yuMySJqMf+Rp4siyUr4kO/0/cXyOnLYglhk7j5tzFPOi4FhgZtSRU9\nYckk5wwcBObUFE0Rmqf0gPcI9WuFUkusIjz3rjuEju1/U6E/VV5gHmMuQy3f9LHB\nnsiLAobx9+TGgs12CvkjWYpW5raUCCn5z/EYNPZSt7rg9CSWqXW009HCfTqi6i7o\nNpZ7qpp5DVQdHNFJunSGvI+k44+i8OE7HEY4xXt+OQKBgQDZ/E1QwJQoHuzPkrGW\nAc0a+NQeG8NwaXwsezlvYXMTbL27SxKXC3dzPT1WgNUKpaKj3wLJPar4NgPPSPi3\nqgmcvMqgwm4B+HPbXc1oxBS7/jD3pWJVyPO9Re17Uc0RYV/DORQhWe1Yq7TyMHvl\nbD/KqIvOxswigVxK4JMIxp4s7wKBgQDRXJfb4BHdR7CGfuTVQ19gH5uLgrK9ezBk\nQOLK+u9yBpoKyYSnD3OH/i0wG5bm3rUegzvwHGKKhDfiLbajMIt04n2DuVUm57HQ\n+Jca29V8XMWfhTbu3kDl+OOFmLvPCwg8C9edNTJWUVYu3EbwsyzCQY5TDroWGQdF\n6cQIkAIbyQKBgQCUtWd1UHuCR16cWOHniQEIhnoGtEAHHx9EJShQkLV1qfhhnlxn\nSL5LkpqWubsc0VR74LbA3N4XCJpevdRXT5vRHoZJV3q+w2UeYQaxkxrmCQoU1/GW\nvklxdRQGzg5M7hXrU7Qk8HlXxYPiuSq8n7WBJqyB+uLmI0P4HO6RzRW5ZwKBgBkr\nf5pQkvU+dCuHP+2fvuyogCPCn8iF8ehroJh0mKrlvklDtu36vpH/7eDVwEubRL0Z\nW/BfCT3L7YgEpOtzn6B6xko60tDtlAQijtAM09qysJOgCV2oXLcJOBlMpm+azO+j\nINXmmlmkR680jlbLw7rK9NhpcdfMRIKUOxwobAh5AoGBAJMN6n7Hy8nJRJZ18iHY\n3hEkVbKrLLMMHFDQj5BZQCeAp1v0Fj30RYJWS4hTzR9ht0MtdmPub460lh9hhqCM\nl3UnCJoz00ApF3Z2FRN/l0KpCFD9Gw2Hjyc3u9sEUpqd8G3cg3IZE6eZ6CZWljFT\nHcuQ2cTFdB8bq8oLUxXeY3Yv\n-----END PRIVATE KEY-----\n",
|
||||
"client_email": "firebase-adminsdk-pgjve@twistter-e4649.iam.gserviceaccount.com",
|
||||
"client_id": "102241295911303209723",
|
||||
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
|
||||
"token_uri": "https://oauth2.googleapis.com/token",
|
||||
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
|
||||
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-pgjve%40twistter-e4649.iam.gserviceaccount.com"
|
||||
}
|
||||
12
twistter-e4649-firebase-adminsdk-pgjve-382fc005e1.json
Normal file
12
twistter-e4649-firebase-adminsdk-pgjve-382fc005e1.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"type": "service_account",
|
||||
"project_id": "twistter-e4649",
|
||||
"private_key_id": "382fc005e17340a21dd39079feca75371330644d",
|
||||
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDL1bwTpEluR6dJ\nVfS/K1d76j2I3Wrn4qSbrTYm4/cAPBPlsBRO0bwrkhr+g0I6rwW/fFz8udjNAFB1\nfDfz769buR6go5us71I5LxMNviIhzFr59ZsEkcnUCgW8G7koicLEjWdstI4lJxZT\nRRolH+SFpPwsQAY399zjdBiCC8STbavVVhe+ChEDl/S2K72W7A7nWSMbLsyGsz2o\nQ9uIG3onwFNE7WRIeObWCxSBKlydMmTJ+p/CsTdFY4fUHb97QsMEmzRJox10kmyt\nP9l5wfJ2wUYvRXRJKq7Mwx1UnLduXP2oe/XvR5fzJLJ780HO6BNBf5IKcTHXHVBA\ne6ZtiL5dAgMBAAECggEAFvfN1NttjXL0KKak3hMA1+z8Y2WqXC1aUFMOMlz8Qhct\nmXNjy8CFAYEvGtVTgHqkR9Vi7PShYfLSc3U8diI155H5H4S6pUaPmfNHTwRzosyn\ncQRPJA6sEqvRGvHMxVfwjbvultMpiTTZpnxiMSNiLqT5PUs26CuSb5bErt1V7dP5\nn/lhY+4rzfXSrw38ZsO/gEvLZ/7iRA+JZgqE3Qs2cD5idxqqOcOLLiW741JpXTmd\n5ug/urJgSyvz+cNo3yHnajEtAxiSfkpU4sUHZ/WWqaRGWxpt3XWILtR9Q/4afPeM\n/T82YvddoW5pUwDpgvZxdVYjopuoxvnS298L0AGySQKBgQDqDD7Yh6SbOR3w4ZN9\nRO7q5KiJbyZmVdZ3lLZddsL/vto9JkUtnLDOMpYnb2TezGfN6ErzAkRQCSUsWK4m\nERbSK6oyUvevhlt/gHGP34uc/OCxGk2D7WCAS3s54ofDt2369tzIpGjsnkYM+h3b\nuZ5lFoWHG1YM3JtgcIIU6UygTwKBgQDe9ArV08wPDuXf4rcldmImQDB7xhGcg9xU\njAKEn5FZW1mvmBy3Sq1qpZj0baZz6eEDn6FBLwH1Ke5gdfrd8WnESUNnFnBBqpA1\nospIgUmKZ1sjyly9CHMQ11Kbzt7+kA9GYZrMbaMjS8M18qFEBZ7CoPLv5DLyabJW\nOkPzTwb/kwKBgQDR3fUkmEzj202bx8pHE97gxfTSd9aJAQN06uaz3GByjyKGnqB9\ni/mGjBnUdrCOj9+s5VT/ntK+qdSpdUODYuOBxiGxSnBK9kFpjTVHe35nYOHiLOHB\nIMPdhtGSUCzJNNvrpBzJ1ZM4SZwq2sSXWFRN9On7Amog0liJG5mpQqGxRQKBgHmP\nzFycF3XaZKH2xm8ppgg/FXBXJYEWMEr07+aJ7kEvWq4wHPAfSoCMe+JB6vDmg2Zr\nYgvdao7W5v83NKpQl5+LZrHNfTWAnxJviSWRQJyzD/Fqw7fZ5Is5K/SCDfn0aC+y\nxilSWhHDnFNM0Hr7KX3rLap43QJpePAk4qnF3AX7AoGBAOe5C1VMKoTapnxvo/FI\nBCvXw05SSEExfXVR0ryoqUxgu1asCkYyJSoWxOZQ+33npQ1/zV1mCXn/lNZcyveW\nZ5/cUw71grW8KBYFrW7LeQIzjZb7xPI3Z4EV0uYd2b69GkQk1buHj/gsswRhGEvx\nJM1DN1SCenbGcVLprM0vVelp\n-----END PRIVATE KEY-----\n",
|
||||
"client_email": "firebase-adminsdk-pgjve@twistter-e4649.iam.gserviceaccount.com",
|
||||
"client_id": "102241295911303209723",
|
||||
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
|
||||
"token_uri": "https://oauth2.googleapis.com/token",
|
||||
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
|
||||
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-pgjve%40twistter-e4649.iam.gserviceaccount.com"
|
||||
}
|
||||
@@ -1,5 +1,10 @@
|
||||
This project was bootstrapped with [Create React App](https://github.com/facebookincubator/create-react-app).
|
||||
|
||||
|
||||
Cloud: https://us-central1-twistter-e4649.cloudfunctions.net/api
|
||||
Local: http://localhost:5001/twistter-e4649/us-central1/api (npm install --save firebase)
|
||||
|
||||
|
||||
Below you will find some information on how to perform common tasks.<br>
|
||||
You can find the most recent version of this guide [here](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md).
|
||||
|
||||
|
||||
77
twistter-frontend/package-lock.json
generated
77
twistter-frontend/package-lock.json
generated
@@ -61,6 +61,14 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"@material-ui/icons": {
|
||||
"version": "4.5.1",
|
||||
"resolved": "https://registry.npmjs.org/@material-ui/icons/-/icons-4.5.1.tgz",
|
||||
"integrity": "sha512-YZ/BgJbXX4a0gOuKWb30mBaHaoXRqPanlePam83JQPZ/y4kl+3aW0Wv9tlR70hB5EGAkEJGW5m4ktJwMgxQAeA==",
|
||||
"requires": {
|
||||
"@babel/runtime": "^7.4.4"
|
||||
}
|
||||
},
|
||||
"@material-ui/styles": {
|
||||
"version": "4.5.0",
|
||||
"resolved": "https://registry.npmjs.org/@material-ui/styles/-/styles-4.5.0.tgz",
|
||||
@@ -2409,6 +2417,11 @@
|
||||
"resolved": "https://registry.npmjs.org/date-now/-/date-now-0.1.4.tgz",
|
||||
"integrity": "sha1-6vQ5/U1ISK105cx9vvIAZyueNFs="
|
||||
},
|
||||
"dayjs": {
|
||||
"version": "1.9.1",
|
||||
"resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.9.1.tgz",
|
||||
"integrity": "sha512-01NCTBg8cuMJG1OQc6PR7T66+AFYiPwgDvdJmvJBn29NGzIG+DIFxPLNjHzwz3cpFIvG+NcwIjP9hSaPVoOaDg=="
|
||||
},
|
||||
"debug": {
|
||||
"version": "2.6.9",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
|
||||
@@ -3058,11 +3071,6 @@
|
||||
"es5-ext": "~0.10.14"
|
||||
}
|
||||
},
|
||||
"eventemitter3": {
|
||||
"version": "3.1.2",
|
||||
"resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-3.1.2.tgz",
|
||||
"integrity": "sha512-tvtQIeLVHjDkJYnzf2dgVMxfuSGJeM/7UCG17TT4EumTfNtF+0nebF/4zWOIkCreAbtNqhGEboB6BWrwqNaw4Q=="
|
||||
},
|
||||
"events": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/events/-/events-1.1.1.tgz",
|
||||
@@ -3084,6 +3092,11 @@
|
||||
"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": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/exit-hook/-/exit-hook-1.1.1.tgz",
|
||||
@@ -3949,6 +3962,11 @@
|
||||
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
|
||||
"integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A=="
|
||||
},
|
||||
"fuse.js": {
|
||||
"version": "3.4.6",
|
||||
"resolved": "https://registry.npmjs.org/fuse.js/-/fuse.js-3.4.6.tgz",
|
||||
"integrity": "sha512-H6aJY4UpLFwxj1+5nAvufom5b2BT2v45P1MkPvdGIK8fWjQx/7o6tTT1+ALV0yawQvbmvCF0ufl2et8eJ7v7Cg=="
|
||||
},
|
||||
"gauge": {
|
||||
"version": "2.7.4",
|
||||
"resolved": "https://registry.npmjs.org/gauge/-/gauge-2.7.4.tgz",
|
||||
@@ -4321,13 +4339,20 @@
|
||||
"integrity": "sha1-ksnBN0w1CF912zWexWzCV8u5P6Q="
|
||||
},
|
||||
"http-proxy": {
|
||||
"version": "1.17.0",
|
||||
"resolved": "https://registry.npmjs.org/http-proxy/-/http-proxy-1.17.0.tgz",
|
||||
"integrity": "sha512-Taqn+3nNvYRfJ3bGvKfBSRwy1v6eePlm3oc/aWVxZp57DQr5Eq3xhKJi7Z4hZpS8PC3H4qI+Yly5EmFacGuA/g==",
|
||||
"version": "1.18.1",
|
||||
"resolved": "https://registry.npmjs.org/http-proxy/-/http-proxy-1.18.1.tgz",
|
||||
"integrity": "sha512-7mz/721AbnJwIVbnaSv1Cz3Am0ZLT/UBwkC92VlxhXv/k/BBQfM2fXElQNC27BVGr0uwUpplYPQM9LnaBMR5NQ==",
|
||||
"requires": {
|
||||
"eventemitter3": "^3.0.0",
|
||||
"eventemitter3": "^4.0.0",
|
||||
"follow-redirects": "^1.0.0",
|
||||
"requires-port": "^1.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"eventemitter3": {
|
||||
"version": "4.0.7",
|
||||
"resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.7.tgz",
|
||||
"integrity": "sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"http-proxy-middleware": {
|
||||
@@ -7159,6 +7184,22 @@
|
||||
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.9.0.tgz",
|
||||
"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-redux": {
|
||||
"version": "7.1.1",
|
||||
"resolved": "https://registry.npmjs.org/react-redux/-/react-redux-7.1.1.tgz",
|
||||
@@ -9717,6 +9758,11 @@
|
||||
"resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz",
|
||||
"integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c="
|
||||
},
|
||||
"typeface-roboto": {
|
||||
"version": "0.0.75",
|
||||
"resolved": "https://registry.npmjs.org/typeface-roboto/-/typeface-roboto-0.0.75.tgz",
|
||||
"integrity": "sha512-VrR/IiH00Z1tFP4vDGfwZ1esNqTiDMchBEXYY9kilT6wRGgFoCAlgkEUMHb1E3mB0FsfZhv756IF0+R+SFPfdg=="
|
||||
},
|
||||
"uglify-js": {
|
||||
"version": "3.4.10",
|
||||
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.4.10.tgz",
|
||||
@@ -9748,6 +9794,11 @@
|
||||
"resolved": "https://registry.npmjs.org/uid-number/-/uid-number-0.0.6.tgz",
|
||||
"integrity": "sha1-DqEOgDXo61uOREnwbaHHMGY7qoE="
|
||||
},
|
||||
"underscore": {
|
||||
"version": "1.11.0",
|
||||
"resolved": "https://registry.npmjs.org/underscore/-/underscore-1.11.0.tgz",
|
||||
"integrity": "sha512-xY96SsN3NA461qIRKZ/+qox37YXPtSBswMGfiNptr+wrt6ds4HaMw23TP612fEyGekRE6LNRiLYr/aqbHXNedw=="
|
||||
},
|
||||
"union-value": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.1.tgz",
|
||||
@@ -9978,6 +10029,14 @@
|
||||
"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": {
|
||||
"version": "0.10.0",
|
||||
"resolved": "https://registry.npmjs.org/watch/-/watch-0.10.0.tgz",
|
||||
|
||||
@@ -4,21 +4,27 @@
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@material-ui/core": "^4.4.3",
|
||||
"@material-ui/icons": "^4.5.1",
|
||||
"@material-ui/styles": "^4.5.0",
|
||||
"@material-ui/system": "^4.5.0",
|
||||
"axios": "^0.19.0",
|
||||
"clsx": "^1.0.4",
|
||||
"create-react-app": "^3.1.2",
|
||||
"dayjs": "^1.8.17",
|
||||
"fuse.js": "^3.4.6",
|
||||
"install": "^0.13.0",
|
||||
"jwt-decode": "^2.2.0",
|
||||
"node-pre-gyp": "^0.13.0",
|
||||
"react": "^16.9.0",
|
||||
"react-dom": "^16.9.0",
|
||||
"react-modal": "^3.11.1",
|
||||
"react-redux": "^7.1.1",
|
||||
"react-router-dom": "^5.1.0",
|
||||
"react-scripts": "0.9.5",
|
||||
"redux": "^4.0.4",
|
||||
"redux-thunk": "^2.3.0"
|
||||
"redux-thunk": "^2.3.0",
|
||||
"typeface-roboto": "0.0.75",
|
||||
"underscore": "^1.9.1"
|
||||
},
|
||||
"devDependencies": {},
|
||||
"scripts": {
|
||||
@@ -39,5 +45,5 @@
|
||||
"last 1 safari version"
|
||||
]
|
||||
},
|
||||
"proxy": "https://us-central1-twistter-e4649.cloudfunctions.net/api"
|
||||
"proxy": "http://localhost:5001/twistter-e4649/us-central1/api"
|
||||
}
|
||||
|
||||
@@ -10,67 +10,80 @@ import jwtDecode from "jwt-decode";
|
||||
// Redux
|
||||
import { Provider } from "react-redux";
|
||||
import store from "./redux/store";
|
||||
import MuiThemeProvider from '@material-ui/core/styles/MuiThemeProvider';
|
||||
import createMuiTheme from '@material-ui/core/styles/createMuiTheme';
|
||||
import themeObject from './util/theme';
|
||||
import { SET_AUTHENTICATED } from './redux/types';
|
||||
import { logoutUser, getUserData } from './redux/actions/userActions';
|
||||
import MuiThemeProvider from "@material-ui/core/styles/MuiThemeProvider";
|
||||
import createMuiTheme from "@material-ui/core/styles/createMuiTheme";
|
||||
import themeObject from "./util/theme";
|
||||
import { SET_AUTHENTICATED } from "./redux/types";
|
||||
import { logoutUser, getUserData } from "./redux/actions/userActions";
|
||||
|
||||
// Components
|
||||
import AuthRoute from "./util/AuthRoute";
|
||||
|
||||
// Pages
|
||||
import home from './pages/Home';
|
||||
import signup from './pages/Signup';
|
||||
import login from './pages/Login';
|
||||
import user from './pages/user';
|
||||
import logout from './pages/Logout';
|
||||
import writeMicroblog from './Writing_Microblogs.js';
|
||||
import editProfile from './pages/editProfile';
|
||||
import userLine from './Userline.js';
|
||||
import home from "./pages/Home";
|
||||
import signup from "./pages/Signup";
|
||||
import login from "./pages/Login";
|
||||
import user from "./pages/user";
|
||||
import logout from "./pages/Logout";
|
||||
import Delete from "./pages/Delete";
|
||||
import writeMicroblog from "./Writing_Microblogs.js";
|
||||
import editProfile from "./pages/editProfile";
|
||||
import userLine from "./Userline.js";
|
||||
import verify from "./pages/verify";
|
||||
import Search from "./pages/Search.js";
|
||||
import directMessages from "./pages/directMessages";
|
||||
import otherUser from "./pages/otherUser";
|
||||
|
||||
const theme = createMuiTheme(themeObject);
|
||||
|
||||
const token = localStorage.FBIdToken;
|
||||
if (token) {
|
||||
const decodedToken = jwtDecode(token);
|
||||
if (decodedToken.exp * 1000 < Date.now()) {
|
||||
store.dispatch(logoutUser);
|
||||
try {
|
||||
const decodedToken = jwtDecode(token);
|
||||
if (decodedToken.exp * 1000 < Date.now()) {
|
||||
store.dispatch(logoutUser());
|
||||
window.location.href = "/login";
|
||||
} else {
|
||||
store.dispatch({ type: SET_AUTHENTICATED });
|
||||
axios.defaults.headers.common["Authorization"] = token;
|
||||
store.dispatch(getUserData());
|
||||
}
|
||||
} catch (invalidTokenError) {
|
||||
store.dispatch(logoutUser());
|
||||
window.location.href = "/login";
|
||||
} else {
|
||||
store.dispatch({ type: SET_AUTHENTICATED });
|
||||
axios.defaults.headers.common['Authorization'] = token;
|
||||
store.dispatch(getUserData());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class App extends Component {
|
||||
render() {
|
||||
return (
|
||||
<MuiThemeProvider theme={theme}>
|
||||
<Provider store={store}>
|
||||
<Router>
|
||||
<div className='container' >
|
||||
<div className="container">
|
||||
<Navbar />
|
||||
</div>
|
||||
|
||||
<div className="app">
|
||||
<div className="app" style={{height: "700"}}>
|
||||
<Switch>
|
||||
{/* AuthRoute checks if the user is logged in and if they are it redirects them to /home */}
|
||||
<AuthRoute exact path="/signup" component={signup} />
|
||||
<AuthRoute exact path="/login" component={login} />
|
||||
<Route exact path="/logout" component={logout} />
|
||||
{/* AuthRoute checks if the user is logged in and if they are it redirects them to /home */}
|
||||
<AuthRoute exact path="/signup" component={signup} />
|
||||
<AuthRoute exact path="/login" component={login} />
|
||||
<AuthRoute exact path="/" component={home} />
|
||||
|
||||
<Route exact path="/user" component={user} />
|
||||
<Route exact path="/home" component={writeMicroblog} />
|
||||
<Route exact path="/edit" component={editProfile} />
|
||||
<Route exact path="/user" component={userLine} />
|
||||
<Route exact path="/logout" component={logout} />
|
||||
<Route exact path="/delete" component={Delete} />
|
||||
|
||||
<AuthRoute exact path="/" component={home}/>
|
||||
<Route exact path="/home" component={home} />
|
||||
<Route exact path="/user" component={user} />
|
||||
<Route exact path="/user/edit" component={editProfile} />
|
||||
<Route exact path="/verify" component={verify} />
|
||||
<Route exact path="/search" component={Search} />
|
||||
<Route exact path="/dm" component={directMessages} />
|
||||
<Route exact path="/user/:userhandle" component={otherUser} />
|
||||
|
||||
<AuthRoute exact path="/" component={home} />
|
||||
</Switch>
|
||||
</div>
|
||||
|
||||
</Router>
|
||||
</Provider>
|
||||
</MuiThemeProvider>
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import React, { Component } from "react";
|
||||
import { BrowserRouter as Router } from 'react-router-dom';
|
||||
import Route from 'react-router-dom/Route';
|
||||
// import { BrowserRouter as Router } from 'react-router-dom';
|
||||
// import Route from 'react-router-dom/Route';
|
||||
import axios from 'axios';
|
||||
import Box from '@material-ui/core/Box'
|
||||
import {borders} from '@material-ui/system';
|
||||
import { sizing } from '@material-ui/system';
|
||||
// import {borders} from '@material-ui/system';
|
||||
// import { sizing } from '@material-ui/system';
|
||||
// var moment = require('moment');
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ class Userline extends Component {
|
||||
<div style={{fontsize: "13px", textAlign: "left", marginLeft: "14px"}}>
|
||||
<p>Userline</p>
|
||||
</div>
|
||||
<Box border={1} width="25%" flex="1" height="auto" m={2} fontSize="13px" textAlign= "left" padding="5px" flexWrap= "wrap" flexDirection= "row" >
|
||||
<Box border={1} width="25%" flex="1" height="auto" m={2} fontSize="13px" textAlign="left" padding="5px" flexWrap="wrap" flexDirection="row" >
|
||||
<div style={{flexWrap: "wrap", flex: "1", flexDirection: "row", wordBreak: "break-word"}}>
|
||||
<p>
|
||||
{sortedPosts.map((microBlog) => <p>Microblog Title: {microBlog.microBlogTitle}
|
||||
@@ -50,7 +50,7 @@ class Userline extends Component {
|
||||
<br></br>Number of comments: {microBlog.commentCount}
|
||||
<br></br>Number of likes: {microBlog.likeCount}
|
||||
<br></br>Body of post: {microBlog.body}
|
||||
<br></br>Tagged topics: {microBlog.microBlogTopics.join("," + " ")}
|
||||
<br></br>Tagged topics: {microBlog.microBlogTopics.join(", ")}
|
||||
</p>)}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@@ -1,108 +1,195 @@
|
||||
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 Writing_Microblogs extends Component {
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
value: '',
|
||||
title: '',
|
||||
topics: '',
|
||||
characterCount: 250
|
||||
|
||||
};
|
||||
|
||||
|
||||
this.handleChange = this.handleChange.bind(this);
|
||||
this.handleSubmit = this.handleSubmit.bind(this);
|
||||
this.handleChangeforPost = this.handleChangeforPost.bind(this);
|
||||
this.handleChangeforTopics = this.handleChangeforTopics.bind(this);
|
||||
|
||||
}
|
||||
|
||||
handleChange(event) {
|
||||
this.setState( {title: event.target.value });
|
||||
}
|
||||
|
||||
handleChangeforTopics(event) {
|
||||
this.setState( {topics: event.target.value});
|
||||
}
|
||||
|
||||
handleSubmit(event) {
|
||||
// alert('A title for the microblog was inputted: ' + this.state.title + '\nA microblog was posted: ' + this.state.value);
|
||||
const postData = {
|
||||
body: this.state.value,
|
||||
userHandle: "new user",
|
||||
userImage: "bing-url",
|
||||
microBlogTitle: this.state.title,
|
||||
microBlogTopics: this.state.topics.split(', ')
|
||||
}
|
||||
const headers = {
|
||||
headers: { 'Content-Type': 'application/json'}
|
||||
}
|
||||
|
||||
axios
|
||||
.post('/putPost', postData, headers)
|
||||
.then((res) =>{
|
||||
alert('Post was shared successfully!')
|
||||
console.log(res.data);
|
||||
})
|
||||
.catch((err) => {
|
||||
alert('An error occured.');
|
||||
console.error(err);
|
||||
})
|
||||
event.preventDefault();
|
||||
this.setState({value: '', title: '',characterCount: 250, topics: ''})
|
||||
}
|
||||
|
||||
handleChangeforPost(event) {
|
||||
this.setState({value: event.target.value })
|
||||
}
|
||||
|
||||
handleChangeforCharacterCount(event) {
|
||||
const charCount = event.target.value.length
|
||||
const charRemaining = 250 - charCount
|
||||
this.setState({characterCount: charRemaining })
|
||||
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
<div style={{ width: "200px", height: "50px", marginTop: "180px", marginLeft: "50px" }}>
|
||||
<form>
|
||||
<textarea placeholder="Enter Microblog Title" value={this.state.title} required onChange={this.handleChange} cols={30} rows={1} />
|
||||
|
||||
</form>
|
||||
</div>
|
||||
<div style={{ width: "200px", height: "50px", marginLeft: "50px"}} >
|
||||
<form>
|
||||
<textarea placeholder="Enter topics seperated by a comma" value={this.state.topics} required onChange={this.handleChangeforTopics} cols={40} rows={1} />
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div style={{ width: "200px", marginLeft: "50px"}}>
|
||||
<form onSubmit={this.handleSubmit}>
|
||||
<textarea value={this.state.value} required maxLength="250" placeholder= "Write Microblog here..."
|
||||
onChange = { (e) => { this.handleChangeforPost(e); this.handleChangeforCharacterCount(e) } } cols={40} rows={20} />
|
||||
<div style={{ fontSize: "14px", marginRight: "-100px"}} >
|
||||
<p2>Characters Left: {this.state.characterCount}</p2>
|
||||
</div>
|
||||
<div style={{ marginRight: "-100px" }}>
|
||||
<button onClick>Share Post</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
);
|
||||
}
|
||||
// import { BrowserRouter as Router } from "react-router-dom";
|
||||
// import Route from "react-router-dom/Route";
|
||||
import axios from "axios";
|
||||
|
||||
// Material-UI
|
||||
import TextField from '@material-ui/core/TextField';
|
||||
// import Typography from '@material-ui/core/Typography';
|
||||
import Button from '@material-ui/core/Button';
|
||||
import withStyles from "@material-ui/styles/withStyles";
|
||||
import CircularProgress from "@material-ui/core/CircularProgress";
|
||||
|
||||
const styles = {
|
||||
container: {
|
||||
position: "fixed"
|
||||
},
|
||||
form: {
|
||||
width: "300px",
|
||||
height: "50px",
|
||||
marginTop: "180px",
|
||||
marginLeft: "50px"
|
||||
},
|
||||
textField: {
|
||||
marginBottom: 15
|
||||
},
|
||||
progress: {
|
||||
position: "absolute"
|
||||
},
|
||||
button: {
|
||||
positon: "relative",
|
||||
marginBottom: 30
|
||||
}
|
||||
}
|
||||
|
||||
export default Writing_Microblogs;
|
||||
class Writing_Microblogs extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
value: "",
|
||||
title: "",
|
||||
topics: "",
|
||||
characterCount: 250,
|
||||
loading: false
|
||||
};
|
||||
|
||||
this.handleChange = this.handleChange.bind(this);
|
||||
this.handleSubmit = this.handleSubmit.bind(this);
|
||||
this.handleChangeforPost = this.handleChangeforPost.bind(this);
|
||||
this.handleChangeforTopics = this.handleChangeforTopics.bind(this);
|
||||
}
|
||||
|
||||
handleChange(event) {
|
||||
this.setState({ title: event.target.value });
|
||||
}
|
||||
|
||||
handleChangeforTopics(event) {
|
||||
this.setState({ topics: event.target.value });
|
||||
}
|
||||
|
||||
handleSubmit = (event) => {
|
||||
// alert('A title for the microblog was inputted: ' + this.state.title + '\nA microblog was posted: ' + this.state.value);
|
||||
const postData = {
|
||||
body: this.state.value,
|
||||
userImage: "bing-url",
|
||||
microBlogTitle: this.state.title,
|
||||
microBlogTopics: this.state.topics.split(", ")
|
||||
};
|
||||
|
||||
this.setState({
|
||||
loading: true
|
||||
})
|
||||
const headers = {
|
||||
headers: { "Content-Type": "application/json" }
|
||||
};
|
||||
|
||||
let postPromise = axios
|
||||
.post("/putPost", postData, headers) // TODO: add topics
|
||||
.then(res => {
|
||||
// alert("Post was shared successfully!");
|
||||
console.log(res.data);
|
||||
})
|
||||
.catch(err => {
|
||||
alert("An error occured.");
|
||||
console.error(err);
|
||||
});
|
||||
console.log(postData.microBlogTopics);
|
||||
// let topicPromises = [];
|
||||
// postData.microBlogTopics.forEach(topic => {
|
||||
// topicPromises.push(axios
|
||||
// .post("/putTopic", {
|
||||
// following: topic
|
||||
// })
|
||||
// .then(res => {
|
||||
// console.log(res.data);
|
||||
// })
|
||||
// .catch(err => {
|
||||
// console.error(err);
|
||||
// })
|
||||
// )
|
||||
// });
|
||||
event.preventDefault();
|
||||
// topicPromises.push(postPromise);
|
||||
Promise.all([postPromise])
|
||||
.then(() => {
|
||||
this.setState({
|
||||
value: "",
|
||||
title: "",
|
||||
characterCount: 250,
|
||||
topics: "",
|
||||
loading: false
|
||||
});
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log(error);
|
||||
})
|
||||
}
|
||||
|
||||
handleChangeforPost(event) {
|
||||
|
||||
this.setState({ value: event.target.value });
|
||||
}
|
||||
|
||||
handleChangeforCharacterCount(event) {
|
||||
const charCount = event.target.value.length;
|
||||
const charRemaining = 250 - charCount;
|
||||
this.setState({ characterCount: charRemaining });
|
||||
}
|
||||
|
||||
render() {
|
||||
const { classes } = this.props;
|
||||
return (
|
||||
<div className={classes.container}>
|
||||
<form noValidate className={classes.form}>
|
||||
<TextField
|
||||
id="title"
|
||||
name="title"
|
||||
label="Title"
|
||||
className={classes.textField}
|
||||
value={this.state.title}
|
||||
variant="outlined"
|
||||
onChange={this.handleChange}
|
||||
fullWidth
|
||||
autoComplete='off'
|
||||
/>
|
||||
|
||||
<TextField
|
||||
id="topics"
|
||||
name="topics"
|
||||
label="Topics"
|
||||
className={classes.textField}
|
||||
value={this.state.topics}
|
||||
variant="outlined"
|
||||
onChange={this.handleChangeforTopics}
|
||||
color="primary"
|
||||
fullWidth
|
||||
autoComplete='off'
|
||||
/>
|
||||
<TextField
|
||||
id="content"
|
||||
name="content"
|
||||
label="Content"
|
||||
color="primary"
|
||||
className={classes.textField}
|
||||
value={this.state.value}
|
||||
helperText={`${this.state.characterCount} characters left`}
|
||||
multiline
|
||||
rows="9"
|
||||
variant="outlined"
|
||||
inputProps={{
|
||||
maxLength: 250
|
||||
}}
|
||||
onChange={(e) => {
|
||||
this.handleChangeforPost(e);
|
||||
this.handleChangeforCharacterCount(e);
|
||||
}}
|
||||
fullWidth
|
||||
autoComplete='off'
|
||||
/>
|
||||
<Button
|
||||
className={classes.button}
|
||||
onClick={this.handleSubmit}
|
||||
disabled={this.state.loading}
|
||||
variant="outlined"
|
||||
color="primary"
|
||||
>
|
||||
Share Post
|
||||
{this.state.loading && <CircularProgress size={30} className={classes.progress} />}
|
||||
</Button>
|
||||
</form>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default withStyles(styles)(Writing_Microblogs);
|
||||
|
||||
@@ -1,76 +1,89 @@
|
||||
/* eslint-disable */
|
||||
import React, { Component } from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
// import PropTypes from 'prop-types';
|
||||
import React, { Component } from "react";
|
||||
import { Link } from "react-router-dom";
|
||||
import PropTypes from "prop-types";
|
||||
|
||||
// Material UI stuff
|
||||
import AppBar from '@material-ui/core/AppBar';
|
||||
import ToolBar from '@material-ui/core/Toolbar';
|
||||
import Button from '@material-ui/core/Button';
|
||||
import AppBar from "@material-ui/core/AppBar";
|
||||
import ToolBar from "@material-ui/core/Toolbar";
|
||||
import Button from "@material-ui/core/Button";
|
||||
import withStyles from "@material-ui/core/styles/withStyles";
|
||||
|
||||
// Redux stuff
|
||||
// import { logoutUser } from '../../redux/actions/userActions';
|
||||
// import { connect } from 'react-redux';
|
||||
import { logoutUser } from "../../redux/actions/userActions";
|
||||
import { connect } from "react-redux";
|
||||
|
||||
// const styles = {
|
||||
// form: {
|
||||
// textAlign: "center"
|
||||
// },
|
||||
// textField: {
|
||||
// marginBottom: 30
|
||||
// },
|
||||
// pageTitle: {
|
||||
// marginBottom: 40
|
||||
// },
|
||||
// button: {
|
||||
// positon: "relative",
|
||||
// marginBottom: 30
|
||||
// },
|
||||
// progress: {
|
||||
// position: "absolute"
|
||||
// }
|
||||
// };
|
||||
const styles = {
|
||||
form: {
|
||||
textAlign: "center"
|
||||
},
|
||||
textField: {
|
||||
marginBottom: 30
|
||||
},
|
||||
pageTitle: {
|
||||
marginBottom: 40
|
||||
},
|
||||
button: {
|
||||
positon: "relative",
|
||||
marginBottom: 30
|
||||
},
|
||||
progress: {
|
||||
position: "absolute"
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
export class Navbar extends Component {
|
||||
render() {
|
||||
return (
|
||||
<AppBar>
|
||||
<ToolBar>
|
||||
<Button component={ Link } to='/'>
|
||||
Home
|
||||
</Button>
|
||||
<Button component={ Link } to='/login'>
|
||||
Login
|
||||
</Button>
|
||||
<Button component={ Link } to='/signup'>
|
||||
Sign Up
|
||||
</Button>
|
||||
<Button component={ Link } to='/logout'>
|
||||
Logout
|
||||
</Button>
|
||||
</ToolBar>
|
||||
</AppBar>
|
||||
)
|
||||
}
|
||||
export class Navbar extends Component {
|
||||
render() {
|
||||
const authenticated = this.props.user.authenticated;
|
||||
return (
|
||||
<AppBar>
|
||||
<ToolBar>
|
||||
<Button component={Link} to="/">
|
||||
Home
|
||||
</Button>
|
||||
{authenticated && (
|
||||
<Button component={Link} to="/user">
|
||||
Profile
|
||||
</Button>
|
||||
)}
|
||||
{authenticated && (
|
||||
<Button component={Link} to="/dm">
|
||||
DMs
|
||||
</Button>
|
||||
)}
|
||||
{!authenticated && (
|
||||
<Button component={Link} to="/login">
|
||||
Login
|
||||
</Button>
|
||||
)}
|
||||
{!authenticated && (
|
||||
<Button component={Link} to="/signup">
|
||||
Sign Up
|
||||
</Button>
|
||||
)}
|
||||
{authenticated && (
|
||||
<Button component={Link} to="/search">
|
||||
Search
|
||||
</Button>
|
||||
)}
|
||||
{authenticated && (
|
||||
<Button style={{position: "absolute", right: 30}} component={Link} to="/logout">
|
||||
Logout
|
||||
</Button>
|
||||
)}
|
||||
</ToolBar>
|
||||
</AppBar>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// const mapStateToProps = (state) => ({
|
||||
// user: state.user
|
||||
// })
|
||||
const mapStateToProps = state => ({
|
||||
user: state.user
|
||||
});
|
||||
|
||||
// const mapActionsToProps = { logoutUser };
|
||||
Navbar.propTypes = {
|
||||
user: PropTypes.object.isRequired,
|
||||
classes: PropTypes.object.isRequired
|
||||
};
|
||||
|
||||
// Navbar.propTypes = {
|
||||
// logoutUser: PropTypes.func.isRequired,
|
||||
// user: PropTypes.object.isRequired,
|
||||
// classes: PropTypes.object.isRequired
|
||||
// }
|
||||
|
||||
// export default connect(mapStateToProps, mapActionsToProps)(withStyles(styles)(Navbar));
|
||||
|
||||
export default Navbar;
|
||||
export default connect(mapStateToProps)(withStyles(styles)(Navbar));
|
||||
|
||||
48
twistter-frontend/src/components/profile/Profile.js
Normal file
48
twistter-frontend/src/components/profile/Profile.js
Normal file
@@ -0,0 +1,48 @@
|
||||
import React, { Component, Fragment } from "react";
|
||||
import PropTypes from "prop-types";
|
||||
import axios from "axios";
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
//MUI
|
||||
import withStyles from "@material-ui/core/styles/withStyles";
|
||||
import Card from "@material-ui/core/CardMedia";
|
||||
import Typography from "@material-ui/core/Typography";
|
||||
import Button from "@material-ui/core/Button";
|
||||
import { Paper } from "@material-ui/core";
|
||||
|
||||
const styles = theme => ({
|
||||
...theme
|
||||
});
|
||||
|
||||
class Profile extends Component {
|
||||
state = {
|
||||
profile: null
|
||||
};
|
||||
|
||||
componentDidMount() {
|
||||
axios
|
||||
.get("/user")
|
||||
.then(res => {
|
||||
console.log(res.data.userData.credentials.handle);
|
||||
this.setState({
|
||||
profile: res.data.userData.credentials.handle
|
||||
});
|
||||
})
|
||||
.catch(err => console.log(err));
|
||||
}
|
||||
render() {
|
||||
let profileMarkup = this.state.profile ? (
|
||||
<p>
|
||||
<Typography variant='h5'>{this.state.profile}</Typography>
|
||||
</p>) : <p>loading profile...</p>
|
||||
|
||||
return profileMarkup;
|
||||
}
|
||||
}
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
user: state.user,
|
||||
classes: PropTypes.object.isRequired
|
||||
});
|
||||
|
||||
export default connect(mapStateToProps)(withStyles(styles)(Profile));
|
||||
BIN
twistter-frontend/src/images/original.png
Normal file
BIN
twistter-frontend/src/images/original.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 60 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 60 KiB After Width: | Height: | Size: 48 KiB |
60
twistter-frontend/src/pages/Delete.js
Normal file
60
twistter-frontend/src/pages/Delete.js
Normal file
@@ -0,0 +1,60 @@
|
||||
/* eslint-disable */
|
||||
import React, { Component } from "react";
|
||||
import PropTypes from "prop-types";
|
||||
|
||||
// Material UI stuff
|
||||
import Button from "@material-ui/core/Button";
|
||||
import withStyles from "@material-ui/core/styles/withStyles";
|
||||
|
||||
// Redux stuff
|
||||
//import { logoutUser } from "../redux/actions/userActions";
|
||||
import { deleteUser } from "../redux/actions/userActions";
|
||||
import { connect } from "react-redux";
|
||||
|
||||
const styles = {
|
||||
form: {
|
||||
textAlign: "center"
|
||||
},
|
||||
textField: {
|
||||
marginBottom: 30
|
||||
},
|
||||
pageTitle: {
|
||||
marginBottom: 40
|
||||
},
|
||||
button: {
|
||||
positon: "relative",
|
||||
marginBottom: 30
|
||||
},
|
||||
progress: {
|
||||
position: "absolute"
|
||||
}
|
||||
};
|
||||
|
||||
export class Delete extends Component {
|
||||
|
||||
componentDidMount() {
|
||||
//this.props.logoutUser();
|
||||
this.props.deleteUser();
|
||||
this.props.history.push('/');
|
||||
}
|
||||
|
||||
render() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
const mapStateToProps = (state) => ({
|
||||
user: state.user
|
||||
});
|
||||
|
||||
//const mapActionsToProps = { logoutUser };
|
||||
const mapActionsToProps = { deleteUser };
|
||||
|
||||
Delete.propTypes = {
|
||||
//logoutUser: PropTypes.func.isRequired,
|
||||
deleteUser: PropTypes.func.isRequired,
|
||||
user: PropTypes.object.isRequired,
|
||||
classes: PropTypes.object.isRequired
|
||||
};
|
||||
|
||||
export default connect(mapStateToProps, mapActionsToProps)(withStyles(styles)(Delete));
|
||||
@@ -1,37 +1,551 @@
|
||||
import React, { Component } from 'react';
|
||||
import '../App.css';
|
||||
/* eslint-disable */
|
||||
import React, { Component } from "react";
|
||||
import PropTypes from "prop-types";
|
||||
import { connect } from "react-redux";
|
||||
import axios from "axios";
|
||||
|
||||
import logo from '../images/twistter-logo.png';
|
||||
// Material UI and React Router
|
||||
|
||||
import CircularProgress from "@material-ui/core/CircularProgress";
|
||||
import Button from "@material-ui/core/Button";
|
||||
import Grid from "@material-ui/core/Grid";
|
||||
import Card from "@material-ui/core/Card";
|
||||
import CardContent from "@material-ui/core/CardContent";
|
||||
import TextField from "@material-ui/core/TextField";
|
||||
|
||||
import Typography from "@material-ui/core/Typography";
|
||||
import withStyles from "@material-ui/styles/withStyles";
|
||||
|
||||
// component
|
||||
import "../App.css";
|
||||
import logo from "../images/twistter-logo.png";
|
||||
import noImage from "../images/no-img.png";
|
||||
import Writing_Microblogs from "../Writing_Microblogs";
|
||||
import ReactModal from "react-modal";
|
||||
|
||||
// Redux
|
||||
import { likePost, unlikePost, getLikes } from "../redux/actions/userActions";
|
||||
|
||||
const styles = {
|
||||
card: {
|
||||
marginBottom: 5
|
||||
}
|
||||
};
|
||||
|
||||
class Home extends Component {
|
||||
state = {
|
||||
likes: [],
|
||||
loading: false,
|
||||
following: null,
|
||||
topics: null
|
||||
};
|
||||
|
||||
componentDidMount() {
|
||||
this.setState({ loading: true });
|
||||
let userPromise = axios
|
||||
.get("/user")
|
||||
.then(res => {
|
||||
console.log(res.data.credentials.following);
|
||||
let list = [];
|
||||
res.data.credentials.following.forEach(element => {
|
||||
list.push(element.handle);
|
||||
});
|
||||
this.setState({
|
||||
following: list,
|
||||
topics: res.data.credentials.followedTopics
|
||||
});
|
||||
})
|
||||
.catch(err => console.log(err));
|
||||
|
||||
let allPosts;
|
||||
let postPromise = axios
|
||||
.get("/getallPosts")
|
||||
.then(res => {
|
||||
// console.log(res.data);
|
||||
// this.setState({
|
||||
// posts: res.data
|
||||
// });
|
||||
allPosts = res.data;
|
||||
// console.log(allPosts)
|
||||
return axios.get("/getAlert")
|
||||
})
|
||||
.then((res) => {
|
||||
// console.log(res.data)
|
||||
// res.data.forEach((adminAlert) => {
|
||||
// allPosts.push(adminAlert);
|
||||
// })
|
||||
this.setState({
|
||||
posts: allPosts
|
||||
});
|
||||
})
|
||||
|
||||
.catch(err => console.log(err));
|
||||
|
||||
Promise.all([userPromise, postPromise])
|
||||
.then(() => {
|
||||
this.setState({
|
||||
loading: false
|
||||
});
|
||||
})
|
||||
.catch(error => {
|
||||
console.log(error);
|
||||
});
|
||||
|
||||
this.props.getLikes();
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
this.setState({
|
||||
likes: nextProps.user.likes
|
||||
});
|
||||
}
|
||||
|
||||
flagPost = (event) => {
|
||||
// Flags a post
|
||||
let postId = event.target.dataset.key ? event.target.dataset.key : event.target.parentNode.dataset.key;
|
||||
console.log(postId);
|
||||
axios.post(`/hidePost`, {postId})
|
||||
.then((res) => {
|
||||
console.log(res.data);
|
||||
})
|
||||
.catch(err => {
|
||||
console.error(err);
|
||||
});
|
||||
// event.preventDefault();
|
||||
}
|
||||
|
||||
handleClickLikeButton = (event) => {
|
||||
// Need the ternary if statement because the user can click on the text or body of the
|
||||
// Button and they are two different html elements
|
||||
let postId = event.target.dataset.key
|
||||
? event.target.dataset.key
|
||||
: event.target.parentNode.dataset.key;
|
||||
console.log(postId);
|
||||
|
||||
let doc = document.getElementById(postId);
|
||||
// console.log(postId);
|
||||
if (this.state.likes.includes(postId)) {
|
||||
this.props.unlikePost(postId, this.state.likes);
|
||||
doc.dataset.likes--;
|
||||
} else {
|
||||
this.props.likePost(postId, this.state.likes);
|
||||
doc.dataset.likes++;
|
||||
}
|
||||
|
||||
doc.innerHTML = "Likes " + doc.dataset.likes;
|
||||
};
|
||||
|
||||
formatDate(dateString) {
|
||||
let newDate = new Date(Date.parse(dateString));
|
||||
return newDate.toDateString();
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
const {
|
||||
UI: { loading }
|
||||
} = this.props;
|
||||
let authenticated = this.props.user.authenticated;
|
||||
let { classes } = this.props;
|
||||
let username = this.props.user.credentials.handle;
|
||||
console.log(username);
|
||||
var hiddenBool = true;
|
||||
if (username === "Admin") {
|
||||
hiddenBool = false;
|
||||
}
|
||||
|
||||
console.log(hiddenBool);
|
||||
let postMarkup = this.state.posts ? ( this.state.following === undefined || this.state.following === null ? <Typography>You aren't following anybody right now</Typography> :
|
||||
this.state.posts.map(post => !post.hidden && this.state.following && (this.state.following.includes(post.userHandle) || post.userHandle === "Admin") ? (
|
||||
<Card className={classes.card} key={post.postId}>
|
||||
<CardContent>
|
||||
<Typography>
|
||||
{/* {
|
||||
this.state.imageUrl ? (<img src={this.state.imageUrl} height="50" width="50" />) :
|
||||
(<img src={noImage} height="50" width="50"/>)
|
||||
} */}
|
||||
{
|
||||
post.profileImage ? (<img src={post.profileImage} height="50" width="50" />) :
|
||||
(<img src={noImage} height="50" width="50"/>)
|
||||
}
|
||||
</Typography>
|
||||
<Typography variant="h5"><b>{post.userHandle}</b></Typography>
|
||||
<Typography variant="body2" color={"textSecondary"}>{this.formatDate(post.createdAt)}</Typography>
|
||||
<br />
|
||||
<Typography variant="body1"><b>{post.microBlogTitle}</b></Typography>
|
||||
<Typography variant="body2">{post.quoteBody}</Typography>
|
||||
<br />
|
||||
<Typography variant="body2">{post.body}</Typography>
|
||||
<br />
|
||||
<Typography variant="body2"><b>Topics:</b> {post.microBlogTopics.join(", ")}</Typography>
|
||||
<br />
|
||||
{!hiddenBool &&
|
||||
<Button
|
||||
onClick={this.flagPost}
|
||||
data-key={post.postId}
|
||||
variant = "contained"
|
||||
color = "primary"
|
||||
>
|
||||
Hide Post
|
||||
</Button>
|
||||
}
|
||||
|
||||
<Typography id={post.postId} data-likes={post.likeCount} variant="body2" color={"textSecondary"}>Likes {post.likeCount}</Typography>
|
||||
{/* <Like microBlog = {post.postId} count = {post.likeCount} name = {username}></Like> */}
|
||||
<Button
|
||||
onClick={this.handleClickLikeButton}
|
||||
data-key={post.postId}
|
||||
disabled={loading}
|
||||
variant="outlined"
|
||||
color="primary"
|
||||
>{
|
||||
this.state.likes && this.state.likes.includes(post.postId) ? 'Unlike' : 'Like'
|
||||
}</Button>
|
||||
<Quote microblog = {post.postId}></Quote>
|
||||
|
||||
{/* <button>Quote</button> */}
|
||||
|
||||
{/* <Typography variant="body2" color={"textSecondary"}>Likes {post.likeCount} Comments {post.commentCount}</Typography> */}
|
||||
|
||||
</CardContent>
|
||||
</Card>
|
||||
) : (
|
||||
<p></p>
|
||||
)
|
||||
)
|
||||
) : (
|
||||
<p>Loading post...</p>
|
||||
);
|
||||
|
||||
return authenticated ? (
|
||||
this.state.loading ? (
|
||||
<CircularProgress
|
||||
size={60}
|
||||
style={{ marginTop: "300px" }}
|
||||
></CircularProgress>
|
||||
) : (
|
||||
<Grid container>
|
||||
<Grid item sm={4} xs={8}>
|
||||
<Writing_Microblogs />
|
||||
</Grid>
|
||||
<Grid item sm={4} xs={8}>
|
||||
{postMarkup}
|
||||
</Grid>
|
||||
</Grid>
|
||||
)
|
||||
) : loading ? (
|
||||
<CircularProgress
|
||||
size={60}
|
||||
style={{ marginTop: "300px" }}
|
||||
></CircularProgress>
|
||||
) : (
|
||||
<div>
|
||||
<div>
|
||||
<img src={logo} className="app-logo" alt="logo" />
|
||||
<br/><br/>
|
||||
<b>Welcome to Twistter!</b>
|
||||
<br/><br/>
|
||||
<b>See the most interesting topics people are following right now.</b>
|
||||
<br />
|
||||
<br />
|
||||
<b>Welcome to Twistter!</b>
|
||||
<br />
|
||||
<br />
|
||||
<b>See the most interesting topics people are following right now.</b>
|
||||
</div>
|
||||
|
||||
<br/><br/><br/><br/>
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
|
||||
<div>
|
||||
<b>Join today or sign in if you already have an account.</b>
|
||||
<br/><br/>
|
||||
<div>
|
||||
<b>Join today or sign in if you already have an account.</b>
|
||||
<br />
|
||||
<br />
|
||||
<form action="./signup">
|
||||
<button className="authButtons signup">Sign up</button>
|
||||
<button className="authButtons signup">Sign up</button>
|
||||
</form>
|
||||
<br/>
|
||||
<br />
|
||||
<form action="./login">
|
||||
<button className="authButtons login">Sign in</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class Quote extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
characterCount: 250,
|
||||
showModal: false,
|
||||
value: ""
|
||||
};
|
||||
|
||||
this.handleSubmitWithoutPost = this.handleSubmitWithoutPost.bind(this);
|
||||
this.handleOpenModal = this.handleOpenModal.bind(this);
|
||||
this.handleCloseModal = this.handleCloseModal.bind(this);
|
||||
this.handleSubmit = this.handleSubmit.bind(this);
|
||||
}
|
||||
|
||||
handleSubmitWithoutPost(event) {
|
||||
const post = {
|
||||
userImage: "bing-url"
|
||||
};
|
||||
const headers = {
|
||||
headers: { "Content-Type": "application/json" }
|
||||
};
|
||||
axios
|
||||
.post(`/quoteWithoutPost/${this.props.microblog}`, post, headers)
|
||||
.then(res => {
|
||||
console.log(res.data);
|
||||
})
|
||||
.catch(err => {
|
||||
console.error(err);
|
||||
});
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
handleOpenModal() {
|
||||
this.setState({ showModal: true });
|
||||
}
|
||||
|
||||
handleCloseModal() {
|
||||
this.setState({ showModal: false, characterCount: 250, value: "" });
|
||||
}
|
||||
|
||||
handleChangeforPost(event) {
|
||||
this.setState({ value: event.target.value });
|
||||
}
|
||||
|
||||
handleChangeforCharacterCount(event) {
|
||||
const charCount = event.target.value.length;
|
||||
const charRemaining = 250 - charCount;
|
||||
this.setState({ characterCount: charRemaining });
|
||||
}
|
||||
|
||||
handleSubmit(event) {
|
||||
const quotedPost = {
|
||||
quoteBody: this.state.value,
|
||||
userImage: "bing-url"
|
||||
};
|
||||
const headers = {
|
||||
headers: { "Content-Type": "application/json" }
|
||||
};
|
||||
axios
|
||||
.post(`/quoteWithPost/${this.props.microblog}`, quotedPost, headers)
|
||||
.then(res => {
|
||||
console.log(res.data);
|
||||
})
|
||||
.catch(err => {
|
||||
console.error(err);
|
||||
});
|
||||
event.preventDefault();
|
||||
this.setState({ showModal: false, characterCount: 250, value: "" });
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
<Button
|
||||
variant="outlined"
|
||||
color="primary"
|
||||
onClick={this.handleOpenModal}
|
||||
>
|
||||
Quote with Post
|
||||
</Button>
|
||||
<ReactModal
|
||||
isOpen={this.state.showModal}
|
||||
style={{
|
||||
content: {
|
||||
height: "50%",
|
||||
width: "25%",
|
||||
marginTop: "auto",
|
||||
marginLeft: "auto",
|
||||
marginRight: "auto",
|
||||
marginBottom: "auto"
|
||||
}
|
||||
}}
|
||||
>
|
||||
<div style={{ width: "200px", marginLeft: "50px" }}>
|
||||
<form style={{ width: "350px" }}>
|
||||
{/* <textarea
|
||||
value={this.state.value}
|
||||
required
|
||||
maxLength="250"
|
||||
placeholder="Write Quoted Post here..."
|
||||
onChange={e => {
|
||||
this.handleChangeforPost(e);
|
||||
this.handleChangeforCharacterCount(e);
|
||||
|
||||
}}
|
||||
cols={40}
|
||||
rows={20}
|
||||
/> */}
|
||||
<TextField
|
||||
style={{ width: 300 }}
|
||||
value={this.state.value}
|
||||
label="Write Quoted Post here..."
|
||||
required
|
||||
multiline
|
||||
color="primary"
|
||||
rows="14"
|
||||
variant="outlined"
|
||||
inputProps={{
|
||||
maxLength: 250
|
||||
}}
|
||||
onChange={e => {
|
||||
this.handleChangeforPost(e);
|
||||
this.handleChangeforCharacterCount(e);
|
||||
}}
|
||||
autoComplete="off"
|
||||
></TextField>
|
||||
|
||||
<div style={{ fontSize: "14px", marginRight: "-100px" }}>
|
||||
<p2>Characters Left: {this.state.characterCount}</p2>
|
||||
</div>
|
||||
<Button
|
||||
variant="outlined"
|
||||
color="primary"
|
||||
onClick={this.handleSubmit}
|
||||
>
|
||||
Share Quoted Post
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
variant="outlined"
|
||||
color="primary"
|
||||
onClick={this.handleCloseModal}
|
||||
>
|
||||
Cancel
|
||||
</Button>
|
||||
</form>
|
||||
</div>
|
||||
</ReactModal>
|
||||
<Button
|
||||
variant="outlined"
|
||||
color="primary"
|
||||
onClick={this.handleSubmitWithoutPost}
|
||||
>
|
||||
Quote without Post
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class Like extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
num: this.props.count
|
||||
};
|
||||
|
||||
this.handleClick = this.handleClick.bind(this);
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.setState({
|
||||
like:
|
||||
localStorage.getItem(this.props.microBlog + this.props.name) === "false"
|
||||
});
|
||||
}
|
||||
|
||||
handleClick(){
|
||||
this.setState({
|
||||
like: !this.state.like
|
||||
});
|
||||
localStorage.setItem(
|
||||
this.props.microBlog + this.props.name,
|
||||
this.state.like.toString()
|
||||
);
|
||||
|
||||
if (this.state.like == false) {
|
||||
this.setState(() => {
|
||||
return { num: this.state.num + 1 };
|
||||
});
|
||||
axios
|
||||
.get(`/like/${this.props.microBlog}`)
|
||||
.then(res => {
|
||||
console.log(res.data);
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
});
|
||||
} else {
|
||||
this.setState(() => {
|
||||
return { num: this.state.num - 1 };
|
||||
});
|
||||
axios
|
||||
.get(`/unlike/${this.props.microBlog}`)
|
||||
.then(res => {
|
||||
console.log(res.data);
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default Home;
|
||||
/* componentDidMount() {
|
||||
axios.get(`/checkforLikePost/${this.props.microBlog}`)
|
||||
.then((res) => {
|
||||
this.setState({
|
||||
like2: res.data
|
||||
})
|
||||
console.log(res.data);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
if (this.state.like2 === this.state.like)
|
||||
{
|
||||
this.setState({
|
||||
like: false
|
||||
})
|
||||
}
|
||||
} */
|
||||
|
||||
render() {
|
||||
const label = this.state.like ? "Unlike" : "Like";
|
||||
return (
|
||||
<div>
|
||||
<Typography variant="body2" color={"textSecondary"}>
|
||||
Likes {this.state.num}
|
||||
</Typography>
|
||||
<button onClick={this.handleClick}>{label}</button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
user: state.user,
|
||||
UI: state.UI
|
||||
});
|
||||
|
||||
const mapActionsToProps = {
|
||||
likePost,
|
||||
unlikePost,
|
||||
getLikes
|
||||
};
|
||||
|
||||
Home.propTypes = {
|
||||
user: PropTypes.object.isRequired,
|
||||
likePost: PropTypes.func.isRequired,
|
||||
unlikePost: PropTypes.func.isRequired,
|
||||
getLikes: PropTypes.func.isRequired,
|
||||
classes: PropTypes.object.isRequired,
|
||||
UI: PropTypes.object.isRequired
|
||||
};
|
||||
|
||||
Like.propTypes = {
|
||||
user: PropTypes.object.isRequired
|
||||
};
|
||||
|
||||
Quote.propTypes = {
|
||||
user: PropTypes.object.isRequired
|
||||
};
|
||||
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
mapActionsToProps
|
||||
)(withStyles(styles)(Home, Like, Quote));
|
||||
|
||||
@@ -16,13 +16,15 @@ import withStyles from "@material-ui/core/styles/withStyles";
|
||||
// Redux stuff
|
||||
import { connect } from 'react-redux';
|
||||
import { loginUser } from '../redux/actions/userActions';
|
||||
import { fontFamily } from '@material-ui/system';
|
||||
|
||||
//Theme
|
||||
const styles = {
|
||||
form: {
|
||||
textAlign: "center"
|
||||
},
|
||||
textField: {
|
||||
marginBottom: 30
|
||||
marginBottom: 20
|
||||
},
|
||||
pageTitle: {
|
||||
// marginTop: 20,
|
||||
@@ -34,6 +36,9 @@ const styles = {
|
||||
},
|
||||
progress: {
|
||||
position: "absolute"
|
||||
},
|
||||
p: {
|
||||
fontFamily: "cursive",
|
||||
}
|
||||
};
|
||||
|
||||
@@ -104,14 +109,17 @@ export class Login extends Component {
|
||||
<Grid item sm />
|
||||
<Grid item sm>
|
||||
<img src={logo} className="app-logo" alt="logo" />
|
||||
<Typography variant="h2" className={classes.pageTitle}>
|
||||
Log in to Twistter
|
||||
<br></br>
|
||||
<Typography variant="h6" className={classes.pageTitle} fontFamily = "Georgia, serif">
|
||||
<b>Log in to Twistter</b>
|
||||
<br></br>
|
||||
</Typography>
|
||||
<br></br>
|
||||
<form noValidate onSubmit={this.handleSubmit}>
|
||||
<TextField
|
||||
id="email"
|
||||
name="email"
|
||||
label="Email*"
|
||||
label="Email or Username*"
|
||||
className={classes.textField}
|
||||
value={this.state.email}
|
||||
helperText={errors.email}
|
||||
@@ -119,6 +127,7 @@ export class Login extends Component {
|
||||
variant="outlined"
|
||||
onChange={this.handleChange}
|
||||
fullWidth
|
||||
autoComplete='off'
|
||||
/>
|
||||
<TextField
|
||||
id="password"
|
||||
@@ -132,6 +141,7 @@ export class Login extends Component {
|
||||
variant="outlined"
|
||||
onChange={this.handleChange}
|
||||
fullWidth
|
||||
autoComplete='off'
|
||||
/>
|
||||
<Button
|
||||
type="submit"
|
||||
@@ -146,7 +156,7 @@ export class Login extends Component {
|
||||
)}
|
||||
</Button>
|
||||
{errors.general && (
|
||||
<Typography color="error">Wrong Email or Password</Typography>
|
||||
<Typography color="error">Invalid username/email or password</Typography>
|
||||
)}
|
||||
</form>
|
||||
</Grid>
|
||||
|
||||
130
twistter-frontend/src/pages/Search.js
Normal file
130
twistter-frontend/src/pages/Search.js
Normal file
@@ -0,0 +1,130 @@
|
||||
import React, { Component } from "react";
|
||||
// import props
|
||||
// import { TextField, Button } from "@material-ui/core";
|
||||
import TextField from "@material-ui/core/TextField"
|
||||
import Grid from "@material-ui/core/Grid";
|
||||
import axios from "axios";
|
||||
import Fuse from "fuse.js";
|
||||
|
||||
import { BrowserRouter as Router } from "react-router-dom";
|
||||
|
||||
import CircularProgress from "@material-ui/core/CircularProgress";
|
||||
|
||||
const fuseOptions = {
|
||||
shouldSort: true,
|
||||
threshold: 0.6,
|
||||
location: 0,
|
||||
distance: 100,
|
||||
maxPatternLength: 32,
|
||||
minMatchCharLength: 1,
|
||||
keys: []
|
||||
};
|
||||
|
||||
let fuse;
|
||||
|
||||
|
||||
export class Search extends Component {
|
||||
state = {
|
||||
handles: [],
|
||||
// searchPhrase: null,
|
||||
searchResult: null,
|
||||
loading: false
|
||||
};
|
||||
|
||||
componentDidMount() {
|
||||
this.setState({loading: true});
|
||||
axios.get("/getAllHandles")
|
||||
.then((res) => {
|
||||
this.setState({
|
||||
handles: res.data,
|
||||
loading: false
|
||||
}, () => {
|
||||
// console.log(res.data);
|
||||
fuse = new Fuse(this.state.handles, fuseOptions); // "list" is the item array
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// handleSearch = () => {
|
||||
// console.log(this.state.searchPhase);
|
||||
// axios.post("/getUserHandles", {
|
||||
// userHandle: this.state.searchPhase
|
||||
// })
|
||||
// .then(res => {
|
||||
// console.log(res);
|
||||
|
||||
// this.setState({
|
||||
// searchResult: res.data
|
||||
// });
|
||||
// })
|
||||
// .catch(err => {
|
||||
// console.log(err);
|
||||
// });
|
||||
// };
|
||||
|
||||
handleChange = (event) => {
|
||||
let result = fuse.search(event.target.value);
|
||||
let parsed = [];
|
||||
result.forEach((res) => {
|
||||
// console.log(res)
|
||||
parsed.push(this.state.handles[res])
|
||||
})
|
||||
this.setState({
|
||||
searchResult: parsed.length !== 0 ? parsed : "No Results"
|
||||
})
|
||||
}
|
||||
|
||||
handleRedirect() {
|
||||
location.reload();
|
||||
}
|
||||
|
||||
render() {
|
||||
let resultMarkup = this.state.searchResult && this.state.searchResult !== "No Results" ? (
|
||||
this.state.searchResult.map(res =>
|
||||
<Router key={res}>
|
||||
<div>
|
||||
<a href={`/user/${res}`}>
|
||||
{res}
|
||||
</a>
|
||||
</div>
|
||||
</Router>
|
||||
)
|
||||
)
|
||||
:
|
||||
this.state.searchResult === "No Results" ?
|
||||
(
|
||||
<p> No results </p>
|
||||
)
|
||||
:
|
||||
(
|
||||
null
|
||||
)
|
||||
|
||||
return (
|
||||
|
||||
this.state.loading
|
||||
?
|
||||
<CircularProgress size={60} style={{marginTop: "300px"}}></CircularProgress>
|
||||
:
|
||||
<Grid>
|
||||
<Grid>
|
||||
<TextField
|
||||
id="standard-required"
|
||||
label="Username"
|
||||
margin="normal"
|
||||
// value={this.state.searchPhrase}
|
||||
onChange={this.handleChange}
|
||||
/>
|
||||
</Grid>
|
||||
<Grid>
|
||||
{/* <Button color="primary" onClick={this.handleSearch}>
|
||||
Search
|
||||
</Button> */}
|
||||
</Grid>
|
||||
<Grid>{resultMarkup}</Grid>
|
||||
</Grid>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default Search;
|
||||
@@ -16,13 +16,17 @@ import withStyles from "@material-ui/core/styles/withStyles";
|
||||
// Redux stuff
|
||||
import { connect } from 'react-redux';
|
||||
import { signupUser } from '../redux/actions/userActions';
|
||||
import { border } from '@material-ui/system';
|
||||
|
||||
const styles = {
|
||||
form: {
|
||||
textAlign: "center"
|
||||
},
|
||||
textField: {
|
||||
marginBottom: 30
|
||||
marginBottom: 20,
|
||||
//border: "1px solid #234",
|
||||
display: "inline-block",
|
||||
boxSizing: "border-box",
|
||||
},
|
||||
pageTitle: {
|
||||
marginBottom: 40
|
||||
@@ -33,6 +37,14 @@ const styles = {
|
||||
},
|
||||
progress: {
|
||||
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>
|
||||
<img src={logo} className="app-logo" alt="logo" />
|
||||
<Typography variant="h2" className={classes.pageTitle}>
|
||||
Create a new account
|
||||
<br></br>
|
||||
<Typography variant="p" className={classes.pageTitle}>
|
||||
<b>Create a new account</b>
|
||||
<br></br>
|
||||
</Typography>
|
||||
<br></br>
|
||||
<form noValidate onSubmit={this.handleSubmit}>
|
||||
<TextField
|
||||
id="handle"
|
||||
@@ -107,6 +122,7 @@ export class Signup extends Component {
|
||||
variant="outlined"
|
||||
onChange={this.handleChange}
|
||||
fullWidth
|
||||
autoComplete='off'
|
||||
/>
|
||||
<TextField
|
||||
id="email"
|
||||
@@ -119,6 +135,7 @@ export class Signup extends Component {
|
||||
variant="outlined"
|
||||
onChange={this.handleChange}
|
||||
fullWidth
|
||||
autoComplete='off'
|
||||
/>
|
||||
<TextField
|
||||
id="password"
|
||||
@@ -132,6 +149,7 @@ export class Signup extends Component {
|
||||
variant="outlined"
|
||||
onChange={this.handleChange}
|
||||
fullWidth
|
||||
autoComplete='off'
|
||||
/>
|
||||
<TextField
|
||||
id="confirmPassword"
|
||||
@@ -145,7 +163,10 @@ export class Signup extends Component {
|
||||
variant="outlined"
|
||||
onChange={this.handleChange}
|
||||
fullWidth
|
||||
autoComplete='off'
|
||||
/>
|
||||
<br></br>
|
||||
<br></br>
|
||||
<Button
|
||||
type="submit"
|
||||
variant="contained"
|
||||
@@ -159,7 +180,7 @@ export class Signup extends Component {
|
||||
)}
|
||||
</Button>
|
||||
{errors.general && (
|
||||
<Typography color="error">Wrong Email or Password</Typography>
|
||||
<Typography color="error">Invalid username/email or password</Typography>
|
||||
)}
|
||||
</form>
|
||||
</Grid>
|
||||
|
||||
677
twistter-frontend/src/pages/directMessages.js
Normal file
677
twistter-frontend/src/pages/directMessages.js
Normal file
@@ -0,0 +1,677 @@
|
||||
import React, { Component } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import dayjs from 'dayjs';
|
||||
import relativeTime from 'dayjs/plugin/relativeTime';
|
||||
import _ from "underscore";
|
||||
|
||||
// Material UI
|
||||
import Box from '@material-ui/core/Box';
|
||||
import Button from '@material-ui/core/Button';
|
||||
import Card from '@material-ui/core/Card';
|
||||
import CircularProgress from '@material-ui/core/CircularProgress';
|
||||
import Fab from '@material-ui/core/Fab';
|
||||
import Grid from '@material-ui/core/Grid';
|
||||
import Popover from '@material-ui/core/Popover';
|
||||
import TextField from '@material-ui/core/TextField';
|
||||
import Typography from '@material-ui/core/Typography';
|
||||
import withStyles from '@material-ui/core/styles/withStyles';
|
||||
|
||||
// Material UI Icons
|
||||
import AddCircleIcon from '@material-ui/icons/AddBox';
|
||||
import CheckMarkIcon from '@material-ui/icons/Check';
|
||||
import ErrorIcon from '@material-ui/icons/ErrorOutline';
|
||||
import SendIcon from '@material-ui/icons/Send';
|
||||
|
||||
// Redux
|
||||
import { connect } from 'react-redux';
|
||||
import {
|
||||
getDirectMessages,
|
||||
createNewDirectMessage,
|
||||
getNewDirectMessages,
|
||||
reloadDirectMessageChannels,
|
||||
sendDirectMessage
|
||||
} from '../redux/actions/dataActions';
|
||||
|
||||
const styles = {
|
||||
pageContainer: {
|
||||
minHeight: 'calc(100vh - 50px - 60px)'
|
||||
},
|
||||
sidePadding: {
|
||||
maxWidth: 350
|
||||
},
|
||||
dmList: {
|
||||
width: 300,
|
||||
marginLeft: 15
|
||||
},
|
||||
dmItemsUpper: {
|
||||
marginBottom: 1,
|
||||
// height: 'calc(100vh - 50px - 142px)',
|
||||
minHeight: 100,
|
||||
maxHeight: 'calc(100vh - 50px - 142px)',
|
||||
overflow: "auto"
|
||||
},
|
||||
dmItemsLower: {
|
||||
|
||||
},
|
||||
dmItemUsernameSelected: {
|
||||
fontSize: 20,
|
||||
color: 'white'
|
||||
},
|
||||
dmItemUsernameUnselected: {
|
||||
fontSize: 20,
|
||||
color: '#1da1f2'
|
||||
},
|
||||
dmItemTimeSelected: {
|
||||
color: '#D6D6D6',
|
||||
fontSize: 12,
|
||||
float: 'right',
|
||||
marginRight: 5,
|
||||
marginTop: 5
|
||||
},
|
||||
dmItemTimeUnselected: {
|
||||
color: 'black',
|
||||
fontSize: 12,
|
||||
float: 'right',
|
||||
marginRight: 5,
|
||||
marginTop: 5
|
||||
},
|
||||
dmRecentMessageSelected: {
|
||||
wordBreak: "break-all",
|
||||
color: '#D6D6D6'
|
||||
},
|
||||
dmRecentMessageUnselected: {
|
||||
wordBreak: "break-all",
|
||||
color: 'black'
|
||||
},
|
||||
dmRecentMessageDisabled: {
|
||||
wordBreak: "break-all",
|
||||
color: 'red'
|
||||
},
|
||||
dmListItemContainer: {
|
||||
height: 100
|
||||
},
|
||||
dmListLayoutContainer: {
|
||||
height: "100%"
|
||||
},
|
||||
dmListRecentMessage: {
|
||||
marginLeft: 10,
|
||||
marginRight: 10
|
||||
},
|
||||
dmListTextLayout: {
|
||||
height: 30
|
||||
},
|
||||
dmCardUnselected: {
|
||||
fontSize: 20,
|
||||
backgroundColor: '#FFFFFF',
|
||||
width: 300
|
||||
},
|
||||
dmCardSelected: {
|
||||
fontSize: 20,
|
||||
backgroundColor: '#1da1f2',
|
||||
width: 300
|
||||
},
|
||||
messagesGrid: {
|
||||
// // margin: "auto"
|
||||
// height: "auto",
|
||||
// width: "auto"
|
||||
},
|
||||
messagesBox: {
|
||||
width: 450
|
||||
},
|
||||
messagesContainer: {
|
||||
height: 'calc(100vh - 50px - 110px)',
|
||||
overflow: 'auto',
|
||||
width: 450,
|
||||
marginLeft: 2,
|
||||
marginRight: 17
|
||||
},
|
||||
fromMessage: {
|
||||
minWidth: 150,
|
||||
maxWidth: 350,
|
||||
minHeight: 40,
|
||||
marginRight: 2,
|
||||
marginTop: 2,
|
||||
marginBottom: 10,
|
||||
backgroundColor: '#008394',
|
||||
color: '#FFFFFF',
|
||||
float: 'right'
|
||||
},
|
||||
toMessage: {
|
||||
minWidth: 150,
|
||||
maxWidth: 350,
|
||||
minHeight: 40,
|
||||
marginLeft: 15,
|
||||
marginTop: 2,
|
||||
marginBottom: 10,
|
||||
backgroundColor: '#008394',
|
||||
color: '#FFFFFF',
|
||||
float: 'left'
|
||||
},
|
||||
messageContent: {
|
||||
// maxWidth: 330,
|
||||
// width: 330,
|
||||
wordBreak: "break-all",
|
||||
textAlign: 'left',
|
||||
marginLeft: 5,
|
||||
marginRight: 5
|
||||
},
|
||||
messageTime: {
|
||||
color: '#D6D6D6',
|
||||
textAlign: 'left',
|
||||
marginLeft: 5,
|
||||
fontSize: 12
|
||||
},
|
||||
writeMessage: {
|
||||
backgroundColor: '#FFFFFF',
|
||||
boxShadow: '0px 0px 5px 0px grey',
|
||||
width: 450
|
||||
},
|
||||
messageTextField: {
|
||||
width: 388
|
||||
},
|
||||
messageButton: {
|
||||
backgroundColor: '#1da1f2',
|
||||
marginTop: 8,
|
||||
marginLeft: 2
|
||||
},
|
||||
loadingUsernameChecks: {
|
||||
height: 55,
|
||||
width: 55,
|
||||
marginLeft: 5
|
||||
},
|
||||
errorIcon: {
|
||||
height: 55,
|
||||
width: 55,
|
||||
marginLeft: 5,
|
||||
color: '#ff3d00'
|
||||
},
|
||||
checkMarkIcon: {
|
||||
height: 55,
|
||||
width: 55,
|
||||
marginLeft: 5,
|
||||
color: '#1da1f2'
|
||||
},
|
||||
createButton: {
|
||||
// textAlign: "center",
|
||||
// display: "block",
|
||||
marginLeft: 96,
|
||||
marginRight: 96,
|
||||
position: "relative"
|
||||
}
|
||||
};
|
||||
|
||||
export class directMessages extends Component {
|
||||
constructor() {
|
||||
super();
|
||||
this.state = {
|
||||
hasChannelSelected: false,
|
||||
selectedChannel: null,
|
||||
dmData: null,
|
||||
anchorEl: null,
|
||||
createDMUsername: '',
|
||||
usernameValid: false,
|
||||
// message: '',
|
||||
drafts: {},
|
||||
errors: null
|
||||
};
|
||||
}
|
||||
|
||||
componentDidUpdate() {
|
||||
if (this.state.hasChannelSelected) {
|
||||
document.getElementById('messagesContainer').scrollTop = document.getElementById(
|
||||
'messagesContainer'
|
||||
).scrollHeight;
|
||||
}
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.props.getDirectMessages();
|
||||
// this.updatePage();
|
||||
}
|
||||
|
||||
// Updates the state whenever redux is updated
|
||||
componentWillReceiveProps(nextProps) {
|
||||
if (nextProps.directMessages && !_.isEqual(nextProps.directMessages, this.state.dmData)) {
|
||||
this.setState({ dmData: nextProps.directMessages}, () => {
|
||||
if (this.state.selectedChannel) {
|
||||
this.state.dmData.forEach((channel) => {
|
||||
if (channel.dmId === this.state.selectedChannel.dmId) {
|
||||
this.setState({
|
||||
selectedChannel: channel
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
updatePage = async() => {
|
||||
while (true) {
|
||||
await this.sleep(15000);
|
||||
// console.log("getting new DMs");
|
||||
this.props.getNewDirectMessages();
|
||||
}
|
||||
}
|
||||
|
||||
sleep = (ms) => {
|
||||
return new Promise(resolve => setTimeout(resolve, ms));
|
||||
}
|
||||
|
||||
// Handles selecting different DM channels
|
||||
handleClickChannel = (event) => {
|
||||
this.setState({
|
||||
hasChannelSelected: true
|
||||
});
|
||||
|
||||
const dmItemsUpper = document.getElementById("dmItemsUpper");
|
||||
let target = event.target;
|
||||
let dmChannelKey;
|
||||
|
||||
// Determine which DM channel was clicked by finding the data-key.
|
||||
// A while loop is necessary, because the user can click on any part of the
|
||||
// DM list item. dmItemsUpper is the list container of the dmItems
|
||||
while (target !== dmItemsUpper) {
|
||||
dmChannelKey = target.dataset.key;
|
||||
|
||||
if (dmChannelKey) {
|
||||
break;
|
||||
} else {
|
||||
target = target.parentNode;
|
||||
}
|
||||
}
|
||||
|
||||
// Save the entire DM channel in the state so that it is easier to load the messages
|
||||
this.state.dmData.forEach((channel) => {
|
||||
if (channel.dmId === dmChannelKey) {
|
||||
this.setState({
|
||||
selectedChannel: channel
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
formatDateToString(dateString) {
|
||||
let newDate = new Date(Date.parse(dateString));
|
||||
return newDate.toDateString();
|
||||
}
|
||||
|
||||
formatDateToTimeDiff(dateString) {
|
||||
return dayjs(dateString).fromNow();
|
||||
}
|
||||
|
||||
shortenText = (text, length) => {
|
||||
// Shorten the text
|
||||
let shortened = text.slice(0, length + 1);
|
||||
|
||||
// Trim whitespace from the end of the text
|
||||
if (shortened[shortened.length - 1] === ' ') {
|
||||
shortened = shortened.trimRight();
|
||||
}
|
||||
|
||||
// Add ... to the end
|
||||
shortened = `${shortened}...`;
|
||||
|
||||
return shortened;
|
||||
}
|
||||
|
||||
handleOpenAddDMPopover = (event) => {
|
||||
this.setState({
|
||||
anchorEl: event.currentTarget
|
||||
});
|
||||
};
|
||||
|
||||
handleCloseAddDMPopover = () => {
|
||||
this.setState({
|
||||
anchorEl: null,
|
||||
createDMUsername: '',
|
||||
usernameValid: false
|
||||
});
|
||||
};
|
||||
|
||||
handleChangeAddDMUsername = (event) => {
|
||||
this.setState({
|
||||
createDMUsername: event.target.value
|
||||
});
|
||||
};
|
||||
|
||||
handleClickCreate = () => {
|
||||
this.props.createNewDirectMessage(this.state.createDMUsername)
|
||||
.then(() => {
|
||||
return this.props.reloadDirectMessageChannels();
|
||||
})
|
||||
.then(() => {
|
||||
this.handleCloseAddDMPopover();
|
||||
return;
|
||||
})
|
||||
.catch(() => {
|
||||
return;
|
||||
})
|
||||
}
|
||||
|
||||
handleChangeMessage = (event) => {
|
||||
let drafts = this.state.drafts;
|
||||
drafts[this.state.selectedChannel.dmId] = event.target.value;
|
||||
this.setState({
|
||||
drafts
|
||||
});
|
||||
}
|
||||
|
||||
handleClickSend = () => {
|
||||
// console.log(this.state.drafts[this.state.selectedChannel.dmId]);
|
||||
let drafts = this.state.drafts;
|
||||
if (this.state.hasChannelSelected && drafts[this.state.selectedChannel.dmId]) {
|
||||
this.props.sendDirectMessage(this.state.selectedChannel.recipient, drafts[this.state.selectedChannel.dmId]);
|
||||
drafts[this.state.selectedChannel.dmId] = null;
|
||||
this.setState({
|
||||
drafts
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
const { classes, user: { credentials: { dmEnabled } } } = this.props;
|
||||
const loadingDirectMessages = this.props.UI.loading2;
|
||||
const creatingDirectMessage = this.props.UI.loading3;
|
||||
const sendingDirectMessage = this.props.UI.loading4;
|
||||
let errors = this.props.UI.errors ? this.props.UI.errors : {};
|
||||
dayjs.extend(relativeTime);
|
||||
|
||||
// Used for the add button on the dmList
|
||||
const open = Boolean(this.state.anchorEl);
|
||||
const id = open ? 'simple-popover' : undefined;
|
||||
|
||||
let dmListMarkup = this.state.dmData ? (
|
||||
this.state.dmData.map((channel) => (
|
||||
<Card
|
||||
onClick={this.handleClickChannel}
|
||||
key={channel.dmId}
|
||||
data-key={channel.dmId}
|
||||
className={
|
||||
this.state.selectedChannel && this.state.selectedChannel.dmId === channel.dmId ? classes.dmCardSelected : classes.dmCardUnselected
|
||||
}
|
||||
>
|
||||
<Box className={classes.dmListItemContainer}>
|
||||
<Grid container direction="column" className={classes.dmListLayoutContainer} spacing={1}>
|
||||
<Grid item>
|
||||
<Grid container className={classes.dmListTextLayout}>
|
||||
<Grid item sm />
|
||||
<Grid item sm>
|
||||
<Typography
|
||||
className={
|
||||
this.state.selectedChannel && this.state.selectedChannel.dmId === channel.dmId ? (
|
||||
classes.dmItemUsernameSelected
|
||||
) : (
|
||||
classes.dmItemUsernameUnselected
|
||||
)
|
||||
}
|
||||
>
|
||||
{channel.recipient}
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid item sm>
|
||||
<Typography
|
||||
className={
|
||||
this.state.selectedChannel && this.state.selectedChannel.dmId === channel.dmId ? (
|
||||
classes.dmItemTimeSelected
|
||||
) : (
|
||||
classes.dmItemTimeUnselected
|
||||
)
|
||||
}
|
||||
>
|
||||
{channel.recentMessageTimestamp ? (
|
||||
this.formatDateToTimeDiff(channel.recentMessageTimestamp)
|
||||
) : null}
|
||||
</Typography>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Grid item className={classes.dmListRecentMessage}>
|
||||
<Typography
|
||||
className={
|
||||
this.state.selectedChannel && this.state.selectedChannel.dmId === channel.dmId ? (
|
||||
channel.hasDirectMessagesEnabled ?
|
||||
classes.dmRecentMessageSelected
|
||||
:
|
||||
classes.dmRecentMessageDisabled
|
||||
) : (
|
||||
channel.hasDirectMessagesEnabled ?
|
||||
classes.dmRecentMessageUnselected
|
||||
:
|
||||
classes.dmRecentMessageDisabled
|
||||
)
|
||||
}
|
||||
>
|
||||
{!channel.hasDirectMessagesEnabled ? "This user has DMs disabled" :
|
||||
!channel.recentMessage ?
|
||||
'No messages'
|
||||
:
|
||||
channel.recentMessage.length > 65 ?
|
||||
this.shortenText(channel.recentMessage, 65)
|
||||
:
|
||||
channel.recentMessage
|
||||
}
|
||||
</Typography>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Box>
|
||||
</Card>
|
||||
))
|
||||
) : (
|
||||
<p>You don't have any DMs yet</p>
|
||||
)
|
||||
|
||||
let messagesMarkup =
|
||||
this.state.selectedChannel !== null ? this.state.selectedChannel.messages.length > 0 ? (
|
||||
this.state.selectedChannel.messages.map((messageObj) => (
|
||||
<Grid item key={messageObj.messageId}>
|
||||
<Card
|
||||
className={
|
||||
messageObj.author === this.state.selectedChannel.recipient ? (
|
||||
classes.toMessage
|
||||
) : (
|
||||
classes.fromMessage
|
||||
)
|
||||
}
|
||||
>
|
||||
<Typography className={classes.messageContent}>{messageObj.message}</Typography>
|
||||
<Typography className={classes.messageTime}>
|
||||
{this.formatDateToString(messageObj.createdAt)}
|
||||
</Typography>
|
||||
</Card>
|
||||
</Grid>
|
||||
))
|
||||
) : (
|
||||
<p>No DMs here</p>
|
||||
) : (
|
||||
<p>Select a DM channel</p>
|
||||
);
|
||||
|
||||
let addDMMarkup = (
|
||||
<div>
|
||||
<AddCircleIcon
|
||||
style={{
|
||||
color: '#1da1f2',
|
||||
height: 82,
|
||||
width: 82,
|
||||
marginTop: 9,
|
||||
cursor: 'pointer'
|
||||
}}
|
||||
aria-describedby={id}
|
||||
onClick={this.handleOpenAddDMPopover}
|
||||
/>
|
||||
<Popover
|
||||
id={id}
|
||||
open={open}
|
||||
anchorEl={this.state.anchorEl}
|
||||
onClose={this.handleCloseAddDMPopover}
|
||||
anchorOrigin={{
|
||||
vertical: 'center',
|
||||
horizontal: 'center'
|
||||
}}
|
||||
transformOrigin={{
|
||||
vertical: 'top',
|
||||
horizontal: 'center'
|
||||
}}
|
||||
>
|
||||
<Box
|
||||
style={{
|
||||
height: 200,
|
||||
width: 400
|
||||
}}
|
||||
>
|
||||
<Grid container>
|
||||
<Grid item sm />
|
||||
<Grid item style={{ height: 200, width: 285 }}>
|
||||
<Grid container direction="column" spacing={2}>
|
||||
<Grid item>
|
||||
<Typography style={{ marginTop: 15 }}>
|
||||
Who would you like to start a DM with?
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid item>
|
||||
<TextField
|
||||
onChange={this.handleChangeAddDMUsername}
|
||||
value={this.state.createDMUsername}
|
||||
label="Username"
|
||||
variant="outlined"
|
||||
helperText={errors.createDirectMessage}
|
||||
error={errors.createDirectMessage ? true : false}
|
||||
style={{
|
||||
width: 265,
|
||||
marginRight: 10,
|
||||
marginLeft: 10,
|
||||
textAlign: 'center',
|
||||
}}
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item>
|
||||
<Button
|
||||
className={classes.createButton}
|
||||
variant="outlined"
|
||||
color="primary"
|
||||
onClick={this.handleClickCreate}
|
||||
disabled={
|
||||
creatingDirectMessage ||
|
||||
this.state.createDMUsername === ""
|
||||
}
|
||||
>
|
||||
Create
|
||||
{creatingDirectMessage &&
|
||||
// Won't accept classes style for some reason
|
||||
<CircularProgress size={30} style={{position: "absolute"}}/>
|
||||
}
|
||||
</Button>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Grid item sm />
|
||||
</Grid>
|
||||
</Box>
|
||||
</Popover>
|
||||
</div>
|
||||
);
|
||||
|
||||
return (
|
||||
loadingDirectMessages ? <CircularProgress size={60} style={{marginTop: "300px"}}></CircularProgress> :
|
||||
(dmEnabled !== undefined && dmEnabled !== null && !dmEnabled ? <Typography>Oops! It looks like you have DMs disabled. You can enable them on the Edit Profile page.</Typography> :
|
||||
<Grid container className={classes.pageContainer}>
|
||||
<Grid item className={classes.sidePadding} sm />
|
||||
<Grid item className={classes.dmList}>
|
||||
<Grid container direction="column">
|
||||
<Grid item className={classes.dmItemsUpper} id="dmItemsUpper">
|
||||
{dmListMarkup}
|
||||
</Grid>
|
||||
<Grid item className={classes.dmItemsLower}>
|
||||
<Card key="5555" data-key="5555" className={classes.dmCardUnselected}>
|
||||
<Box className={classes.dmListItemContainer}>
|
||||
{addDMMarkup}
|
||||
</Box>
|
||||
</Card>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Grid item className={classes.messagesGrid} sm>
|
||||
<Box>
|
||||
{this.state.hasChannelSelected && (
|
||||
<Card className={classes.messagesBox}>
|
||||
<Box className={classes.messagesContainer} id="messagesContainer">
|
||||
<Grid container direction="column">
|
||||
{messagesMarkup}
|
||||
</Grid>
|
||||
</Box>
|
||||
<Box className={classes.writeMessage}>
|
||||
<TextField
|
||||
className={classes.messageTextField}
|
||||
variant="outlined"
|
||||
multiline
|
||||
rows={2}
|
||||
margin="dense"
|
||||
disabled={!this.state.selectedChannel.hasDirectMessagesEnabled}
|
||||
value={
|
||||
!this.state.selectedChannel.hasDirectMessagesEnabled ?
|
||||
"This user has DMs disabled"
|
||||
:
|
||||
this.state.drafts[this.state.selectedChannel.dmId] ?
|
||||
this.state.drafts[this.state.selectedChannel.dmId]
|
||||
:
|
||||
""
|
||||
}
|
||||
onChange={this.handleChangeMessage}
|
||||
/>
|
||||
<Fab
|
||||
className={classes.messageButton}
|
||||
onClick={this.handleClickSend}
|
||||
disabled={
|
||||
sendingDirectMessage ||
|
||||
!this.state.drafts[this.state.selectedChannel.dmId] ||
|
||||
this.state.drafts[this.state.selectedChannel.dmId] === ""
|
||||
}
|
||||
>
|
||||
<SendIcon style={{ color: '#FFFFFF' }} />
|
||||
{
|
||||
sendingDirectMessage &&
|
||||
<CircularProgress size={30} style={{position: "absolute"}}/>
|
||||
// Won't accept classes style for some reason
|
||||
}
|
||||
</Fab>
|
||||
</Box>
|
||||
</Card>
|
||||
)}
|
||||
{!this.state.hasChannelSelected &&
|
||||
this.state.dmData && <Typography>Select a DM on the left</Typography>}
|
||||
</Box>
|
||||
</Grid>
|
||||
<Grid item className={classes.sidePadding} sm />
|
||||
</Grid>
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
directMessages.propTypes = {
|
||||
classes: PropTypes.object.isRequired,
|
||||
getDirectMessages: PropTypes.func.isRequired,
|
||||
createNewDirectMessage: PropTypes.func.isRequired,
|
||||
getNewDirectMessages: PropTypes.func.isRequired,
|
||||
reloadDirectMessageChannels: PropTypes.func.isRequired,
|
||||
sendDirectMessage: PropTypes.func.isRequired,
|
||||
user: PropTypes.object.isRequired,
|
||||
UI: PropTypes.object.isRequired
|
||||
};
|
||||
|
||||
const mapStateToProps = (state) => ({
|
||||
user: state.user,
|
||||
UI: state.UI,
|
||||
directMessages: state.data.directMessages
|
||||
});
|
||||
|
||||
const mapActionsToProps = {
|
||||
getDirectMessages,
|
||||
createNewDirectMessage,
|
||||
getNewDirectMessages,
|
||||
reloadDirectMessageChannels,
|
||||
sendDirectMessage
|
||||
};
|
||||
|
||||
export default connect(mapStateToProps, mapActionsToProps)(withStyles(styles)(directMessages));
|
||||
@@ -1,16 +1,28 @@
|
||||
import React, { Component } from "react";
|
||||
import { Link } from 'react-router-dom';
|
||||
import axios from "axios";
|
||||
import PropTypes from "prop-types";
|
||||
// TODO: Add a read-only '@' in the left side of the handle input
|
||||
// TODO: Add a cancel button, that takes the user back to their profile page
|
||||
|
||||
import noImage from '../images/no-img.png';
|
||||
|
||||
// Material-UI stuff
|
||||
import Box from "@material-ui/core/Box"
|
||||
import Button from "@material-ui/core/Button";
|
||||
import CircularProgress from "@material-ui/core/CircularProgress";
|
||||
import Grid from "@material-ui/core/Grid";
|
||||
import Popover from "@material-ui/core/Popover";
|
||||
import TextField from "@material-ui/core/TextField";
|
||||
import Typography from "@material-ui/core/Typography";
|
||||
import withStyles from "@material-ui/core/styles/withStyles";
|
||||
import FormControlLabel from "@material-ui/core/FormControlLabel";
|
||||
import Switch from "@material-ui/core/Switch";
|
||||
import IconButton from "@material-ui/core/IconButton";
|
||||
import EditIcon from "@material-ui/icons/Edit";
|
||||
import Tooltip from "@material-ui/core/Tooltip";
|
||||
|
||||
// Redux stuff
|
||||
import { connect } from "react-redux";
|
||||
import { uploadImage } from "../redux/actions/userActions";
|
||||
|
||||
const styles = {
|
||||
form: {
|
||||
@@ -27,34 +39,77 @@ const styles = {
|
||||
positon: "relative",
|
||||
marginBottom: 30
|
||||
},
|
||||
box: {
|
||||
position: "relative"
|
||||
},
|
||||
back: {
|
||||
float: "left",
|
||||
marginLeft: 15
|
||||
},
|
||||
delete: {
|
||||
float: "right",
|
||||
marginRight: 15
|
||||
},
|
||||
progress: {
|
||||
position: "absolute"
|
||||
},
|
||||
uploadProgress: {
|
||||
position: "absolute",
|
||||
marginLeft: -155,
|
||||
marginTop: 95
|
||||
},
|
||||
popoverBackground: {
|
||||
marginTop: "-100px",
|
||||
width: "calc(100vw)",
|
||||
height: 'calc(100vh + 100px)',
|
||||
backgroundColor: "gray",
|
||||
position: "absolute",
|
||||
opacity: "70%"
|
||||
}
|
||||
};
|
||||
|
||||
export class edit extends Component {
|
||||
export class editProfile extends Component {
|
||||
// mapReduxToState = (credentials) => {
|
||||
// this.setState({
|
||||
// imageUrl: credentials.imageUrl ? credentials.imageUrl : noImage,
|
||||
// firstName: credentials.firstName ? credentials.firstName : '',
|
||||
// lastName: credentials.lastName ? credentials.lastName : '',
|
||||
// email: credentials.email ? credentials.email : 'error, email doesn\'t exist',
|
||||
// handle: credentials.handle ? credentials.handle : 'error, handle doesn\'t exist',
|
||||
// bio: credentials.bio ? credentials.bio : ''
|
||||
// });
|
||||
// };
|
||||
|
||||
// Runs as soon as the page loads.
|
||||
// Sets the default values of all the textboxes to the data
|
||||
// that is stored in the database for the user.
|
||||
componentDidMount() {
|
||||
// const { credentials } = this.props;
|
||||
// console.log(this.props.user);
|
||||
// this.mapReduxToState(credentials);
|
||||
this.setState({pageLoading: true})
|
||||
|
||||
axios
|
||||
.get("/getProfileInfo")
|
||||
.then((res) => {
|
||||
// Need to have the ternary if statements, because react throws an error if
|
||||
// any of the res.data keys are undefined
|
||||
this.setState({
|
||||
firstName: res.data.firstName,
|
||||
lastName: res.data.lastName,
|
||||
imageUrl: res.data.imageUrl,
|
||||
firstName: res.data.firstName ? res.data.firstName : "",
|
||||
lastName: res.data.lastName ? res.data.lastName : "",
|
||||
email: res.data.email,
|
||||
handle: res.data.handle,
|
||||
bio: res.data.bio
|
||||
bio: res.data.bio ? res.data.bio : "",
|
||||
dmEnabled: res.data.dmEnabled === false ? false : true,
|
||||
pageLoading: false
|
||||
});
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error(err);
|
||||
if (err.response.status === 403) {
|
||||
alert("You are not logged in");
|
||||
// TODO: Redirect them, to the profile they are trying to edit
|
||||
// If they are on /itsjimmy/edit, they will be redirected to /itsjimmy
|
||||
this.props.history.push('../');
|
||||
// This user is not logged in
|
||||
this.props.history.push('/');
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -63,12 +118,17 @@ export class edit extends Component {
|
||||
constructor() {
|
||||
super();
|
||||
this.state = {
|
||||
imageUrl: "",
|
||||
firstName: "",
|
||||
lastName: "",
|
||||
email: "",
|
||||
handle: "",
|
||||
bio: "",
|
||||
dmEnabled: false,
|
||||
togglingDirectMessages: false,
|
||||
anchorEl: null,
|
||||
loading: false,
|
||||
pageLoading: false,
|
||||
errors: {}
|
||||
};
|
||||
}
|
||||
@@ -88,6 +148,14 @@ export class edit extends Component {
|
||||
handle: this.state.handle,
|
||||
bio: this.state.bio
|
||||
};
|
||||
|
||||
// Removes all keys from newProfileData that are empty, undefined, or null
|
||||
Object.keys(newProfileData).forEach(key => {
|
||||
if (newProfileData[key] === "" || newProfileData[key] === undefined || newProfileData[key] === null) {
|
||||
delete newProfileData[key];
|
||||
}
|
||||
})
|
||||
|
||||
axios
|
||||
.post("/updateProfileInfo", newProfileData)
|
||||
.then((res) => {
|
||||
@@ -95,11 +163,11 @@ export class edit extends Component {
|
||||
this.setState({
|
||||
loading: false
|
||||
});
|
||||
// this.props.history.push('/');
|
||||
// TODO: Need to redirect user to their profile page
|
||||
this.props.history.push('/user');
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
// TODO: Should redirect to login page if they get a 403
|
||||
this.setState({
|
||||
errors: err.response.data,
|
||||
loading: false
|
||||
@@ -120,114 +188,324 @@ export class edit extends Component {
|
||||
});
|
||||
};
|
||||
|
||||
handleDMSwitch = () => {
|
||||
let enable;
|
||||
|
||||
if (this.state.dmEnabled) {
|
||||
enable = {enable: false};
|
||||
} else {
|
||||
enable = {enable: true};
|
||||
}
|
||||
|
||||
this.setState({
|
||||
dmEnabled: enable.enable,
|
||||
togglingDirectMessages: true
|
||||
});
|
||||
|
||||
axios.post("/dms/toggle", enable)
|
||||
.then(() => {
|
||||
this.setState({
|
||||
togglingDirectMessages: false
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
handleImageChange = (event) => {
|
||||
if (event.target.files[0]) {
|
||||
const image = event.target.files[0];
|
||||
const formData = new FormData();
|
||||
formData.append('image', image, image.name);
|
||||
this.props.uploadImage(formData);
|
||||
}
|
||||
}
|
||||
|
||||
handleEditPicture = () => {
|
||||
const fileInput = document.getElementById('imageUpload');
|
||||
fileInput.click();
|
||||
}
|
||||
|
||||
// logging = () => {
|
||||
// console.log(this.state);
|
||||
// console.log(this.props);
|
||||
// this.mapReduxToState(this.props.credentials);
|
||||
// }
|
||||
|
||||
handleOpenConfirmDelete = (event) => {
|
||||
this.setState({
|
||||
// anchorEl: event.currentTarget
|
||||
anchorEl: document.getElementById("container-grid")
|
||||
});
|
||||
};
|
||||
|
||||
handleCloseConfirmDelete = () => {
|
||||
this.setState({
|
||||
anchorEl: null,
|
||||
createDMUsername: ''
|
||||
});
|
||||
};
|
||||
|
||||
render() {
|
||||
const { classes } = this.props;
|
||||
const uploading = this.props.UI.loading;
|
||||
const { errors, loading } = this.state;
|
||||
|
||||
|
||||
let imageMarkup = this.props.user.credentials.imageUrl ? (
|
||||
<Box
|
||||
// className={classes.box}
|
||||
>
|
||||
<img
|
||||
src={this.props.user.credentials.imageUrl}
|
||||
height="250"
|
||||
width="250"
|
||||
className={classes.box}/>
|
||||
{uploading && (
|
||||
<CircularProgress size={60} className={classes.uploadProgress} />
|
||||
)}
|
||||
</Box>
|
||||
) : (
|
||||
<Box
|
||||
// className={classes.box}
|
||||
>
|
||||
<img
|
||||
src={noImage}
|
||||
height="250"
|
||||
width="250"
|
||||
className={classes.box}/>
|
||||
{uploading && (
|
||||
<CircularProgress size={60} className={classes.uploadProgress} />
|
||||
)}
|
||||
</Box>
|
||||
)
|
||||
|
||||
// Used for the delete button
|
||||
const open = Boolean(this.state.anchorEl);
|
||||
const id = open ? 'simple-popover' : undefined;
|
||||
|
||||
return (
|
||||
<Grid container className={classes.form}>
|
||||
<Grid item sm />
|
||||
<Grid item sm>
|
||||
<Typography variant="h2" className={classes.pageTitle}>
|
||||
Edit Profile
|
||||
</Typography>
|
||||
<form noValidate onSubmit={this.handleSubmit}>
|
||||
<Grid container className={classes.form} spacing={4}>
|
||||
<Grid item sm>
|
||||
<TextField
|
||||
id="firstName"
|
||||
name="firstName"
|
||||
label="First Name"
|
||||
className={classes.textField}
|
||||
value={this.state.firstName}
|
||||
helperText={errors.firstName}
|
||||
error={errors.firstName ? true : false}
|
||||
variant="outlined"
|
||||
onChange={this.handleChange}
|
||||
fullWidth
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item sm>
|
||||
<TextField
|
||||
id="lastName"
|
||||
name="lastName"
|
||||
label="Last Name"
|
||||
className={classes.textField}
|
||||
value={this.state.lastName}
|
||||
helperText={errors.lastname}
|
||||
error={errors.lastName ? true : false}
|
||||
variant="outlined"
|
||||
onChange={this.handleChange}
|
||||
fullWidth
|
||||
/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<TextField
|
||||
id="email"
|
||||
name="email"
|
||||
label="Email*"
|
||||
className={classes.textField}
|
||||
value={this.state.email}
|
||||
disabled
|
||||
helperText="(disabled)"
|
||||
// INFO: These will be uncommented if changing emails is allowed
|
||||
// helperText={errors.email}
|
||||
// error={errors.email ? true : false}
|
||||
variant="outlined"
|
||||
onChange={this.handleChange}
|
||||
fullWidth
|
||||
/>
|
||||
<TextField
|
||||
id="handle"
|
||||
name="handle"
|
||||
label="Handle*"
|
||||
className={classes.textField}
|
||||
value={this.state.handle}
|
||||
disabled
|
||||
helperText="(disabled)"
|
||||
// INFO: These will be uncommented if changing usernames is allowed
|
||||
// helperText={errors.handle}
|
||||
// error={errors.handle ? true : false}
|
||||
variant="outlined"
|
||||
onChange={this.handleChange}
|
||||
fullWidth
|
||||
/>
|
||||
<TextField
|
||||
id="bio"
|
||||
name="bio"
|
||||
label="Bio"
|
||||
className={classes.textField}
|
||||
value={this.state.bio}
|
||||
helperText={errors.bio}
|
||||
error={errors.bio ? true : false}
|
||||
multiline
|
||||
rows="8"
|
||||
variant="outlined"
|
||||
onChange={this.handleChange}
|
||||
fullWidth
|
||||
/>
|
||||
this.state.pageLoading ?
|
||||
<CircularProgress size={60} style={{marginTop: "300px"}}></CircularProgress>
|
||||
:
|
||||
<Grid container className={classes.form} id="container-grid">
|
||||
<Grid item sm >
|
||||
<Button
|
||||
type="submit"
|
||||
variant="contained"
|
||||
variant="outlined"
|
||||
color="primary"
|
||||
className={classes.button}
|
||||
disabled={loading}
|
||||
// className={classes.button}
|
||||
disabled={loading || uploading}
|
||||
className={classes.back}
|
||||
component={ Link }
|
||||
to='/user'
|
||||
>
|
||||
Submit
|
||||
{loading && (
|
||||
<CircularProgress size={30} className={classes.progress} />
|
||||
)}
|
||||
Back to Profile
|
||||
</Button>
|
||||
</form>
|
||||
</Grid>
|
||||
<Grid item sm>
|
||||
<Typography variant="h2" className={classes.pageTitle}>
|
||||
Edit Profile
|
||||
</Typography>
|
||||
<form noValidate onSubmit={this.handleSubmit}>
|
||||
{imageMarkup}
|
||||
<input type="file" id="imageUpload" onChange={this.handleImageChange} hidden = "hidden"/>
|
||||
<Tooltip title="Edit profile picture" placement="top">
|
||||
<IconButton onClick={this.handleEditPicture} className="button">
|
||||
<EditIcon color="primary"/>
|
||||
</IconButton></Tooltip>
|
||||
<Grid container className={classes.form} spacing={4}>
|
||||
<Grid item sm>
|
||||
<TextField
|
||||
id="firstName"
|
||||
name="firstName"
|
||||
label="First Name"
|
||||
className={classes.textField}
|
||||
value={this.state.firstName}
|
||||
helperText={errors.firstName}
|
||||
error={errors.firstName ? true : false}
|
||||
variant="outlined"
|
||||
onChange={this.handleChange}
|
||||
fullWidth
|
||||
autoComplete='off'
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item sm>
|
||||
<TextField
|
||||
id="lastName"
|
||||
name="lastName"
|
||||
label="Last Name"
|
||||
className={classes.textField}
|
||||
value={this.state.lastName}
|
||||
helperText={errors.lastname}
|
||||
error={errors.lastName ? true : false}
|
||||
variant="outlined"
|
||||
onChange={this.handleChange}
|
||||
fullWidth
|
||||
autoComplete='off'
|
||||
/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<TextField
|
||||
id="email"
|
||||
name="email"
|
||||
label="Email*"
|
||||
className={classes.textField}
|
||||
value={this.state.email}
|
||||
disabled
|
||||
helperText="(disabled)"
|
||||
// INFO: These will be uncommented if changing emails is allowed
|
||||
// helperText={errors.email}
|
||||
// error={errors.email ? true : false}
|
||||
variant="outlined"
|
||||
onChange={this.handleChange}
|
||||
fullWidth
|
||||
autoComplete='off'
|
||||
/>
|
||||
<TextField
|
||||
id="handle"
|
||||
name="handle"
|
||||
label="Handle*"
|
||||
className={classes.textField}
|
||||
value={"@" + this.state.handle}
|
||||
disabled
|
||||
helperText="(disabled)"
|
||||
// INFO: These will be uncommented if changing usernames is allowed
|
||||
// helperText={errors.handle}
|
||||
// error={errors.handle ? true : false}
|
||||
variant="outlined"
|
||||
onChange={this.handleChange}
|
||||
fullWidth
|
||||
autoComplete='off'
|
||||
/>
|
||||
<TextField
|
||||
id="bio"
|
||||
name="bio"
|
||||
label="Bio"
|
||||
className={classes.textField}
|
||||
value={this.state.bio}
|
||||
helperText={errors.bio}
|
||||
error={errors.bio ? true : false}
|
||||
multiline
|
||||
rows="8"
|
||||
variant="outlined"
|
||||
onChange={this.handleChange}
|
||||
fullWidth
|
||||
autoComplete='off'
|
||||
/>
|
||||
<FormControlLabel
|
||||
control={
|
||||
<Switch
|
||||
color="primary"
|
||||
disabled={this.state.togglingDirectMessages}
|
||||
checked={this.state.dmEnabled}
|
||||
onChange={this.handleDMSwitch}
|
||||
/>
|
||||
}
|
||||
label="Enable Direct Messages"
|
||||
/>
|
||||
<br></br>
|
||||
<Button
|
||||
type="submit"
|
||||
variant="contained"
|
||||
color="primary"
|
||||
className={classes.button}
|
||||
disabled={loading}
|
||||
//component={ Link }
|
||||
//to='/user'
|
||||
>
|
||||
Submit
|
||||
{loading && (
|
||||
<CircularProgress size={30} className={classes.progress} />
|
||||
)}
|
||||
</Button>
|
||||
|
||||
</form>
|
||||
</Grid>
|
||||
<Grid item sm>
|
||||
<Button
|
||||
variant="outlined"
|
||||
color="secondary"
|
||||
className={classes.delete}
|
||||
onClick={this.handleOpenConfirmDelete}
|
||||
>
|
||||
Delete Account
|
||||
</Button>
|
||||
</Grid>
|
||||
<Box hidden={!Boolean(this.state.anchorEl)} className={classes.popoverBackground}></Box>
|
||||
<Popover
|
||||
id={id}
|
||||
open={open}
|
||||
anchorEl={this.state.anchorEl}
|
||||
onClose={this.handleCloseConfirmDelete}
|
||||
anchorOrigin={{
|
||||
vertical: 'center',
|
||||
horizontal: 'center'
|
||||
}}
|
||||
transformOrigin={{
|
||||
vertical: 'top',
|
||||
horizontal: 'center'
|
||||
}}
|
||||
style={{
|
||||
marginTop: "-200px"
|
||||
}}
|
||||
>
|
||||
<Box
|
||||
style={{
|
||||
height: 200,
|
||||
width: 400
|
||||
}}
|
||||
>
|
||||
<Grid container direction="column" spacing={3}>
|
||||
<Grid item>
|
||||
<Typography style={{marginTop: 30, marginLeft: 50, marginRight: 50, textAlign: "center", fontSize: 24}}>Are you sure you want to delete your account?</Typography>
|
||||
</Grid>
|
||||
<Grid item>
|
||||
<Button
|
||||
color="secondary"
|
||||
variant="contained"
|
||||
component={ Link }
|
||||
to='/delete'
|
||||
style={{
|
||||
marginBottom: "-40px",
|
||||
marginLeft: 10,
|
||||
width: 90
|
||||
}}
|
||||
>
|
||||
Yes
|
||||
</Button>
|
||||
<Button
|
||||
color="primary"
|
||||
variant="outlined"
|
||||
onClick={this.handleCloseConfirmDelete}
|
||||
style={{
|
||||
marginBottom: "-40px",
|
||||
marginLeft: 195
|
||||
}}
|
||||
>
|
||||
Cancel
|
||||
</Button>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Box>
|
||||
</Popover>
|
||||
</Grid>
|
||||
<Grid item sm />
|
||||
</Grid>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
edit.propTypes = {
|
||||
classes: PropTypes.object.isRequired
|
||||
|
||||
const mapStateToProps = (state) => ({
|
||||
user: state.user,
|
||||
UI: state.UI,
|
||||
// credentials: state.user.credentials
|
||||
});
|
||||
|
||||
const mapActionsToProps = { uploadImage }
|
||||
|
||||
editProfile.propTypes = {
|
||||
uploadImage: PropTypes.func.isRequired,
|
||||
classes: PropTypes.object.isRequired,
|
||||
user: PropTypes.object.isRequired,
|
||||
UI: PropTypes.object.isRequired
|
||||
};
|
||||
|
||||
export default withStyles(styles)(edit);
|
||||
// export default withStyles(styles)(edit);
|
||||
export default connect(mapStateToProps, mapActionsToProps)(withStyles(styles)(editProfile));
|
||||
|
||||
360
twistter-frontend/src/pages/otherUser.js
Normal file
360
twistter-frontend/src/pages/otherUser.js
Normal file
@@ -0,0 +1,360 @@
|
||||
/* eslint-disable */
|
||||
import React, { Component } from "react";
|
||||
import PropTypes from "prop-types";
|
||||
import { connect } from "react-redux";
|
||||
import axios from "axios";
|
||||
//import '../App.css';
|
||||
|
||||
// Material UI and React Router
|
||||
import { makeStyles, styled } from "@material-ui/core/styles";
|
||||
import withStyles from "@material-ui/core/styles/withStyles";
|
||||
|
||||
import { Link } from "react-router-dom";
|
||||
import Card from "@material-ui/core/Card";
|
||||
import CardMedia from "@material-ui/core/CardMedia";
|
||||
import CardContent from "@material-ui/core/CardContent";
|
||||
import Button from "@material-ui/core/Button";
|
||||
import Grid from "@material-ui/core/Grid";
|
||||
|
||||
import Chip from "@material-ui/core/Chip";
|
||||
import Typography from "@material-ui/core/Typography";
|
||||
import AddCircle from "@material-ui/icons/AddCircle";
|
||||
import TextField from "@material-ui/core/TextField";
|
||||
import VerifiedIcon from "@material-ui/icons/CheckSharp";
|
||||
import DoneIcon from "@material-ui/icons/Done";
|
||||
import CircularProgress from "@material-ui/core/CircularProgress";
|
||||
|
||||
// component
|
||||
import "../App.css";
|
||||
import noImage from "../images/no-img.png";
|
||||
import Writing_Microblogs from "../Writing_Microblogs";
|
||||
|
||||
const MyChip = styled(Chip)({
|
||||
margin: 2,
|
||||
color: "primary"
|
||||
});
|
||||
|
||||
const styles = {
|
||||
button: {
|
||||
positon: "relative",
|
||||
float: "left",
|
||||
marginLeft: 30,
|
||||
marginTop: 20
|
||||
},
|
||||
paper: {
|
||||
// marginLeft: "10%",
|
||||
// marginRight: "10%"
|
||||
},
|
||||
card: {
|
||||
marginBottom: 5
|
||||
},
|
||||
profileImage: {
|
||||
marginTop: 20
|
||||
},
|
||||
topicsContainer: {
|
||||
border: "lightgray solid 1px",
|
||||
marginTop: 20,
|
||||
paddingTop: 10,
|
||||
paddingBottom: 10,
|
||||
height: 300
|
||||
},
|
||||
addCircle: {
|
||||
width: 65,
|
||||
height: 65,
|
||||
marginTop: 10
|
||||
},
|
||||
username: {
|
||||
marginBottom: 100
|
||||
}
|
||||
};
|
||||
|
||||
class user extends Component {
|
||||
constructor() {
|
||||
super();
|
||||
this.state = {
|
||||
profile: window.location.pathname.split("/").pop(),
|
||||
imageUrl: null,
|
||||
topics: null,
|
||||
user: null,
|
||||
following: null,
|
||||
posts: null,
|
||||
myTopics: null,
|
||||
followingList: null,
|
||||
loading: false
|
||||
};
|
||||
}
|
||||
|
||||
handleSub = () => {
|
||||
if (this.state.following === true) {
|
||||
axios
|
||||
.post("/removeSub", {
|
||||
unfollow: this.state.profile
|
||||
})
|
||||
.then(res => {
|
||||
console.log("removed sub");
|
||||
this.setState({
|
||||
following: false,
|
||||
myTopics: []
|
||||
});
|
||||
})
|
||||
.catch(function(err) {
|
||||
console.log(err);
|
||||
});
|
||||
} else {
|
||||
axios
|
||||
.post("/addSubscription", {
|
||||
following: this.state.profile
|
||||
})
|
||||
.then(res => {
|
||||
console.log("adding sub");
|
||||
this.setState({
|
||||
following: true
|
||||
});
|
||||
})
|
||||
.catch(function(err) {
|
||||
console.log(err);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
handleAdd = newTopic => {
|
||||
axios
|
||||
.post("/putNewTopic", {
|
||||
handle: this.state.profile,
|
||||
topic: newTopic
|
||||
})
|
||||
.then(() => {
|
||||
let temp = this.state.myTopics;
|
||||
temp.push(newTopic);
|
||||
this.setState({
|
||||
myTopics: temp
|
||||
});
|
||||
})
|
||||
.catch(err => {
|
||||
console.err(err);
|
||||
});
|
||||
};
|
||||
|
||||
componentDidMount() {
|
||||
this.setState({ loading: true });
|
||||
let otherUserPromise = axios
|
||||
.post("/getUserDetails", {
|
||||
handle: this.state.profile
|
||||
})
|
||||
.then(res => {
|
||||
this.setState({
|
||||
imageUrl: res.data.userData.imageUrl,
|
||||
topics: res.data.userData.followedTopics
|
||||
});
|
||||
})
|
||||
.catch(err => console.log(err));
|
||||
|
||||
let userPromise = axios
|
||||
.get("/user")
|
||||
.then(res => {
|
||||
let list = [];
|
||||
let fol = false;
|
||||
res.data.credentials.following.forEach(follow => {
|
||||
// console.log(follow);
|
||||
if (this.state.profile === follow.handle) {
|
||||
fol = true;
|
||||
list = follow.topics;
|
||||
}
|
||||
});
|
||||
this.setState({
|
||||
following: fol,
|
||||
myTopics: list
|
||||
});
|
||||
})
|
||||
.catch(err => console.log(err));
|
||||
|
||||
let posts = axios
|
||||
.post("/getOtherUsersPosts", {
|
||||
handle: this.state.profile
|
||||
})
|
||||
.then(res => {
|
||||
// console.log(res.data);
|
||||
this.setState({
|
||||
posts: res.data
|
||||
});
|
||||
})
|
||||
.catch(err => console.log(err));
|
||||
|
||||
// Only add Admin posts if this is not the Admin account
|
||||
let alertPromise;
|
||||
if (this.state.profile !== "Admin") {
|
||||
alertPromise = axios
|
||||
.get("/getAlert")
|
||||
.then(res => {
|
||||
let temp = this.state.posts;
|
||||
// console.log(res.data);
|
||||
res.data.forEach(element => {
|
||||
element ? temp.push(element) : console.err;
|
||||
});
|
||||
// temp.push(res.data[0]);
|
||||
this.setState({
|
||||
posts: temp
|
||||
});
|
||||
})
|
||||
.catch(function(err) {
|
||||
console.log(err);
|
||||
});
|
||||
} else {
|
||||
alertPromise = new Promise((resolve, reject) => {
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
|
||||
Promise.all([otherUserPromise, userPromise, posts, alertPromise])
|
||||
.then(() => {
|
||||
this.setState({ loading: false });
|
||||
})
|
||||
.catch(error => {
|
||||
console.log(error);
|
||||
});
|
||||
}
|
||||
|
||||
formatDate(dateString) {
|
||||
let newDate = new Date(Date.parse(dateString));
|
||||
return newDate.toDateString();
|
||||
}
|
||||
|
||||
render() {
|
||||
const { classes } = this.props;
|
||||
|
||||
let followMarkup = this.state.following ? (
|
||||
<Button variant="contained" color="primary" onClick={this.handleSub}>
|
||||
unfollow
|
||||
</Button>
|
||||
) : (
|
||||
<Button variant="contained" color="primary" onClick={this.handleSub}>
|
||||
follow
|
||||
</Button>
|
||||
);
|
||||
let profileMarkup = this.state.profile ? (
|
||||
<div>
|
||||
<Typography variant="h5">
|
||||
@{this.state.profile}{" "}
|
||||
{this.state.verified ? (
|
||||
<VerifiedIcon style={{ fill: "#1397D5" }} />
|
||||
) : null}
|
||||
</Typography>
|
||||
{followMarkup}
|
||||
</div>
|
||||
) : (
|
||||
<p>loading username...</p>
|
||||
);
|
||||
|
||||
// console.log(this.state.topics);
|
||||
// console.log(this.state.myTopics);
|
||||
let topicsMarkup = this.state.topics ? (
|
||||
this.state.topics.map(
|
||||
topic =>
|
||||
this.state.myTopics ? (
|
||||
this.state.myTopics.includes(topic) ? (
|
||||
<MyChip
|
||||
label={topic}
|
||||
key={{ topic }.id}
|
||||
onDelete
|
||||
deleteIcon={<DoneIcon />}
|
||||
/>
|
||||
) : this.state.following ? (
|
||||
<MyChip
|
||||
label={topic}
|
||||
key={{ topic }.id}
|
||||
color="secondary"
|
||||
clickable
|
||||
onClick={key => this.handleAdd(topic)}
|
||||
/>
|
||||
) : (
|
||||
<MyChip label={topic} key={{ topic }.id} color="secondary" />
|
||||
)
|
||||
) : (
|
||||
<p></p>
|
||||
)
|
||||
// topic => <MyChip label={topic} key={{ topic }.topic.id} /> // console.log({ topic }.topic.id)
|
||||
)
|
||||
) : (
|
||||
<p> no topic yet</p>
|
||||
);
|
||||
|
||||
let imageMarkup = this.state.imageUrl ? (
|
||||
<img src={this.state.imageUrl} height="150" width="150" />
|
||||
) : (
|
||||
<img src={noImage} height="150" width="150" />
|
||||
);
|
||||
//(this.state.posts);
|
||||
let postMarkup = this.state.posts ? (
|
||||
this.state.posts.map(post => (
|
||||
<Card className={classes.card} key={post.postId} data-key={post.postId}>
|
||||
<CardContent>
|
||||
<Typography>
|
||||
{this.state.imageUrl ? (
|
||||
<img src={this.state.imageUrl} height="50" width="50" />
|
||||
) : (
|
||||
<img src={noImage} height="50" width="50" />
|
||||
)}
|
||||
</Typography>
|
||||
<Typography variant="h4">
|
||||
<b>{post.userHandle}</b>
|
||||
</Typography>
|
||||
<Typography variant="body2" color={"textSecondary"}>
|
||||
{this.formatDate(post.createdAt)}
|
||||
</Typography>
|
||||
|
||||
<br />
|
||||
<Typography variant="body1">
|
||||
<b>{post.microBlogTitle}</b>
|
||||
</Typography>
|
||||
<Typography variant="body2">{post.quoteBody}</Typography>
|
||||
|
||||
<br />
|
||||
<Typography variant="body2">{post.body}</Typography>
|
||||
<br />
|
||||
<Typography variant="body2">
|
||||
<b>Topics:</b> {post.microBlogTopics.join(", ")}
|
||||
</Typography>
|
||||
<br />
|
||||
<Typography variant="body2" color={"textSecondary"}>
|
||||
Likes {post.likeCount}
|
||||
</Typography>
|
||||
</CardContent>
|
||||
</Card>
|
||||
))
|
||||
) : (
|
||||
<p>Posts</p>
|
||||
);
|
||||
|
||||
return this.state.loading ? (
|
||||
<CircularProgress
|
||||
size={60}
|
||||
style={{ marginTop: "300px" }}
|
||||
></CircularProgress>
|
||||
) : (
|
||||
<Grid container spacing={10}>
|
||||
<Grid item sm={4} xs={8}>
|
||||
{imageMarkup}
|
||||
{profileMarkup}
|
||||
{/* {followMarkup} */}
|
||||
{topicsMarkup}
|
||||
<br />
|
||||
</Grid>
|
||||
<Grid item sm={4} xs={8}>
|
||||
{postMarkup}
|
||||
<br />
|
||||
</Grid>
|
||||
</Grid>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
user: state.user
|
||||
});
|
||||
|
||||
user.propTypes = {
|
||||
user: PropTypes.object.isRequired,
|
||||
classes: PropTypes.object.isRequired
|
||||
};
|
||||
|
||||
export default connect(mapStateToProps)(withStyles(styles)(user));
|
||||
@@ -1,49 +1,349 @@
|
||||
/* eslint-disable */
|
||||
import React, { Component } from 'react';
|
||||
import axios from 'axios';
|
||||
import React, { Component } from "react";
|
||||
import PropTypes from "prop-types";
|
||||
import { connect } from "react-redux";
|
||||
import axios from "axios";
|
||||
//import '../App.css';
|
||||
import { makeStyles, styled } from '@material-ui/core/styles';
|
||||
import Grid from '@material-ui/core/Grid';
|
||||
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 Paper from '@material-ui/core/Paper';
|
||||
// Material-UI
|
||||
import withStyles from "@material-ui/core/styles/withStyles";
|
||||
import { makeStyles, styled } from "@material-ui/core/styles";
|
||||
import { Link } from "react-router-dom";
|
||||
import Card from "@material-ui/core/Card";
|
||||
import CardMedia from "@material-ui/core/CardMedia";
|
||||
import CardContent from "@material-ui/core/CardContent";
|
||||
import Button from "@material-ui/core/Button";
|
||||
import Grid from "@material-ui/core/Grid";
|
||||
import CircularProgress from "@material-ui/core/CircularProgress";
|
||||
|
||||
import Chip from "@material-ui/core/Chip";
|
||||
import Typography from "@material-ui/core/Typography";
|
||||
import AddCircle from "@material-ui/icons/AddCircle";
|
||||
import TextField from "@material-ui/core/TextField";
|
||||
import VerifiedIcon from "@material-ui/icons/CheckSharp";
|
||||
import Paper from "@material-ui/core/Paper";
|
||||
import GridList from "@material-ui/core/GridList";
|
||||
import GridListTile from "@material-ui/core/GridListTile";
|
||||
import GridListTileBar from "@material-ui/core/GridListTileBar";
|
||||
import Container from "@material-ui/core/Container";
|
||||
|
||||
const PostCard = styled(Card)({
|
||||
background: 'linear-gradient(45deg, #1da1f2 90%)',
|
||||
border: 3,
|
||||
borderRadius: 3,
|
||||
height:325,
|
||||
width: 345,
|
||||
padding: '0 30px',
|
||||
// component
|
||||
import "../App.css";
|
||||
import noImage from "../images/no-img.png";
|
||||
import Writing_Microblogs from "../Writing_Microblogs";
|
||||
|
||||
const MyChip = styled(Chip)({
|
||||
margin: 2,
|
||||
color: "primary"
|
||||
});
|
||||
|
||||
const styles = {
|
||||
button: {
|
||||
positon: "relative",
|
||||
float: "left",
|
||||
marginLeft: 30,
|
||||
marginTop: 20
|
||||
},
|
||||
paper: {
|
||||
// marginLeft: "10%",
|
||||
// marginRight: "10%"
|
||||
},
|
||||
card: {
|
||||
marginBottom: 5
|
||||
},
|
||||
profileImage: {
|
||||
marginTop: 20
|
||||
},
|
||||
topicsContainer: {
|
||||
border: "lightgray solid 1px",
|
||||
marginTop: 20,
|
||||
paddingTop: 10,
|
||||
paddingBottom: 10,
|
||||
height: 300
|
||||
},
|
||||
addCircle: {
|
||||
width: 65,
|
||||
height: 65,
|
||||
marginTop: 10
|
||||
},
|
||||
username: {
|
||||
marginBottom: 100
|
||||
}
|
||||
};
|
||||
|
||||
class user extends Component {
|
||||
componentDidMount(){
|
||||
//TODO: get user details
|
||||
//TODO: get posts
|
||||
constructor() {
|
||||
super();
|
||||
this.state = {
|
||||
profile: null,
|
||||
imageUrl: null,
|
||||
topics: null,
|
||||
newTopic: "",
|
||||
loading: false
|
||||
};
|
||||
}
|
||||
|
||||
handleDelete = topic => {
|
||||
console.log(topic);
|
||||
axios
|
||||
.post(`/deleteTopic`, {
|
||||
unfollow: topic
|
||||
})
|
||||
.then(() => {
|
||||
let tempTopics = this.state.topics;
|
||||
tempTopics.forEach((oldTopic, index) => {
|
||||
if (oldTopic === topic) {
|
||||
tempTopics.splice(index, 1);
|
||||
}
|
||||
});
|
||||
this.setState({
|
||||
topics: tempTopics
|
||||
});
|
||||
})
|
||||
.catch(function(err) {
|
||||
console.log(err);
|
||||
});
|
||||
};
|
||||
|
||||
handleAddCircle = () => {
|
||||
axios
|
||||
.post("/putTopic", {
|
||||
following: this.state.newTopic
|
||||
})
|
||||
.then(() => {
|
||||
let tempTopics = this.state.topics;
|
||||
tempTopics.push(this.state.newTopic);
|
||||
this.setState({
|
||||
topics: tempTopics,
|
||||
newTopic: ""
|
||||
});
|
||||
})
|
||||
.catch(function(err) {
|
||||
console.log(err);
|
||||
});
|
||||
};
|
||||
|
||||
handleChange(event) {
|
||||
this.setState({
|
||||
newTopic: event.target.value
|
||||
});
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.setState({loading: true})
|
||||
let userPromise = axios
|
||||
.get("/user")
|
||||
.then(res => {
|
||||
this.setState({
|
||||
profile: res.data.credentials.handle,
|
||||
imageUrl: res.data.credentials.imageUrl,
|
||||
verified: res.data.credentials.verified
|
||||
? res.data.credentials.verified
|
||||
: false,
|
||||
topics: res.data.credentials.followedTopics
|
||||
});
|
||||
})
|
||||
.catch(err => console.log(err));
|
||||
|
||||
let postsPromise = axios
|
||||
.get("/getallPostsforUser")
|
||||
.then(res => {
|
||||
// console.log(res.data);
|
||||
this.setState({
|
||||
posts: res.data
|
||||
});
|
||||
})
|
||||
.catch(err => console.log(err));
|
||||
|
||||
Promise.all([userPromise, postsPromise])
|
||||
.then(() => {
|
||||
this.setState({loading: false});
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log(error)
|
||||
})
|
||||
}
|
||||
|
||||
formatDate(dateString) {
|
||||
let newDate = new Date(Date.parse(dateString));
|
||||
return newDate.toDateString();
|
||||
}
|
||||
|
||||
render() {
|
||||
const { classes } = this.props;
|
||||
let authenticated = this.props.user.authenticated;
|
||||
|
||||
let profileMarkup = this.state.profile ? (
|
||||
<div>
|
||||
<Typography variant="h5" className={classes.username}>
|
||||
@{this.state.profile}{" "}
|
||||
{this.state.verified ? (
|
||||
<VerifiedIcon style={{ fill: "#1397D5" }} />
|
||||
) : null}
|
||||
</Typography>
|
||||
</div>
|
||||
) : (
|
||||
<p className={classes.username}>loading username...</p>
|
||||
);
|
||||
|
||||
let topicsMarkup = this.state.topics ? (
|
||||
this.state.topics.map(
|
||||
topic => (
|
||||
<MyChip
|
||||
label={topic}
|
||||
key={topic}
|
||||
onDelete={key => this.handleDelete(topic)}
|
||||
/>
|
||||
) // console.log({ topic }.topic.id)
|
||||
)
|
||||
) : (
|
||||
<p> loading topics...</p>
|
||||
);
|
||||
|
||||
let imageMarkup = this.state.imageUrl ? (
|
||||
<img
|
||||
className={classes.profileImage}
|
||||
src={this.state.imageUrl}
|
||||
height="250"
|
||||
width="250"
|
||||
/>
|
||||
) : (
|
||||
<img
|
||||
className={classes.profileImage}
|
||||
src={noImage}
|
||||
height="250"
|
||||
width="250"
|
||||
/>
|
||||
);
|
||||
|
||||
let postMarkup = this.state.posts ? (
|
||||
this.state.posts.map(post => (
|
||||
<Card className={classes.card} key={post.postId}>
|
||||
<CardContent>
|
||||
<Typography>
|
||||
{this.state.imageUrl ? (
|
||||
<img src={this.state.imageUrl} height="50" width="50" />
|
||||
) : (
|
||||
<img src={noImage} height="50" width="50" />
|
||||
)}
|
||||
</Typography>
|
||||
<Typography variant="h6">
|
||||
<b>{post.userHandle}</b>
|
||||
</Typography>
|
||||
<Typography variant="body2" color={"textSecondary"}>
|
||||
{this.formatDate(post.createdAt) }
|
||||
</Typography>
|
||||
|
||||
<br />
|
||||
<Typography variant="body1">
|
||||
<b>{post.microBlogTitle}</b>
|
||||
</Typography>
|
||||
<Typography variant="body2">{post.quoteBody}</Typography>
|
||||
|
||||
<br />
|
||||
<Typography variant="body2">{post.body}</Typography>
|
||||
<br />
|
||||
<Typography variant="body2">
|
||||
<b>Topics:</b> {post.microBlogTopics.join(", ")}
|
||||
</Typography>
|
||||
<br />
|
||||
<Typography variant="body2" color={"textSecondary"}>
|
||||
Likes {post.likeCount}
|
||||
</Typography>
|
||||
</CardContent>
|
||||
</Card>
|
||||
))
|
||||
) : (
|
||||
<p>My Posts</p>
|
||||
);
|
||||
|
||||
// FIX: This needs to check if user's profile page being displayed
|
||||
// is the same as the user who is logged in
|
||||
// Can't check for that right now, because this page is always
|
||||
// showing the logged in users profile, instead of retreiving the
|
||||
// profile based on the URL entered
|
||||
let editButtonMarkup = true ? (
|
||||
<Link to="/user/edit">
|
||||
<Button className={classes.button} variant="outlined" color="primary">
|
||||
Edit Profile
|
||||
</Button>
|
||||
</Link>
|
||||
) : null;
|
||||
|
||||
let verifyButtonMarkup = this.state.profile === "Admin" ?
|
||||
<Link to="/verify">
|
||||
<Button className={classes.button} variant="outlined" color="primary">
|
||||
Verify Users
|
||||
</Button>
|
||||
</Link>
|
||||
:
|
||||
null
|
||||
|
||||
return (
|
||||
<Grid container spacing={16}>
|
||||
<Grid item sm={8} xs={12}>
|
||||
<p>Post</p>
|
||||
this.state.loading ? <CircularProgress size={60} style={{marginTop: "300px"}}></CircularProgress> :
|
||||
<div>
|
||||
{/* <Paper className={classes.paper}> */}
|
||||
<Grid container direction="column">
|
||||
<Grid item>
|
||||
<Grid container>
|
||||
<Grid item sm>
|
||||
{editButtonMarkup}
|
||||
{verifyButtonMarkup}
|
||||
</Grid>
|
||||
<Grid item sm>
|
||||
{/* <Grid container direction="column"> */}
|
||||
{/* <Grid item sm> */}
|
||||
{imageMarkup}
|
||||
{profileMarkup}
|
||||
{/* </Grid> */}
|
||||
{/* <Grid item sm> */}
|
||||
{/* {postMarkup} */}
|
||||
{/* </Grid> */}
|
||||
{/* </Grid> */}
|
||||
</Grid>
|
||||
<Grid item sm>
|
||||
<Container className={classes.topicsContainer} maxWidth="xs">
|
||||
{topicsMarkup}
|
||||
</Container>
|
||||
<TextField
|
||||
id="newTopic"
|
||||
label="new topic"
|
||||
// defaultValue=""
|
||||
margin="normal"
|
||||
variant="outlined"
|
||||
value={this.state.newTopic}
|
||||
onChange={event => this.handleChange(event)}
|
||||
/>
|
||||
<AddCircle
|
||||
className={classes.addCircle}
|
||||
color="primary"
|
||||
// iconStyle={classes.addCircle}
|
||||
clickable="true"
|
||||
onClick={this.handleAddCircle}
|
||||
cursor="pointer"
|
||||
/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Grid item>
|
||||
<Grid container>
|
||||
<Grid item sm />
|
||||
<Grid item>{postMarkup}</Grid>
|
||||
<Grid item sm />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Grid item sm={4} xs={12}>
|
||||
<PostCard>
|
||||
<CardMedia image="./no-img-png" />
|
||||
<CardContent>Username</CardContent>
|
||||
</PostCard>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
user: state.user
|
||||
});
|
||||
|
||||
user.propTypes = {
|
||||
user: PropTypes.object.isRequired,
|
||||
classes: PropTypes.object.isRequired
|
||||
};
|
||||
|
||||
export default user;
|
||||
export default connect(mapStateToProps)(withStyles(styles)(user));
|
||||
|
||||
153
twistter-frontend/src/pages/verify.js
Normal file
153
twistter-frontend/src/pages/verify.js
Normal file
@@ -0,0 +1,153 @@
|
||||
import React, { Component } from "react";
|
||||
import axios from "axios";
|
||||
import PropTypes from "prop-types";
|
||||
// TODO: Add a read-only '@' in the left side of the handle input
|
||||
// TODO: Add a cancel button, that takes the user back to their profile page
|
||||
|
||||
// Material-UI stuff
|
||||
import Button from "@material-ui/core/Button";
|
||||
import { Link } from 'react-router-dom';
|
||||
import CircularProgress from "@material-ui/core/CircularProgress";
|
||||
import Grid from "@material-ui/core/Grid";
|
||||
import TextField from "@material-ui/core/TextField";
|
||||
import Typography from "@material-ui/core/Typography";
|
||||
import withStyles from "@material-ui/core/styles/withStyles";
|
||||
|
||||
const styles = {
|
||||
form: {
|
||||
textAlign: "center"
|
||||
},
|
||||
textField: {
|
||||
marginBottom: 30
|
||||
},
|
||||
pageTitle: {
|
||||
// marginTop: 20,
|
||||
marginBottom: 40
|
||||
},
|
||||
button: {
|
||||
positon: "relative",
|
||||
marginBottom: 10
|
||||
},
|
||||
progress: {
|
||||
position: "absolute"
|
||||
}
|
||||
};
|
||||
|
||||
export class verify extends Component {
|
||||
|
||||
// Constructor for the state
|
||||
constructor() {
|
||||
super();
|
||||
this.state = {
|
||||
handle: "",
|
||||
loading: false,
|
||||
errors: {}
|
||||
};
|
||||
}
|
||||
|
||||
// // Runs whenever the submit button is clicked.
|
||||
handleSubmit = (event) => {
|
||||
event.preventDefault();
|
||||
this.setState({
|
||||
loading: true
|
||||
});
|
||||
const verifyHandle = {
|
||||
user: this.state.handle
|
||||
};
|
||||
|
||||
axios
|
||||
.post("/verifyUser", verifyHandle)
|
||||
.then((res) => {
|
||||
console.log(res);
|
||||
this.setState({
|
||||
loading: false
|
||||
});
|
||||
// this.props.history.push('/');
|
||||
// TODO: Need to redirect user to their profile page
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
this.setState({
|
||||
errors: err.response.data,
|
||||
loading: false
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
// Updates the state whenever one of the textboxes changes.
|
||||
// The key is the name of the textbox and the value is the
|
||||
// value in the text box.
|
||||
// Also sets errors to null of textboxes that have been edited
|
||||
handleChange = (event) => {
|
||||
this.setState({
|
||||
[event.target.name]: event.target.value,
|
||||
errors: {
|
||||
[event.target.name]: null
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
render() {
|
||||
const { classes } = this.props;
|
||||
const { loading } = this.state;
|
||||
|
||||
return (
|
||||
<Grid container className={classes.form}>
|
||||
<Grid item sm />
|
||||
<Grid item sm>
|
||||
<Typography variant="h4" className={classes.pageTitle}>
|
||||
Verify Users
|
||||
</Typography>
|
||||
<form noValidate onSubmit={this.handleSubmit}>
|
||||
<TextField
|
||||
id="handle"
|
||||
name="handle"
|
||||
label="Username"
|
||||
className={classes.textField}
|
||||
value={this.state.handle}
|
||||
// helperText={errors.handle}
|
||||
// error={errors.handle ? true : false}
|
||||
variant="outlined"
|
||||
onChange={this.handleChange}
|
||||
fullWidth
|
||||
/>
|
||||
<Grid container direction="column">
|
||||
<Grid item>
|
||||
<Button
|
||||
type="submit"
|
||||
variant="contained"
|
||||
color="primary"
|
||||
className={classes.button}
|
||||
disabled={loading}
|
||||
>
|
||||
Submit
|
||||
{loading && (
|
||||
<CircularProgress size={30} className={classes.progress} />
|
||||
)}
|
||||
</Button>
|
||||
</Grid>
|
||||
<Grid item>
|
||||
<Button
|
||||
variant="oulined"
|
||||
color="primary"
|
||||
// className={classes.button}
|
||||
component={ Link }
|
||||
to='/user'
|
||||
>
|
||||
Back to Profile
|
||||
</Button>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</form>
|
||||
</Grid>
|
||||
<Grid item sm />
|
||||
</Grid>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
verify.propTypes = {
|
||||
classes: PropTypes.object.isRequired
|
||||
};
|
||||
|
||||
export default withStyles(styles)(verify);
|
||||
@@ -0,0 +1,147 @@
|
||||
import {
|
||||
SET_DIRECT_MESSAGES,
|
||||
LOADING_UI,
|
||||
SET_ERRORS,
|
||||
CLEAR_ERRORS,
|
||||
SET_LOADING_UI_2,
|
||||
SET_LOADING_UI_3,
|
||||
SET_LOADING_UI_4,
|
||||
SET_NOT_LOADING_UI_2,
|
||||
SET_NOT_LOADING_UI_3,
|
||||
SET_NOT_LOADING_UI_4
|
||||
} from '../types';
|
||||
import axios from "axios";
|
||||
|
||||
// TODO: Tidy up these functions. They shouldn't have all these promises in them.
|
||||
|
||||
export const getDirectMessages = () => (dispatch) => {
|
||||
dispatch({type: SET_LOADING_UI_2});
|
||||
axios.get('/dms')
|
||||
.then((res) => {
|
||||
dispatch({
|
||||
type: SET_DIRECT_MESSAGES,
|
||||
payload: res.data.data
|
||||
});
|
||||
dispatch({type: SET_NOT_LOADING_UI_2});
|
||||
dispatch({type: CLEAR_ERRORS});
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error(err);
|
||||
dispatch({
|
||||
type: SET_ERRORS,
|
||||
payload: {
|
||||
errors: err.response.data.error
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
export const getNewDirectMessages = () => (dispatch) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios.get('/dms')
|
||||
.then((res) => {
|
||||
dispatch({
|
||||
type: SET_DIRECT_MESSAGES,
|
||||
payload: res.data.data
|
||||
});
|
||||
dispatch({type: SET_NOT_LOADING_UI_2});
|
||||
dispatch({type: CLEAR_ERRORS});
|
||||
resolve();
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
reject(err);
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export const reloadDirectMessageChannels = () => (dispatch) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios.get('/dms')
|
||||
.then((res) => {
|
||||
dispatch({
|
||||
type: SET_DIRECT_MESSAGES,
|
||||
payload: res.data.data
|
||||
});
|
||||
dispatch({type: SET_NOT_LOADING_UI_3});
|
||||
dispatch({type: CLEAR_ERRORS});
|
||||
resolve();
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
reject(err);
|
||||
})
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
export const createNewDirectMessage = (username) => (dispatch) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
dispatch({type: SET_LOADING_UI_3});
|
||||
const data = {
|
||||
user: username
|
||||
}
|
||||
// console.log(username);
|
||||
|
||||
axios.post('/dms/new', data)
|
||||
.then((res) => {
|
||||
// console.log(res.data);
|
||||
if (res.data.err) {
|
||||
dispatch({
|
||||
type: SET_ERRORS,
|
||||
payload: {
|
||||
createDirectMessage: res.data.err
|
||||
}
|
||||
});
|
||||
dispatch({type: SET_NOT_LOADING_UI_3});
|
||||
} else {
|
||||
// dispatch(getNewDirectMessages());
|
||||
// dispatch({type: SET_NOT_LOADING_UI_3});
|
||||
}
|
||||
resolve();
|
||||
})
|
||||
.catch((err) => {
|
||||
dispatch({
|
||||
type: SET_ERRORS,
|
||||
payload: {
|
||||
createDirectMessage: err.response.data.error
|
||||
}
|
||||
});
|
||||
dispatch({type: SET_NOT_LOADING_UI_3});
|
||||
console.log(err.response.data);
|
||||
reject(err);
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
export const sendDirectMessage = (user, message) => (dispatch) => {
|
||||
dispatch({type: SET_LOADING_UI_4});
|
||||
const data = {
|
||||
message,
|
||||
user
|
||||
};
|
||||
|
||||
axios.post('/dms/send', data)
|
||||
.then((res) => {
|
||||
// console.log(res);
|
||||
return axios.get('/dms')
|
||||
})
|
||||
.then((res) => {
|
||||
dispatch({
|
||||
type: SET_DIRECT_MESSAGES,
|
||||
payload: res.data.data
|
||||
});
|
||||
dispatch({type: SET_NOT_LOADING_UI_4});
|
||||
dispatch({type: CLEAR_ERRORS});
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
dispatch({
|
||||
type: SET_ERRORS,
|
||||
payload: {
|
||||
sendDirectMessage: err.response.data
|
||||
}
|
||||
})
|
||||
dispatch({type: SET_NOT_LOADING_UI_4});
|
||||
})
|
||||
}
|
||||
@@ -1,19 +1,42 @@
|
||||
import {SET_USER, SET_ERRORS, CLEAR_ERRORS, LOADING_UI, SET_AUTHENTICATED, SET_UNAUTHENTICATED} from '../types';
|
||||
|
||||
import {
|
||||
SET_USER,
|
||||
SET_ERRORS,
|
||||
CLEAR_ERRORS,
|
||||
LOADING_UI,
|
||||
// SET_AUTHENTICATED,
|
||||
SET_UNAUTHENTICATED,
|
||||
LIKE_POST,
|
||||
UNLIKE_POST,
|
||||
SET_LIKES,
|
||||
LOADING_USER
|
||||
} from '../types';
|
||||
import axios from 'axios';
|
||||
|
||||
// Saves Authorization in browser local storage and adds it as a header to axios
|
||||
const setAuthorizationHeader = (token) => {
|
||||
const FBIdToken = `Bearer ${token}`;
|
||||
localStorage.setItem('FBIdToken', FBIdToken);
|
||||
axios.defaults.headers.common['Authorization'] = FBIdToken;
|
||||
}
|
||||
|
||||
// Gets Database info for the logged in user and sets it in Redux
|
||||
export const getUserData = () => (dispatch) => {
|
||||
dispatch({ type: LOADING_USER });
|
||||
axios.get('/user')
|
||||
.then((res) => {
|
||||
dispatch({
|
||||
type: SET_USER,
|
||||
payload: res.data,
|
||||
})
|
||||
});
|
||||
dispatch({type: CLEAR_ERRORS});
|
||||
})
|
||||
.catch((err) => console.error(err));
|
||||
}
|
||||
|
||||
// Sends login data to firebase and sets the user data in Redux
|
||||
export const loginUser = (loginData, history) => (dispatch) => {
|
||||
dispatch({type: CLEAR_ERRORS});
|
||||
dispatch({ type: LOADING_UI });
|
||||
axios
|
||||
.post("/login", loginData)
|
||||
@@ -21,7 +44,7 @@ export const loginUser = (loginData, history) => (dispatch) => {
|
||||
// Save the login token
|
||||
setAuthorizationHeader(res.data.token);
|
||||
dispatch(getUserData());
|
||||
dispatch({ type: CLEAR_ERRORS })
|
||||
// dispatch({ type: CLEAR_ERRORS })
|
||||
// Redirects to home page
|
||||
history.push('/home');
|
||||
})
|
||||
@@ -33,7 +56,9 @@ export const loginUser = (loginData, history) => (dispatch) => {
|
||||
});
|
||||
};
|
||||
|
||||
// Sends signup data to firebase and sets the user data in Redux
|
||||
export const signupUser = (newUserData, history) => (dispatch) => {
|
||||
dispatch({type: CLEAR_ERRORS});
|
||||
dispatch({ type: LOADING_UI });
|
||||
axios
|
||||
.post("/signup", newUserData)
|
||||
@@ -43,7 +68,7 @@ export const signupUser = (newUserData, history) => (dispatch) => {
|
||||
// Save the signup token
|
||||
setAuthorizationHeader(res.data.token);
|
||||
dispatch(getUserData());
|
||||
dispatch({ type: CLEAR_ERRORS })
|
||||
// dispatch({ type: CLEAR_ERRORS })
|
||||
// Redirects to home page
|
||||
history.push('/home');
|
||||
})
|
||||
@@ -55,14 +80,93 @@ export const signupUser = (newUserData, history) => (dispatch) => {
|
||||
});
|
||||
};
|
||||
|
||||
// Deletes the Authorization header and clears all user data from Redux
|
||||
export const logoutUser = () => (dispatch) => {
|
||||
localStorage.removeItem('FBIdToken');
|
||||
delete axios.defaults.headers.common['Authorization'];
|
||||
dispatch({ type: SET_UNAUTHENTICATED });
|
||||
}
|
||||
|
||||
const setAuthorizationHeader = (token) => {
|
||||
const FBIdToken = `Bearer ${token}`;
|
||||
localStorage.setItem('FBIdToken', FBIdToken);
|
||||
axios.defaults.headers.common['Authorization'] = FBIdToken;
|
||||
}
|
||||
|
||||
export const deleteUser = () => (dispatch) => {
|
||||
axios
|
||||
.delete("/delete")
|
||||
.then((res) => {
|
||||
console.log(res);
|
||||
console.log("User account successfully deleted.");
|
||||
}
|
||||
)
|
||||
.catch((err) => {
|
||||
dispatch ({
|
||||
type: SET_ERRORS,
|
||||
payload: err.response.data,
|
||||
})
|
||||
});
|
||||
|
||||
localStorage.removeItem('FBIdToken');
|
||||
delete axios.defaults.headers.common['Authorization'];
|
||||
dispatch({ type: SET_UNAUTHENTICATED });
|
||||
}
|
||||
|
||||
export const getLikes = () => (dispatch) => {
|
||||
axios.get('/likes')
|
||||
.then((res) => {
|
||||
dispatch({
|
||||
type: SET_LIKES,
|
||||
payload: res.data
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export const likePost = (postId, postArray) => (dispatch) => {
|
||||
postArray.push(postId);
|
||||
dispatch({
|
||||
type: LIKE_POST,
|
||||
payload: {
|
||||
likes: postArray
|
||||
}
|
||||
})
|
||||
axios.get(`/like/${postId}`)
|
||||
.then((res) => {
|
||||
getLikes();
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
|
||||
export const unlikePost = (postId, postArray) => (dispatch) => {
|
||||
let i;
|
||||
for (i = 0; i < postArray.length; i++) {
|
||||
if (postArray[i] === postId) {
|
||||
postArray.splice(i, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
dispatch({
|
||||
type: UNLIKE_POST,
|
||||
payload: {
|
||||
likes: postArray
|
||||
}
|
||||
})
|
||||
|
||||
axios.get(`/unlike/${postId}`)
|
||||
.then((res) => {
|
||||
getLikes();
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
// Sends an image data form to firebase to be uploaded to the user profile
|
||||
export const uploadImage = (formData) => (dispatch) => {
|
||||
dispatch({ type: LOADING_UI });
|
||||
axios.post('/user/image', formData)
|
||||
.then(() => {
|
||||
dispatch(getUserData());
|
||||
// dispatch({ type: CLEAR_ERRORS });
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
import {SET_DIRECT_MESSAGES, SET_USERNAME_VALID, SET_USERNAME_INVALID} from '../types';
|
||||
|
||||
const initialState = {
|
||||
directMessages: null,
|
||||
};
|
||||
|
||||
export default function(state = initialState, action) {
|
||||
switch(action.type) {
|
||||
case SET_DIRECT_MESSAGES:
|
||||
return {
|
||||
...state,
|
||||
directMessages: action.payload
|
||||
};
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,20 @@
|
||||
import { SET_ERRORS, CLEAR_ERRORS, LOADING_UI } from '../types';
|
||||
import {
|
||||
SET_ERRORS,
|
||||
CLEAR_ERRORS,
|
||||
LOADING_UI,
|
||||
SET_LOADING_UI_2,
|
||||
SET_LOADING_UI_3,
|
||||
SET_LOADING_UI_4,
|
||||
SET_NOT_LOADING_UI_2,
|
||||
SET_NOT_LOADING_UI_3,
|
||||
SET_NOT_LOADING_UI_4
|
||||
} from '../types';
|
||||
|
||||
const initialState = {
|
||||
loading: false,
|
||||
loading2: false,
|
||||
loading3: false,
|
||||
loading4: false,
|
||||
errors: null
|
||||
};
|
||||
|
||||
@@ -23,7 +36,37 @@ export default function(state = initialState, action) {
|
||||
return {
|
||||
...state,
|
||||
loading: true
|
||||
}
|
||||
};
|
||||
case SET_LOADING_UI_2:
|
||||
return {
|
||||
...state,
|
||||
loading2: true
|
||||
};
|
||||
case SET_LOADING_UI_3:
|
||||
return {
|
||||
...state,
|
||||
loading3: true
|
||||
};
|
||||
case SET_LOADING_UI_4:
|
||||
return {
|
||||
...state,
|
||||
loading4: true
|
||||
};
|
||||
case SET_NOT_LOADING_UI_2:
|
||||
return {
|
||||
...state,
|
||||
loading2: false
|
||||
};
|
||||
case SET_NOT_LOADING_UI_3:
|
||||
return {
|
||||
...state,
|
||||
loading3: false
|
||||
};
|
||||
case SET_NOT_LOADING_UI_4:
|
||||
return {
|
||||
...state,
|
||||
loading4: false
|
||||
};
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,17 @@
|
||||
import {SET_USER, SET_ERRORS, CLEAR_ERRORS, LOADING_UI, SET_AUTHENTICATED, SET_UNAUTHENTICATED} from '../types';
|
||||
|
||||
import {
|
||||
SET_USER,
|
||||
// SET_ERRORS,
|
||||
// CLEAR_ERRORS,
|
||||
// LOADING_UI,
|
||||
SET_AUTHENTICATED,
|
||||
SET_UNAUTHENTICATED,
|
||||
LOADING_USER,
|
||||
LIKE_POST,
|
||||
UNLIKE_POST,
|
||||
SET_LIKES
|
||||
} from '../types';
|
||||
|
||||
|
||||
const initialState = {
|
||||
authenticated: false,
|
||||
@@ -19,9 +32,31 @@ export default function(state = initialState, action) {
|
||||
return initialState;
|
||||
case SET_USER:
|
||||
return {
|
||||
...state,
|
||||
authenticated: true,
|
||||
loading: false,
|
||||
...action.payload,
|
||||
};
|
||||
case LIKE_POST:
|
||||
return {
|
||||
...state,
|
||||
...action.payload
|
||||
}
|
||||
case UNLIKE_POST:
|
||||
return {
|
||||
...state,
|
||||
...action.payload
|
||||
}
|
||||
case SET_LIKES:
|
||||
return {
|
||||
...state,
|
||||
...action.payload
|
||||
}
|
||||
case LOADING_USER:
|
||||
return {
|
||||
...state,
|
||||
loading: true
|
||||
}
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
||||
@@ -3,10 +3,22 @@ export const SET_AUTHENTICATED = 'SET_AUTHENTICATED';
|
||||
export const SET_UNAUTHENTICATED = 'SET_UNAUTHENTICATED';
|
||||
export const SET_USER = 'SET_USER';
|
||||
export const LOADING_USER = 'LOADING_USER';
|
||||
export const LIKE_POST = 'LIKE_POST';
|
||||
export const UNLIKE_POST = 'UNLIKE_POST';
|
||||
export const SET_LIKES = 'SET_LIKES';
|
||||
|
||||
// UI reducer types
|
||||
export const SET_ERRORS = 'SET_ERRORS';
|
||||
export const LOADING_UI = 'LOADING_UI';
|
||||
export const SET_LOADING_UI_2 = 'SET_LOADING_UI_2';
|
||||
export const SET_LOADING_UI_3 = 'SET_LOADING_UI_3';
|
||||
export const SET_LOADING_UI_4 = 'SET_LOADING_UI_4';
|
||||
export const SET_NOT_LOADING_UI_2 = 'SET_NOT_LOADING_UI_2';
|
||||
export const SET_NOT_LOADING_UI_3 = 'SET_NOT_LOADING_UI_3';
|
||||
export const SET_NOT_LOADING_UI_4 = 'SET_NOT_LOADING_UI_4';
|
||||
export const CLEAR_ERRORS = 'CLEAR_ERRORS';
|
||||
|
||||
// Data reducer types
|
||||
// Data reducer types
|
||||
export const SET_DIRECT_MESSAGES = 'SET_DIRECT_MESSAGES';
|
||||
export const SET_USERNAME_VALID = 'SET_USERNAME_VALID';
|
||||
export const SET_USERNAME_INVALID = 'SET_USERNAME_INVALID';
|
||||
@@ -50,7 +50,13 @@ export default {
|
||||
marginBottom: 20
|
||||
},
|
||||
paper: {
|
||||
padding: 20
|
||||
padding: 10,
|
||||
display: 'flex',
|
||||
justifyContent: 'center',
|
||||
flexWrap: 'wrap'
|
||||
},
|
||||
chip: {
|
||||
margin: 0.5,
|
||||
},
|
||||
profile: {
|
||||
'& .image-wrapper': {
|
||||
|
||||
Reference in New Issue
Block a user