'use client' import { useState } from 'react' import { Dialog, DialogContent, DialogHeader, DialogTitle, } from '@/components/ui/dialog' import { Button } from '@/components/ui/button' import { useScheduleHistory, useRollbackSchedule } from '@/hooks/use-channels' interface Props { channelId: string open: boolean onOpenChange: (open: boolean) => void } const fmtDateRange = (from: string, until: string) => `${new Date(from).toLocaleDateString()} – ${new Date(until).toLocaleDateString()}` export function ScheduleHistoryDialog({ channelId, open, onOpenChange }: Props) { const { data: entries } = useScheduleHistory(channelId) const rollback = useRollbackSchedule() const [confirmId, setConfirmId] = useState(null) return ( Schedule history
{(entries ?? []).map((entry, i) => (
Gen #{entry.generation} {i === 0 && ( active )}
{fmtDateRange(entry.valid_from, entry.valid_until)}
{i > 0 && ( confirmId === entry.id ? (
Roll back to gen #{entry.generation}?
) : ( ) )}
))} {(entries ?? []).length === 0 && (

No schedule history yet. Generate a schedule to get started.

)}
) }