"use client"; import { useAtom } from "jotai"; import { featureInformationAtom } from "../../state/feature-information"; import { useState } from "react"; import { ChevronDown, ChevronRight, X } from "lucide-react"; import { Button } from "@/shared/components/ui/button"; import { ColumnDef, RowData } from "@tanstack/react-table"; import { DataTable } from "@/shared/components/data-table"; export default function FeatureInformation() { const [featureInformation, setFeatureInformation] = useAtom(featureInformationAtom); const [expandedFeatures, setExpandedFeatures] = useState>({}); if (!featureInformation || featureInformation.length === 0) { return null; } const toggleFeature = (featureName: string) => { setExpandedFeatures((prev) => ({ ...prev, [featureName]: !prev[featureName], })); }; return (
Feature Information
{featureInformation.map((feature) => { if (feature.info.length === 0) return null; const propertyKeys = Array.from( new Set( // eslint-disable-next-line @typescript-eslint/no-explicit-any feature.info.flatMap((infoItem: { properties: any }) => Object.keys(infoItem.properties || {})) ) ); // eslint-disable-next-line @typescript-eslint/no-explicit-any const columns: ColumnDef[] = propertyKeys.map((key: any) => { const column: ColumnDef = { accessorKey: key, header: key, }; return column; }); const tableData = feature.info.map( // eslint-disable-next-line @typescript-eslint/no-explicit-any (infoItem: { properties: { id: any } }) => ({ ...infoItem.properties, id: infoItem.properties?.id || Math.random().toString(36).substring(7), }) ); const isExpanded = expandedFeatures[feature.name] ?? false; return (
{isExpanded && (
{tableData.length > 0 ? (
) : (
No properties available
)}
)}
); })}
); }