<commit_before>import React from 'react'
import PropTypes from 'prop-types'
import getConfig from 'next/config'
import {translate} from 'react-i18next'

import VectorDownload from '../downloads/vector'

const {publicRuntimeConfig: {
  PUBLIC_URL,
  GEODATA_API_URL
}} = getConfig()

class ServiceResource extends React.Component {
  static propTypes = {
    recordId: PropTypes.string.isRequired,
    resource: PropTypes.shape({
      serviceType: PropTypes.string.isRequired,
      href: PropTypes.string.isRequired,
      features: PropTypes.arrayOf(PropTypes.shape({
        typeName: PropTypes.string.isRequired,
        available: PropTypes.bool.isRequired,
        name: PropTypes.string
      })).isRequired
    }).isRequired,

    setPreview: PropTypes.func.isRequired,
    t: PropTypes.func.isRequired
  }

  renderFeature(feature) {
    const {recordId, resource, setPreview} = this.props

    const url = `${GEODATA_API_URL}/services/${resource.serviceId}/feature-types/${feature.name}/download`
    const embed = `${PUBLIC_URL}/embed/datasets/${recordId}/resources/wfs:${resource.serviceId}/${feature.typeName}`

    return (
      <VectorDownload
        name={feature.typeName}
        url={url}
        available={feature.available}
        setPreview={() => setPreview(url, feature.typeName, embed)}
      />
    )
  }

  render() {
    const {resource, t} = this.props
<commit_msg>Fix wfs preview<commit_after>import React from 'react'
import PropTypes from 'prop-types'
import getConfig from 'next/config'
import {translate} from 'react-i18next'

import VectorDownload from '../downloads/vector'

const {publicRuntimeConfig: {
  PUBLIC_URL,
  GEODATA_API_URL
}} = getConfig()

class ServiceResource extends React.Component {
  static propTypes = {
    recordId: PropTypes.string.isRequired,
    resource: PropTypes.shape({
      serviceType: PropTypes.string.isRequired,
      href: PropTypes.string.isRequired,
      features: PropTypes.arrayOf(PropTypes.shape({
        typeName: PropTypes.string.isRequired,
        available: PropTypes.bool.isRequired,
        name: PropTypes.string
      })).isRequired
    }).isRequired,

    setPreview: PropTypes.func.isRequired,
    t: PropTypes.func.isRequired
  }

  renderFeature(feature) {
    const {recordId, resource, setPreview} = this.props

    const url = `${GEODATA_API_URL}/services/${resource.serviceId}/feature-types/${feature.name}/download`
    const embed = `${PUBLIC_URL}/embed/datasets/${recordId}/resources/wfs:${resource.serviceId}/${feature.typeName}`

    return (
      <VectorDownload
        name={feature.typeName}
        url={url}
        available={feature.available}
        setPreview={() => setPreview(url, feature.name, embed)}
      />
    )
  }

  render() {
    const {resource, t} = this.props

{'fraction_non_alphanumeric': 0.12383679312813171, 'fraction_numerical': 0.0014316392269148174, 'mean_word_length': 3.5595432300163132, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6534041', 'n_tokens_mistral': 817, 'n_tokens_neox': 834, 'n_words': 160}