"use client";
/**
* VaniOfTheDayCTA — a home-page card suggesting the day's "Vāṇī of the Day":
* one prose chapter, verse, or lecture chosen by the backend (the same for
* everyone that day, never repeating within 90 days). Tapping it opens the
* item. Renders nothing until/unless the pick loads, so it never leaves an
* empty frame. Styled to match SadhnaStreakCTA.
*/
import { useEffect, useState } from "react";
import Link from "next/link";
import { ChevronRight } from "lucide-react";
import { getVaniOfTheDay, type Vani } from "@/lib/vani";
/** Quote-marks glyph (svgrepo). Inherits color via `currentColor`. */
function QuotesIcon({ className }: { className?: string }) {
return (
);
}
export function VaniOfTheDayCTA() {
const [vani, setVani] = useState(null);
useEffect(() => {
let cancelled = false;
getVaniOfTheDay()
.then((v) => {
if (!cancelled) setVani(v);
})
.catch(() => {
/* card simply doesn't render */
});
return () => {
cancelled = true;
};
}, []);
if (!vani) return null;
// Third line: the book name for a verse/chapter, or "Lecture • DATE"
// (label + date) for a transcript.
const source =
vani.kind === "transcript"
? [vani.label, vani.date].filter(Boolean).join(" • ")
: vani.book_title || vani.label;
return (