<commit_before>/**
 * Es6 module for React Component.
 * Component module React classes combine elements to
 * bigger parts of the page.
 *
 * @file
 * @module
 *
 * @author <EMAIL> (<NAME>), 2021
 */
import { default as React, FunctionComponent, ReactNode } from 'react';
import classnames from 'classnames';

import { P } from '../element/paragraph';

type Props = {
    htmlElement?: keyof JSX.IntrinsicElements;
    className?: string;
    isCentered?: boolean;
    itemType?: string;
    children?: ReactNode;
    content?: {
        name: string;
        streetAddress: string;
        postalCode: string;
        locality: string;
        email: string;
        phone: string;
        phoneNumbers: string;
        website: string;
    }
}

/**
 * Function representing a component to return a single react child element.
 *
 * @function
 * @param {object} [props] - The current component props
 * @returns {ReactElement} React component markup
 */
export const ModulePerson: FunctionComponent<Props> = (props) => {
    const {
        children,
        className,
        content,
        htmlElement: HtmlElement = 'div',
        isCentered = false,
        itemType = 'http://schema.org/Person'
    } = props;

    if (!content) {
        return null;
    }

    const componentClassName = classnames(
        {
            'is-centered': isCentered
        },
        'm-person',
        className
    );
    const componentSchema = itemType ? { itemScope: true, itemType } : null;

    return (
        <HtmlElement className={componentClassName} {...componentSchema}>
            {content.name && (
                <P className="m-person__name">
                    <strong>{content.name}</strong>
                </P>
            )}
            {content.streetAddress && content.postalCode && content.locality && (
                <address
                    className="m-person__address c-type--address"
                    itemProp="address"
                    itemScope
                    itemType="http://schema.org/Address"
                >
                    <span
                        className="m-person__street-address"
                        itemProp="street-address"
                    >
                        {content.streetAddress}
                    </span>
                    <span
                        className="m-person__postal-code"
                        itemProp="postal-code"
                    >
                        {content.postalCode}
                    </span>
                    <span className="m-person__locality" itemProp="locality">
                        {content.locality}
                    </span>
                </address>
            )}
            {content.email && (
                <P className="m-person__email">
                    <abbr title="E-Mail address">E.</abbr>{' '}
                    <a href={`mailto:${content.email}`} itemProp="email">
                        {content.email}
                    </a>
                </P>
            )}
            {content.phoneNumbers && content.phone && (
                <P className="m-person__phone">
                    <abbr title="Phonenumber">P.</abbr>{' '}
                    <a
                        href={`tel:${content.phoneNumbers}`}
                        itemProp="telephone"
                    >
                        {content.phone}
                    </a>
                </P>
            )}
            {content.website && (
                <P className="m-person__website">
                    <abbr title="Website">W.</abbr>{' '}
                    <a href={`${content.website}`}>{content.website}</a>
                </P>
            )}
            {children}<commit_msg>Make component fail safe<commit_after>/**
 * Es6 module for React Component.
 * Component module React classes combine elements to
 * bigger parts of the page.
 *
 * @file
 * @module
 *
 * @author <EMAIL> (<NAME>), 2021
 */
import { default as React, FunctionComponent, ReactNode } from 'react';
import classnames from 'classnames';

import { P } from '../element/paragraph';

type Props = {
    htmlElement?: keyof JSX.IntrinsicElements;
    className?: string;
    isCentered?: boolean;
    itemType?: string;
    children?: ReactNode;
    content?: {
        name: string;
        streetAddress: string;
        postalCode: string;
        locality: string;
        email: string;
        phone: string;
        phoneNumbers: string;
        website: string;
    }
}

/**
 * Function representing a component to return a single react child element.
 *
 * @function
 * @param {object} [props] - The current component props
 * @returns {ReactElement} React component markup
 */
export const ModulePerson: FunctionComponent<Props> = (props) => {
    const {
        children,
        className,
        content,
        htmlElement: HtmlElement = 'div',
        isCentered = false,
        itemType = 'http://schema.org/Person'
    } = props;

    if (!content) {
        return null;
    }

    const componentClassName = classnames(
        {
            'is-centered': isCentered
        },
        'm-person',
        className
    );
    const componentSchema = itemType ? { itemScope: true, itemType } : null;

    return (
        <HtmlElement className={componentClassName} {...componentSchema}>
            {content?.name && (
                <P className="m-person__name">
                    <strong>{content.name}</strong>
                </P>
            )}
            {content?.streetAddress && content?.postalCode && content?.locality && (
                <address
                    className="m-person__address c-type--address"
                    itemProp="address"
                    itemScope
                    itemType="http://schema.org/Address"
                >
                    <span
                        className="m-person__street-address"
                        itemProp="street-address"
                    >
                        {content.streetAddress}
                    </span>
                    <span
                        className="m-person__postal-code"
                        itemProp="postal-code"
                    >
                        {content.postalCode}
                    </span>
                    <span className="m-person__locality" itemProp="locality">
                        {content.locality}
                    </span>
                </address>
            )}
            {content?.email && (
                <P className="m-person__email">
                    <abbr title="E-Mail address">E.</abbr>{' '}
                    <a href={`mailto:${content.email}`} itemProp="email">
                        {content.email}
                    </a>
                </P>
            )}
            {content?.phoneNumbers && content?.phone && (
                <P className="m-person__phone">
                    <abbr title="Phonenumber">P.</abbr>{' '}
                    <a
                        href={`tel:${content.phoneNumbers}`}
                        itemProp="telephone"
                    >
                        {content.phone}
                    </a>
                </P>
            )}
            {content?.website && (
                <P className="m-person__website">
                    <abbr title="Website">W.</abbr>{' '}
                    <a href={`${content.website}`}>{content.website}</a>
                </P>
            )}
            {children}
{'fraction_non_alphanumeric': 0.11827526364971298, 'fraction_numerical': 0.0013349352556401015, 'mean_word_length': 1.3238213399503722, 'pattern_counts': {'":': 0, '<': 71, '<?xml version=': 0, '>': 73, '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': '3512155', 'n_tokens_mistral': 1956, 'n_tokens_neox': 1814, 'n_words': 394}