<commit_before>import PropTypes from "prop-types";
import React from "react";
import styled from "styled-components";
import useSWR from "swr";

import MANUAL_REVALIDATION_SWR_CONFIG from "@agir/front/allPages/SWRContext";
import { getEventEndpoint } from "@agir/events/common/api";

import Button from "@agir/front/genericComponents/Button";
import FeatherIcon from "@agir/front/genericComponents/FeatherIcon";
import PageFadeIn from "@agir/front/genericComponents/PageFadeIn";
import StyledCard from "./StyledCard";

const StyledReportCard = styled(StyledCard)`
  background-color: ${(props) => props.theme.primary100};

  h5 {
    color: ${(props) =>
      props.$submitted ? props.theme.black1000 : props.theme.primary500};
  }

  p + ${Button} {
    margin-top: 1rem;
  }
`;

export const ReportFormCard = (props) => {
  const { title, description, url, submitted } = props;

  return (
    <StyledReportCard $submitted={submitted}>
      <h5>{title}</h5>
      {submitted ? (
        <p>
          <FeatherIcon inline name="check" /> Vous avez répondu à ce formulaire
        </p>
      ) : (
        <p dangerouslySetInnerHTML={{ __html: description }} />
      )}
      {!submitted && (
        <Button link small color="primary" href={url}>
          Je complète
        </Button>
      )}
    </StyledReportCard>
  );
};

ReportFormCard.propTypes = {
  title: PropTypes.string.isRequired,
  description: PropTypes.string,
  url: PropTypes.string.isRequired,
  submitted: PropTypes.bool.isRequired,
};

const ConnectedReportFormCard = ({ eventPk }) => {
  const { data } = useSWR(
    eventPk && getEventEndpoint("getEventReportForm", { eventPk }),
    MANUAL_REVALIDATION_SWR_CONFIG
  );
  return (
    <PageFadeIn ready={!!data?.url}>
      {data && (
        <ReportFormCard
          title={data?.title}
          description={data?.description}
          url={data?.url}
          submitted={data?.submitted}
        />
      )}
    </PageFadeIn>
  );
};

ReportFormCard.propTypes = {
  eventPk: PropTypes.string,
};

export default ConnectedReportFormCard;
<commit_msg>Fix bad import in agir/events/components/eventPage/ReportFormCard<commit_after>import PropTypes from "prop-types";
import React from "react";
import styled from "styled-components";
import useSWR from "swr";

import { MANUAL_REVALIDATION_SWR_CONFIG } from "@agir/front/allPages/SWRContext";
import { getEventEndpoint } from "@agir/events/common/api";

import Button from "@agir/front/genericComponents/Button";
import FeatherIcon from "@agir/front/genericComponents/FeatherIcon";
import PageFadeIn from "@agir/front/genericComponents/PageFadeIn";
import StyledCard from "./StyledCard";

const StyledReportCard = styled(StyledCard)`
  background-color: ${(props) => props.theme.primary100};

  h5 {
    color: ${(props) =>
      props.$submitted ? props.theme.black1000 : props.theme.primary500};
  }

  p + ${Button} {
    margin-top: 1rem;
  }
`;

export const ReportFormCard = (props) => {
  const { title, description, url, submitted } = props;

  return (
    <StyledReportCard $submitted={submitted}>
      <h5>{title}</h5>
      {submitted ? (
        <p>
          <FeatherIcon inline name="check" /> Vous avez répondu à ce formulaire
        </p>
      ) : (
        <p dangerouslySetInnerHTML={{ __html: description }} />
      )}
      {!submitted && (
        <Button link small color="primary" href={url}>
          Je complète
        </Button>
      )}
    </StyledReportCard>
  );
};

ReportFormCard.propTypes = {
  title: PropTypes.string.isRequired,
  description: PropTypes.string,
  url: PropTypes.string.isRequired,
  submitted: PropTypes.bool.isRequired,
};

const ConnectedReportFormCard = ({ eventPk }) => {
  const { data } = useSWR(
    eventPk && getEventEndpoint("getEventReportForm", { eventPk }),
    MANUAL_REVALIDATION_SWR_CONFIG
  );
  return (
    <PageFadeIn ready={!!data?.url}>
      {data && (
        <ReportFormCard
          title={data?.title}
          description={data?.description}
          url={data?.url}
          submitted={data?.submitted}
        />
      )}
    </PageFadeIn>
  );
};

ReportFormCard.propTypes = {
  eventPk: PropTypes.string,
};

export default ConnectedReportFormCard;

{'fraction_non_alphanumeric': 0.13589015151515152, 'fraction_numerical': 0.006628787878787879, 'mean_word_length': 3.2806484295845997, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 37, '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': '669841', 'n_tokens_mistral': 1363, 'n_tokens_neox': 1340, 'n_words': 266}