<commit_before>import React, { useCallback, useState } from 'react'
import { useMutation } from '@apollo/client'

import styled from 'styled-components'

import Box from 'v2/components/UI/Box'
import Text from 'v2/components/UI/Text'
import { Input } from 'v2/components/UI/Inputs'
import TitledDialog from 'v2/components/UI/TitledDialog'
import restrictMutation from './mutations/restrictMutation'
import {
  restrictMutation as RestrictMutation,
  restrictMutationVariables,
} from '__generated__/restrictMutation'

const Container = styled(Box).attrs({
  py: 5,
  px: 7,
})`
  display: flex;
  flex-direction: column;
  justify-content: center;
`

const Copy = styled(Text).attrs({
  f: 4,
  color: 'gray.bold',
  pb: 3,
})`
  ul {
    margin-left: ${props => props.theme.space[1]};
  }
  li {
    margin-top: ${props => props.theme.space[3]};
    margin-bottom: ${props => props.theme.space[3]};
  }
`

const TextInput = styled(Input).attrs({
  flex: 1,
  f: 2,
})``

interface RestrictPersonModalProps {
  id: string
  name: string
}

export const RestrictPersonModal: React.FC<RestrictPersonModalProps> = ({
  id,
  name,
}) => {
  const [disabled, setDisabled] = useState(true)
  const [mode, setMode] = useState<
    'resting' | 'restricting' | 'error' | 'confirmed'
  >('resting')
  const [restrictContent] = useMutation<
    RestrictMutation,
    restrictMutationVariables
  >(restrictMutation, { variables: { id } })

  const onPress = useCallback(() => {
    setMode('restricting')
    restrictContent()
      .then(() => {
        setMode('confirmed')
      })
      .catch(() => {
        setMode('error')
      })
  }, [setMode, restrictContent])

  const onChange = useCallback(
    ({ target: { value } }) => {
      console.log({ value })
      setDisabled(value != id)
    },
    [setDisabled]
  )

  return (
    <TitledDialog<commit_msg>Prevent default and redirect on done<commit_after>import React, { useCallback, useState } from 'react'
import { useMutation } from '@apollo/client'

import styled from 'styled-components'

import Box from 'v2/components/UI/Box'
import Text from 'v2/components/UI/Text'
import { Input } from 'v2/components/UI/Inputs'
import TitledDialog from 'v2/components/UI/TitledDialog'
import restrictMutation from './mutations/restrictMutation'
import {
  restrictMutation as RestrictMutation,
  restrictMutationVariables,
} from '__generated__/restrictMutation'

const Container = styled(Box).attrs({
  py: 5,
  px: 7,
})`
  display: flex;
  flex-direction: column;
  justify-content: center;
`

const Copy = styled(Text).attrs({
  f: 4,
  color: 'gray.bold',
  pb: 3,
})`
  ul {
    margin-left: ${props => props.theme.space[1]};
  }
  li {
    margin-top: ${props => props.theme.space[3]};
    margin-bottom: ${props => props.theme.space[3]};
  }
`

const TextInput = styled(Input).attrs({
  flex: 1,
  f: 2,
})``

interface RestrictPersonModalProps {
  id: string
  name: string
}

export const RestrictPersonModal: React.FC<RestrictPersonModalProps> = ({
  id,
  name,
}) => {
  const [disabled, setDisabled] = useState(true)
  const [mode, setMode] = useState<
    'resting' | 'restricting' | 'error' | 'confirmed'
  >('resting')
  const [restrictContent] = useMutation<
    RestrictMutation,
    restrictMutationVariables
  >(restrictMutation, { variables: { id } })

  const onPress = useCallback(
    e => {
      e.preventDefault()
      setMode('restricting')
      restrictContent()
        .then(() => {
          setMode('confirmed')
          setTimeout(() => {
            setMode('resting')
            window.location.href = '/'
          }, 3000)
        })
        .catch(() => {
          setMode('error')
        })
    },
    [setMode, restrictContent]
  )

  const onChange = useCallback(
    ({ target: { value } }) => {
      console.log({ value })
      setDisabled(value != id)
    },
    [setDisabled]
  )

  return (
    <TitledDialog
{'fraction_non_alphanumeric': 0.1477882894400409, 'fraction_numerical': 0.0076706724622858605, 'mean_word_length': 3.2989010989010987, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 26, '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': '6895036', 'n_tokens_mistral': 1308, 'n_tokens_neox': 1297, 'n_words': 284}