<commit_before>/**
 *
 * EditView
 *
 */

import React, { useEffect, useReducer, useRef, useState } from 'react';
import { useHistory, useParams } from 'react-router-dom';
import { get, isEmpty, isEqual } from 'lodash';
import { Header, Inputs as InputsIndex } from '@buffetjs/custom';
import { Play } from '@buffetjs/icons';
import {
  request,
  useGlobalContext,
  getYupInnerErrors,
  BackHeader,
} from 'strapi-helper-plugin';

import Inputs from '../../../components/Inputs';
import TriggerContainer from '../../../components/TriggerContainer';

import reducer, { initialState } from './reducer';
import form from './utils/form';
import schema from './utils/schema';
import { cleanData } from './utils/formatData';

import Wrapper from './Wrapper';

function EditView() {
  const isMounted = useRef();
  const { formatMessage } = useGlobalContext();
  const [submittedOnce, setSubmittedOnce] = useState(false);
  const [reducerState, dispatch] = useReducer(reducer, initialState);
  const { push } = useHistory();
  const { id } = useParams();
  const abortController = new AbortController();
  const { signal } = abortController;
  const isCreating = id === 'create';

  const {
    formErrors,
    modifiedData,
    initialData,
    isTriggering,
    triggerResponse,
  } = reducerState.toJS();

  useEffect(() => {
    isMounted.current = true;

    const fetchData = async () => {
      try {
        const { data } = await request(`/admin/webhooks/${id}`, {
          method: 'GET',
        });

        if (isMounted.current) {
          dispatch({
            type: 'GET_DATA_SUCCEEDED',
            data,
          });
        }
      } catch (err) {
        if (isMounted.current) {
          if (err.code !== 20) {
            strapi.notification.error('notification.error');
          }
        }
      }
    };

    if (!isCreating) {
      fetchData();
    }

    return () => {
      isMounted.current = false;
      abortController.abort();
    };
    //eslint-disable-next-line react-hooks/exhaustive-deps
  }, [id, isCreating]);

  const { name } = modifiedData;

  const areActionDisabled =
    isEqual(initialData, modifiedData) || Object.keys(formErrors).length > 0;<commit_msg>eslint dep disable fix<commit_after>/**
 *
 * EditView
 *
 */

import React, { useEffect, useReducer, useRef, useState } from 'react';
import { useHistory, useParams } from 'react-router-dom';
import { get, isEmpty, isEqual } from 'lodash';
import { Header, Inputs as InputsIndex } from '@buffetjs/custom';
import { Play } from '@buffetjs/icons';
import {
  request,
  useGlobalContext,
  getYupInnerErrors,
  BackHeader,
} from 'strapi-helper-plugin';

import Inputs from '../../../components/Inputs';
import TriggerContainer from '../../../components/TriggerContainer';

import reducer, { initialState } from './reducer';
import form from './utils/form';
import schema from './utils/schema';
import { cleanData } from './utils/formatData';

import Wrapper from './Wrapper';

function EditView() {
  const isMounted = useRef();
  const { formatMessage } = useGlobalContext();
  const [submittedOnce, setSubmittedOnce] = useState(false);
  const [reducerState, dispatch] = useReducer(reducer, initialState);
  const { push } = useHistory();
  const { id } = useParams();
  const abortController = new AbortController();
  const { signal } = abortController;
  const isCreating = id === 'create';

  const {
    formErrors,
    modifiedData,
    initialData,
    isTriggering,
    triggerResponse,
  } = reducerState.toJS();

  useEffect(() => {
    isMounted.current = true;

    const fetchData = async () => {
      try {
        const { data } = await request(`/admin/webhooks/${id}`, {
          method: 'GET',
        });

        if (isMounted.current) {
          dispatch({
            type: 'GET_DATA_SUCCEEDED',
            data,
          });
        }
      } catch (err) {
        if (isMounted.current) {
          if (err.code !== 20) {
            strapi.notification.error('notification.error');
          }
        }
      }
    };

    if (!isCreating) {
      fetchData();
    }

    return () => {
      isMounted.current = false;
      abortController.abort();
    };
    // eslint-disable-next-line react-hooks/exhaustive-deps
  }, [id, isCreating]);

  const { name } = modifiedData;

  const areActionDisabled =
    isEqual(initialData, modifiedData) || Object.keys(formErrors).length > 0;
{'fraction_non_alphanumeric': 0.1448619284744228, 'fraction_numerical': 0.001358080579447714, 'mean_word_length': 2.7866323907455013, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '1793647', 'n_tokens_mistral': 1345, 'n_tokens_neox': 1327, 'n_words': 314}