90 lines
3.2 KiB
TypeScript
90 lines
3.2 KiB
TypeScript
import type { Organization } from "../../../shared/api/schemas";
|
|
import { Section, TrustLevel } from "../../../shared/ui";
|
|
import { candidateCardLevelLabels, organizationTrustLevel } from "../model/verification-labels";
|
|
import styles from "./candidate-card-preview.module.css";
|
|
|
|
type CandidateCard = Organization["candidate_card"];
|
|
|
|
type CandidateCardPreviewProps = {
|
|
card: CandidateCard;
|
|
};
|
|
|
|
const contactLabels = {
|
|
website: "Сайт",
|
|
email: "Почта для связи",
|
|
phone: "Телефон компании",
|
|
telegram: "Telegram компании",
|
|
} as const;
|
|
|
|
type CompanyCardViewProps = {
|
|
card: CandidateCard;
|
|
/** Level of the company name heading inside the surrounding outline. */
|
|
headingLevel?: 3 | 4;
|
|
};
|
|
|
|
/**
|
|
* The card of the organization exactly as a candidate sees it, built from
|
|
* `candidate_card` that the server returns to the owner. It shows no
|
|
* membership, role, account, or verification basis.
|
|
*/
|
|
export function CompanyCardView({ card, headingLevel = 3 }: CompanyCardViewProps) {
|
|
const contacts = (Object.keys(contactLabels) as (keyof typeof contactLabels)[]).flatMap((key) => {
|
|
const value = card.contacts[key];
|
|
return value ? [{ label: contactLabels[key], value }] : [];
|
|
});
|
|
const NameHeading = headingLevel === 3 ? "h3" : "h4";
|
|
const SubHeading = headingLevel === 3 ? "h4" : "h5";
|
|
|
|
return (
|
|
<article className={styles.card} aria-label="Предпросмотр карточки компании">
|
|
<header className={styles.header}>
|
|
<div>
|
|
<NameHeading className={styles.name}>{card.name}</NameHeading>
|
|
<p className={styles.level}>
|
|
<TrustLevel
|
|
level={organizationTrustLevel[card.verification_level]}
|
|
label={candidateCardLevelLabels[card.verification_level]}
|
|
/>
|
|
</p>
|
|
</div>
|
|
{card.sphere ? <p className={styles.sphere}>{card.sphere}</p> : null}
|
|
</header>
|
|
{card.description ? <p className={styles.description}>{card.description}</p> : null}
|
|
{contacts.length > 0 ? (
|
|
<dl className={styles.contacts}>
|
|
{contacts.map(({ label, value }) => (
|
|
<div className={styles.contact} key={label}>
|
|
<dt>{label}</dt>
|
|
<dd>{value}</dd>
|
|
</div>
|
|
))}
|
|
</dl>
|
|
) : null}
|
|
{card.representatives && card.representatives.length > 0 ? (
|
|
<div className={styles.representatives}>
|
|
<SubHeading>Представители компании</SubHeading>
|
|
<ul>
|
|
{card.representatives.map((representative, index) => (
|
|
<li key={`${representative.name}-${index}`}>
|
|
<span>{representative.name}</span>
|
|
<span>{representative.job_title}</span>
|
|
</li>
|
|
))}
|
|
</ul>
|
|
</div>
|
|
) : null}
|
|
</article>
|
|
);
|
|
}
|
|
|
|
export function CandidateCardPreview({ card }: CandidateCardPreviewProps) {
|
|
return (
|
|
<Section
|
|
title="Так карточку увидит кандидат"
|
|
description="Проверьте описание и контакты, которые увидит кандидат."
|
|
>
|
|
<CompanyCardView card={card} />
|
|
</Section>
|
|
);
|
|
}
|