feat(frontend): redesign the candidate cabinet with step-by-step profile and questionnaire forms

This commit is contained in:
shira committed 2026-10-10 09:50:27 +03:00
1 parent 15590d127c
commit c836d02ea3
77 files changed
+5409 -1618

No files matched your search

@@ -1,7 +1,7 @@
import type { Ref } from "react";
import type { AssessmentResult } from "../../../shared/api/schemas";
import { paths } from "../../../shared/config/paths";
import { TextLink } from "../../../shared/ui";
import { Mono, TextLink } from "../../../shared/ui";
import { describeAssessmentResult } from "../../../entities/assessment";
import styles from "./assessment-history.module.css";
@@ -23,7 +23,9 @@ export function AssessmentHistoryList({ items, timeZone, listRef }: AssessmentHi
const view = describeAssessmentResult(item, timeZone ? { timeZone } : {});
return (
<li key={item.attempt_id} className={styles.item}>
<p className={styles.kind}>{view.kindLabel}</p>
<p className={styles.kind}>
{view.kindLabel} · <Mono>{view.decidedDay}</Mono>
</p>
<h2 className={styles.title}>{view.title}</h2>
<p className={styles.summary}>{view.summary.text}</p>
<dl className={styles.facts}>
@@ -10,22 +10,60 @@
font-size: var(--font-size-s);
}
/* A timeline: the results hang on a circuit trace, newest first. */
.list {
position: relative;
display: grid;
gap: var(--space-4);
margin: 0;
padding: 0;
padding: 0 0 0 var(--space-5);
list-style: none;
}
.list::before {
position: absolute;
top: var(--space-5);
bottom: var(--space-5);
left: 0.25rem;
width: var(--line-thin);
content: "";
background: var(--color-divider);
}
.item {
position: relative;
display: grid;
gap: var(--space-3);
min-width: 0;
padding: var(--space-4);
padding: var(--space-5);
border: var(--line-thin) solid var(--color-divider);
border-radius: var(--radius-m);
background: var(--color-surface);
transition: border-color var(--duration-fast) var(--easing-standard);
}
.item:hover {
border-color: var(--color-border-hover);
}
.item::before {
position: absolute;
top: var(--space-5);
left: calc(-1 * var(--space-5) + 0.25rem - 0.25rem + 0.5px);
width: 0.5rem;
height: 0.5rem;
border: var(--line-thin) solid var(--color-accent);
border-radius: 50%;
content: "";
background: var(--color-canvas);
}
.item:first-child::before {
background: var(--color-accent);
}
.more {
display: flex;
}
.item p {
@@ -35,6 +73,7 @@
.kind {
color: var(--color-text-secondary);
font-family: var(--font-mono);
font-size: var(--font-size-xs);
letter-spacing: var(--letter-spacing-label);
text-transform: uppercase;
@@ -42,6 +81,7 @@
.title {
margin: 0;
color: var(--color-text-strong);
font-size: var(--font-size-l);
line-height: var(--line-height-snug);
overflow-wrap: anywhere;
@@ -76,7 +116,7 @@
@media (width < 42rem) {
.item {
padding: var(--space-3);
padding: var(--space-4);
}
}
@@ -9,6 +9,7 @@ import {
ErrorState,
ForbiddenState,
LoadingState,
Skeleton,
} from "../../../shared/ui";
import {
isAssessmentAccessLoss,
@@ -79,7 +80,14 @@ export function AssessmentHistory({ actor, queryClient }: AssessmentHistoryProps
/>
);
}
if (history.isPending) return <LoadingState label="Загружаем историю результатов..." />;
if (history.isPending) {
return (
<div className={styles.root}>
<LoadingState label="Загружаем историю результатов..." />
<Skeleton shape="card" lines={3} />
</div>
);
}
if (history.isError && !history.data) {
return (
<ErrorState
@@ -128,13 +136,15 @@ export function AssessmentHistory({ actor, queryClient }: AssessmentHistoryProps
onRetry={() => void loadMore()}
/>
) : history.hasNextPage ? (
<Button
variant="secondary"
isBusy={history.isFetchingNextPage}
onClick={() => void loadMore()}
>
{history.isFetchingNextPage ? "Загружаем..." : "Показать еще"}
</Button>
<div className={styles.more}>
<Button
variant="secondary"
isBusy={history.isFetchingNextPage}
onClick={() => void loadMore()}
>
{history.isFetchingNextPage ? "Загружаем..." : "Показать еще"}
</Button>
</div>
) : null}
</div>
);
@@ -3,32 +3,55 @@
gap: var(--space-6);
}
/* The next step is the one dominant block of the home screen. */
/* The next step is the one dominant block of the home screen: a panel with
* the circuit trace drawn behind its right half. */
.card {
display: grid;
gap: var(--space-3);
padding: var(--space-5);
border: var(--line-strong) solid var(--color-border-strong);
border-radius: var(--radius-l);
background: var(--color-surface);
position: relative;
overflow: hidden;
isolation: isolate;
}
.decor {
position: absolute;
z-index: -1;
top: 50%;
right: calc(-1 * var(--space-6));
width: min(28rem, 70%);
height: auto;
opacity: 0.55;
transform: translateY(-50%);
}
@media (width < 48rem) {
.decor {
top: auto;
bottom: calc(-1 * var(--space-6));
opacity: 0.3;
transform: none;
}
}
.card-eyebrow {
color: var(--color-accent);
font-family: var(--font-mono);
font-size: var(--font-size-xs);
font-weight: var(--font-weight-bold);
font-weight: var(--font-weight-medium);
letter-spacing: var(--letter-spacing-label);
text-transform: uppercase;
}
.card-title {
font-size: var(--font-size-xl);
font-weight: var(--font-weight-bold);
line-height: var(--line-height-snug);
max-width: 36rem;
color: var(--color-text-strong);
font-size: var(--font-size-title);
font-weight: var(--font-weight-medium);
letter-spacing: var(--letter-spacing-display);
line-height: 1.2;
}
.card-text {
max-width: 44rem;
max-width: 40rem;
color: var(--color-text);
font-size: var(--font-size-m);
line-height: var(--line-height-body);
}
@@ -68,19 +91,26 @@
list-style: none;
}
.standing,
.link {
display: flex;
flex-wrap: wrap;
gap: var(--space-2) var(--space-4);
align-items: center;
justify-content: space-between;
min-width: 0;
padding: var(--space-4);
padding: var(--space-3) var(--space-4);
border: var(--line-thin) solid var(--color-divider);
border-radius: var(--radius-m);
background: var(--color-surface);
transition: border-color var(--duration-fast) var(--easing-standard);
}
.link:hover {
border-color: var(--color-border-hover);
}
.standing-title {
margin-bottom: var(--space-3);
font-size: var(--font-size-m);
font-weight: var(--font-weight-bold);
}
.facts {
@@ -108,16 +138,10 @@
overflow-wrap: anywhere;
}
.link {
display: flex;
flex-wrap: wrap;
gap: var(--space-2) var(--space-4);
align-items: center;
justify-content: space-between;
}
.link-label {
font-weight: var(--font-weight-bold);
color: var(--color-text-strong);
font-family: var(--font-mono);
font-weight: var(--font-weight-medium);
}
.link-status {
@@ -11,12 +11,16 @@ import { useGetCurrentSession } from "../../../shared/api/endpoints/identity/ide
import { paths } from "../../../shared/config";
import {
ButtonLink,
Card,
CircuitTrace,
EmptyState,
ErrorState,
ForbiddenState,
isAccessDenied,
LoadingState,
Section,
Skeleton,
Tag,
TextLink,
TrustLevel,
} from "../../../shared/ui";
@@ -109,7 +113,8 @@ function NextStepCard({ journey }: { journey: CandidateJourney }) {
// produced a result, showing "consents" would contradict the result blocks.
const showSavedStep = !journey.hasResults;
return (
<section className={styles.card} aria-labelledby="next-step-title">
<Card as="section" tone="panel" labelledBy="next-step-title" className={styles.card}>
<CircuitTrace className={styles.decor} />
<p className={styles["card-eyebrow"]}>Следующий шаг</p>
<h2 id="next-step-title" className={styles["card-title"]}>
{view.title}
@@ -135,7 +140,7 @@ function NextStepCard({ journey }: { journey: CandidateJourney }) {
: null}
</p>
) : null}
</section>
</Card>
);
}
@@ -155,34 +160,40 @@ function Standings({ journey }: { journey: CandidateJourney }) {
) : (
<ul className={styles.standings}>
{journey.standings.map((standing) => (
<li key={standing.specialization} className={styles.standing}>
<h3 className={styles["standing-title"]}>
{specializationLabels[standing.specialization]}
</h3>
<dl className={styles.facts}>
<dt>Заявлено (самооценка)</dt>
<dd>
<TrustLevel
level="claimed"
label={
standing.declaredGrade
? `Заявлено: ${gradeLabels[standing.declaredGrade]}`
: "Уровень не указан"
}
/>
</dd>
<dt>Подтвержденная категория</dt>
<dd>
{standing.confirmedGrade ? (
<li key={standing.specialization}>
<Card tone="raised" labelledBy={`standing-${standing.specialization}`}>
<h3 id={`standing-${standing.specialization}`} className={styles["standing-title"]}>
<Tag tone="grade">
{standing.confirmedGrade
? `${specializationLabels[standing.specialization]} · ${gradeLabels[standing.confirmedGrade]}`
: specializationLabels[standing.specialization]}
</Tag>
</h3>
<dl className={styles.facts}>
<dt>Заявлено (самооценка)</dt>
<dd>
<TrustLevel
level="confirmed"
label={`Подтверждено тестом: ${gradeLabels[standing.confirmedGrade]}`}
level="claimed"
label={
standing.declaredGrade
? `Заявлено: ${gradeLabels[standing.declaredGrade]}`
: "Уровень не указан"
}
/>
) : (
<TrustLevel level="none" label="Пока не подтверждена" />
)}
</dd>
</dl>
</dd>
<dt>Подтвержденная категория</dt>
<dd>
{standing.confirmedGrade ? (
<TrustLevel
level="confirmed"
label={`Подтверждено тестом: ${gradeLabels[standing.confirmedGrade]}`}
/>
) : (
<TrustLevel level="none" label="Пока не подтверждена" />
)}
</dd>
</dl>
</Card>
</li>
))}
</ul>
@@ -291,7 +302,12 @@ export function CandidateNextStep() {
);
}
if (state.status === "pending") {
return <LoadingState label="Определяем следующий шаг..." />;
return (
<div className={styles.root}>
<LoadingState label="Определяем следующий шаг..." />
<Skeleton shape="card" lines={3} />
</div>
);
}
if (state.status === "error") {
if (isAccessDenied(state.error)) return <ForbiddenState error={state.error} />;
@@ -100,3 +100,23 @@
padding: 0;
}
}
/* A strip that hides tabs fades at that edge, so the cut tab reads as "more
* to scroll". The fade is a mask, so the strip keeps its own background. */
.list[data-fade-end] {
mask-image: linear-gradient(to right, #000 calc(100% - 3rem), transparent);
}
.list[data-fade-start] {
mask-image: linear-gradient(to left, #000 calc(100% - 3rem), transparent);
}
.list[data-fade-start][data-fade-end] {
mask-image: linear-gradient(
to right,
transparent,
#000 3rem,
#000 calc(100% - 3rem),
transparent
);
}
@@ -1,4 +1,4 @@
import { useEffect, useRef } from "react";
import { useEffect, useRef, useState, type RefObject } from "react";
import { Outlet, useLocation } from "react-router-dom";
import { paths } from "../../../shared/config";
import { HeaderPlate, MainRegion, NavItem, SkipLink, Wordmark } from "../../../shared/ui";
@@ -13,7 +13,7 @@ const navigation = [
{ to: paths.candidate.invitations, label: "Приглашения", end: false },
{ to: paths.candidate.notifications, label: "Уведомления", end: false },
{ to: paths.candidate.privacy, label: "Приватность", end: false },
{ to: paths.support, label: "Поддержка", end: false },
{ to: paths.candidate.supportCases, label: "Поддержка", end: false },
] as const;
/**
@@ -35,6 +35,38 @@ function useCurrentTabInView() {
return listRef;
}
type ScrollEdges = { start: boolean; end: boolean };
/**
* Whether the tab strip hides tabs before or after the visible part. The
* shell fades that edge, so a cut tab reads as "scroll for more".
*/
function useScrollEdges(listRef: RefObject<HTMLUListElement | null>): ScrollEdges {
const [edges, setEdges] = useState<ScrollEdges>({ start: false, end: false });
useEffect(() => {
const list = listRef.current;
if (!list) return;
const update = () => {
const start = list.scrollLeft > 1;
const end = list.scrollLeft + list.clientWidth < list.scrollWidth - 1;
setEdges((current) =>
current.start === start && current.end === end ? current : { start, end },
);
};
update();
list.addEventListener("scroll", update, { passive: true });
const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(update);
observer?.observe(list);
return () => {
list.removeEventListener("scroll", update);
observer?.disconnect();
};
}, [listRef]);
return edges;
}
/**
* Candidate cabinet layout, designed for phones first. On a phone the
* section tabs form a bar at the bottom of the screen, within thumb reach;
@@ -43,6 +75,7 @@ function useCurrentTabInView() {
*/
export function CandidateShell() {
const listRef = useCurrentTabInView();
const edges = useScrollEdges(listRef);
return (
<div className={styles.shell}>
@@ -51,7 +84,12 @@ export function CandidateShell() {
<HeaderPlate className={styles.plate}>
<Wordmark to={paths.candidate.root} context="Кабинет кандидата" />
<nav className={styles.nav} aria-label="Разделы кабинета кандидата">
<ul ref={listRef} className={styles.list}>
<ul
ref={listRef}
className={styles.list}
data-fade-start={edges.start || undefined}
data-fade-end={edges.end || undefined}
>
{navigation.map((item) => (
<li key={item.to}>
<NavItem to={item.to} end={item.end}>