Skip to content

Commit

Permalink
Functioning notifiction button for current user
Browse files Browse the repository at this point in the history
  • Loading branch information
aditya161216 committed Dec 12, 2024
1 parent 41ca32f commit b65ad13
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
5 changes: 3 additions & 2 deletions frontend/src/Bell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faBell } from "@fortawesome/free-solid-svg-icons";
import { useEffect, useState } from "react";

const currUserID = "bcanuser33" // test
// get current user id
const currUserID = sessionStorage.getItem('userId');

const BellButton = () => {

Expand Down Expand Up @@ -39,7 +40,7 @@ const BellButton = () => {
{isClicked &&
<div className="notification-modal">
<div className="notification-modal-content">
<h4>Notifications</h4>
<h4>Notifications for {currUserID}</h4>
<ul>
{notifications.map((notification, index) => (
<li key={index} className="notification-item">
Expand Down
1 change: 1 addition & 0 deletions frontend/src/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const Dashboard = observer(() => {
const store = getStore();

const handleLogout = () => {
sessionStorage.clear() // clear session storage while logging out to remove user data
logout();
};

Expand Down
9 changes: 9 additions & 0 deletions frontend/src/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { setAuthentication } from './external/bcanSatchel/actions.js'; // Correc
import { observer } from 'mobx-react-lite';
import { useNavigate } from 'react-router-dom';

console.log("user id before logging in: " , sessionStorage.getItem('userId'))

const Login = observer(() => {
const [username, setUsername] = useState('');
const [password, setPassword] = useState('');
Expand All @@ -30,6 +32,13 @@ const Login = observer(() => {
console.log('Login response data:', data);

if (data.access_token) {
// store the username in session storage for use by other functions
sessionStorage.setItem('userId', data.user.userId);

// console.log(data.user)

console.log('Username stored:', sessionStorage.getItem('userId'));

setAuthentication(true, data.user, data.access_token);
navigate('/dashboard');
alert(data.message); // Alert wit message from backend indicating success
Expand Down

0 comments on commit b65ad13

Please sign in to comment.