<commit_before>import React from 'react';
import PropTypes from 'prop-types'
import Row from "./Row";
import questions from '../../bundles/SellerRegistration/components/DisclosuresForm/questions';
import isEmpty from 'lodash/isEmpty';
import format from 'date-fns/format';
import startCase from 'lodash/startCase';

import './SellerProfile.css';

const documentTitle = {
    financial: 'Financial Statement',
    liability: 'Public Liability Insurance',
    workers: 'Workers Compensation Insurance'
};

const govExperienceTitle = {
    no_experience: "None yet",
    local: "Local government",
    state: "State/territory government",
    federal: "Federal/Commonwealth government",
    international: "International government"
}

const PrivateInfo = (props) => {
    const {
        documents = {},
        documentsUrl,
        case_studies = {},
        number_of_employees,
        government_experience,
        other_panels,
        signed_agreements = [],
        recruiter_info = {},
        pricing = {}
    } = props;
    return (
        <article styleName="privateInfo">
            <h3 className="au-display-md"> PRIVATE INFORMATION FOR DIGITAL MARKETPLACE ASSESSMENT PURPOSES ONLY </h3>
            <Row title="Case Study Referees" show={true}>
                {case_studies && Object.keys(case_studies).map((study, i) => {
                    const {title, referee_name, refereeName, referee_email, refereeEmail, referee_position, refereePosition} = case_studies[study];
                    return (<div key={i}>Case Study: "{title}" <br/> Referee: {referee_name || refereeName}
                        ({referee_position || refereePosition}) {referee_email || refereeEmail}
                        <hr/>
                    </div>)
                })
                }
            </Row>
            <Row title="Business Details" show={true}>
                Number of Employees: {number_of_employees}<br/>
                Government experience: <ul>
                {Object.keys(government_experience).map((key, i) => {
                    return (<li key={i}>{govExperienceTitle[key]}</li>)
                })
                }
            </ul>
                {other_panels && <p>Other panels: {other_panels}</p>}
            </Row>
            <Row title="Disclosures" show={true}>
                {Object.keys(questions).map((key, i) => {
                    const question = questions[key];
                    const answer = props['disclosures'][key];
                    const details = props['disclosures'][key + "_details"];
                    return (<p key={i}><b>{question}</b> {answer} - {details}</p>)
                })}
            </Row>
            <Row title="Master Agreement" show={!isEmpty(signed_agreements)}>
                {signed_agreements.map((agreement, i) => {
                    const {version, url, name, email_address, signed_at} = agreement;
                    return (<div key={i}>Agreement: <a href={url}>{version}</a> <br/> {name} ({email_address}) signed
                        at {format(new Date(signed_at), 'YYYY-MM-DD HH:mm')}
                        <hr/>
                    </div>)
                })}
            </Row>
            <Row title="Documents" show={!isEmpty(documents)}>
                <table className="content-table" styleName="content-table">
                    <thead>
                    <tr>
                        <th>Document type </th>
                        <th>Expiry</th>
                    </tr>
                    </thead>
                    <tbody>
                    {Object.keys(documents).map((key, val) => {
                        const {filename, expiry, application_id, noWorkersCompensation} = documents[key];
                        const url = application_id ? `/admin/application/${application_id}/documents/` : documentsUrl
                        return (
                            <tr key={val}>
                                <td>
                                    {key == 'workers' && noWorkersCompensation
                                        ? documentTitle[key]
                                        : <a href={`${url}${filename}`}>{documentTitle[key]}</a>
                                    }
                                </td>
                                <td>
                                    {expiry && format(new Date(expiry), 'DD/MM/YYYY')}
                                </td>
                            </tr>
                        )
                    })}
                    </tbody>
                </table>
                {documents.workers.noWorkersCompensation && 
                    <p>
                        <b>Workers compensation insurance not held by this seller</b>
                    </p>
                }
            </Row>
            <Row title="Recruiter Info" show={!isEmpty(recruiter_info)}>
              {Object.keys(recruiter_info).map((key, i) => {
                return (
                  <div key={i}>
                    <h4 className="au-display-sm">{key}</h4>
                    {Object.keys(recruiter_info[key]).map((subKey, j) => {
                      return (
                        <div key={`${key}-${subKey}`}>
                          {startCase(subKey)}:{recruiter_info[key][subKey]}
                        </div><commit_msg>[Seller profile] Add checks before accessing noWorkersCompensation property (#706)<commit_after>import React from 'react';
import PropTypes from 'prop-types'
import Row from "./Row";
import questions from '../../bundles/SellerRegistration/components/DisclosuresForm/questions';
import isEmpty from 'lodash/isEmpty';
import format from 'date-fns/format';
import startCase from 'lodash/startCase';

import './SellerProfile.css';

const documentTitle = {
    financial: 'Financial Statement',
    liability: 'Public Liability Insurance',
    workers: 'Workers Compensation Insurance'
};

const govExperienceTitle = {
    no_experience: "None yet",
    local: "Local government",
    state: "State/territory government",
    federal: "Federal/Commonwealth government",
    international: "International government"
}

const PrivateInfo = (props) => {
    const {
        documents = {},
        documentsUrl,
        case_studies = {},
        number_of_employees,
        government_experience,
        other_panels,
        signed_agreements = [],
        recruiter_info = {},
        pricing = {}
    } = props;
    return (
        <article styleName="privateInfo">
            <h3 className="au-display-md"> PRIVATE INFORMATION FOR DIGITAL MARKETPLACE ASSESSMENT PURPOSES ONLY </h3>
            <Row title="Case Study Referees" show={true}>
                {case_studies && Object.keys(case_studies).map((study, i) => {
                    const {title, referee_name, refereeName, referee_email, refereeEmail, referee_position, refereePosition} = case_studies[study];
                    return (<div key={i}>Case Study: "{title}" <br/> Referee: {referee_name || refereeName}
                        ({referee_position || refereePosition}) {referee_email || refereeEmail}
                        <hr/>
                    </div>)
                })
                }
            </Row>
            <Row title="Business Details" show={true}>
                Number of Employees: {number_of_employees}<br/>
                Government experience: <ul>
                {Object.keys(government_experience).map((key, i) => {
                    return (<li key={i}>{govExperienceTitle[key]}</li>)
                })
                }
            </ul>
                {other_panels && <p>Other panels: {other_panels}</p>}
            </Row>
            <Row title="Disclosures" show={true}>
                {Object.keys(questions).map((key, i) => {
                    const question = questions[key];
                    const answer = props['disclosures'][key];
                    const details = props['disclosures'][key + "_details"];
                    return (<p key={i}><b>{question}</b> {answer} - {details}</p>)
                })}
            </Row>
            <Row title="Master Agreement" show={!isEmpty(signed_agreements)}>
                {signed_agreements.map((agreement, i) => {
                    const {version, url, name, email_address, signed_at} = agreement;
                    return (<div key={i}>Agreement: <a href={url}>{version}</a> <br/> {name} ({email_address}) signed
                        at {format(new Date(signed_at), 'YYYY-MM-DD HH:mm')}
                        <hr/>
                    </div>)
                })}
            </Row>
            <Row title="Documents" show={!isEmpty(documents)}>
                <table className="content-table" styleName="content-table">
                    <thead>
                    <tr>
                        <th>Document type </th>
                        <th>Expiry</th>
                    </tr>
                    </thead>
                    <tbody>
                    {Object.keys(documents).map((key, val) => {
                        const {filename, expiry, application_id, noWorkersCompensation} = documents[key];
                        const url = application_id ? `/admin/application/${application_id}/documents/` : documentsUrl
                        return (
                            <tr key={val}>
                                <td>
                                    {key == 'workers' && noWorkersCompensation
                                        ? documentTitle[key]
                                        : <a href={`${url}${filename}`}>{documentTitle[key]}</a>
                                    }
                                </td>
                                <td>
                                    {expiry && format(new Date(expiry), 'DD/MM/YYYY')}
                                </td>
                            </tr>
                        )
                    })}
                    </tbody>
                </table>
                {documents && documents.workers && documents.workers.noWorkersCompensation && 
                    <p>
                        <b>Workers compensation insurance not held by this seller</b>
                    </p>
                }
            </Row>
            <Row title="Recruiter Info" show={!isEmpty(recruiter_info)}>
              {Object.keys(recruiter_info).map((key, i) => {
                return (
                  <div key={i}>
                    <h4 className="au-display-sm">{key}</h4>
                    {Object.keys(recruiter_info[key]).map((subKey, j) => {
                      return (
                        <div key={`${key}-${subKey}`}>
                          {startCase(subKey)}:{recruiter_info[key][subKey]}
                        </div>
{'fraction_non_alphanumeric': 0.12686913717841553, 'fraction_numerical': 0.0010216401968979288, 'mean_word_length': 1.4100268576544315, 'pattern_counts': {'":': 0, '<': 131, '<?xml version=': 0, '>': 147, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7235515', 'n_tokens_mistral': 2866, 'n_tokens_neox': 2636, 'n_words': 553}