This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
setToastMessage = (type, message) => { | |
switch(type) { | |
case "error": | |
this.toastRef.setError(message); | |
break; | |
case "success": | |
this.toastRef.setSuccess(message); | |
break; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
showToastForMentionMessage = (message) => { | |
if (message.text.includes(`@${this.state.loggedInUser.name}`)) { | |
const toastMessage = `You was tagged by ${message.sender.name}`; | |
this.context.setToastMessage("success", toastMessage); | |
} | |
} | |
//callback for listener functions | |
messageUpdated = (key, message, group, options) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CometChatMessages extends React.PureComponent { | |
... | |
messageSent = messages => { | |
const message = messages[0]; | |
const messageList = [...this.state.messageList]; | |
let messageKey = messageList.findIndex(m => m._id === message._id); | |
if (messageKey > -1) { | |
const newMessageObj = { ...message }; | |
const transformedMessage = this.messageListRef.transformSingleMessage(newMessageObj); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
class CometChatMessageList extends React.PureComponent { | |
... | |
constructor(props, context) { | |
... | |
this.members = React.createRef(); | |
} | |
componentDidMount() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DROP DATABASE IF EXISTS tinder_clone; | |
CREATE DATABASE tinder_clone; | |
USE tinder_clone; | |
CREATE TABLE user_account ( | |
id BIGINT NOT NULL AUTO_INCREMENT, | |
user_email VARCHAR(255) NOT NULL, | |
user_password VARCHAR(255) NOT NULL, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require("dotenv").config(); | |
const bodyParser = require("body-parser"); | |
const cors = require("cors"); | |
const express = require("express"); | |
const multer = require("multer"); | |
const mysql = require("mysql"); | |
const path = require("path"); | |
const PORT = process.env.PORT || 8080; | |
const app = express(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const authRoutes = require("./auth"); | |
const userRoutes = require("./users"); | |
const matchRequestsRoutes = require("./requests"); | |
module.exports = function ({ app, dbConn, upload, constants }) { | |
authRoutes({ app, dbConn }); | |
userRoutes({ app, dbConn, upload }); | |
matchRequestsRoutes({ app, dbConn, constants }); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function ({ app, dbConn }) { | |
app.post("/login", (req, res) => { | |
const { email, password } = req.body; | |
if (email && password) { | |
const sql = "SELECT * FROM user_account WHERE user_email = ? AND user_password = ?"; | |
dbConn.query(sql, [email, password], function (err, result) { | |
if (result && result.length !== 0) { | |
res.status(200).jsonp({ gender: result[0].user_gender, uid: result[0].user_cometchat_uid }); | |
} else { | |
res.status(200).jsonp({ message: "Your username or password is not correct" }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.post("/users/create", upload.single("avatar"), (req, res, next) => { | |
// validate the avatar. The avatar is requied. | |
const file = req.file; | |
if (!file || !file.mimetype.includes("jpeg")) { | |
res.status(200).jsonp({ | |
message: "Please upload your avatar, the image should be .jpg format", | |
}); | |
} else { | |
const avatar = `/img/${file.filename}`; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const transformRecommendedUsers = (users) => { | |
if (users && users.length !== 0) { | |
return users.map(user => { | |
return { | |
id: user.id, | |
user_age: user.user_age, | |
user_avatar: user.user_avatar, | |
user_cometchat_uid: user.user_cometchat_uid, | |
user_email: user.user_email, | |
user_full_name: user.user_full_name, |