import { useParams } from "react-router-dom";

import { Column } from "@/common/components/Matrix/Column";
import { Matrix } from "@/common/components/Matrix/Matrix";
import { CameraModel } from "@/contracts/client.schemas";

export const CameraListPage = () => {
	const { assetId } = useParams();
	if (!assetId) {
		throw new Error("Asset id is required");
	}

	const columns: Column<CameraModel>[] = [
		{
			name: "name",
			title: "Name",
		},
		{
			name: "address",
			title: "URL",
		},
	];

	return (
		<Matrix
			baseUrl="/api/cameras"
			title="Cameras"
			columns={columns}
			getModelTitle={(model: CameraModel) => model.name}
			notificationMethodPrefix="CAMERAS"
			filters={{ assetId }}
			canCreate={true}
			canRemove={true}
			canView={true}
		/>
	);
};
