<commit_before>import React from 'react';
import { ContactGroup } from 'proton-shared/lib/interfaces/contacts/Contact';
import LabelStack, { LabelDescription } from '../labelStack/LabelStack';

interface Props {
    contactGroups: ContactGroup[];
}

const ContactGroupLabels = ({ contactGroups }: Props) => {
    const labels = contactGroups.reduce((acc: LabelDescription[], contactGroup: ContactGroup) => {
        return contactGroup
            ? [
                  ...acc,
                  {
                      name: contactGroup.Name,
                      color: contactGroup.Color,
                      title: contactGroup.Name,
                  },
              ]
            : acc;
    }, []);

    return <LabelStack labels={labels} isStacked />;
};
<commit_msg>[MAILWEB-1569] Add a link on the contact group label<commit_after>import React, { MouseEvent } from 'react';
import { APPS } from 'proton-shared/lib/constants';
import { ContactGroup } from 'proton-shared/lib/interfaces/contacts/Contact';
import LabelStack, { LabelDescription } from '../labelStack/LabelStack';
import { useAppLink } from '../link';

interface Props {
    contactGroups: ContactGroup[];
}

const ContactGroupLabels = ({ contactGroups }: Props) => {
    const appLink = useAppLink();

    const labels = contactGroups.reduce((acc: LabelDescription[], contactGroup: ContactGroup) => {
        return contactGroup
            ? [
                  ...acc,
                  {
                      name: contactGroup.Name,
                      color: contactGroup.Color,
                      title: contactGroup.Name,
                      onClick: (event: MouseEvent) => {
                          appLink(`/?contactGroupID=${contactGroup.ID}`, APPS.PROTONCONTACTS);
                          event.stopPropagation();
                      },
                  },
              ]
            : acc;
    }, []);

    return <LabelStack labels={labels} isStacked />;
};

{'fraction_non_alphanumeric': 0.11857506361323156, 'fraction_numerical': 0.002035623409669211, 'mean_word_length': 1.8784773060029283, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 10, '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': '980137', 'n_tokens_mistral': 506, 'n_tokens_neox': 491, 'n_words': 108}