<commit_before>import React from 'react';
import PropTypes from 'prop-types';
import { c } from 'ttag';
import { Alert, Bordered, Toggle, useMailSettings, useToggle, useApiWithoutResult } from 'react-components';
import { PM_SIGNATURE } from 'proton-shared/lib/constants';
import { updatePMSignature } from 'proton-shared/lib/api/mailSettings';

const PMSignatureToggle = ({ id }) => {
    const { request, loading } = useApiWithoutResult(updatePMSignature);
    const [{ PMSignature }] = useMailSettings();
    const { state, toggle } = useToggle(!!PMSignature);
    const isMandatory = PMSignature === 2;

    const handleChange = async ({ target }) => {
        await request(+target.checked);
        toggle();
    };

    if (isMandatory) {
        return (
            <>
                <Bordered dangerouslySetInnerHTML={{ __html: <div>{PM_SIGNATURE}</div> }} />
                <Alert>{c('Info')<commit_msg>Add success notif when updating PMSignature<commit_after>import React from 'react';
import PropTypes from 'prop-types';
import { c } from 'ttag';
import {
    Alert,
    Bordered,
    Toggle,
    useMailSettings,
    useToggle,
    useNotifications,
    useApiWithoutResult
} from 'react-components';
import { PM_SIGNATURE } from 'proton-shared/lib/constants';
import { updatePMSignature } from 'proton-shared/lib/api/mailSettings';

const PMSignatureToggle = ({ id }) => {
    const { createNotification } = useNotifications();
    const { request, loading } = useApiWithoutResult(updatePMSignature);
    const [{ PMSignature }] = useMailSettings();
    const { state, toggle } = useToggle(!!PMSignature);
    const isMandatory = PMSignature === 2;

    const handleChange = async ({ target }) => {
        toggle();
        await request(+target.checked);
        createNotification({ text: c('Success').t`Preference saved` });
    };

    if (isMandatory) {
        return (
            <>
                <Bordered dangerouslySetInnerHTML={{ __html: <div>{PM_SIGNATURE}</div> }} />
                <Alert>{c('Info')
{'fraction_non_alphanumeric': 0.13464373464373464, 'fraction_numerical': 0.0009828009828009828, 'mean_word_length': 3.3044397463002113, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 17, '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': '3434413', 'n_tokens_mistral': 607, 'n_tokens_neox': 601, 'n_words': 136}