Skip to content

Commit f89ef54

Browse files
Merge pull request #1233 from OpenSignLabs/raktima-patch-3
feat: enable dismiss button to hide notification in header
2 parents f2ee03e + b9d9f87 commit f89ef54

File tree

1 file changed

+32
-9
lines changed

1 file changed

+32
-9
lines changed

apps/OpenSign/src/components/Header.js

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ const Header = ({ showSidebar }) => {
2020
const { t, i18n } = useTranslation();
2121
const navigate = useNavigate();
2222
const { width } = useWindowSize();
23+
const current_notification_version = "1"; // Update this with each new feature release
24+
// Get the dismissed version from local storage
25+
const dismissedVersion = localStorage.getItem("notificationDismissedVersion");
2326
const username = localStorage.getItem("username") || "";
2427
const image = localStorage.getItem("profileImg") || dp;
2528
const [isOpen, setIsOpen] = useState(false);
@@ -30,7 +33,10 @@ const Header = ({ showSidebar }) => {
3033
);
3134
const [emailUsed, setEmailUsed] = useState(0);
3235
const [isModal, setIsModal] = useState(false);
33-
36+
const [showNotification, setShowNotification] = useState(
37+
(!dismissedVersion || dismissedVersion !== current_notification_version) &&
38+
true
39+
);
3440
const toggleDropdown = () => {
3541
setIsOpen(!isOpen);
3642
};
@@ -115,17 +121,34 @@ const Header = ({ showSidebar }) => {
115121
const handleMailUsed = () => {
116122
setIsModal(!isModal);
117123
};
124+
// Handle dismissing the notification
125+
const dismissNotification = () => {
126+
// Store the current version as dismissed in local storage
127+
localStorage.setItem(
128+
"notificationDismissedVersion",
129+
current_notification_version
130+
);
131+
setShowNotification(false);
132+
};
118133
return (
119134
<div>
120-
{isEnableSubscription && (
121-
<div className="shadow py-1 text-center bg-[#CAE4FA] text-[14px] p-1">
122-
{t("header-news")}
123-
<span
124-
className="cursor-pointer font-medium underline text-blue-800"
125-
onClick={() => navigate("/profile")}
135+
{isEnableSubscription && showNotification && (
136+
<div className="flex justify-between items-center shadow py-1 bg-[#CAE4FA] p-1">
137+
<div className="text-center text-[14px] ml-auto">
138+
{t("header-news")}
139+
<span
140+
className="cursor-pointer font-medium underline text-blue-800"
141+
onClick={() => navigate("/profile")}
142+
>
143+
{" " + t("header-news-btn") + "."}
144+
</span>
145+
</div>
146+
<div
147+
className="ml-auto mr-1 cursor-pointer"
148+
onClick={() => dismissNotification()}
126149
>
127-
{" " + t("header-news-btn") + "."}
128-
</span>
150+
<i className="fa-light fa-xmark"></i>
151+
</div>
129152
</div>
130153
)}
131154
<div className="op-navbar bg-base-100 shadow">

0 commit comments

Comments
 (0)