Fondation
This commit is contained in:
parent
2ec888892c
commit
901f81e8f7
@ -22,25 +22,23 @@ type Event = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export function CalendarWidget() {
|
export function CalendarWidget() {
|
||||||
const sessionResult = useSession();
|
|
||||||
const { data: session } = sessionResult;
|
|
||||||
const [events, setEvents] = useState<Event[]>([]);
|
const [events, setEvents] = useState<Event[]>([]);
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const [error, setError] = useState<string | null>(null);
|
const [error, setError] = useState<string | null>(null);
|
||||||
const { triggerNotification } = useWidgetNotification();
|
const { triggerNotification } = useWidgetNotification();
|
||||||
const lastEventCountRef = useRef<number>(-1);
|
const lastEventCountRef = useRef<number>(-1);
|
||||||
|
const { data: session, status } = useSession();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const currentStatus = sessionResult.status;
|
console.log("Calendar Widget - Session Status:", status);
|
||||||
console.log("Calendar Widget - Session Status:", currentStatus);
|
|
||||||
console.log("Calendar Widget - Session Data:", session);
|
console.log("Calendar Widget - Session Data:", session);
|
||||||
|
|
||||||
if (currentStatus === "loading") {
|
if (status === "loading") {
|
||||||
console.log("Calendar Widget - Session is loading");
|
console.log("Calendar Widget - Session is loading");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentStatus !== "authenticated" || !session) {
|
if (status !== "authenticated" || !session) {
|
||||||
console.log("Calendar Widget - Not authenticated, skipping fetch");
|
console.log("Calendar Widget - Not authenticated, skipping fetch");
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
return;
|
return;
|
||||||
@ -201,7 +199,7 @@ export function CalendarWidget() {
|
|||||||
}, 300000);
|
}, 300000);
|
||||||
|
|
||||||
return () => clearInterval(intervalId);
|
return () => clearInterval(intervalId);
|
||||||
}, [session, sessionResult.status, triggerNotification]);
|
}, [session, status, triggerNotification]);
|
||||||
|
|
||||||
const formatEventDate = (date: Date, isAllDay: boolean) => {
|
const formatEventDate = (date: Date, isAllDay: boolean) => {
|
||||||
let dateString = "";
|
let dateString = "";
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user