feat(invitations): add the invitation compose screen with a candidate-side preview
This commit is contained in:
1 parent
1a067221f7
commit
cb08f212cc
35 files changed
+4170
-67
No files matched your search
@@ -0,0 +1,4 @@
|
||||
// Public API of the invitation-preview widget: the company card and the
|
||||
// terms of an invitation as the candidate sees them.
|
||||
|
||||
export { InvitationPreview } from "./ui/invitation-preview";
|
||||
@@ -0,0 +1,97 @@
|
||||
.root {
|
||||
display: grid;
|
||||
gap: var(--space-4);
|
||||
min-width: 0;
|
||||
padding: var(--space-4);
|
||||
border: var(--line-strong) solid var(--color-accent);
|
||||
border-radius: var(--radius-m);
|
||||
background: var(--color-canvas);
|
||||
}
|
||||
|
||||
.heading {
|
||||
display: grid;
|
||||
gap: var(--space-2);
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: var(--font-size-l);
|
||||
font-weight: var(--font-weight-bold);
|
||||
}
|
||||
|
||||
.hint {
|
||||
margin: 0;
|
||||
color: var(--color-text-secondary);
|
||||
line-height: var(--line-height-body);
|
||||
}
|
||||
|
||||
.company {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.terms {
|
||||
display: grid;
|
||||
gap: var(--space-4);
|
||||
min-width: 0;
|
||||
padding: var(--space-4);
|
||||
border: var(--line-thin) solid var(--color-divider);
|
||||
border-radius: var(--radius-m);
|
||||
background: var(--color-surface);
|
||||
}
|
||||
|
||||
.role {
|
||||
overflow-wrap: anywhere;
|
||||
font-size: var(--font-size-l);
|
||||
font-weight: var(--font-weight-bold);
|
||||
}
|
||||
|
||||
.facts,
|
||||
.package {
|
||||
display: grid;
|
||||
gap: var(--space-3);
|
||||
min-width: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.fact {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(9rem, 14rem) minmax(0, 1fr);
|
||||
gap: var(--space-1) var(--space-4);
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.fact > dt {
|
||||
color: var(--color-text-secondary);
|
||||
}
|
||||
|
||||
.fact > dd {
|
||||
min-width: 0;
|
||||
margin: 0;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.package .fact {
|
||||
grid-template-columns: minmax(7rem, 10rem) minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.multiline {
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
.list {
|
||||
display: grid;
|
||||
gap: var(--space-1);
|
||||
margin: 0;
|
||||
padding-left: var(--space-5);
|
||||
}
|
||||
|
||||
@media (width < 36rem) {
|
||||
.root,
|
||||
.terms {
|
||||
padding: var(--space-3);
|
||||
}
|
||||
|
||||
.fact,
|
||||
.package .fact {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
import { renderToStaticMarkup } from "react-dom/server";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type { CandidateOrganizationCard, InvitationTerms } from "../../../shared/api/schemas";
|
||||
import { InvitationPreview } from "./invitation-preview";
|
||||
|
||||
const card: CandidateOrganizationCard = {
|
||||
id: "0199b4f2-7c1e-7d3a-9f00-aabbccddee01",
|
||||
name: "Северный ветер",
|
||||
description: "Платежная инфраструктура для малого бизнеса",
|
||||
sphere: "Финтех",
|
||||
contacts: { website: "https://north.example", email: null, phone: null, telegram: null },
|
||||
verification_level: "e0",
|
||||
};
|
||||
|
||||
const terms: InvitationTerms = {
|
||||
role_title: "Middle Go-разработчик",
|
||||
specialization: "backend",
|
||||
grade: "middle",
|
||||
offer_type: "full_time",
|
||||
tasks: ["Развивать сервис выплат", "Перевести отчеты на события"],
|
||||
team: "Пять бэкенд-разработчиков\nи QA-инженер",
|
||||
tech_stack: ["Go", "PostgreSQL"],
|
||||
work_formats: ["remote", "hybrid"],
|
||||
location: "Москва",
|
||||
communication_method: { channel: "video_call", details: "Созвон с тимлидом" },
|
||||
salary: {
|
||||
salary_from: 100000,
|
||||
salary_to: 140000,
|
||||
currency: "RUB",
|
||||
period: "month",
|
||||
tax_basis: "net",
|
||||
},
|
||||
package: {
|
||||
bonus: { status: "provided", description: "Квартальная премия до 20%" },
|
||||
equipment: { status: "provided", description: "Ноутбук и монитор" },
|
||||
training: { status: "not_provided" },
|
||||
health_insurance: { status: "not_provided" },
|
||||
},
|
||||
};
|
||||
|
||||
const text = (html: string) => html.replace(/<[^>]+>/g, " ").replace(/\s+/g, " ");
|
||||
|
||||
describe("invitation preview", () => {
|
||||
it("shows the company card and every term as the candidate sees them", () => {
|
||||
const html = renderToStaticMarkup(
|
||||
<InvitationPreview
|
||||
card={card}
|
||||
terms={terms}
|
||||
responsePeriodDays={7}
|
||||
responseDeadlineAt={null}
|
||||
/>,
|
||||
);
|
||||
const content = text(html);
|
||||
|
||||
for (const value of [
|
||||
"Северный ветер",
|
||||
"Платежная инфраструктура для малого бизнеса",
|
||||
"Уровень E0",
|
||||
"Middle Go-разработчик",
|
||||
"Backend, Middle",
|
||||
"Полная занятость",
|
||||
"Развивать сервис выплат",
|
||||
"Перевести отчеты на события",
|
||||
"Go, PostgreSQL",
|
||||
"Удаленно, Гибридно",
|
||||
"Москва",
|
||||
"Видеозвонок. Созвон с тимлидом",
|
||||
"Квартальная премия до 20%",
|
||||
"Ноутбук и монитор",
|
||||
"7 дней с момента доставки",
|
||||
]) {
|
||||
expect(content).toContain(value);
|
||||
}
|
||||
expect(content).toMatch(/от 100\s000 ₽ до 140\s000 ₽ в месяц, после налога \(net\)/);
|
||||
expect(html.match(/Не предусмотрено/g)).toHaveLength(2);
|
||||
expect(html).toContain('data-package="training"');
|
||||
expect(html).not.toContain("<time");
|
||||
});
|
||||
|
||||
it("shows the server deadline of a sent invitation and a fallback without the card", () => {
|
||||
const html = renderToStaticMarkup(
|
||||
<InvitationPreview
|
||||
card={null}
|
||||
cardFallback={<p>Карточка недоступна</p>}
|
||||
terms={{ ...terms, location: null, work_formats: ["remote"] }}
|
||||
responsePeriodDays={7}
|
||||
responseDeadlineAt="2026-10-16T10:00:00Z"
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(html).toContain("Карточка недоступна");
|
||||
expect(html).toContain('<time dateTime="2026-10-16T10:00:00Z">16 октября 2026');
|
||||
expect(html).toContain("10:00 UTC</time>");
|
||||
expect(text(html)).toContain("Не требуется: только удаленная работа");
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,146 @@
|
||||
import type { ReactNode } from "react";
|
||||
import type { CandidateOrganizationCard, InvitationTerms } from "../../../shared/api/schemas";
|
||||
import { CompanyCardView } from "../../../entities/company";
|
||||
import {
|
||||
communicationChannelLabels,
|
||||
formatSalaryRange,
|
||||
formatServerMoment,
|
||||
notProvidedLabel,
|
||||
offerTypeLabels,
|
||||
packageItemKeys,
|
||||
packageItemLabels,
|
||||
responsePeriodLabel,
|
||||
} from "../../../entities/invitation";
|
||||
import { gradeLabels, specializationLabels, workFormatLabels } from "../../../entities/match";
|
||||
import styles from "./invitation-preview.module.css";
|
||||
|
||||
type InvitationPreviewProps = {
|
||||
/** The company card as the candidate sees it, or null while it is unavailable. */
|
||||
card: CandidateOrganizationCard | null;
|
||||
/** What to show instead of the card, for example a loading or error state. */
|
||||
cardFallback?: ReactNode;
|
||||
terms: InvitationTerms;
|
||||
responsePeriodDays: number;
|
||||
/** The server deadline once the invitation is delivered; null for an unsent draft. */
|
||||
responseDeadlineAt: string | null;
|
||||
title?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* The invitation through the eyes of the candidate: the company card and
|
||||
* every term, each condition of the package shown either with its
|
||||
* description or as explicitly not provided. It renders data only and sends
|
||||
* nothing; the same view serves the preview of a draft and a sent invitation.
|
||||
*/
|
||||
export function InvitationPreview({
|
||||
card,
|
||||
cardFallback,
|
||||
terms,
|
||||
responsePeriodDays,
|
||||
responseDeadlineAt,
|
||||
title = "Так приглашение увидит кандидат",
|
||||
}: InvitationPreviewProps) {
|
||||
const location =
|
||||
terms.location ??
|
||||
(terms.work_formats.every((format) => format === "remote")
|
||||
? "Не требуется: только удаленная работа"
|
||||
: "Не указано");
|
||||
|
||||
return (
|
||||
<div className={styles.root}>
|
||||
<div className={styles.heading}>
|
||||
<h3 className={styles.title}>{title}</h3>
|
||||
<p className={styles.hint}>
|
||||
Кандидат видит карточку компании и все условия до решения. Контакты кандидата компания
|
||||
получит только после принятия приглашения.
|
||||
</p>
|
||||
</div>
|
||||
<section className={styles.company} aria-label="Компания">
|
||||
{card ? <CompanyCardView card={card} headingLevel={4} /> : cardFallback}
|
||||
</section>
|
||||
<article className={styles.terms} aria-label="Условия приглашения">
|
||||
<h4 className={styles.role}>{terms.role_title}</h4>
|
||||
<dl className={styles.facts}>
|
||||
<div className={styles.fact}>
|
||||
<dt>Специализация и грейд</dt>
|
||||
<dd>{`${specializationLabels[terms.specialization]}, ${gradeLabels[terms.grade]}`}</dd>
|
||||
</div>
|
||||
<div className={styles.fact}>
|
||||
<dt>Тип предложения</dt>
|
||||
<dd>{offerTypeLabels[terms.offer_type]}</dd>
|
||||
</div>
|
||||
<div className={styles.fact}>
|
||||
<dt>Задачи</dt>
|
||||
<dd>
|
||||
<ul className={styles.list}>
|
||||
{terms.tasks.map((task, index) => (
|
||||
<li key={`${index}-${task}`}>{task}</li>
|
||||
))}
|
||||
</ul>
|
||||
</dd>
|
||||
</div>
|
||||
<div className={styles.fact}>
|
||||
<dt>Команда</dt>
|
||||
<dd className={styles.multiline}>{terms.team}</dd>
|
||||
</div>
|
||||
<div className={styles.fact}>
|
||||
<dt>Технологии</dt>
|
||||
<dd>{terms.tech_stack.join(", ")}</dd>
|
||||
</div>
|
||||
<div className={styles.fact}>
|
||||
<dt>Формат работы</dt>
|
||||
<dd>{terms.work_formats.map((format) => workFormatLabels[format]).join(", ")}</dd>
|
||||
</div>
|
||||
<div className={styles.fact}>
|
||||
<dt>Место работы</dt>
|
||||
<dd>{location}</dd>
|
||||
</div>
|
||||
<div className={styles.fact}>
|
||||
<dt>Зарплатная вилка</dt>
|
||||
<dd data-term="salary">{formatSalaryRange(terms.salary)}</dd>
|
||||
</div>
|
||||
<div className={styles.fact}>
|
||||
<dt>Способ связи после принятия</dt>
|
||||
<dd data-term="communication">
|
||||
{communicationChannelLabels[terms.communication_method.channel]}
|
||||
{terms.communication_method.details
|
||||
? `. ${terms.communication_method.details}`
|
||||
: null}
|
||||
</dd>
|
||||
</div>
|
||||
<div className={styles.fact}>
|
||||
<dt>Пакет</dt>
|
||||
<dd>
|
||||
<dl className={styles.package}>
|
||||
{packageItemKeys.map((key) => {
|
||||
const item = terms.package[key];
|
||||
return (
|
||||
<div key={key} className={styles.fact} data-package={key}>
|
||||
<dt>{packageItemLabels[key]}</dt>
|
||||
<dd>{item.status === "provided" ? item.description : notProvidedLabel}</dd>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</dl>
|
||||
</dd>
|
||||
</div>
|
||||
<div className={styles.fact}>
|
||||
<dt>Срок ответа</dt>
|
||||
<dd>
|
||||
{responseDeadlineAt ? (
|
||||
<>
|
||||
{"До "}
|
||||
<time dateTime={responseDeadlineAt}>
|
||||
{formatServerMoment(responseDeadlineAt)}
|
||||
</time>
|
||||
</>
|
||||
) : (
|
||||
`${responsePeriodLabel(responsePeriodDays)} с момента доставки`
|
||||
)}
|
||||
</dd>
|
||||
</div>
|
||||
</dl>
|
||||
</article>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -71,7 +71,7 @@ describe("match list", () => {
|
||||
|
||||
it("links every entry to the invitation with the organization-scoped handle, also unconfirmed ones", () => {
|
||||
const html = render(matchModelFixture());
|
||||
const links = [...html.matchAll(/href="(\/employer\/invitations\?[^"]+)"/g)].map(
|
||||
const links = [...html.matchAll(/href="(\/employer\/invitations\/new\?[^"]+)"/g)].map(
|
||||
(match) => new URL((match[1] ?? "").replaceAll("&", "&"), "http://x"),
|
||||
);
|
||||
|
||||
|
||||
Reference in new issue
Block a user