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

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

export const CheckListTablePage = () => {
	const { organizationId } = useParams();

	const columns: Column<CheckListTemplateModel>[] = [
		{
			name: "type",
			title: "Type",
			convert: (x) =>
				x === CheckListType.ByFalseAlarm
					? "By false alarm"
					: "By real alarm",
		},
	];

	return (
		<Matrix<CheckListTemplateModel>
			title="Check list templates"
			columns={columns}
			baseUrl="/api/check-list-templates"
			filters={{
				organizationId,
			}}
			notificationMethodPrefix="CHECK_LIST_TEMPLATES"
			getModelTitle={(x) => x.type}
			canCreate={true}
			canRemove={false}
			canView={true}
		/>
	);
};
