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("/requests/create", (req, res) => { | |
const { matchRequestFrom, matchRequestTo, matchRequestSender, matchRequestReceiver } = req.body; | |
if (matchRequestFrom && matchRequestTo && matchRequestSender && matchRequestReceiver) { | |
// check the request existed in the database or not. | |
const sql = "SELECT * FROM match_request WHERE match_request_from = ? AND match_request_to = ?"; | |
dbConn.query(sql, [matchRequestFrom, matchRequestTo], function (err, result) { | |
if (err) { | |
res.status(200).jsonp({ message: "The system error. Please try again" }); | |
} else if (result && result.length !== 0) { | |
res.status(200).jsonp({ message: "The match request existed in the system." }); |
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("/requests/get", (req, res) => { | |
const { ccUid } = req.body; | |
const sql = "SELECT * FROM match_request WHERE match_request_from = ? || match_request_to = ?"; | |
dbConn.query(sql, [ccUid, ccUid], function (err, result) { | |
if (err) { | |
res.status(200).jsonp({ message: 'Cannot get the list of match requests' }); | |
} else { | |
res.status(200).jsonp(result); | |
} | |
}); |
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 getUpdateRequest = (id, status) => { | |
if (status && status === constants.matchRequestStatus.accepted) { | |
return { | |
payload: [status, new Date(), id], | |
sql: "UPDATE match_request SET match_request_status = ?, accepted_date = ? WHERE id = ?" | |
}; | |
} | |
return { | |
payload: [status, id], | |
sql: "UPDATE match_request SET match_request_status = ? WHERE id = ?" |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8" /> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
<title>Login</title> | |
<link rel="stylesheet" href="/css/styles.css" /> | |
<script | |
defer |
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
window.addEventListener("DOMContentLoaded", function () { | |
function shouldRedirectToHomePage(user, isLoginPage) { | |
return user && isLoginPage; | |
} | |
function shouldRedirectToLoginPage(user, isLoginPage) { | |
return !user && !isLoginPage; | |
} | |
const authenticatedUser = JSON.parse(localStorage.getItem("auth")); |
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 loading = document.getElementById('loading'); | |
function hideLoading() { | |
loading.classList.add('loading--hide'); | |
} | |
function showLoading() { | |
loading.classList.remove('loading--hide'); | |
loading.classList.add('loading--active'); | |
} |
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 registerNewAccount = ({ avatar, email, password, fullname, age, gender }) => { | |
showLoading(); | |
const userUuid = uuid.v4(); | |
const form = new FormData(); | |
form.append("avatar", avatar); | |
form.append("email", email); | |
form.append("password", password); | |
form.append("age", age); | |
form.append("gender", gender); | |
form.append("ccUid", userUuid); |
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
loginBtn.addEventListener("click", function () { | |
// show loading indicator. | |
showLoading(); | |
// get input user's credentials. | |
const email = emailLoginInputElement ? emailLoginInputElement.value : null; | |
const password = passwordLoginInputElement ? passwordLoginInputElement.value : null; | |
if (isUserCredentialsValid({ email, password })) { | |
axios | |
.post("/login", { email, password }) | |
.then((res) => { |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8" /> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
<title>Tinder Clone - CometChat JS SDK</title> | |
<link rel="stylesheet" href="/css/styles.css" /> | |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.css"> | |
</head> |
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
window.addEventListener("DOMContentLoaded", function () { | |
... | |
// set header information | |
const authenticatedUser = JSON.parse(localStorage.getItem("auth")); | |
if (authenticatedUser) { | |
... | |
// show authenticated user on the header. | |
const headerRight = document.getElementById("header__right"); | |
const userImage = document.getElementById("user__image"); | |
const userName = document.getElementById("user__name"); |