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

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

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

	return (
		<Matrix<ResponsiblePersonModel>
			baseUrl="/api/responsible-persons"
			title="Responsible Persons"
			columns={[
				{
					name: "name",
					title: "Name",
				},
				{
					name: "key",
					title: "Key",
				},
			]}
			getModelTitle={(model) => model.name}
			notificationMethodPrefix="RESPONSIBLE-PERSONS"
			filters={{ assetId }}
			canCreate={true}
			canRemove={true}
			canView={true}
		/>
	);
};
