feat(frontend): complete candidate flow and public pages
This commit is contained in:
1 parent
a69b1a79bb
commit
e4be4a3956
63 files changed
+1903
-746
No files matched your search
@@ -0,0 +1,93 @@
|
||||
import { useGetCurrentSession } from "../../../shared/api/endpoints/identity/identity";
|
||||
import { paths } from "../../../shared/config";
|
||||
import {
|
||||
buildSteps,
|
||||
Card,
|
||||
ErrorState,
|
||||
ForbiddenState,
|
||||
isAccessDenied,
|
||||
LoadingState,
|
||||
Stepper,
|
||||
TextLink,
|
||||
} from "../../../shared/ui";
|
||||
import { useCandidateJourney } from "../../../entities/candidate";
|
||||
import styles from "./candidate-journey-progress.module.css";
|
||||
|
||||
const journeySteps = [
|
||||
{ id: "profile", label: "Профиль" },
|
||||
{ id: "questionnaire", label: "Анкета" },
|
||||
{ id: "assessment", label: "Тест" },
|
||||
] as const;
|
||||
|
||||
export function CandidateJourneyProgress() {
|
||||
const session = useGetCurrentSession();
|
||||
const state = useCandidateJourney(session.data);
|
||||
|
||||
if (session.isError) {
|
||||
if (isAccessDenied(session.error)) return <ForbiddenState error={session.error} />;
|
||||
return (
|
||||
<ErrorState
|
||||
error={session.error}
|
||||
isRetrying={session.isRefetching}
|
||||
onRetry={() => void session.refetch()}
|
||||
title="Не удалось проверить вход"
|
||||
/>
|
||||
);
|
||||
}
|
||||
if (session.isPending) {
|
||||
return <LoadingState label="Проверяем вход перед загрузкой прогресса..." />;
|
||||
}
|
||||
if (!session.data || session.data.account.scenario !== "candidate") {
|
||||
return (
|
||||
<ForbiddenState
|
||||
title="Прогресс кандидата недоступен"
|
||||
description="Откройте кабинет кандидата, чтобы продолжить заполнение профиля."
|
||||
/>
|
||||
);
|
||||
}
|
||||
if (state.status === "pending") {
|
||||
return <LoadingState label="Загружаем прогресс профиля, анкеты и теста..." />;
|
||||
}
|
||||
if (state.status === "error") {
|
||||
if (isAccessDenied(state.error)) return <ForbiddenState error={state.error} />;
|
||||
return (
|
||||
<ErrorState
|
||||
error={state.error}
|
||||
isRetrying={state.isRetrying}
|
||||
onRetry={state.retry}
|
||||
title="Не удалось загрузить прогресс"
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
const currentIndex =
|
||||
state.journey.nextStep.kind === "profile"
|
||||
? 0
|
||||
: state.journey.nextStep.kind === "questionnaire"
|
||||
? 1
|
||||
: state.journey.nextStep.kind === "result"
|
||||
? journeySteps.length
|
||||
: 2;
|
||||
|
||||
return (
|
||||
<Card as="section" tone="panel" labelledBy="candidate-journey-progress-title">
|
||||
<h2 id="candidate-journey-progress-title" className={styles.title}>
|
||||
Профиль, анкета и тест
|
||||
</h2>
|
||||
<Stepper
|
||||
label="Прогресс заполнения профиля кандидата"
|
||||
steps={buildSteps(journeySteps, currentIndex)}
|
||||
/>
|
||||
<p className={styles.note}>
|
||||
{state.journey.questionnaireSaved
|
||||
? "Самооценка сохранена. Подтвержденную категорию присваивает только тест."
|
||||
: "Сначала сохраните профиль и анкету, затем проверьте уровень тестом."}
|
||||
</p>
|
||||
<div className={styles.links}>
|
||||
<TextLink to={paths.candidate.profile}>Профиль</TextLink>
|
||||
<TextLink to={paths.candidate.questionnaire}>Анкета</TextLink>
|
||||
<TextLink to={paths.candidate.assessment}>Тест</TextLink>
|
||||
</div>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user