Skip to content

Commit

Permalink
fix(notifications): toggle notification open state on click
Browse files Browse the repository at this point in the history
  • Loading branch information
FussuChalice authored Nov 22, 2024
1 parent a798b55 commit 9af4f90
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
10 changes: 6 additions & 4 deletions src/features/app_notification/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ import ButtonIcon from '@components/icon_button';
import NotificationContainer from './container';

const AppNotification = () => {
const { handleCloseNotification, handleOpenNotification, open, count } =
useAppNotification();
const { handleToggleNotificationState, open, count } = useAppNotification();

return (
<>
<ButtonIcon onClick={handleOpenNotification}>
<ButtonIcon onClick={handleToggleNotificationState}>
<Badge
badgeContent={count}
slotProps={{
Expand All @@ -30,7 +29,10 @@ const AppNotification = () => {
</Badge>
</ButtonIcon>

<NotificationContainer onClose={handleCloseNotification} open={open} />
<NotificationContainer
onClose={handleToggleNotificationState}
open={open}
/>
</>
);
};
Expand Down
11 changes: 3 additions & 8 deletions src/features/app_notification/useAppNotification.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,15 @@ const useAppNotification = () => {

const count = notifications.filter((record) => !record.read).length;

const handleOpenNotification = async () => {
const handleToggleNotificationState = async () => {
setIsMyAssignmentOpen(false);

setOpen(true);
};

const handleCloseNotification = () => {
setOpen(false);
setOpen((prev) => !prev);
};

return {
open,
handleOpenNotification,
handleCloseNotification,
handleToggleNotificationState,
count,
};
};
Expand Down

0 comments on commit 9af4f90

Please sign in to comment.