<commit_before>import { FormEvent, useState } from 'react';
import { c } from 'ttag';
import { Organization } from '@proton/shared/lib/interfaces';
import { requiredValidator } from '@proton/shared/lib/helpers/formValidators';

import { Card, ErrorButton, FormModal, InputFieldTwo, useFormErrors } from '../../components';

interface Props {
    organization: Organization;
    onConfirm: () => void;
    onClose?: () => void;
}

const MemberDowngradeModal = ({ organization, onConfirm, ...rest }: Props) => {
    const { validator, onFormSubmit } = useFormErrors();
    const [confirmText, setConfirmText] = useState('');
    const organizationName = organization.Name;
    return (
        <FormModal
            small
            title={c('Title').t`Delete organization?`}
            close={c('Action').t`Cancel`}
            submit={<ErrorButton type="submit">{c('Action').t`Delete`}</ErrorButton>}
            onSubmit={(event: FormEvent) => {
                event.preventDefault();
                if (!onFormSubmit()) {
                    return;
                }
                onConfirm();
                rest.onClose?.();
            }}
            {...rest}
        >
            <div className="mb1">{c('Member downgrade modal')
                .t`This will permanently delete all sub-users, accounts, and data associated with your organization.`}</div>
            <Card rounded className="text-break user-select mb1">
                {organizationName}
            </Card>
            <InputFieldTwo
                id="confirm-text"
                bigger
                label={c('Label').t`Enter organization name to confirm`}
                error={validator([
                    requiredValidator(confirmText),
                    confirmText !== organizationName ? c('Error').t`Organization not recognized. Try again.` : '',
                ])}
                autoFocus
                value={confirmText}
                onValue={setConfirmText}
            />
        </FormModal>
    );<commit_msg>Migrate MemberDowngradeModal<commit_after>import { FormEvent, useState } from 'react';
import { c } from 'ttag';
import { Organization } from '@proton/shared/lib/interfaces';
import { requiredValidator } from '@proton/shared/lib/helpers/formValidators';

import {
    Button,
    Card,
    Form,
    InputFieldTwo,
    ModalProps,
    ModalTwo as Modal,
    ModalTwoHeader as ModalHeader,
    ModalTwoContent as ModalContent,
    ModalTwoFooter as ModalFooter,
    useFormErrors,
} from '../../components';

interface Props extends ModalProps {
    organization: Organization;
    onConfirm: () => void;
}

const MemberDowngradeModal = ({ organization, onConfirm, onClose, ...rest }: Props) => {
    const { validator, onFormSubmit } = useFormErrors();
    const [confirmText, setConfirmText] = useState('');
    const organizationName = organization.Name;

    return (
        <Modal
            as={Form}
            onSubmit={(event: FormEvent) => {
                event.preventDefault();
                if (!onFormSubmit()) {
                    return;
                }
                onConfirm();
                onClose?.();
            }}
            onClose={onClose}
            {...rest}
        >
            <ModalHeader title={c('Title').t`Delete organization?`} />
            <ModalContent>
                <div className="mb1">
                    {c('Member downgrade modal')
                        .t`This will permanently delete all sub-users, accounts, and data associated with your organization.`}
                </div>
                <Card rounded className="text-break user-select mb1">
                    {organizationName}
                </Card>
                <InputFieldTwo
                    id="confirm-text"
                    bigger
                    label={c('Label').t`Enter organization name to confirm`}
                    error={validator([
                        requiredValidator(confirmText),
                        confirmText !== organizationName ? c('Error').t`Organization not recognized. Try again.` : '',
                    ])}
                    autoFocus
                    value={confirmText}
                    onValue={setConfirmText}
                />
            </ModalContent>
            <ModalFooter>
                <Button onClick={onClose}>{c('Action').t`Cancel`}</Button>
                <Button type="submit" color="danger">
                    {c('Action').t`Delete`}
                </Button>
            </ModalFooter>
        </Modal>
    );
{'fraction_non_alphanumeric': 0.12217591577100241, 'fraction_numerical': 0.000877385391533231, 'mean_word_length': 1.732174955062912, 'pattern_counts': {'":': 0, '<': 28, '<?xml version=': 0, '>': 35, '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': '3227373', 'n_tokens_mistral': 1153, 'n_tokens_neox': 1111, 'n_words': 251}