import React, { useState, useRef, useEffect } from 'react' import { cn } from '../utils' import { VscAdd, VscChromeMinimize } from "react-icons/vsc"; import { ScheduleProps } from '@/types'; import moment from 'moment'; interface CollapseProps { title: string rerganizedSchedule?: { yearAndMonth: string schedules: ScheduleProps[] } } const ScheduleCollapse: React.FC = ({ title, rerganizedSchedule }) => { const [isOpen, setIsOpen] = useState(false) const [height, setHeight] = useState(0) const ref = useRef(null) useEffect(() => { if (isOpen) setHeight(ref.current?.scrollHeight) else setHeight(0) }, [isOpen]) return (
{rerganizedSchedule ? (
{rerganizedSchedule.schedules.map((schedule, index) => (

{ moment.utc(schedule.date).format("MM月DD日")}

{schedule.title}

{schedule.info1}

{schedule.info2}

))}
) : (
)}
) } export default ScheduleCollapse