feat(assessment): add the review band of attempt signals and the disclosed collector

This commit is contained in:
shira committed 2026-10-08 23:04:57 +03:00
1 parent 68286af8b7
commit b3c6dc870b
124 files changed
+13522 -633

No files matched your search

@@ -0,0 +1,149 @@
import { useEffect, useRef } from "react";
import { Button } from "../../../shared/ui";
import {
browserSignals,
notCollected,
serverSignals,
type DisclosedSignal,
} from "../model/notice-content";
import styles from "./signal-notice.module.css";
type ContentProps = { headingLevel: "h3" | "h4" };
function SignalList({ signals }: { signals: readonly DisclosedSignal[] }) {
return (
<ul>
{signals.map((signal) => (
<li key={signal.code}>
<strong>{signal.title}.</strong> {signal.detail}
</li>
))}
</ul>
);
}
/**
* The disclosed list, shared by the page summary and the confirmation dialog.
* The heading level follows the heading that precedes it in each place.
*/
export function SignalNoticeContent({ headingLevel }: ContentProps) {
const Heading = headingLevel;
return (
<div className={styles.content}>
<p>
Во время полной проверки собираются технические сигналы. Они помогают назначить ручную
перепроверку и сами по себе не меняют результат, категорию и квоты.
</p>
<Heading>Что фиксирует браузер</Heading>
<p>События сохраняются, только пока действует согласие C3.</p>
<SignalList signals={browserSignals} />
<Heading>Что измеряет сервер</Heading>
<SignalList signals={serverSignals} />
<Heading>Что не собирается</Heading>
<ul>
{notCollected.map((item) => (
<li key={item}>{item}</li>
))}
</ul>
<p>
Адреса и токены сессий не хранятся: для них есть только односторонние отпечатки. Во время
теста сбор ничего не показывает и не блокирует: ввод, вставка и отправка ответов работают
как обычно. Браузерные сигналы легко исказить, а ложные срабатывания возможны, например при
случайном переключении окна, поэтому это только подсказка. Демонстрационный запуск сигналы
не собирает.
</p>
<p>
Подтверждение хранится на сервере. Оно не заменяет согласие C3, которое управляется отдельно
на странице приватности.
</p>
</div>
);
}
/** Always visible description on the screen where the attempt is started. */
export function SignalNoticeSummary() {
return (
<aside className={styles.summary} aria-labelledby="assessment-signals-title">
<h3 id="assessment-signals-title">Какие данные фиксируются во время проверки</h3>
<SignalNoticeContent headingLevel="h4" />
</aside>
);
}
export type SignalNoticeDialogProps = {
open: boolean;
busy: boolean;
errorMessage: string | null;
onConfirm: () => void;
onClose: () => void;
};
/**
* Modal notice shown before a real attempt starts. It is a native dialog, so
* the browser traps focus inside, closes it with Escape, and returns focus to
* the control that opened it. Closing never confirms anything.
*/
export function SignalNoticeDialog({
open,
busy,
errorMessage,
onConfirm,
onClose,
}: SignalNoticeDialogProps) {
const dialogRef = useRef<HTMLDialogElement>(null);
useEffect(() => {
const dialog = dialogRef.current;
if (!dialog) return;
if (open && !dialog.open) {
dialog.showModal();
// Start at the heading so a screen reader reads the notice before any action.
dialog.querySelector<HTMLElement>("#signal-notice-title")?.focus();
}
if (!open && dialog.open) dialog.close();
}, [open]);
return (
<dialog
ref={dialogRef}
className={styles.dialog}
aria-labelledby="signal-notice-title"
onCancel={(event) => {
// A request in flight finishes first, so a closed notice never hides a stored confirmation.
if (busy) event.preventDefault();
}}
onClose={() => {
// A second Escape can close the dialog even though the first was refused.
// While the confirmation is being saved the dialog stays modal.
const dialog = dialogRef.current;
if (busy && dialog && !dialog.open) {
dialog.showModal();
return;
}
onClose();
}}
>
{open ? (
<>
<h2 id="signal-notice-title" tabIndex={-1} className={styles.title}>
Перед началом: какие сигналы собираются
</h2>
<SignalNoticeContent headingLevel="h3" />
{errorMessage ? (
<p className={styles.error} role="alert">
{errorMessage}
</p>
) : null}
<div className={styles.actions}>
<Button isBusy={busy} onClick={onConfirm}>
{busy ? "Сохраняем подтверждение..." : "Подтверждаю ознакомление и начинаю"}
</Button>
<Button variant="secondary" disabled={busy} onClick={onClose}>
Закрыть без подтверждения
</Button>
</div>
</>
) : null}
</dialog>
);
}