<commit_before>import * as React from 'react';
import { useState, useEffect } from 'react';
import { RootState } from 'js/store';
import { useSelector, useDispatch } from 'react-redux';
import { mapController } from 'js/controllers/mapController';
import { setActiveFeatures } from 'js/store/mapview/actions';

const AnalysisSpinner = (): React.ReactElement => <h4>Geom Registering...</h4>;

const BaseAnalysis = (props: any): JSX.Element => {
  const dispatch = useDispatch();
  const [selectedAnalysis, selectAnalysis] = useState('');

  const { activeFeatures, activeFeatureIndex } = useSelector(
    (store: RootState) => store.mapviewState
  );

  const { analysisModules } = useSelector(
    (store: RootState) => store.appSettings
  );

  function runAnalysis() {
    console.log('runAnalysis', selectedAnalysis);
    const mod = analysisModules.find(
      module => module.analysisId === selectedAnalysis
    );
    if (mod) {
      const activeLayer = activeFeatures[activeFeatureIndex[0]];
      const activeFeature = activeLayer.features[activeFeatureIndex[1]];

      fetch(
        `https://api.resourcewatch.org/v1/widget/${mod.widgetId}?${activeFeature.attributes.geostoreId}`
      )
        .then((response: any) => response.json())
        .then((analysisMod: any) => {
          console.log('analysisMod', analysisMod);
          //TODO: This is where we stopped!
        });
    }
  }

  const DefaultTabView = (props: any): JSX.Element => (
    <div className="data-tab-default-container">
      <p>Select a shape on the map</p>
    </div>
  );

  const AnalysisOptions = (props: any): JSX.Element => (
    <>
      <select onChange={evt => selectAnalysis(evt.target.value)}>
        {analysisModules.map((module: any, i: number) => {
          return (
            <option value={module.analysisId} key={i}>
              {module.label.en}
            </option>
          );
        })}
      </select>
      <button onClick={runAnalysis}>RUN ANALYSIS</button>
    </>
  );

  if (activeFeatures.length === 0) {
    return <DefaultTabView />;
  } else {<commit_msg>Added value to analyisDropdown component<commit_after>import * as React from 'react';
import { useState, useEffect } from 'react';
import { RootState } from 'js/store';
import { useSelector, useDispatch } from 'react-redux';
import { mapController } from 'js/controllers/mapController';
import { setActiveFeatures } from 'js/store/mapview/actions';

const AnalysisSpinner = (): React.ReactElement => <h4>Geom Registering...</h4>;

const BaseAnalysis = (props: any): JSX.Element => {
  const dispatch = useDispatch();
  const [selectedAnalysis, selectAnalysis] = useState('');

  const { activeFeatures, activeFeatureIndex } = useSelector(
    (store: RootState) => store.mapviewState
  );

  const { analysisModules } = useSelector(
    (store: RootState) => store.appSettings
  );

  function runAnalysis() {
    console.log('runAnalysis', selectedAnalysis);
    const mod = analysisModules.find(
      module => module.analysisId === selectedAnalysis
    );
    if (mod) {
      const activeLayer = activeFeatures[activeFeatureIndex[0]];
      const activeFeature = activeLayer.features[activeFeatureIndex[1]];

      fetch(
        `https://api.resourcewatch.org/v1/widget/${mod.widgetId}?${activeFeature.attributes.geostoreId}`
      )
        .then((response: any) => response.json())
        .then((analysisMod: any) => {
          console.log('analysisMod', analysisMod);
          //TODO: This is where we stopped!
        });
    }
  }

  const DefaultTabView = (props: any): JSX.Element => (
    <div className="data-tab-default-container">
      <p>Select a shape on the map</p>
    </div>
  );

  const AnalysisOptions = (props: any): JSX.Element => (
    <>
      <select
        value={selectedAnalysis}
        onChange={evt => selectAnalysis(evt.target.value)}
      >
        {analysisModules.map((module: any, i: number) => {
          return (
            <option value={module.analysisId} key={i}>
              {module.label.en}
            </option>
          );
        })}
      </select>
      {/* if we have run/slected a chjart, show that chart, ELSE, show the button beloow (either way shows the dropdown above) */}
      <button onClick={runAnalysis}>RUN ANALYSIS</button>
    </>
  );

  if (activeFeatures.length === 0) {
    return <DefaultTabView />;
  } else {
{'fraction_non_alphanumeric': 0.14445458694659974, 'fraction_numerical': 0.0027384755819260614, 'mean_word_length': 3.0211009174311925, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 55, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6429760', 'n_tokens_mistral': 1286, 'n_tokens_neox': 1278, 'n_words': 289}