<commit_before>import Marker from "../location/marker";
import Component from "../../../pure-render-component";
import {Popup} from "react-leaflet";
import translatable from "../../../translatable";
import cn from "classnames";
import OverviewChart from "../../../../oce/visualizations/charts/overview";
import {cacheFn} from "../../../tools"

class LocationWrapper extends translatable(Component){
  constructor(props){
    super(props);
    this.state = {
      currentTab: 0
    }
  }

  render(){
    let {currentTab} = this.state;
    let {data, translations, filters, years, styling} = this.props;
    let CurrentTab = this.constructor.TABS[currentTab];
    return (
        <Marker {...this.props}>
          <Popup>
            <div>
              <ul className="nav nav-tabs">
                {this.constructor.TABS.map((Tab, index) =>
                  <li key={index}
                      className={cn({active: index == currentTab})}
                      onClick={e => this.setState({currentTab: index})}
                  >
                    <a href="javascript:void(0);">{Tab.getName(this.__.bind(this))}</a>
                  </li>
                )}
              </ul>
              <CurrentTab
                  data={data}
                  translations={translations}
                  filters={filters}
                  years={years}
                  styling={styling}
              />
            </div>
          </Popup>
        </Marker>
    )
  }
}

class Tab extends translatable(Component){}

class Overview extends Tab{
  static getName(__){
    return __('Overview');
  }

  render(){
    let {data} = this.props;
    let {name, count, amount} = data;
    return <div>
      <h3>{name}</h3>
      <p>
        <strong>{this.__('Number of Tenders:')}</strong> {count}
      </p>
      <p>
        <strong>{this.__('Total Funding for the location:')}</strong> {amount.toLocaleString()}
      </p>
    </div>
  }
}

let addTenderDeliveryLocationId = cacheFn(
    (filters, id) => filters.set('tenderDeliveryLocationIdentifier', id)
);

class ChartTab extends Tab{
  constructor(props){
    super(props);
    this.state = {
      chartData: null
    }
  }

  render(){
    let {filters, styling, years, translations, data} = this.props;
    return <div>
      <this.constructor.Chart
          filters={addTenderDeliveryLocationId(filters, data._id)}
          styling={styling}
          years={years}
          translations={translations}
          data={this.state.chartData}
          requestNewData={(_, chartData) => this.setState({chartData})}
          width={400}
      />
    </div>
  }
}

class OverviewChartTab extends ChartTab{
  static getName(__){
    return __('Overview chart');
  }
}

OverviewChartTab.Chart = OverviewChart;

class CostEffectiveness extends Tab{
  static getName(__){
    return __('Cost effectiveness');
  }
}

class ProcurementMethod extends Tab{
  static getName(__){
    return __('Procurement method');
  }
}

LocationWrapper.TABS = [Overview, OverviewChartTab, CostEffectiveness, ProcurementMethod];

export default LocationWrapper;<commit_msg>OCE-39 Removed procurement method location chart tab from OCE.<commit_after>import Marker from "../location/marker";
import Component from "../../../pure-render-component";
import {Popup} from "react-leaflet";
import translatable from "../../../translatable";
import cn from "classnames";
import OverviewChart from "../../../../oce/visualizations/charts/overview";
import CostEffectiveness from "../../../../oce/visualizations/charts/cost-effectiveness";
import {cacheFn} from "../../../tools"

class LocationWrapper extends translatable(Component){
  constructor(props){
    super(props);
    this.state = {
      currentTab: 0
    }
  }

  render(){
    let {currentTab} = this.state;
    let {data, translations, filters, years, styling} = this.props;
    let CurrentTab = this.constructor.TABS[currentTab];
    return (
        <Marker {...this.props}>
          <Popup>
            <div>
              <ul className="nav nav-tabs">
                {this.constructor.TABS.map((Tab, index) =>
                  <li key={index}
                      className={cn({active: index == currentTab})}
                      onClick={e => this.setState({currentTab: index})}
                  >
                    <a href="javascript:void(0);">{Tab.getName(this.__.bind(this))}</a>
                  </li>
                )}
              </ul>
              <CurrentTab
                  data={data}
                  translations={translations}
                  filters={filters}
                  years={years}
                  styling={styling}
              />
            </div>
          </Popup>
        </Marker>
    )
  }
}

class Tab extends translatable(Component){}

class Overview extends Tab{
  static getName(__){
    return __('Overview');
  }

  render(){
    let {data} = this.props;
    let {name, count, amount} = data;
    return <div>
      <h3>{name}</h3>
      <p>
        <strong>{this.__('Number of Tenders:')}</strong> {count}
      </p>
      <p>
        <strong>{this.__('Total Funding for the location:')}</strong> {amount.toLocaleString()}
      </p>
    </div>
  }
}

let addTenderDeliveryLocationId = cacheFn(
    (filters, id) => filters.set('tenderLoc', id)
);

export class ChartTab extends Tab{
  constructor(props){
    super(props);
    this.state = {
      chartData: null
    }
  }

  render(){
    let {filters, styling, years, translations, data} = this.props;
    return <div>
      <this.constructor.Chart
          filters={addTenderDeliveryLocationId(filters, data._id)}
          styling={styling}
          years={years}
          translations={translations}
          data={this.state.chartData}
          requestNewData={(_, chartData) => this.setState({chartData})}
          width={400}
      />
    </div>
  }
}

class OverviewChartTab extends ChartTab{
  static getName(__){
    return __('Overview chart');
  }
}

OverviewChartTab.Chart = OverviewChart;

class CostEffectivenessTab extends ChartTab{
  static getName(__){
    return __('Cost effectiveness');
  }
}

CostEffectivenessTab.Chart = CostEffectiveness;

LocationWrapper.TABS = [Overview, OverviewChartTab, CostEffectivenessTab];

export default LocationWrapper;
{'fraction_non_alphanumeric': 0.14396948990942318, 'fraction_numerical': 0.0025425075480692834, 'mean_word_length': 2.2145045965270684, 'pattern_counts': {'":': 0, '<': 59, '<?xml version=': 0, '>': 67, 'https://': 0, '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': '3431863', 'n_tokens_mistral': 1843, 'n_tokens_neox': 1778, 'n_words': 396}