feat(frontend): edit projects and show semantic match evidence
This commit is contained in:
1 parent
5a731c25b7
commit
bc00d6901f
52 files changed
+2992
-111
No files matched your search
@@ -0,0 +1,70 @@
|
||||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
||||
import { renderToString } from "react-dom/server";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type { AnonymousCardContent } from "../../../shared/api/schemas";
|
||||
import { matchCardQueryKeys } from "../api/card";
|
||||
import { CandidateCardDetails } from "./candidate-card-details";
|
||||
|
||||
const accountId = "11111111-1111-4111-8111-111111111111";
|
||||
const organizationId = "22222222-2222-4222-8222-222222222222";
|
||||
const handle = "cv1_AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
|
||||
|
||||
const card: AnonymousCardContent = {
|
||||
pseudonym: handle,
|
||||
categories: null,
|
||||
stack: ["go"],
|
||||
self_assessment: null,
|
||||
experience_band: "3_6",
|
||||
work_formats: null,
|
||||
salary_compatibility: null,
|
||||
projects: [
|
||||
{
|
||||
title: "Платежный шлюз",
|
||||
description: "Проводки и сверки.\nВыплаты по расписанию.",
|
||||
stack: ["Go", "PostgreSQL"],
|
||||
repository_verified: true,
|
||||
},
|
||||
{ title: "Каталог", description: null, stack: [], repository_verified: false },
|
||||
],
|
||||
};
|
||||
|
||||
function render(content: AnonymousCardContent): string {
|
||||
const client = new QueryClient();
|
||||
client.setQueryData(matchCardQueryKeys.card(accountId, organizationId, handle), content);
|
||||
return renderToString(
|
||||
<QueryClientProvider client={client}>
|
||||
<CandidateCardDetails
|
||||
id="card-panel"
|
||||
accountId={accountId}
|
||||
organizationId={organizationId}
|
||||
candidateHandle={handle}
|
||||
open
|
||||
/>
|
||||
</QueryClientProvider>,
|
||||
).replaceAll("<!-- -->", "");
|
||||
}
|
||||
|
||||
describe("candidate card details", () => {
|
||||
it("lists the published projects with tags and a badge for a verified repository", () => {
|
||||
const html = render(card);
|
||||
|
||||
expect(html).toContain(">Проекты</h6>");
|
||||
expect(html).toContain("Платежный шлюз");
|
||||
expect(html).toContain("Выплаты по расписанию.");
|
||||
expect(html).toContain(">PostgreSQL<");
|
||||
expect(html.match(/Подтвержден публичным репозиторием/g)).toHaveLength(1);
|
||||
expect(html).toContain("Каталог");
|
||||
});
|
||||
|
||||
it("shows no address or link of a repository", () => {
|
||||
const html = render(card);
|
||||
|
||||
expect(html).not.toContain("github");
|
||||
expect(html).not.toMatch(/href="https?:/);
|
||||
});
|
||||
|
||||
it("shows no projects block while the card carries none", () => {
|
||||
expect(render({ ...card, projects: null })).not.toContain(">Проекты</h6>");
|
||||
expect(render({ ...card, projects: [] })).not.toContain(">Проекты</h6>");
|
||||
});
|
||||
});
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
ForbiddenState,
|
||||
isAccessDenied,
|
||||
LoadingState,
|
||||
PublishedProjects,
|
||||
StatusView,
|
||||
TrustLevel,
|
||||
} from "../../../shared/ui";
|
||||
@@ -155,6 +156,12 @@ export function CandidateCardDetails({
|
||||
<dt>Зарплатные ожидания</dt>
|
||||
<dd>{details.salaryCompatibility ?? "Нет значения в карточке"}</dd>
|
||||
</dl>
|
||||
{details.projects && details.projects.length > 0 ? (
|
||||
<section aria-label="Проекты кандидата">
|
||||
<h6 className={styles.subtitle}>Проекты</h6>
|
||||
<PublishedProjects projects={details.projects} />
|
||||
</section>
|
||||
) : null}
|
||||
{hasCategories ? (
|
||||
<section aria-label="Подтверждающие факты оценки">
|
||||
<h6 className={styles.subtitle}>Подтверждающие факты оценки</h6>
|
||||
|
||||
@@ -223,3 +223,72 @@
|
||||
flex: 1 1 100%;
|
||||
}
|
||||
}
|
||||
|
||||
/* "Matches by meaning": a requirement of the need, an arrow, the card item
|
||||
* that matched it, and the similarity band as a tag. The words carry the
|
||||
* meaning; the arrow only repeats the direction. */
|
||||
.semantic {
|
||||
display: grid;
|
||||
gap: var(--space-2);
|
||||
min-width: 0;
|
||||
padding-block-start: var(--space-2);
|
||||
border-block-start: var(--line-thin) solid var(--color-divider);
|
||||
}
|
||||
|
||||
.semantic-title {
|
||||
margin: 0;
|
||||
color: var(--color-text-secondary);
|
||||
font-size: var(--font-size-xs);
|
||||
font-weight: var(--font-weight-medium);
|
||||
letter-spacing: var(--letter-spacing-label);
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.semantic-list {
|
||||
display: grid;
|
||||
gap: var(--space-3);
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.semantic-list li {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
gap: var(--space-1) var(--space-3);
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.semantic-side {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0 var(--space-2);
|
||||
align-items: baseline;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.semantic-side .caption {
|
||||
flex: none;
|
||||
}
|
||||
|
||||
.semantic-text {
|
||||
min-width: 0;
|
||||
color: var(--color-text);
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.semantic-arrow {
|
||||
color: var(--color-text-secondary);
|
||||
}
|
||||
|
||||
.semantic-badge,
|
||||
.semantic-band {
|
||||
display: inline-flex;
|
||||
}
|
||||
|
||||
@media (width >= 48rem) {
|
||||
.semantic-list li {
|
||||
grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto;
|
||||
align-items: baseline;
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ import type { ReactNode } from "react";
|
||||
import type { MatchSearchStackTag } from "../../../shared/api/schemas";
|
||||
import { Card, Mono, Tag, TrustLevel, VisuallyHidden } from "../../../shared/ui";
|
||||
import type { MatchCardModel } from "../model/adapter";
|
||||
import { evidenceRows, type EvidenceRow } from "../model/explanation";
|
||||
import { evidenceRows, semanticBlock, type EvidenceRow } from "../model/explanation";
|
||||
import {
|
||||
experienceBandLabels,
|
||||
gradeLabels,
|
||||
@@ -61,6 +61,7 @@ export function MatchCardView({
|
||||
const confirmed = card.confirmationStatus === "confirmed";
|
||||
const context = card.publicContext;
|
||||
const sources = evidenceRows(card);
|
||||
const semantic = semanticBlock(card);
|
||||
const shortSpecialization = specializationShortLabels[card.specialization];
|
||||
const compatibility = context.salaryCompatibility;
|
||||
|
||||
@@ -180,6 +181,47 @@ export function MatchCardView({
|
||||
) : (
|
||||
<p className={styles.unknown}>Сервер не вернул пояснений по источникам.</p>
|
||||
)}
|
||||
{semantic ? (
|
||||
<div className={styles.semantic}>
|
||||
<h6 id={`${headingId}-semantic`} className={styles["semantic-title"]}>
|
||||
Совпадения по смыслу
|
||||
</h6>
|
||||
{semantic.kind === "evidence" ? (
|
||||
<ul className={styles["semantic-list"]} aria-labelledby={`${headingId}-semantic`}>
|
||||
{semantic.rows.map((row) => (
|
||||
<li key={row.key} data-similarity={row.similarity}>
|
||||
<span className={styles["semantic-side"]}>
|
||||
<span className={styles.caption}>{row.requirementLabel}</span>
|
||||
<span className={styles["semantic-text"]}>{row.requirementText}</span>
|
||||
</span>
|
||||
<span className={styles["semantic-arrow"]} aria-hidden="true">
|
||||
→
|
||||
</span>
|
||||
<VisuallyHidden>совпало с:</VisuallyHidden>
|
||||
<span className={styles["semantic-side"]}>
|
||||
<span className={styles.caption}>{row.itemKindLabel}</span>
|
||||
<span className={styles["semantic-text"]}>{row.itemLabel}</span>
|
||||
{row.repositoryVerified ? (
|
||||
<span className={styles["semantic-badge"]}>
|
||||
<Tag tone="success" dot>
|
||||
Публичный репозиторий
|
||||
</Tag>
|
||||
</span>
|
||||
) : null}
|
||||
</span>
|
||||
<span className={styles["semantic-band"]}>
|
||||
<Tag tone={row.similarity === "high" ? "accent" : "neutral"}>
|
||||
{row.similarityLabel}
|
||||
</Tag>
|
||||
</span>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
) : (
|
||||
<p className={styles.unknown}>Совпадения по смыслу: {semantic.text}.</p>
|
||||
)}
|
||||
</div>
|
||||
) : null}
|
||||
</Card>
|
||||
</div>
|
||||
{actions ? <div className={styles.actions}>{actions}</div> : null}
|
||||
|
||||
Reference in new issue
Block a user