<commit_before>import React, { useRef } from "react";
import { EditOutlined } from "@ant-design/icons";
import { Button, Modal } from "antd";
import { MarkdownEditor } from "../../components/markdown/MarkdownEditor";
import { FONT_COLOR_PRIMARY } from "../../styles/fonts";

export function EditAnnouncement({ announcement, updateAnnouncement }) {
  const markdownRef = useRef();

  function saveMarkdown() {
    const md = markdownRef.current.getMarkdown();
    updateAnnouncement({ message: md, id: announcement.id });
  }

  function displayModal() {
    Modal.confirm({
      title: i18n("EditAnnouncement.title"),
      icon: <EditOutlined style={{ color: FONT_COLOR_PRIMARY }} />,
      width: "80%",
      content: (
        <MarkdownEditor ref={markdownRef} markdown={announcement.message} />
      ),
      okText: i18n("EditAnnouncement.okBtn"),
      onOk() {
        saveMarkdown();
      }
    });
  }

  return (
    <Button shape={"circle"} onClick={displayModal}><commit_msg>Added comments to EditAnnouncement.jsx<commit_after>import React, { useRef } from "react";
import { EditOutlined } from "@ant-design/icons";
import { Button, Modal } from "antd";
import { MarkdownEditor } from "../../components/markdown/MarkdownEditor";
import { FONT_COLOR_PRIMARY } from "../../styles/fonts";

/**
 * Render React component to edit an announcement.
 * @param {string} announcement - announcement to edit.
 * @param {function} updateAnnouncement - function to update the announcement.
 * @returns {*}
 * @constructor
 */
export function EditAnnouncement({ announcement, updateAnnouncement }) {
  const markdownRef = useRef();

  function saveMarkdown() {
    const md = markdownRef.current.getMarkdown();
    updateAnnouncement({ message: md, id: announcement.id });
  }

  function displayModal() {
    Modal.confirm({
      title: i18n("EditAnnouncement.title"),
      icon: <EditOutlined style={{ color: FONT_COLOR_PRIMARY }} />,
      width: "80%",
      content: (
        <MarkdownEditor ref={markdownRef} markdown={announcement.message} />
      ),
      okText: i18n("EditAnnouncement.okBtn"),
      onOk() {
        saveMarkdown();
      }
    });
  }

  return (
    <Button shape={"circle"} onClick={displayModal}>
{'fraction_non_alphanumeric': 0.14554411106135243, 'fraction_numerical': 0.005373936408419167, 'mean_word_length': 3.6061855670103093, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '1891171', 'n_tokens_mistral': 677, 'n_tokens_neox': 659, 'n_words': 153}