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('/reactions/delete', (req, res) => { | |
| const { postId, userId } = req.body; | |
| if (!postId || !userId) { | |
| res.status(200).jsonp({ message: 'Cannot create the post reaction, please try again' }); | |
| } | |
| const deleteReactionsSql = "DELETE FROM post_reaction WHERE post_id = ? AND user_id = ?"; | |
| dbConn.query(deleteReactionsSql, [postId, userId], function (error, response) { | |
| if (response && response.affectedRows) { | |
| res.status(200).jsonp({ postId, userId }); | |
| } else { |
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('/notifications/create', (req, res) => { | |
| const { notificationImage, notificationMessage, userId } = req.body; | |
| if (!notificationImage || !notificationMessage || !userId) { | |
| res.status(200).jsonp({ message: 'Cannot creat the notification, please try again' }); | |
| } | |
| const createNotification = [[notificationImage, notificationMessage, userId]]; | |
| const createNotificationSql = "INSERT INTO user_notification (notification_image, notification_message, user_id) VALUES ?"; | |
| dbConn.query(createNotificationSql, [createNotification], function (error, insertedNotification) { | |
| if (insertedNotification) { | |
| res.status(200).jsonp({ id: insertedNotification.insertId, notification_image: notificationImage, notification_message: notificationMessage, user_id: userId }); |
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.get('/notifications/:id', (req, res) => { | |
| const userId = req.params.id; | |
| const getNotificationsSql = "SELECT * FROM user_notification WHERE user_id = ? ORDER BY id DESC"; | |
| dbConn.query(getNotificationsSql, [userId], function (error, notifications) { | |
| if (notifications) { | |
| res.status(200).jsonp(notifications); | |
| } else { | |
| res.status(200).jsonp({ message: 'Cannot get your notifications, please try again' }); | |
| } | |
| }); |
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
| useEffect(() => { | |
| initCometChat(); | |
| }, []); | |
| const initCometChat = async () => { | |
| const { CometChat } = await import('@cometchat-pro/chat'); | |
| const appID = `${process.env.REACT_APP_COMETCHAT_APP_ID}`; | |
| const region = `${process.env.REACT_APP_COMETCHAT_REGION}`; | |
| const appSetting = new CometChat.AppSettingsBuilder().subscribePresenceForAllUsers().setRegion(region).build(); | |
| CometChat.init(appID, appSetting).then( |
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
| import { useEffect, useRef, useContext } from "react"; | |
| import validator from "validator"; | |
| import { useHistory } from 'react-router-dom'; | |
| import axios from 'axios'; | |
| import withModal from "../common/Modal"; | |
| import SignUp from "../register/SignUp"; | |
| import Context from "../../context"; | |
| const Login = (props) => { | |
| const { toggleModal } = props; |
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 loginCometChat = async (user) => { | |
| const authKey = `${process.env.REACT_APP_COMETCHAT_AUTH_KEY}`; | |
| return await cometChat.login(user.id, authKey); | |
| }; |
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
| import { useState } from 'react'; | |
| const withModal = ModalComponent => WrapperComponent => { | |
| return function (props) { | |
| const [isModalShown, setIsModalShown] = useState(false); | |
| return ( | |
| <> | |
| <WrapperComponent toggleModal={setIsModalShown} {...props} /> |
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
| import { useRef, useContext, useState } from "react"; | |
| import validator from "validator"; | |
| import { v4 as uuidv4 } from "uuid"; | |
| import axios from 'axios'; | |
| import Context from "../../context"; | |
| function SignUp(props) { | |
| const { toggleModal } = props; | |
| const { cometChat, setIsLoading } = useContext(Context); |
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 createCometChatAccount = async ({ userUuid, fullname, avatar }) => { | |
| const authKey = `${process.env.REACT_APP_COMETCHAT_AUTH_KEY}`; | |
| const user = new cometChat.User(userUuid); | |
| user.setName(fullname); | |
| user.setAvatar(avatar); | |
| return await cometChat.createUser(user, authKey); | |
| }; |
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
| import { useContext } from 'react'; | |
| import { useHistory } from 'react-router-dom'; | |
| import withModal from '../common/Modal'; | |
| import Create from '../create/Create'; | |
| import Context from '../../context'; | |
| import logo from '../../logo.png'; | |
| const Header = (props) => { | |
| const { toggleModal } = props; |