import React, {useEffect, useState} from 'react'; import {MapGeoJSONFeature} from 'maplibre-gl'; import {Button, Alert, Grid} from '@trussworks/react-uswds'; import * as styles from './CreateReportPanel.module.scss'; import * as constants from '../../data/constants'; // @ts-ignore import deleteIcon from '/node_modules/uswds/dist/img/usa-icons/close.svg'; interface ICreateReportPanel { deleteTractHandler: (feature: MapGeoJSONFeature) => void, className: string, exitHandler: () => void, featureList: MapGeoJSONFeature[], maxNumTracts: number, showTooManyTractsAlert: boolean, } const CreateReportPanel = ({ className, featureList, maxNumTracts, showTooManyTractsAlert, deleteTractHandler, exitHandler, }: ICreateReportPanel, ) => { const [numPrevTracts, setNumPrevTracts] = useState(0); useEffect(() => { // If adding a tract then scroll to the bottom of the tract list to always show the last added tract if (numPrevTracts < featureList.length) { const container = document.getElementById('j40-create-report-tract-list'); if (container) container.scrollTop = container.scrollHeight; } setNumPrevTracts(featureList.length); }, [featureList, numPrevTracts]); /** * Handle the creation of a report. */ const handleCreateReport = () => { if (featureList.length === 1) { // TODO: One tract report } else { // TODO: Multi tract report } }; return (

Create Report

{showTooManyTractsAlert ? You can only select up to {maxNumTracts} tracts for a report. : Select up to {maxNumTracts} tracts in the map }

{featureList.length} tract{featureList.length === 1 ? '' : 's'} selected

{featureList.map((item, index) => ( {item.id}, {item.properties[constants.STATE_NAME]} ))}
); }; export default CreateReportPanel;