import { useState, useEffect, useRef } from "react";
import { useQuery } from "@tanstack/react-query";
import { Link, useParams } from "wouter";
import { usePageMeta } from "@/hooks/use-page-meta";
import {
Star,
Heart,
Briefcase,
TrendingUp,
ChevronLeft,
ChevronRight,
Calendar,
CalendarDays,
Sparkles,
Lightbulb,
AlertTriangle,
Moon,
Sun,
ArrowRight,
Loader2,
} from "lucide-react";
import Header from "@/components/header";
import Footer from "@/components/footer";
import InterstitialAd from "@/components/interstitial-ad";
import { InArticleAd, PageSideAds } from "@/components/adsense";
import {
SIGNS,
ELEMENT_COLORS,
getHoroscope as getStaticHoroscope,
getRating,
getLuckyNumbers,
getDailyColor,
} from "@/lib/horoscope-data";
interface AIHoroscope {
signIndex: number;
signName: string;
general: string;
love: string;
career: string;
health: string;
tip: string;
weekly: string;
monthly: string;
imageUrl?: string | null;
}
function StarRating({ count }: { count: number }) {
return (
{Array.from({ length: 5 }).map((_, i) => (
))}
);
}
function SignGrid({ onSelect, selectedIndex, aiHoroscopes }: { onSelect: (i: number) => void; selectedIndex: number | null; aiHoroscopes: AIHoroscope[] }) {
return (
Ihr Sternzeichen wählen
{SIGNS.map((sign, i) => {
const ec = ELEMENT_COLORS[sign.element];
const aiH = aiHoroscopes.find(h => h.signIndex === i);
const horoscope = aiH || getStaticHoroscope(i);
const isSelected = selectedIndex === i;
return (
);
})}
);
}
function SignDetail({ signIndex, onNavigate, aiHoroscopes }: { signIndex: number; onNavigate: (i: number) => void; aiHoroscopes: AIHoroscope[] }) {
const [tab, setTab] = useState<"daily" | "weekly" | "monthly">("daily");
const sign = SIGNS[signIndex];
const ec = ELEMENT_COLORS[sign.element];
const aiH = aiHoroscopes.find(h => h.signIndex === signIndex);
const horoscope = aiH || getStaticHoroscope(signIndex);
const luckyNums = getLuckyNumbers(signIndex);
const dailyColor = getDailyColor(signIndex);
const detailRef = useRef(null);
const isAI = !!aiH;
const prevIndex = (signIndex - 1 + SIGNS.length) % SIGNS.length;
const nextIndex = (signIndex + 1) % SIGNS.length;
useEffect(() => {
setTab("daily");
}, [signIndex]);
return (
{sign.symbol}
{sign.name}
{(horoscope as any).imageUrl && (

)}
{sign.symbol}
{sign.name}
{sign.date}
{sign.element}
Planet: {sign.planet}
Farbe: {sign.color}
Stein: {sign.stone}
Glückszahlen
{luckyNums.join(", ")}
Kompatibel
{sign.compatible.join(", ")}
{(["daily", "weekly", "monthly"] as const).map((t) => (
))}
{tab === "daily" && (
Allgemein
{horoscope.general}
Liebe & Partnerschaft
{horoscope.love}
)}
{tab === "weekly" && (
Wochenhoroskop
{horoscope.weekly}
)}
{tab === "monthly" && (
Monatshoroskop
{horoscope.monthly}
)}
{tab === "daily" && (
Beruf & Finanzen
{horoscope.career}
Gesundheit & Wohlbefinden
{horoscope.health}
Tipp des Tages: {horoscope.tip}
)}
Weitere Sternzeichen entdecken
{SIGNS.filter((_, i) => i !== signIndex).map((s) => {
const origIdx = SIGNS.findIndex((x) => x.name === s.name);
const sEc = ELEMENT_COLORS[s.element];
return (
);
})}
);
}
export default function HoroscopePage() {
const params = useParams<{ sign?: string }>();
const [selected, setSelected] = useState(null);
const detailRef = useRef(null);
const { data: aiHoroscopes = [], isLoading: aiLoading } = useQuery({
queryKey: ["/api/horoscopes/today"],
staleTime: 1000 * 60 * 30,
refetchOnWindowFocus: true,
});
useEffect(() => {
if (params.sign) {
const idx = SIGNS.findIndex((s) => s.name.toLowerCase() === params.sign?.toLowerCase());
if (idx >= 0) setSelected(idx);
}
}, [params.sign]);
const selectedSign = selected !== null ? SIGNS[selected] : null;
const selectedAi = selected !== null ? aiHoroscopes.find(h => h.signIndex === selected) : null;
const today = new Date().toLocaleDateString("de-AT", { day: "numeric", month: "long", year: "numeric" });
const metaTitle = selectedSign
? `${selectedSign.symbol} ${selectedSign.name} Horoskop – Tages-, Wochen- & Monatshoroskop`
: "Horoskop – Tages-, Wochen- & Monatshoroskop für alle Sternzeichen";
const metaDesc = selectedSign
? `${selectedSign.name} Horoskop für heute, ${today}. Tägliches, wöchentliches und monatliches Horoskop für ${selectedSign.name} (${selectedSign.date}). Liebe, Beruf & Gesundheit bei FOLX TV.`
: `Kostenloses Tageshoroskop, Wochenhoroskop & Monatshoroskop für alle 12 Sternzeichen. Liebe, Beruf, Gesundheit – Ihr persönliches Horoskop bei FOLX TV, ${today}.`;
const ogImage = "https://folx.tv/images/horoskop-og.jpg";
usePageMeta(metaTitle, metaDesc, {
ogTitle: metaTitle,
ogDescription: metaDesc,
ogImage,
ogType: "website",
});
const handleSelect = (i: number) => {
setSelected(i);
setTimeout(() => {
detailRef.current?.scrollIntoView({ behavior: "smooth", block: "start" });
}, 100);
};
return (
Horoskop
Entdecken Sie, was die Sterne für Sie bereithalten — Ihr persönliches Tageshoroskop für alle zwölf Sternzeichen.
{aiLoading && (
Horoskope werden von den Sternen gelesen...
)}
{selected !== null ? (
) : (
Wählen Sie oben Ihr Sternzeichen
für Ihr persönliches Tages-, Wochen- und Monatshoroskop
)}
);
}