<commit_before>/**
 * Created by quasarchimaere on 30.07.2019.
 */
import React from "react";
import { get, getIn } from "../utils.js";

import * as atomUtils from "../redux/utils/atom-utils.js";
import * as processUtils from "../redux/utils/process-utils.js";
import WonOtherCard from "./cards/other-card.jsx";
import WonSkeletonCard from "./cards/skeleton-card.jsx";
import WonPersonaCard from "./cards/persona-card.jsx";
import PokemonRaidCard from "./cards/pokemon-raid-card.jsx";
import PropTypes from "prop-types";
import { connect } from "react-redux";

import "~/style/_atom-card.scss";

const mapStateToProps = (state, ownProps) => {
  const atom = getIn(state, ["atoms", ownProps.atomUri]);
  const isPersona = atomUtils.isPersona(atom);
  const process = get(state, "process");
  const isSkeleton =
    !(
      processUtils.isAtomLoaded(process, ownProps.atomUri) &&
      !get(atom, "isBeingCreated")
    ) ||
    get(atom, "isBeingCreated") ||
    processUtils.hasAtomFailedToLoad(process, ownProps.atomUri) ||
    processUtils.isAtomLoading(process, ownProps.atomUri) ||
    processUtils.isAtomToLoad(process, ownProps.atomUri);

  const isPokemonRaid =
    getIn(atom, ["matchedUseCase", "identifier"]) === "pokemonGoRaid";

  if (isSkeleton) {
    return {
      atomUri: ownProps.atomUri,
      showHolder: ownProps.showHolder,
      showSuggestions: ownProps.showSuggestions,
      currentLocation: ownProps.currentLocation,
      isPersona: false,
      isPokemonRaid: false,
      isOtherAtom: false,
      isSkeleton: true,
    };
  } else if (isPersona) {
    return {
      atomUri: ownProps.atomUri,
      showHolder: ownProps.showHolder,
      showSuggestions: ownProps.showSuggestions,
      currentLocation: ownProps.currentLocation,
      isPersona: true,
      isPokemonRaid: false,
      isOtherAtom: false,
      isSkeleton: false,
    };
  } else if (isPokemonRaid) {
    return {
      atomUri: ownProps.atomUri,
      showHolder: ownProps.showHolder,
      showSuggestions: ownProps.showSuggestions,
      currentLocation: ownProps.currentLocation,
      isPersona: false,
      isPokemonRaid: true,
      isOtherAtom: false,
      isSkeleton: false,
    };
  } else {
    return {
      atomUri: ownProps.atomUri,
      showHolder: ownProps.showHolder,
      showSuggestions: ownProps.showSuggestions,
      currentLocation: ownProps.currentLocation,
      isPersona: false,
      isPokemonRaid: false,
      isOtherAtom: true,
      isSkeleton: false,
    };
  }
};

class WonAtomCard extends React.Component {
  render() {
    let cardContent;
    if (this.props.isSkeleton) {
      cardContent = (
        <WonSkeletonCard
          atomUri={this.props.atomUri}
          showSuggestions={this.props.showSuggestions}
          showHolder={this.props.showHolder}
        />
      );
    } else if (this.props.isPersona) {
      cardContent = <WonPersonaCard atomUri={this.props.atomUri} />;
    } else if (this.props.isPokemonRaid) {
      cardContent = <PokemonRaidCard atomUri={this.props.atomUri} />;
    } else {
      cardContent = (
        <WonOtherCard
          atomUri={this.props.atomUri}
          showSuggestions={this.props.showSuggestions}
          showHolder={this.props.showHolder}
          currentLocation={this.props.currentLocation}
        />
      );
    }

    return <won-atom-card>{cardContent}</won-atom-card>;
  }
}

WonAtomCard.propTypes = {<commit_msg>Fixes minor bug -> suggestions for raids where never displayed in the atom-card<commit_after>/**
 * Created by quasarchimaere on 30.07.2019.
 */
import React from "react";
import { get, getIn } from "../utils.js";

import * as atomUtils from "../redux/utils/atom-utils.js";
import * as processUtils from "../redux/utils/process-utils.js";
import WonOtherCard from "./cards/other-card.jsx";
import WonSkeletonCard from "./cards/skeleton-card.jsx";
import WonPersonaCard from "./cards/persona-card.jsx";
import PokemonRaidCard from "./cards/pokemon-raid-card.jsx";
import PropTypes from "prop-types";
import { connect } from "react-redux";

import "~/style/_atom-card.scss";

const mapStateToProps = (state, ownProps) => {
  const atom = getIn(state, ["atoms", ownProps.atomUri]);
  const isPersona = atomUtils.isPersona(atom);
  const process = get(state, "process");
  const isSkeleton =
    !(
      processUtils.isAtomLoaded(process, ownProps.atomUri) &&
      !get(atom, "isBeingCreated")
    ) ||
    get(atom, "isBeingCreated") ||
    processUtils.hasAtomFailedToLoad(process, ownProps.atomUri) ||
    processUtils.isAtomLoading(process, ownProps.atomUri) ||
    processUtils.isAtomToLoad(process, ownProps.atomUri);

  const isPokemonRaid =
    getIn(atom, ["matchedUseCase", "identifier"]) === "pokemonGoRaid";

  if (isSkeleton) {
    return {
      atomUri: ownProps.atomUri,
      showHolder: ownProps.showHolder,
      showSuggestions: ownProps.showSuggestions,
      currentLocation: ownProps.currentLocation,
      isPersona: false,
      isPokemonRaid: false,
      isOtherAtom: false,
      isSkeleton: true,
    };
  } else if (isPersona) {
    return {
      atomUri: ownProps.atomUri,
      showHolder: ownProps.showHolder,
      showSuggestions: ownProps.showSuggestions,
      currentLocation: ownProps.currentLocation,
      isPersona: true,
      isPokemonRaid: false,
      isOtherAtom: false,
      isSkeleton: false,
    };
  } else if (isPokemonRaid) {
    return {
      atomUri: ownProps.atomUri,
      showHolder: ownProps.showHolder,
      showSuggestions: ownProps.showSuggestions,
      currentLocation: ownProps.currentLocation,
      isPersona: false,
      isPokemonRaid: true,
      isOtherAtom: false,
      isSkeleton: false,
    };
  } else {
    return {
      atomUri: ownProps.atomUri,
      showHolder: ownProps.showHolder,
      showSuggestions: ownProps.showSuggestions,
      currentLocation: ownProps.currentLocation,
      isPersona: false,
      isPokemonRaid: false,
      isOtherAtom: true,
      isSkeleton: false,
    };
  }
};

class WonAtomCard extends React.Component {
  render() {
    let cardContent;
    if (this.props.isSkeleton) {
      cardContent = (
        <WonSkeletonCard
          atomUri={this.props.atomUri}
          showSuggestions={this.props.showSuggestions}
          showHolder={this.props.showHolder}
        />
      );
    } else if (this.props.isPersona) {
      cardContent = <WonPersonaCard atomUri={this.props.atomUri} />;
    } else if (this.props.isPokemonRaid) {
      cardContent = (
        <PokemonRaidCard
          atomUri={this.props.atomUri}
          showSuggestions={this.props.showSuggestions}
          showHolder={this.props.showHolder}
          currentLocation={this.props.currentLocation}
        />
      );
    } else {
      cardContent = (
        <WonOtherCard
          atomUri={this.props.atomUri}
          showSuggestions={this.props.showSuggestions}
          showHolder={this.props.showHolder}
          currentLocation={this.props.currentLocation}
        />
      );
    }

    return <won-atom-card>{cardContent}</won-atom-card>;
  }
}

WonAtomCard.propTypes = {
{'fraction_non_alphanumeric': 0.11860825468375828, 'fraction_numerical': 0.002253838568812509, 'mean_word_length': 3.0112994350282487, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 18, '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': '6080553', 'n_tokens_mistral': 2326, 'n_tokens_neox': 2256, 'n_words': 414}