"use client";

import { useState } from "react";
import { useMutation } from "convex/react";
import { api } from "@/convex/_generated/api";

export default function SeedPage() {
  const seed = useMutation(api.seed.seedDemo);
  const [done, setDone] = useState(false);
  return (
    <div className="flex min-h-dvh items-center justify-center p-6">
      <div className="space-y-4 rounded-xl border bg-card p-6 text-center">
        <h1 className="text-lg font-semibold">Popular dados de demonstração</h1>
        <button
          className="inline-flex items-center justify-center rounded-md bg-primary px-3 py-2 text-sm font-medium text-primary-foreground"
          onClick={async () => {
            await seed({});
            setDone(true);
          }}
        >
          Executar seed
        </button>
        {done && <p className="text-sm text-green-600">Ok! Abra a página de Tickets.</p>}
      </div>
    </div>
  );
}
