mirror of
https://github.com/kamranahmedse/developer-roadmap.git
synced 2025-08-27 02:54:27 +02:00
Update the hide end key to 14 days
This commit is contained in:
@@ -2,18 +2,18 @@ import { Database, X } from 'lucide-react';
|
|||||||
import { useState, useEffect } from 'react';
|
import { useState, useEffect } from 'react';
|
||||||
import { cn } from '../../lib/classname';
|
import { cn } from '../../lib/classname';
|
||||||
|
|
||||||
const COURSE_ANNOUNCEMENT_STORAGE_KEY = '__course_announcement_closed_at__';
|
const HIDE_ANNOUNCEMENT_END_KEY = '__course_announcement_closed_at__';
|
||||||
|
|
||||||
export function CourseAnnouncement() {
|
export function CourseAnnouncement() {
|
||||||
const [isVisible, setIsVisible] = useState(false);
|
const [isVisible, setIsVisible] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const closedAt = Number(
|
const hiddenEndAt = Number(
|
||||||
localStorage.getItem(COURSE_ANNOUNCEMENT_STORAGE_KEY) || '0',
|
localStorage.getItem(HIDE_ANNOUNCEMENT_END_KEY) || '0',
|
||||||
);
|
);
|
||||||
|
|
||||||
// only show if the closed at passed 3 days ago
|
// only show if the closed at passed 14 days ago
|
||||||
const shouldShow = closedAt < Date.now();
|
const shouldShow = hiddenEndAt < Date.now();
|
||||||
if (!shouldShow) {
|
if (!shouldShow) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -56,10 +56,11 @@ export function CourseAnnouncement() {
|
|||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
setIsVisible(false);
|
setIsVisible(false);
|
||||||
|
|
||||||
const threeDaysFromNow = Date.now() + 1000 * 60 * 60 * 24 * 3;
|
// 14 days from now
|
||||||
|
const fourteenDaysFromNow = Date.now() + 1000 * 60 * 60 * 24 * 14;
|
||||||
localStorage.setItem(
|
localStorage.setItem(
|
||||||
COURSE_ANNOUNCEMENT_STORAGE_KEY,
|
HIDE_ANNOUNCEMENT_END_KEY,
|
||||||
String(threeDaysFromNow),
|
String(fourteenDaysFromNow),
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
Reference in New Issue
Block a user