<commit_before>
import React from 'react'
import PropTypes from 'prop-types'
import cx from 'classnames'
import { Label } from 'light-ui'
import locales, { switchLanguage, getLocale } from 'LOCALES'
import styles from '../Resume/shared/common.css'
import AsyncGithub from '../shared/AsyncGithub'
import Icon from 'COMPONENTS/Icon'

const locale = getLocale()
const resumeLocales = locales('resume')

class ResumeUIWrapper extends React.Component {
  constructor(props) {
    super(props)
    this.state = {
      showGithub: false
    }
    this.changeShowGithub = this.changeShowGithub.bind(this)
  }

  changeShowGithub(showGithub) {
    this.setState({ showGithub })
  }

  getSectionTitle(section) {
    const { resume } = this.props
    const { info } = resume
    const { freshGraduate } = info
    const { title, subTitle } = resumeLocales.sections[section]
    const result = freshGraduate ? subTitle : title
    return result || title
  }

  renderEducations() {
    return null
  }

  renderWorkExperiences() {
    return null
  }

  renderPersonalProjects() {
    return null
  }

  renderSupplements() {
    return null
  }

  renderSocialLinks() {
    return null
  }

  renderUpdateTime() {
    const { resume, updateText, fromDownload } = this.props
    const { updateAt } = resume
    if (!updateAt || fromDownload) return false
    return {
      updateAt,
      updateText
    }
  }

  renderCustomModules() {
    const { resume } = this.props
    const { customModules = [] } = resume
    return customModules.map((module, index) => this.renderCustomModule(module, index))
  }

  renderCustomModule(module, key) {
    return null
  }

  renderResumeSections() {
    const { resume } = this.props
    const { info } = resume
    const { freshGraduate } = info
    let sectionFuncs = []
    if (freshGraduate) {
      sectionFuncs = [
        this.renderEducations,
        this.renderWorkExperiences,
        this.renderPersonalProjects,
        this.renderCustomModules,
        this.renderSupplements,
        this.renderSocialLinks
      ]
    } else {
      sectionFuncs = [
        this.renderWorkExperiences,
        this.renderPersonalProjects,
        this.renderEducations,
        this.renderCustomModules,
        this.renderSupplements,
        this.renderSocialLinks
      ]
    }
    return sectionFuncs.map((func, index) => func && func.call(this, index))
  }

  renderGitHub() {
    const { showGithub } = this.state
    const { shareInfo, login } = this.props
    const { useGithub, github } = shareInfo

    return useGithub && showGithub ? (
      <div className={styles.container}>
        <div className={styles.github_wrapper}>
          <a
            onClick={() => this.changeShowGithub(false)}
            className={cx(
              styles.baseLink,
              styles.baseInfo,
              styles.githubBack
            )}
          >
            <Icon icon="arrow-left" />
            {resumeLocales.options.back}
          </a>
          <AsyncGithub
            isShare
            login={login}
            githubSection={github}
            cardClass={styles.githubCard}
          />
        </div>
      </div>
    ) : null
  }

  renderLabels(labels, labelProps = {}, labelContainerClassName = '') {
    const dom = labels.map((label, i) => (
      <Label
        min
        key={i}
        theme="flat"
        color="light"
        text={label}
        clickable={false}
        className={styles.label}
        {...labelProps}
      />
    ))

    return (
      <div className={cx(styles.labelContainer, labelContainerClassName)}>
        {dom}
      </div>
    )
  }

  renderLanguages(labelProps = {}) {
    const { resume } = this.props
    const { info } = resume
    const resumeInfo = info || {}
    const { languages = [] } = resumeInfo

    return this.renderLabels(languages, labelProps)
  }

  renderResumeLanguages(className = '') {
    const { resume } = this.props
    const { languages = [] } = resume
    if (languages.length < 2) return null

    const languageDoms = languages.reduce((list, language, index) => {
      list.push(
        <span
          key={`language-${index}`}<commit_msg>update resume download render<commit_after>
import React from 'react'
import PropTypes from 'prop-types'
import cx from 'classnames'
import { Label } from 'light-ui'
import locales, { switchLanguage, getLocale } from 'LOCALES'
import styles from '../Resume/shared/common.css'
import AsyncGithub from '../shared/AsyncGithub'
import Icon from 'COMPONENTS/Icon'

const locale = getLocale()
const resumeLocales = locales('resume')

class ResumeUIWrapper extends React.Component {
  constructor(props) {
    super(props)
    this.state = {
      showGithub: false
    }
    this.changeShowGithub = this.changeShowGithub.bind(this)
  }

  changeShowGithub(showGithub) {
    this.setState({ showGithub })
  }

  getSectionTitle(section) {
    const { resume } = this.props
    const { info } = resume
    const { freshGraduate } = info
    const { title, subTitle } = resumeLocales.sections[section]
    const result = freshGraduate ? subTitle : title
    return result || title
  }

  renderEducations() {
    return null
  }

  renderWorkExperiences() {
    return null
  }

  renderPersonalProjects() {
    return null
  }

  renderSupplements() {
    return null
  }

  renderSocialLinks() {
    return null
  }

  renderUpdateTime() {
    const { resume, updateText, fromDownload } = this.props
    const { updateAt } = resume
    if (!updateAt || fromDownload) return false
    return {
      updateAt,
      updateText
    }
  }

  renderCustomModules() {
    const { resume } = this.props
    const { customModules = [] } = resume
    return customModules.map((module, index) => this.renderCustomModule(module, index))
  }

  renderCustomModule(module, key) {
    return null
  }

  renderResumeSections() {
    const { resume } = this.props
    const { info } = resume
    const { freshGraduate } = info
    let sectionFuncs = []
    if (freshGraduate) {
      sectionFuncs = [
        this.renderEducations,
        this.renderWorkExperiences,
        this.renderPersonalProjects,
        this.renderCustomModules,
        this.renderSupplements,
        this.renderSocialLinks
      ]
    } else {
      sectionFuncs = [
        this.renderWorkExperiences,
        this.renderPersonalProjects,
        this.renderEducations,
        this.renderCustomModules,
        this.renderSupplements,
        this.renderSocialLinks
      ]
    }
    return sectionFuncs.map((func, index) => func && func.call(this, index))
  }

  renderGitHub() {
    const { showGithub } = this.state
    const { shareInfo, login } = this.props
    const { useGithub, github } = shareInfo

    return useGithub && showGithub ? (
      <div className={styles.container}>
        <div className={styles.github_wrapper}>
          <a
            onClick={() => this.changeShowGithub(false)}
            className={cx(
              styles.baseLink,
              styles.baseInfo,
              styles.githubBack
            )}
          >
            <Icon icon="arrow-left" />
            {resumeLocales.options.back}
          </a>
          <AsyncGithub
            isShare
            login={login}
            githubSection={github}
            cardClass={styles.githubCard}
          />
        </div>
      </div>
    ) : null
  }

  renderLabels(labels, labelProps = {}, labelContainerClassName = '') {
    const dom = labels.map((label, i) => (
      <Label
        min
        key={i}
        theme="flat"
        color="light"
        text={label}
        clickable={false}
        className={styles.label}
        {...labelProps}
      />
    ))

    return (
      <div className={cx(styles.labelContainer, labelContainerClassName)}>
        {dom}
      </div>
    )
  }

  renderLanguages(labelProps = {}) {
    const { resume } = this.props
    const { info } = resume
    const resumeInfo = info || {}
    const { languages = [] } = resumeInfo

    return this.renderLabels(languages, labelProps)
  }

  renderResumeLanguages(className = '') {
    const { resume, fromDownload } = this.props
    if (fromDownload) return null

    const { languages = [] } = resume
    if (languages.length < 2) return null

    const languageDoms = languages.reduce((list, language, index) => {
      list.push(
        <span
          key={`language-${index}`}
{'fraction_non_alphanumeric': 0.11074104912572856, 'fraction_numerical': 0.00023789699060306887, 'mean_word_length': 2.318074191002368, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 7, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2404451', 'n_tokens_mistral': 2469, 'n_tokens_neox': 2416, 'n_words': 519}