"use client"
import { useState, useEffect } from "react"
import { Calendar as CalendarIcon } from "lucide-react"
import { Button } from "@/components/ui/button"
import {
Dialog,
DialogContent,
DialogHeader,
DialogTitle,
} from "@/components/ui/dialog"
import { solar2lunar, formatDate } from "@/lib/lunar-calendar"
import dynamic from 'next/dynamic'
// 动态导入 Ant Design 日历组件(避免 SSR 问题)
const AntdLunarCalendar = dynamic(
() => import('@/components/antd-lunar-calendar').then(mod => ({ default: mod.AntdLunarCalendar })),
{ ssr: false, loading: () =>
加载中...
}
)
interface CalendarDialogProps {
open: boolean
onOpenChange: (open: boolean) => void
}
export function CalendarDialog({ open, onOpenChange }: CalendarDialogProps) {
const [selectedDate, setSelectedDate] = useState(new Date())
// 获取农历信息
const lunarInfo = solar2lunar(selectedDate)
// 格式化显示
const solarStr = formatDate(selectedDate)
const [year, monthNum, day] = solarStr.split('-')
const weekDay = ['日', '一', '二', '三', '四', '五', '六'][selectedDate.getDay()]
// 当对话框打开时,重置为当前日期
useEffect(() => {
if (open) {
const now = new Date()
setSelectedDate(now)
}
}, [open])
return (
)
}