Skip to content

Commit 894f20d

Browse files
Merge pull request #3401 from OneCommunityGlobal/Koushica_hotfix_BellNotification
Koushica - Hotfix - bell notification
2 parents 8794ac9 + e088847 commit 894f20d

6 files changed

Lines changed: 47 additions & 6 deletions

File tree

src/actions/dashboardActions.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export const INCREMENT_DASHBOARD_TASK_COUNT = 'INCREMENT_DASHBOARD_TASK_COUNT';
2+
export const UPDATE_SUMMARY_BAR_DATA = 'UPDATE_SUMMARY_BAR_DATA'
23

34
export const incrementDashboardTaskCount = (taskId) => {
45
console.log(`Dispatching incrementDashboardTaskCount for task ID: ${taskId}`);
@@ -7,3 +8,11 @@ export const incrementDashboardTaskCount = (taskId) => {
78
payload: { taskId },
89
};
910
};
11+
12+
export const updateSummaryBarData = ({summaryBarData}) => {
13+
console.log(summaryBarData);
14+
return {
15+
type: UPDATE_SUMMARY_BAR_DATA,
16+
payload: { summaryBarData },
17+
};
18+
};

src/components/Dashboard/Dashboard.jsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import {
1515
DEV_ADMIN_ACCOUNT_CUSTOM_WARNING_MESSAGE_DEV_ENV_ONLY,
1616
PROTECTED_ACCOUNT_MODIFICATION_WARNING_MESSAGE,
1717
} from 'utils/constants';
18+
import { useDispatch } from 'react-redux';
19+
import { updateSummaryBarData } from 'actions/dashboardActions';
1820

1921
export function Dashboard(props) {
2022
const [popup, setPopup] = useState(false);
@@ -27,6 +29,8 @@ export function Dashboard(props) {
2729
const isNotAllowedToEdit = cantUpdateDevAdminDetails(viewingUser?.email, authUser.email);
2830
const darkMode = useSelector(state => state.theme.darkMode);
2931

32+
const dispatch = useDispatch();
33+
3034
const toggle = (forceOpen = null) => {
3135
if (isNotAllowedToEdit) {
3236
const warningMessage =
@@ -61,6 +65,11 @@ export function Dashboard(props) {
6165
};
6266
}, []);
6367

68+
useEffect(()=>{
69+
console.log(summaryBarData)
70+
dispatch(updateSummaryBarData({summaryBarData}));
71+
},[summaryBarData])
72+
6473
return (
6574
<Container fluid className={darkMode ? 'bg-oxford-blue' : ''}>
6675
<SummaryBar

src/components/Header/BellNotification.jsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { useState, useEffect, useCallback, useRef, useMemo } from 'react';
33
import { useSelector } from 'react-redux';
44

5-
export default function BellNotification() {
5+
export default function BellNotification({userId}) {
66
// State variables to manage notifications and UI state
77
const [hasNotification, setHasNotification] = useState(false);
88
const [isDataReady, setIsDataReady] = useState(false);
@@ -13,7 +13,13 @@ export default function BellNotification() {
1313
const timeEntries = useSelector(state => state.timeEntries?.weeks?.[0] || []);
1414
const weeklycommittedHours = useSelector(state => state.userProfile?.weeklycommittedHours || 0);
1515
const darkMode = useSelector(state => state.theme.darkMode);
16-
const userId = useSelector(state => state.auth.user?.userid);
16+
// const userId = useSelector(state => {
17+
// console.log(state.auth)
18+
// return state.auth.user?.userid});
19+
// const checkSessionStorage = () => JSON.parse(sessionStorage.getItem('viewingUser')) ?? false;
20+
// const [viewingUser, setViewingUser] = useState(checkSessionStorage);
21+
// const [displayUserId, setDisplayUserId] = useState( viewingUser?.userId || userId);
22+
1723

1824
/**
1925
* Memoized function to calculate the total effort (hours + minutes) logged by the user
@@ -127,6 +133,10 @@ export default function BellNotification() {
127133
};
128134
}, []);
129135

136+
useEffect(() => {
137+
setIsDataReady(false);
138+
},[userId])
139+
130140
/**
131141
* Utility function to format time values in hours and minutes
132142
*/

src/components/Header/Header.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ export function Header(props) {
441441
</NavItem>
442442
)}
443443
<NavItem className="responsive-spacing">
444-
<BellNotification />
444+
<BellNotification userId={displayUserId}/>
445445
</NavItem>
446446
{(canAccessUserManagement ||
447447
canAccessBadgeManagement ||

src/components/UserManagement/UserSearchPanel.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,9 @@ function UserSearchPanel({
7676
{CREATE_NEW_USER}
7777
</button>
7878

79-
<div className="input-group-prepend" style={{marginRight: "5px"}}>
79+
<div className="input-group-prepend">
8080
<span className={`input-group-text ${darkMode ? 'bg-yinmn-blue text-light' : ''}`}>{SEARCH}</span>
81+
</div>
8182
<input
8283
// autoFocus
8384
type="text"
@@ -89,8 +90,8 @@ function UserSearchPanel({
8990
onChange={e => {
9091
onSearch(e.target.value);
9192
}}
93+
style={{marginRight: "5px"}}
9294
/>
93-
</div>
9495
<div className="input-group-prepend">
9596
<span className={`input-group-text ${darkMode ? 'bg-yinmn-blue text-light' : ''}`}>{SHOW}</span>
9697
<select

src/reducers/dashboardReducer.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
import { INCREMENT_DASHBOARD_TASK_COUNT } from '../actions/dashboardActions';
1+
import {
2+
INCREMENT_DASHBOARD_TASK_COUNT,
3+
UPDATE_SUMMARY_BAR_DATA,
4+
} from '../actions/dashboardActions';
25

36
const initialState = {
47
taskCounts: {},
8+
summaryBarData: {},
59
};
610

711
// eslint-disable-next-line default-param-last
@@ -20,6 +24,14 @@ const dashboardReducer = (state = initialState, action) => {
2024
},
2125
};
2226
}
27+
case UPDATE_SUMMARY_BAR_DATA: {
28+
// Wrap case block in braces to avoid scoping issues
29+
const { summaryBarData } = action.payload;
30+
return {
31+
...state,
32+
summaryBarData,
33+
};
34+
}
2335
default: {
2436
return state;
2537
}

0 commit comments

Comments
 (0)