<commit_before>import React, { useState } from 'react';
import { c } from 'ttag';
import { Alert, GenericError, FormModal } from '../../../index';
import { algorithmInfo } from 'pmcrypto';
import { getAlgorithmExists } from 'proton-shared/lib/keys/keysAlgorithm';
import { DEFAULT_ENCRYPTION_CONFIG, ENCRYPTION_CONFIGS, ENCRYPTION_TYPES } from 'proton-shared/lib/constants';
import { EncryptionConfig } from 'proton-shared/lib/interfaces';

import SelectEncryption from './SelectEncryption';

enum STEPS {
    SELECT_ENCRYPTION = 1,
    WARNING = 2,
    GENERATE_KEY = 3,
    SUCCESS = 4,
    FAILURE = 5
}

interface Props {
    onClose?: () => void;
    existingAlgorithms: algorithmInfo[];
    onAdd: (config: EncryptionConfig) => Promise<string>;
}
const AddKeyModal = ({ onClose, existingAlgorithms, onAdd, ...rest }: Props) => {
    const [step, setStep] = useState(STEPS.SELECT_ENCRYPTION);
    const [encryptionType, setEncryptionType] = useState<ENCRYPTION_TYPES>(DEFAULT_ENCRYPTION_CONFIG);
    const [newKeyFingerprint, setNewKeyFingerprint] = useState();

    const handleProcess = () => {
        onAdd(ENCRYPTION_CONFIGS[encryptionType])
            .then((fingerprint) => {
                setNewKeyFingerprint(fingerprint);
                setStep(STEPS.SUCCESS);
            })
            .catch(() => {
                setStep(STEPS.FAILURE);
            });
    };
<commit_msg>Fix small typescript issues for the new version<commit_after>import React, { useState } from 'react';
import { c } from 'ttag';
import { Alert, GenericError, FormModal } from '../../../index';
import { algorithmInfo } from 'pmcrypto';
import { getAlgorithmExists } from 'proton-shared/lib/keys/keysAlgorithm';
import { DEFAULT_ENCRYPTION_CONFIG, ENCRYPTION_CONFIGS, ENCRYPTION_TYPES } from 'proton-shared/lib/constants';
import { EncryptionConfig } from 'proton-shared/lib/interfaces';

import SelectEncryption from './SelectEncryption';

enum STEPS {
    SELECT_ENCRYPTION = 1,
    WARNING = 2,
    GENERATE_KEY = 3,
    SUCCESS = 4,
    FAILURE = 5
}

interface Props {
    onClose?: () => void;
    existingAlgorithms: algorithmInfo[];
    onAdd: (config: EncryptionConfig) => Promise<string>;
}
const AddKeyModal = ({ onClose, existingAlgorithms, onAdd, ...rest }: Props) => {
    const [step, setStep] = useState(STEPS.SELECT_ENCRYPTION);
    const [encryptionType, setEncryptionType] = useState<ENCRYPTION_TYPES>(DEFAULT_ENCRYPTION_CONFIG);
    const [newKeyFingerprint, setNewKeyFingerprint] = useState<string>();

    const handleProcess = () => {
        onAdd(ENCRYPTION_CONFIGS[encryptionType])
            .then((fingerprint) => {
                setNewKeyFingerprint(fingerprint);
                setStep(STEPS.SUCCESS);
            })
            .catch(() => {
                setStep(STEPS.FAILURE);
            });
    };

{'fraction_non_alphanumeric': 0.12834978843441466, 'fraction_numerical': 0.003526093088857546, 'mean_word_length': 3.378086419753086, 'pattern_counts': {'":': 0, '<': 8, '<?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': '3312688', 'n_tokens_mistral': 909, 'n_tokens_neox': 856, 'n_words': 179}