I'm building a React component to display data from a Database and have a Delete button that should fire a handleDelete(); function however it doesn't seem to be firing. Is this because of hydration? Or?
import { db, LiveEvents, Submissions, eq } from "astro:db";
import {
Table,
TableBody,
TableCaption,
TableCell,
TableHead,
TableHeader,
TableRow,
} from "@/components/ui/table";
const BandSchedule = ({ bands }: { bands: any[] }) => {
const tableData = bands.map((bands) => ({
...bands,
}));
const handleDelete = async (id: string) => {
console.log("Deleting submission with id: ", id);
await db.delete(LiveEvents, eq("id", id));
};
return (
<Table>
<TableHeader>
<TableRow className="text-md bg-gray-300 hover:bg-gray-300">
<TableHead scope="col">Date</TableHead>
<TableHead scope="col">Band Name</TableHead>
<TableHead scope="col">Website</TableHead>
<TableHead scope="col">Action</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{tableData.map((bands) => (
<TableRow
key={bands.id}
className="text-xs hover:bg-gray-200 hover:cursor-pointer"
>
<TableCell>{bands.date}</TableCell>
<TableCell>{bands.name}</TableCell>
<TableCell>{bands.website}</TableCell>
<TableCell>
<button
className="px-3 py-2 text-xs font-medium text-white bg-gray-500 rounded-full hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500"
onClick={() => handleDelete(bands.id)}
>
Delete
</button>
</TableCell>
</TableRow>
))}
</TableBody>
</Table>
);
};
export default BandSchedule;