import MissionControl from '@/components/MissionControl';
import db from '@/lib/db';

const FALLBACK_PASS_TIME = 1769610273000;

export default function Home() {
  const row = db.prepare(
    'SELECT pass_time FROM iss_passes WHERE pass_time > datetime("now") LIMIT 1'
  ).get() as { pass_time: string } | undefined;

  const nextPass = row ? new Date(row.pass_time) : new Date(FALLBACK_PASS_TIME);

  return (
    <main>
      <MissionControl initialIssPass={nextPass} />
    </main>
  );
}