diff --git a/client/src/components/horoscope-widget.tsx b/client/src/components/horoscope-widget.tsx index 6247f66..69ecfcb 100644 --- a/client/src/components/horoscope-widget.tsx +++ b/client/src/components/horoscope-widget.tsx @@ -1,4 +1,4 @@ -import { useState } from "react"; +import { useState, useEffect, useCallback } from "react"; import { Star, ChevronLeft, ChevronRight, X } from "lucide-react"; const SIGNS = [ @@ -31,31 +31,13 @@ const DAILY_TEXTS = [ "Einfühlungsvermögen und Mitgefühl stärken heute Ihre Beziehungen.", ]; -function getCurrentSignIndex(): number { - const now = new Date(); - const month = now.getMonth() + 1; - const day = now.getDate(); - if ((month === 3 && day >= 21) || (month === 4 && day <= 19)) return 0; - if ((month === 4 && day >= 20) || (month === 5 && day <= 20)) return 1; - if ((month === 5 && day >= 21) || (month === 6 && day <= 20)) return 2; - if ((month === 6 && day >= 21) || (month === 7 && day <= 22)) return 3; - if ((month === 7 && day >= 23) || (month === 8 && day <= 22)) return 4; - if ((month === 8 && day >= 23) || (month === 9 && day <= 22)) return 5; - if ((month === 9 && day >= 23) || (month === 10 && day <= 22)) return 6; - if ((month === 10 && day >= 23) || (month === 11 && day <= 21)) return 7; - if ((month === 11 && day >= 22) || (month === 12 && day <= 21)) return 8; - if ((month === 12 && day >= 22) || (month === 1 && day <= 19)) return 9; - if ((month === 1 && day >= 20) || (month === 2 && day <= 18)) return 10; - return 11; -} - function getDailyText(signIndex: number): string { const dayOfYear = Math.floor((Date.now() - new Date(new Date().getFullYear(), 0, 0).getTime()) / 86400000); return DAILY_TEXTS[(signIndex + dayOfYear) % DAILY_TEXTS.length]; } -function HoroscopeModal({ onClose }: { onClose: () => void }) { - const [selected, setSelected] = useState(getCurrentSignIndex()); +function HoroscopeModal({ onClose, initialSign }: { onClose: () => void; initialSign: number }) { + const [selected, setSelected] = useState(initialSign); return (