<commit_before>// Copyright (c) ppy Pty Ltd <<EMAIL>>. Licensed under the GNU Affero General Public License v3.0.
// See the LICENCE file in the repository root for full licence text.

import { Modal } from 'components/modal';
import { SelectOptions } from 'components/select-options';
import { intersectionWith } from 'lodash';
import { action, makeObservable, observable } from 'mobx';
import { observer } from 'mobx-react';
import * as React from 'react';

const bn = 'report-form';
const maxLength = 2000;
const availableOptions = [
  { id: 'Cheating', text: osu.trans('users.report.options.cheating') },
  { id: 'MultipleAccounts', text: osu.trans('users.report.options.multiple_accounts') },
  { id: 'Insults', text: osu.trans('users.report.options.insults') },
  { id: 'Spam', text: osu.trans('users.report.options.spam') },
  { id: 'UnwantedContent', text: osu.trans('users.report.options.unwanted_content') },
  { id: 'Nonsense', text: osu.trans('users.report.options.nonsense') },
  { id: 'Other', text: osu.trans('users.report.options.other') },
];

interface Props {
  completed: boolean;
  disabled: boolean;
  onClose: () => void;
  onSubmit: ({ comments }: { comments: string }) => void;
  title: React.ReactNode;
  visible: boolean;
  visibleOptions: string[];
}

interface ReportOption {
  id: string;
  text: string;
}

@observer
export class ReportForm extends React.Component<Props> {
  static readonly defaultProps = {
    visibleOptions: availableOptions.map((option) => option.id),
  };

  @observable private comments = '';
  private readonly options = intersectionWith(availableOptions, this.props.visibleOptions, (left, right) => left.id === right);
  @observable private selectedReason = this.options[0];

  constructor(props: Props) {
    super(props);

    makeObservable(this);
  }

  render() {
    return this.props.visible ? this.renderForm() : null;
  }

  @action
  private readonly handleCommentsChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
    this.comments = e.target.value;
  };

  @action<commit_msg>Properly use props instead of making it static on init<commit_after>// Copyright (c) ppy Pty Ltd <<EMAIL>>. Licensed under the GNU Affero General Public License v3.0.
// See the LICENCE file in the repository root for full licence text.

import { Modal } from 'components/modal';
import { SelectOptions } from 'components/select-options';
import { intersectionWith } from 'lodash';
import { action, computed, makeObservable, observable } from 'mobx';
import { observer } from 'mobx-react';
import * as React from 'react';

const bn = 'report-form';
const maxLength = 2000;
const availableOptions = [
  { id: 'Cheating', text: osu.trans('users.report.options.cheating') },
  { id: 'MultipleAccounts', text: osu.trans('users.report.options.multiple_accounts') },
  { id: 'Insults', text: osu.trans('users.report.options.insults') },
  { id: 'Spam', text: osu.trans('users.report.options.spam') },
  { id: 'UnwantedContent', text: osu.trans('users.report.options.unwanted_content') },
  { id: 'Nonsense', text: osu.trans('users.report.options.nonsense') },
  { id: 'Other', text: osu.trans('users.report.options.other') },
];

interface Props {
  completed: boolean;
  disabled: boolean;
  onClose: () => void;
  onSubmit: ({ comments }: { comments: string }) => void;
  title: React.ReactNode;
  visible: boolean;
  visibleOptions?: string[];
}

interface ReportOption {
  id: string;
  text: string;
}

@observer
export class ReportForm extends React.Component<Props> {
  @observable private comments = '';
  @observable private selectedReason = this.options[0];

  @computed
  private get options() {
    if (this.props.visibleOptions == null) {
      return availableOptions;
    }

    return intersectionWith(availableOptions, this.props.visibleOptions, (left, right) => left.id === right);
  }

  constructor(props: Props) {
    super(props);

    makeObservable(this);
  }

  render() {
    return this.props.visible ? this.renderForm() : null;
  }

  @action
  private readonly handleCommentsChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
    this.comments = e.target.value;
  };

  @action
{'fraction_non_alphanumeric': 0.14591346153846155, 'fraction_numerical': 0.0033653846153846156, 'mean_word_length': 4.42503259452412, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 20, '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': '6952685', 'n_tokens_mistral': 1318, 'n_tokens_neox': 1278, 'n_words': 334}