feat: add candidate profile, questionnaire and company forms
This commit is contained in:
1 parent
3a61a8e8bb
commit
f81cd0ae09
68 files changed
+9517
-54
No files matched your search
@@ -0,0 +1,61 @@
|
||||
.root {
|
||||
display: grid;
|
||||
gap: var(--space-5);
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.root > section {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.server-step,
|
||||
.form-error,
|
||||
.conflict,
|
||||
.continuation {
|
||||
min-width: 0;
|
||||
margin: 0 0 var(--space-4);
|
||||
padding: var(--space-4);
|
||||
border: var(--line-thin) solid var(--color-divider);
|
||||
border-radius: var(--radius-m);
|
||||
background: var(--color-surface);
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.server-step {
|
||||
color: var(--color-text-secondary);
|
||||
}
|
||||
|
||||
.form-error,
|
||||
.conflict {
|
||||
border-width: var(--line-strong);
|
||||
border-color: var(--color-danger);
|
||||
}
|
||||
|
||||
.form-error {
|
||||
font-weight: var(--font-weight-medium);
|
||||
}
|
||||
|
||||
.conflict h2 {
|
||||
margin: 0 0 var(--space-2);
|
||||
font-size: var(--font-size-l);
|
||||
}
|
||||
|
||||
.conflict p,
|
||||
.continuation p {
|
||||
margin: 0 0 var(--space-3);
|
||||
line-height: var(--line-height-body);
|
||||
}
|
||||
|
||||
.continuation {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: var(--space-3);
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin: var(--space-5) 0 0;
|
||||
}
|
||||
|
||||
.continuation p {
|
||||
flex: 1 1 16rem;
|
||||
margin: 0;
|
||||
}
|
||||
@@ -0,0 +1,362 @@
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { useQueryClient, type UseQueryResult } from "@tanstack/react-query";
|
||||
import {
|
||||
buildCandidateProfileUpdate,
|
||||
mapProfileServerErrors,
|
||||
toCandidateProfileDraft,
|
||||
type CandidateProfileDraft,
|
||||
type ProfileFormIssue,
|
||||
} from "../../../entities/candidate";
|
||||
import { getOnboardingDestination } from "../../../entities/session";
|
||||
import { ApiRequestError } from "../../../shared/api";
|
||||
import {
|
||||
type GetMyProfileQueryError,
|
||||
type GetMyProfileQueryResult,
|
||||
getGetMyProfileQueryKey,
|
||||
useGetMyProfile,
|
||||
useSaveMyProfile,
|
||||
} from "../../../shared/api/endpoints/candidate/candidate";
|
||||
import {
|
||||
getGetCurrentSessionQueryKey,
|
||||
useGetCurrentSession,
|
||||
} from "../../../shared/api/endpoints/identity/identity";
|
||||
import type { Account, CandidateProfile, Session } from "../../../shared/api/schemas";
|
||||
import { paths } from "../../../shared/config";
|
||||
import {
|
||||
Button,
|
||||
ButtonLink,
|
||||
ErrorState,
|
||||
ForbiddenState,
|
||||
LoadingState,
|
||||
Section,
|
||||
} from "../../../shared/ui";
|
||||
import { ProfileForm } from "./profile-form";
|
||||
import styles from "./edit-profile.module.css";
|
||||
|
||||
type OnboardingStep = Account["onboarding_step"];
|
||||
|
||||
function stepLabel(step: OnboardingStep): string {
|
||||
switch (step) {
|
||||
case "candidate_consents":
|
||||
return "Согласия";
|
||||
case "candidate_profile":
|
||||
return "Профиль";
|
||||
case "candidate_questionnaire":
|
||||
return "Анкета";
|
||||
case "candidate_assessment":
|
||||
return "Оценка навыков";
|
||||
case "employer_company":
|
||||
return "Компания";
|
||||
case "completed":
|
||||
return "Завершено";
|
||||
}
|
||||
}
|
||||
|
||||
function ProfileAccessDenied({ error }: { error: unknown }) {
|
||||
return (
|
||||
<ForbiddenState
|
||||
error={error}
|
||||
title="Профиль недоступен"
|
||||
description="Сервер не подтвердил доступ к профилю кандидата. Обновите вход или откройте подходящий кабинет."
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export function EditProfile() {
|
||||
const queryClient = useQueryClient();
|
||||
const profile = useGetMyProfile({
|
||||
query: {
|
||||
gcTime: 0,
|
||||
staleTime: 0,
|
||||
refetchOnMount: "always",
|
||||
retry: false,
|
||||
},
|
||||
});
|
||||
const session = useGetCurrentSession();
|
||||
const profileAccessError =
|
||||
profile.isError &&
|
||||
profile.error instanceof ApiRequestError &&
|
||||
(profile.error.status === 401 || profile.error.status === 403)
|
||||
? profile.error
|
||||
: null;
|
||||
const sessionAccessError =
|
||||
session.isError &&
|
||||
session.error instanceof ApiRequestError &&
|
||||
(session.error.status === 401 || session.error.status === 403)
|
||||
? session.error
|
||||
: null;
|
||||
|
||||
useEffect(() => {
|
||||
if (!profileAccessError && !sessionAccessError) return;
|
||||
queryClient.removeQueries({ queryKey: getGetMyProfileQueryKey(), exact: true });
|
||||
}, [profileAccessError, queryClient, sessionAccessError]);
|
||||
|
||||
if (profile.isPending && !profile.data) {
|
||||
return <LoadingState label="Загружаем профиль кандидата..." />;
|
||||
}
|
||||
if (profileAccessError) {
|
||||
return <ProfileAccessDenied error={profileAccessError} />;
|
||||
}
|
||||
if (sessionAccessError) {
|
||||
return <ProfileAccessDenied error={sessionAccessError} />;
|
||||
}
|
||||
if (!profile.data) {
|
||||
if (profile.error instanceof ApiRequestError && profile.error.status === 403) {
|
||||
return <ProfileAccessDenied error={profile.error} />;
|
||||
}
|
||||
if (profile.error instanceof ApiRequestError && profile.error.status === 401) {
|
||||
return <ProfileAccessDenied error={profile.error} />;
|
||||
}
|
||||
return (
|
||||
<ErrorState
|
||||
error={profile.error}
|
||||
isRetrying={profile.isRefetching}
|
||||
onRetry={() => void profile.refetch()}
|
||||
title="Не удалось загрузить профиль"
|
||||
/>
|
||||
);
|
||||
}
|
||||
if (!session.data) {
|
||||
if (session.error instanceof ApiRequestError && session.error.status === 403) {
|
||||
return <ProfileAccessDenied error={session.error} />;
|
||||
}
|
||||
if (session.error && !session.isFetching) {
|
||||
return (
|
||||
<ErrorState
|
||||
error={session.error}
|
||||
isRetrying={session.isRefetching}
|
||||
onRetry={() => void session.refetch()}
|
||||
title="Не удалось проверить текущий вход"
|
||||
/>
|
||||
);
|
||||
}
|
||||
return <LoadingState label="Проверяем текущий вход..." />;
|
||||
}
|
||||
if (session.data.account.scenario !== "candidate") {
|
||||
return (
|
||||
<ForbiddenState
|
||||
title="Профиль кандидата недоступен"
|
||||
description="Войдите в кабинет, связанный со сценарием кандидата."
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<ProfileEditor key={session.data.account.id} profile={profile.data} profileQuery={profile} />
|
||||
);
|
||||
}
|
||||
|
||||
type ProfileQueryResult = UseQueryResult<GetMyProfileQueryResult, GetMyProfileQueryError>;
|
||||
|
||||
type ProfileEditorProps = {
|
||||
profile: CandidateProfile;
|
||||
profileQuery: ProfileQueryResult;
|
||||
};
|
||||
|
||||
function ProfileEditor({ profile, profileQuery }: ProfileEditorProps) {
|
||||
const queryClient = useQueryClient();
|
||||
const session = useGetCurrentSession();
|
||||
const saveInFlight = useRef(false);
|
||||
const [draft, setDraft] = useState<CandidateProfileDraft>(() => toCandidateProfileDraft(profile));
|
||||
const [issues, setIssues] = useState<ProfileFormIssue[]>([]);
|
||||
const [formError, setFormError] = useState<string | null>(null);
|
||||
const [savingState, setSavingState] = useState<"idle" | "saving" | "saved" | "failed">("idle");
|
||||
const [conflict, setConflict] = useState(false);
|
||||
const [latestLoadError, setLatestLoadError] = useState(false);
|
||||
const [forbidden, setForbidden] = useState(false);
|
||||
const [savedStep, setSavedStep] = useState<OnboardingStep | null>(null);
|
||||
const saveMutation = useSaveMyProfile({
|
||||
request: {
|
||||
headers: session.data ? { "X-CSRF-Token": session.data.csrf_token } : {},
|
||||
},
|
||||
mutation: { gcTime: 0 },
|
||||
});
|
||||
|
||||
const changeDraft = (next: CandidateProfileDraft) => {
|
||||
setDraft(next);
|
||||
setIssues([]);
|
||||
setFormError(null);
|
||||
setSavingState("idle");
|
||||
setSavedStep(null);
|
||||
};
|
||||
|
||||
async function handleSubmit() {
|
||||
if (!session.data || conflict || forbidden || saveInFlight.current) return;
|
||||
const result = buildCandidateProfileUpdate(draft);
|
||||
setIssues(result.issues);
|
||||
setFormError(null);
|
||||
setSavedStep(null);
|
||||
if (!result.data) {
|
||||
setSavingState("failed");
|
||||
return;
|
||||
}
|
||||
|
||||
const submittingSession = session.data;
|
||||
const isSubmittingSessionCurrent = () => {
|
||||
const current = queryClient.getQueryData<Session>(getGetCurrentSessionQueryKey());
|
||||
return Boolean(
|
||||
current &&
|
||||
current.account.id === submittingSession.account.id &&
|
||||
current.csrf_token === submittingSession.csrf_token,
|
||||
);
|
||||
};
|
||||
saveInFlight.current = true;
|
||||
setSavingState("saving");
|
||||
try {
|
||||
const saved = await saveMutation.mutateAsync({ data: result.data });
|
||||
if (!isSubmittingSessionCurrent()) return;
|
||||
queryClient.setQueryData(getGetMyProfileQueryKey(), saved);
|
||||
setDraft(toCandidateProfileDraft(saved));
|
||||
setIssues([]);
|
||||
setConflict(false);
|
||||
setLatestLoadError(false);
|
||||
setSavingState("saved");
|
||||
const refreshedSession = await session.refetch();
|
||||
if (
|
||||
refreshedSession.data &&
|
||||
!refreshedSession.isError &&
|
||||
refreshedSession.data.account.id === submittingSession.account.id
|
||||
) {
|
||||
setSavedStep(refreshedSession.data.account.onboarding_step);
|
||||
} else {
|
||||
setFormError("Профиль сохранен. Не удалось проверить следующий шаг на сервере.");
|
||||
}
|
||||
} catch (error: unknown) {
|
||||
if (!isSubmittingSessionCurrent()) return;
|
||||
setSavingState("failed");
|
||||
if (error instanceof ApiRequestError && error.status === 412) {
|
||||
setConflict(true);
|
||||
setLatestLoadError(false);
|
||||
const refreshed = await profileQuery.refetch();
|
||||
if (!refreshed.data || refreshed.isError) setLatestLoadError(true);
|
||||
return;
|
||||
}
|
||||
if (error instanceof ApiRequestError && error.status === 400) {
|
||||
const serverIssues = mapProfileServerErrors(error.fieldErrors);
|
||||
setIssues(serverIssues);
|
||||
setFormError(
|
||||
serverIssues.length === 0
|
||||
? "Сервер не сохранил изменения. Проверьте формат данных и повторите попытку."
|
||||
: null,
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (error instanceof ApiRequestError && error.status === 403) {
|
||||
if (error.code === "csrf_check_failed") {
|
||||
const refreshed = await session.refetch();
|
||||
setFormError(
|
||||
refreshed.data
|
||||
? "Проверка входа обновлена. Данные формы сохранены, повторите сохранение."
|
||||
: "Вход больше не подтвержден. Войдите снова, чтобы продолжить работу с профилем.",
|
||||
);
|
||||
return;
|
||||
}
|
||||
setForbidden(true);
|
||||
setFormError(
|
||||
"Сервер больше не подтверждает доступ к профилю. Изменения не были отправлены.",
|
||||
);
|
||||
void session.refetch();
|
||||
return;
|
||||
}
|
||||
if (error instanceof ApiRequestError && error.status === 401) {
|
||||
setFormError(
|
||||
"Вход больше не подтвержден. Войдите снова, чтобы продолжить работу с профилем.",
|
||||
);
|
||||
void session.refetch();
|
||||
return;
|
||||
}
|
||||
setFormError("Не удалось сохранить профиль. Проверьте подключение и повторите попытку.");
|
||||
} finally {
|
||||
saveInFlight.current = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function loadCurrentVersion() {
|
||||
setLatestLoadError(false);
|
||||
const refreshed = await profileQuery.refetch();
|
||||
if (!refreshed.data || refreshed.isError) {
|
||||
setLatestLoadError(true);
|
||||
return;
|
||||
}
|
||||
setDraft(toCandidateProfileDraft(refreshed.data));
|
||||
setIssues([]);
|
||||
setFormError(null);
|
||||
setConflict(false);
|
||||
setLatestLoadError(false);
|
||||
setSavedStep(null);
|
||||
setSavingState("idle");
|
||||
}
|
||||
|
||||
const currentStep = session.data?.account.onboarding_step;
|
||||
const continuation = savedStep
|
||||
? getOnboardingDestination({ scenario: "candidate", onboarding_step: savedStep })
|
||||
: null;
|
||||
const continuationLabel = savedStep ? stepLabel(savedStep) : null;
|
||||
|
||||
return (
|
||||
<div className={styles.root}>
|
||||
<Section
|
||||
title="Личные сведения"
|
||||
description="Заполните только то, что готовы указать. Профиль сохраняется на сервере и не требует резюме или внешнего аккаунта."
|
||||
>
|
||||
{currentStep ? (
|
||||
<p className={styles["server-step"]}>
|
||||
Сохраненный шаг аккаунта: <strong>{stepLabel(currentStep)}</strong>.
|
||||
</p>
|
||||
) : null}
|
||||
{conflict ? (
|
||||
<div className={styles.conflict} role="alert" aria-labelledby="profile-conflict-title">
|
||||
<h2 id="profile-conflict-title">Профиль обновлен в другом окне</h2>
|
||||
<p>
|
||||
Введенные здесь изменения не отправлены. Сравнение и автоматическое объединение не
|
||||
выполняются. При замене черновика данные из этой формы будут удалены.
|
||||
</p>
|
||||
{latestLoadError ? (
|
||||
<p>Не удалось получить текущую версию. Черновик сохранен в памяти формы.</p>
|
||||
) : null}
|
||||
<Button
|
||||
variant="secondary"
|
||||
isBusy={profileQuery.isRefetching}
|
||||
aria-describedby="profile-conflict-title"
|
||||
onClick={() => void loadCurrentVersion()}
|
||||
>
|
||||
{profileQuery.isRefetching
|
||||
? "Загружаем текущую версию..."
|
||||
: "Заменить черновик актуальной версией"}
|
||||
</Button>
|
||||
</div>
|
||||
) : null}
|
||||
{forbidden ? (
|
||||
<div className={styles["form-error"]} role="alert">
|
||||
Профиль больше недоступен. Данные формы останутся до ухода со страницы.
|
||||
</div>
|
||||
) : null}
|
||||
{formError ? (
|
||||
<div className={styles["form-error"]} role="alert">
|
||||
{formError}
|
||||
</div>
|
||||
) : null}
|
||||
<ProfileForm
|
||||
draft={draft}
|
||||
issues={issues}
|
||||
isSaving={savingState === "saving"}
|
||||
savingState={savingState}
|
||||
onDraftChange={changeDraft}
|
||||
onSubmit={() => void handleSubmit()}
|
||||
/>
|
||||
{savedStep && continuation ? (
|
||||
<div className={styles.continuation} role="status">
|
||||
<p>Профиль сохранен. Сервер подтвердил шаг аккаунта: {continuationLabel}.</p>
|
||||
{continuation !== paths.candidate.profile ? (
|
||||
<ButtonLink to={continuation} variant="secondary">
|
||||
Открыть сохраненный шаг
|
||||
</ButtonLink>
|
||||
) : (
|
||||
<p>Серверный шаг остается «Профиль».</p>
|
||||
)}
|
||||
</div>
|
||||
) : null}
|
||||
</Section>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,276 @@
|
||||
.form {
|
||||
display: grid;
|
||||
gap: var(--space-6);
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.editor-fields {
|
||||
display: grid;
|
||||
gap: var(--space-6);
|
||||
min-width: 0;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
.editor-legend {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
overflow: hidden;
|
||||
clip-path: inset(50%);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.issue-summary {
|
||||
min-width: 0;
|
||||
padding: var(--space-4);
|
||||
border: var(--line-strong) solid var(--color-danger);
|
||||
border-radius: var(--radius-m);
|
||||
background: var(--color-surface);
|
||||
}
|
||||
|
||||
.issue-summary h2,
|
||||
.categories h2 {
|
||||
margin: 0;
|
||||
font-size: var(--font-size-l);
|
||||
}
|
||||
|
||||
.issue-summary ul,
|
||||
.categories ul {
|
||||
margin: var(--space-3) 0 0;
|
||||
padding-left: var(--space-5);
|
||||
}
|
||||
|
||||
.group {
|
||||
display: grid;
|
||||
gap: var(--space-4);
|
||||
min-width: 0;
|
||||
margin: 0;
|
||||
padding: var(--space-4);
|
||||
border: var(--line-thin) solid var(--color-divider);
|
||||
border-radius: var(--radius-m);
|
||||
}
|
||||
|
||||
.group legend {
|
||||
max-width: 100%;
|
||||
padding-inline: var(--space-2);
|
||||
font-size: var(--font-size-l);
|
||||
font-weight: var(--font-weight-bold);
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.group-description,
|
||||
.hint,
|
||||
.categories p {
|
||||
margin: 0;
|
||||
color: var(--color-text-secondary);
|
||||
line-height: var(--line-height-body);
|
||||
}
|
||||
|
||||
.field {
|
||||
display: grid;
|
||||
gap: var(--space-2);
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.field > label {
|
||||
font-weight: var(--font-weight-bold);
|
||||
}
|
||||
|
||||
.field input,
|
||||
.field select,
|
||||
.field textarea {
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
max-width: 100%;
|
||||
min-height: 2.75rem;
|
||||
padding: var(--space-3);
|
||||
border: var(--line-thin) solid var(--color-border-strong);
|
||||
border-radius: var(--radius-s);
|
||||
color: var(--color-text);
|
||||
background: var(--color-surface);
|
||||
font: inherit;
|
||||
}
|
||||
|
||||
.field textarea {
|
||||
resize: vertical;
|
||||
}
|
||||
|
||||
.field input[aria-invalid="true"],
|
||||
.field select[aria-invalid="true"],
|
||||
.field textarea[aria-invalid="true"] {
|
||||
border-width: var(--line-strong);
|
||||
border-color: var(--color-danger);
|
||||
}
|
||||
|
||||
.overlap input {
|
||||
width: 1.25rem;
|
||||
height: 1.25rem;
|
||||
margin: 0.125rem 0 0;
|
||||
}
|
||||
|
||||
.overlap input:focus-visible {
|
||||
outline: var(--line-strong) solid var(--color-focus-ring);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
.field input:focus-visible,
|
||||
.field select:focus-visible,
|
||||
.field textarea:focus-visible {
|
||||
outline: var(--line-strong) solid var(--color-focus-ring);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
.hint,
|
||||
.error,
|
||||
.claim-status {
|
||||
font-size: var(--font-size-s);
|
||||
line-height: var(--line-height-body);
|
||||
}
|
||||
|
||||
.error {
|
||||
margin: 0;
|
||||
color: var(--color-text);
|
||||
font-weight: var(--font-weight-bold);
|
||||
}
|
||||
|
||||
.claim-status {
|
||||
color: var(--color-text-secondary);
|
||||
}
|
||||
|
||||
.suggestion {
|
||||
min-width: 0;
|
||||
padding: var(--space-2) var(--space-3);
|
||||
border-inline-start: var(--line-strong) solid var(--color-accent);
|
||||
background: var(--color-canvas);
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.suggestion summary {
|
||||
cursor: pointer;
|
||||
font-size: var(--font-size-s);
|
||||
font-weight: var(--font-weight-medium);
|
||||
}
|
||||
|
||||
.suggestion blockquote,
|
||||
.suggestion p {
|
||||
margin: var(--space-2) 0 0;
|
||||
white-space: pre-wrap;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.item {
|
||||
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);
|
||||
}
|
||||
|
||||
.item-header,
|
||||
.item-actions,
|
||||
.list-row,
|
||||
.actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: var(--space-3);
|
||||
align-items: center;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.item-header {
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.item-header h3,
|
||||
.list h3,
|
||||
.overlap-list h3 {
|
||||
margin: 0;
|
||||
font-size: var(--font-size-m);
|
||||
}
|
||||
|
||||
.grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: var(--space-4);
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.list,
|
||||
.overlap-list {
|
||||
display: grid;
|
||||
gap: var(--space-3);
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.list-row {
|
||||
align-items: flex-end;
|
||||
}
|
||||
|
||||
.list-row > .field {
|
||||
flex: 1 1 14rem;
|
||||
}
|
||||
|
||||
.overlap {
|
||||
display: grid;
|
||||
grid-template-columns: auto minmax(0, 1fr);
|
||||
gap: var(--space-3);
|
||||
align-items: start;
|
||||
min-width: 0;
|
||||
padding: var(--space-3);
|
||||
border: var(--line-thin) solid var(--color-border-strong);
|
||||
border-radius: var(--radius-s);
|
||||
}
|
||||
|
||||
.overlap label,
|
||||
.overlap p {
|
||||
margin: 0;
|
||||
line-height: var(--line-height-body);
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.categories {
|
||||
display: grid;
|
||||
gap: var(--space-2);
|
||||
min-width: 0;
|
||||
padding: var(--space-4);
|
||||
border: var(--line-thin) solid var(--color-divider);
|
||||
border-radius: var(--radius-m);
|
||||
}
|
||||
|
||||
.actions {
|
||||
justify-content: space-between;
|
||||
padding-top: var(--space-2);
|
||||
}
|
||||
|
||||
.actions > :first-child {
|
||||
flex: 1 1 12rem;
|
||||
}
|
||||
|
||||
@media (width < 48rem) {
|
||||
.grid {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
@media (width < 30rem) {
|
||||
.group {
|
||||
padding: var(--space-3);
|
||||
}
|
||||
|
||||
.item {
|
||||
padding: var(--space-3);
|
||||
}
|
||||
|
||||
.actions {
|
||||
align-items: stretch;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.item-actions {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
import { renderToString } from "react-dom/server";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { toCandidateProfileDraft } from "../../../entities/candidate";
|
||||
import type { CandidateProfile } from "../../../shared/api/schemas";
|
||||
import { ProfileForm } from "./profile-form";
|
||||
|
||||
const emptyProfile: CandidateProfile = {
|
||||
version: 0,
|
||||
full_name: { status: "unknown", value: null, source: null },
|
||||
contacts: {
|
||||
email: { status: "unknown", value: null, source: null },
|
||||
phone: { status: "unknown", value: null, source: null },
|
||||
telegram: { status: "unknown", value: null, source: null },
|
||||
},
|
||||
stack: [],
|
||||
roles: [],
|
||||
experience: [],
|
||||
experience_overlaps: [],
|
||||
soft_skills: [],
|
||||
terms: {
|
||||
location: { status: "unknown", value: null, source: null },
|
||||
relocation: { status: "unknown", value: null, source: null },
|
||||
salary_minimum: { status: "unknown", value: null, source: null },
|
||||
},
|
||||
confirmed_categories: [],
|
||||
updated_at: null,
|
||||
};
|
||||
|
||||
function profileWithOverlap(status: "confirmed" | "needs_confirmation"): CandidateProfile {
|
||||
const source = {
|
||||
origin: "manual" as const,
|
||||
trust_level: 0 as const,
|
||||
quote: null,
|
||||
extraction_version: null,
|
||||
confirmed_at: null,
|
||||
};
|
||||
return {
|
||||
...emptyProfile,
|
||||
experience: [
|
||||
{
|
||||
employer_name: "Первая компания",
|
||||
specialization: "backend",
|
||||
started_on: "2024-01",
|
||||
ended_on: "2024-12",
|
||||
summary: null,
|
||||
status: "confirmed",
|
||||
source,
|
||||
},
|
||||
{
|
||||
employer_name: "Вторая компания",
|
||||
specialization: "frontend",
|
||||
started_on: "2024-06",
|
||||
ended_on: "2025-01",
|
||||
summary: null,
|
||||
status: "confirmed",
|
||||
source,
|
||||
},
|
||||
],
|
||||
experience_overlaps: [{ first_index: 0, second_index: 1, status }],
|
||||
};
|
||||
}
|
||||
|
||||
describe("ProfileForm", () => {
|
||||
it("renders an empty profile as editable controls without inventing claims or categories", () => {
|
||||
const html = renderToString(
|
||||
<ProfileForm
|
||||
draft={toCandidateProfileDraft(emptyProfile)}
|
||||
issues={[]}
|
||||
isSaving={false}
|
||||
savingState="idle"
|
||||
onDraftChange={vi.fn()}
|
||||
onSubmit={vi.fn()}
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(html).toContain('name="full_name"');
|
||||
expect(html).toContain('name="contact_email"');
|
||||
expect(html).toContain("Добавить место работы");
|
||||
expect(html).toContain("Добавить специализацию");
|
||||
expect(html).toContain("Подтвержденных категорий пока нет.");
|
||||
expect(html).not.toContain("резюме обязательно");
|
||||
const describedIds = [...html.matchAll(/aria-describedby="([^"]+)"/g)].flatMap((match) =>
|
||||
(match[1] ?? "").split(" "),
|
||||
);
|
||||
expect(describedIds.length).toBeGreaterThan(0);
|
||||
expect(describedIds.every((id) => html.includes(`id="${id}"`))).toBe(true);
|
||||
});
|
||||
|
||||
it("renders confirmed overlap copy with a separating space and keeps new overlap confirmation explicit", () => {
|
||||
const props = {
|
||||
issues: [],
|
||||
isSaving: false,
|
||||
savingState: "idle" as const,
|
||||
onDraftChange: vi.fn(),
|
||||
onSubmit: vi.fn(),
|
||||
};
|
||||
const confirmedHtml = renderToString(
|
||||
<ProfileForm draft={toCandidateProfileDraft(profileWithOverlap("confirmed"))} {...props} />,
|
||||
);
|
||||
const unconfirmedHtml = renderToString(
|
||||
<ProfileForm
|
||||
draft={toCandidateProfileDraft(profileWithOverlap("needs_confirmation"))}
|
||||
{...props}
|
||||
/>,
|
||||
);
|
||||
const confirmedText = confirmedHtml.replaceAll("<!-- -->", "").replace(/\s+/g, " ");
|
||||
const unconfirmedText = unconfirmedHtml.replaceAll("<!-- -->", "").replace(/\s+/g, " ");
|
||||
|
||||
expect(confirmedText).toContain("Параллельная работа в местах 1 и 2 подтверждена ранее:");
|
||||
expect(confirmedText).not.toContain("2подтверждена ранее");
|
||||
expect(unconfirmedText).toContain(
|
||||
"Подтверждаю, что места работы 1 и 2 действительно шли параллельно:",
|
||||
);
|
||||
expect(unconfirmedText).not.toContain("подтверждена ранее");
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,895 @@
|
||||
import { useId, useRef, type FormEvent, type ReactNode } from "react";
|
||||
import {
|
||||
addExperience,
|
||||
addRole,
|
||||
addSoftSkill,
|
||||
addStack,
|
||||
moveExperience,
|
||||
removeExperience,
|
||||
removeItem,
|
||||
reviewExperienceOverlaps,
|
||||
setParallelAcknowledgement,
|
||||
updateExperienceDraft,
|
||||
updateFieldDraft,
|
||||
updateRoleDraft,
|
||||
updateSalaryDraft,
|
||||
updateSoftSkillDraft,
|
||||
updateStackDraft,
|
||||
type CandidateProfileDraft,
|
||||
type ProfileFormIssue,
|
||||
} from "../../../entities/candidate";
|
||||
import type { CandidateProfile } from "../../../shared/api/schemas";
|
||||
import { Button, SavingStatus } from "../../../shared/ui";
|
||||
import styles from "./profile-form.module.css";
|
||||
|
||||
type Specialization = CandidateProfile["roles"][number]["specialization"];
|
||||
type Grade = NonNullable<CandidateProfile["roles"][number]["self_assessed_grade"]>;
|
||||
|
||||
const specializations: ReadonlyArray<{ value: Specialization; label: string }> = [
|
||||
{ value: "backend", label: "Backend" },
|
||||
{ value: "frontend", label: "Frontend" },
|
||||
{ value: "mobile", label: "Mobile" },
|
||||
{ value: "network_engineer", label: "Сетевой инженер" },
|
||||
{ value: "devops_sre", label: "DevOps / SRE" },
|
||||
{ value: "data_analyst", label: "Аналитик данных" },
|
||||
{ value: "ds_ml", label: "DS / ML" },
|
||||
{ value: "information_security", label: "Информационная безопасность" },
|
||||
{ value: "qa", label: "QA" },
|
||||
];
|
||||
|
||||
const grades: ReadonlyArray<{ value: Grade; label: string }> = [
|
||||
{ value: "intern", label: "Стажер" },
|
||||
{ value: "junior", label: "Junior" },
|
||||
{ value: "middle", label: "Middle" },
|
||||
{ value: "senior", label: "Senior" },
|
||||
];
|
||||
|
||||
type ProfileFormProps = {
|
||||
draft: CandidateProfileDraft;
|
||||
issues: readonly ProfileFormIssue[];
|
||||
isSaving: boolean;
|
||||
savingState: "idle" | "saving" | "saved" | "failed";
|
||||
onDraftChange: (draft: CandidateProfileDraft) => void;
|
||||
onSubmit: () => void;
|
||||
};
|
||||
|
||||
function errorFor(issues: readonly ProfileFormIssue[], field: string): string | undefined {
|
||||
return issues.find((issue) => issue.field === field)?.message;
|
||||
}
|
||||
|
||||
function ErrorText({ id, children }: { id: string; children?: string | undefined }) {
|
||||
return children ? (
|
||||
<p className={styles.error} id={id}>
|
||||
{children}
|
||||
</p>
|
||||
) : null;
|
||||
}
|
||||
|
||||
function Suggestion({ source }: { source: { quote: string | null; origin: string } | null }) {
|
||||
if (!source || source.origin === "manual") return null;
|
||||
const origin = source.origin === "imported" ? "Импортировано" : "Предложено из документа";
|
||||
return (
|
||||
<details className={styles.suggestion}>
|
||||
<summary>{origin}. Значение пока не подтверждено.</summary>
|
||||
{source.quote ? <blockquote>{source.quote}</blockquote> : <p>Цитата не сохранена.</p>}
|
||||
</details>
|
||||
);
|
||||
}
|
||||
|
||||
type FieldProps = {
|
||||
id: string;
|
||||
label: string;
|
||||
error?: string | undefined;
|
||||
description?: ReactNode | undefined;
|
||||
suggestion?: { quote: string | null; origin: string } | null | undefined;
|
||||
children: ReactNode;
|
||||
};
|
||||
|
||||
function Field({ id, label, error, description, suggestion, children }: FieldProps) {
|
||||
return (
|
||||
<div className={styles.field}>
|
||||
<label htmlFor={id}>{label}</label>
|
||||
{description ? (
|
||||
<p className={styles.hint} id={`${id}-hint`}>
|
||||
{description}
|
||||
</p>
|
||||
) : null}
|
||||
{children}
|
||||
{suggestion ? (
|
||||
<div id={`${id}-suggestion`}>
|
||||
<Suggestion source={suggestion} />
|
||||
</div>
|
||||
) : null}
|
||||
<ErrorText id={`${id}-error`}>{error}</ErrorText>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function describedBy(
|
||||
id: string,
|
||||
error?: string,
|
||||
suggestion?: boolean,
|
||||
hint?: boolean,
|
||||
): string | undefined {
|
||||
const values = [
|
||||
hint ? `${id}-hint` : "",
|
||||
suggestion ? `${id}-suggestion` : "",
|
||||
error ? `${id}-error` : "",
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(" ");
|
||||
return values || undefined;
|
||||
}
|
||||
|
||||
function SourceLabel({ status }: { status: "confirmed" | "extracted" | "unknown" }) {
|
||||
if (status === "extracted")
|
||||
return <span className={styles["claim-status"]}>Нужно проверить</span>;
|
||||
if (status === "unknown") return <span className={styles["claim-status"]}>Не указано</span>;
|
||||
return null;
|
||||
}
|
||||
|
||||
export function ProfileForm({
|
||||
draft,
|
||||
issues,
|
||||
isSaving,
|
||||
savingState,
|
||||
onDraftChange,
|
||||
onSubmit,
|
||||
}: ProfileFormProps) {
|
||||
const prefix = `profile-${useId().replaceAll(":", "")}`;
|
||||
const rowSequence = useRef(0);
|
||||
const newRowId = (kind: string) => `${kind}-draft-${++rowSequence.current}`;
|
||||
const fieldId = (field: string) => `${prefix}-${field.replaceAll(".", "-")}`;
|
||||
const issue = (field: string) => errorFor(issues, field);
|
||||
const setDraft = (next: CandidateProfileDraft) => onDraftChange(next);
|
||||
|
||||
function handleSubmit(event: FormEvent<HTMLFormElement>) {
|
||||
event.preventDefault();
|
||||
event.currentTarget.querySelector<HTMLButtonElement>('button[type="submit"]')?.focus();
|
||||
onSubmit();
|
||||
}
|
||||
|
||||
const overlaps = reviewExperienceOverlaps(draft);
|
||||
|
||||
return (
|
||||
<form className={styles.form} onSubmit={handleSubmit} noValidate>
|
||||
{issues.length > 0 ? (
|
||||
<div
|
||||
className={styles["issue-summary"]}
|
||||
role="alert"
|
||||
aria-labelledby={`${prefix}-issues-title`}
|
||||
>
|
||||
<h2 id={`${prefix}-issues-title`}>Проверьте профиль</h2>
|
||||
<ul>
|
||||
{issues.map((item, index) => (
|
||||
<li key={`${item.field}-${index}`}>{item.message}</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
<fieldset className={styles["editor-fields"]} disabled={isSaving}>
|
||||
<legend className={styles["editor-legend"]}>Данные профиля</legend>
|
||||
<fieldset className={styles.group}>
|
||||
<legend>Имя и контакты</legend>
|
||||
<Field
|
||||
id={fieldId("fullName")}
|
||||
label="Имя и фамилия"
|
||||
error={issue("fullName")}
|
||||
suggestion={draft.fullName.source}
|
||||
>
|
||||
<input
|
||||
id={fieldId("fullName")}
|
||||
name="full_name"
|
||||
autoComplete="name"
|
||||
maxLength={200}
|
||||
value={draft.fullName.value}
|
||||
aria-invalid={Boolean(issue("fullName"))}
|
||||
aria-describedby={describedBy(
|
||||
fieldId("fullName"),
|
||||
issue("fullName"),
|
||||
Boolean(draft.fullName.source),
|
||||
)}
|
||||
onChange={(event) =>
|
||||
setDraft({
|
||||
...draft,
|
||||
fullName: updateFieldDraft(draft.fullName, event.currentTarget.value),
|
||||
})
|
||||
}
|
||||
/>
|
||||
<SourceLabel status={draft.fullName.status} />
|
||||
</Field>
|
||||
<Field
|
||||
id={fieldId("contacts.email")}
|
||||
label="Контактный email"
|
||||
error={issue("contacts.email")}
|
||||
suggestion={draft.contacts.email.source}
|
||||
description="Это контакт профиля. Он может отличаться от адреса входа."
|
||||
>
|
||||
<input
|
||||
id={fieldId("contacts.email")}
|
||||
name="contact_email"
|
||||
type="email"
|
||||
autoComplete="email"
|
||||
maxLength={254}
|
||||
value={draft.contacts.email.value}
|
||||
aria-invalid={Boolean(issue("contacts.email"))}
|
||||
aria-describedby={describedBy(
|
||||
fieldId("contacts.email"),
|
||||
issue("contacts.email"),
|
||||
Boolean(draft.contacts.email.source),
|
||||
true,
|
||||
)}
|
||||
onChange={(event) =>
|
||||
setDraft({
|
||||
...draft,
|
||||
contacts: {
|
||||
...draft.contacts,
|
||||
email: updateFieldDraft(draft.contacts.email, event.currentTarget.value),
|
||||
},
|
||||
})
|
||||
}
|
||||
/>
|
||||
<SourceLabel status={draft.contacts.email.status} />
|
||||
</Field>
|
||||
<Field
|
||||
id={fieldId("contacts.phone")}
|
||||
label="Телефон"
|
||||
error={issue("contacts.phone")}
|
||||
suggestion={draft.contacts.phone.source}
|
||||
description="Международный формат E.164, например +70000000000."
|
||||
>
|
||||
<input
|
||||
id={fieldId("contacts.phone")}
|
||||
name="contact_phone"
|
||||
type="tel"
|
||||
autoComplete="tel"
|
||||
inputMode="tel"
|
||||
maxLength={16}
|
||||
value={draft.contacts.phone.value}
|
||||
aria-invalid={Boolean(issue("contacts.phone"))}
|
||||
aria-describedby={describedBy(
|
||||
fieldId("contacts.phone"),
|
||||
issue("contacts.phone"),
|
||||
Boolean(draft.contacts.phone.source),
|
||||
true,
|
||||
)}
|
||||
onChange={(event) =>
|
||||
setDraft({
|
||||
...draft,
|
||||
contacts: {
|
||||
...draft.contacts,
|
||||
phone: updateFieldDraft(draft.contacts.phone, event.currentTarget.value),
|
||||
},
|
||||
})
|
||||
}
|
||||
/>
|
||||
<SourceLabel status={draft.contacts.phone.status} />
|
||||
</Field>
|
||||
<Field
|
||||
id={fieldId("contacts.telegram")}
|
||||
label="Telegram"
|
||||
error={issue("contacts.telegram")}
|
||||
suggestion={draft.contacts.telegram.source}
|
||||
description="Укажите имя пользователя с символом @."
|
||||
>
|
||||
<input
|
||||
id={fieldId("contacts.telegram")}
|
||||
name="contact_telegram"
|
||||
autoComplete="off"
|
||||
maxLength={33}
|
||||
value={draft.contacts.telegram.value}
|
||||
aria-invalid={Boolean(issue("contacts.telegram"))}
|
||||
aria-describedby={describedBy(
|
||||
fieldId("contacts.telegram"),
|
||||
issue("contacts.telegram"),
|
||||
Boolean(draft.contacts.telegram.source),
|
||||
true,
|
||||
)}
|
||||
onChange={(event) =>
|
||||
setDraft({
|
||||
...draft,
|
||||
contacts: {
|
||||
...draft.contacts,
|
||||
telegram: updateFieldDraft(draft.contacts.telegram, event.currentTarget.value),
|
||||
},
|
||||
})
|
||||
}
|
||||
/>
|
||||
<SourceLabel status={draft.contacts.telegram.status} />
|
||||
</Field>
|
||||
</fieldset>
|
||||
|
||||
<fieldset className={styles.group}>
|
||||
<legend>Опыт работы</legend>
|
||||
<p className={styles["group-description"]}>
|
||||
Укажите специализацию и месяцы работы. Пустая дата окончания означает, что работа
|
||||
продолжается.
|
||||
</p>
|
||||
{draft.experience.map((item, index) => {
|
||||
const base = `experience.${index}`;
|
||||
const specialId = fieldId(`${base}.specialization`);
|
||||
const startId = fieldId(`${base}.started_on`);
|
||||
const endId = fieldId(`${base}.ended_on`);
|
||||
const employerId = fieldId(`${base}.employer_name`);
|
||||
const summaryId = fieldId(`${base}.summary`);
|
||||
return (
|
||||
<section
|
||||
className={styles.item}
|
||||
key={item.id}
|
||||
aria-labelledby={`${prefix}-experience-${index}-title`}
|
||||
>
|
||||
<div className={styles["item-header"]}>
|
||||
<h3 id={`${prefix}-experience-${index}-title`}>Место работы {index + 1}</h3>
|
||||
<div className={styles["item-actions"]}>
|
||||
<Button
|
||||
variant="quiet"
|
||||
aria-label={`Переместить место работы ${index + 1} выше`}
|
||||
disabled={index === 0 || isSaving}
|
||||
onClick={() => setDraft(moveExperience(draft, index, -1))}
|
||||
>
|
||||
Выше
|
||||
</Button>
|
||||
<Button
|
||||
variant="quiet"
|
||||
aria-label={`Переместить место работы ${index + 1} ниже`}
|
||||
disabled={index === draft.experience.length - 1 || isSaving}
|
||||
onClick={() => setDraft(moveExperience(draft, index, 1))}
|
||||
>
|
||||
Ниже
|
||||
</Button>
|
||||
<Button
|
||||
variant="quiet"
|
||||
aria-label={`Удалить место работы ${index + 1}`}
|
||||
disabled={isSaving}
|
||||
onClick={() => setDraft(removeExperience(draft, item.id))}
|
||||
>
|
||||
Удалить
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<div className={styles.grid}>
|
||||
<Field
|
||||
id={employerId}
|
||||
label="Компания"
|
||||
error={issue(`${base}.employer_name`)}
|
||||
suggestion={item.source}
|
||||
>
|
||||
<input
|
||||
id={employerId}
|
||||
value={item.employer_name ?? ""}
|
||||
maxLength={200}
|
||||
aria-invalid={Boolean(issue(`${base}.employer_name`))}
|
||||
aria-describedby={describedBy(
|
||||
employerId,
|
||||
issue(`${base}.employer_name`),
|
||||
Boolean(item.source),
|
||||
)}
|
||||
onChange={(event) =>
|
||||
setDraft(
|
||||
updateExperienceDraft(draft, item.id, {
|
||||
employer_name: event.currentTarget.value || null,
|
||||
}),
|
||||
)
|
||||
}
|
||||
/>
|
||||
</Field>
|
||||
<Field
|
||||
id={specialId}
|
||||
label="Специализация"
|
||||
error={issue(`${base}.specialization`)}
|
||||
suggestion={item.source}
|
||||
>
|
||||
<select
|
||||
id={specialId}
|
||||
value={item.specialization}
|
||||
aria-invalid={Boolean(issue(`${base}.specialization`))}
|
||||
aria-describedby={describedBy(
|
||||
specialId,
|
||||
issue(`${base}.specialization`),
|
||||
Boolean(item.source),
|
||||
)}
|
||||
onChange={(event) =>
|
||||
setDraft(
|
||||
updateExperienceDraft(draft, item.id, {
|
||||
specialization: event.currentTarget.value as Specialization | "",
|
||||
}),
|
||||
)
|
||||
}
|
||||
>
|
||||
<option value="">Выберите специализацию</option>
|
||||
{specializations.map((option) => (
|
||||
<option key={option.value} value={option.value}>
|
||||
{option.label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</Field>
|
||||
<Field
|
||||
id={startId}
|
||||
label="Начало работы"
|
||||
error={issue(`${base}.started_on`)}
|
||||
description="Месяц и год."
|
||||
suggestion={item.source}
|
||||
>
|
||||
<input
|
||||
id={startId}
|
||||
type="month"
|
||||
value={item.started_on}
|
||||
aria-invalid={Boolean(issue(`${base}.started_on`))}
|
||||
aria-describedby={describedBy(
|
||||
startId,
|
||||
issue(`${base}.started_on`),
|
||||
Boolean(item.source),
|
||||
true,
|
||||
)}
|
||||
onChange={(event) =>
|
||||
setDraft(
|
||||
updateExperienceDraft(draft, item.id, {
|
||||
started_on: event.currentTarget.value,
|
||||
}),
|
||||
)
|
||||
}
|
||||
/>
|
||||
</Field>
|
||||
<Field
|
||||
id={endId}
|
||||
label="Окончание работы"
|
||||
error={issue(`${base}.ended_on`)}
|
||||
description="Оставьте пустым, если работаете здесь сейчас."
|
||||
suggestion={item.source}
|
||||
>
|
||||
<input
|
||||
id={endId}
|
||||
type="month"
|
||||
value={item.ended_on ?? ""}
|
||||
aria-invalid={Boolean(issue(`${base}.ended_on`))}
|
||||
aria-describedby={describedBy(
|
||||
endId,
|
||||
issue(`${base}.ended_on`),
|
||||
Boolean(item.source),
|
||||
true,
|
||||
)}
|
||||
onChange={(event) =>
|
||||
setDraft(
|
||||
updateExperienceDraft(draft, item.id, {
|
||||
ended_on: event.currentTarget.value || null,
|
||||
}),
|
||||
)
|
||||
}
|
||||
/>
|
||||
</Field>
|
||||
<Field id={summaryId} label="Чем занимались" error={issue(`${base}.summary`)}>
|
||||
<textarea
|
||||
id={summaryId}
|
||||
rows={3}
|
||||
maxLength={1000}
|
||||
value={item.summary ?? ""}
|
||||
aria-invalid={Boolean(issue(`${base}.summary`))}
|
||||
aria-describedby={describedBy(summaryId, issue(`${base}.summary`))}
|
||||
onChange={(event) =>
|
||||
setDraft(
|
||||
updateExperienceDraft(draft, item.id, {
|
||||
summary: event.currentTarget.value || null,
|
||||
}),
|
||||
)
|
||||
}
|
||||
/>
|
||||
</Field>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
})}
|
||||
<Button
|
||||
variant="secondary"
|
||||
disabled={draft.experience.length >= 20 || isSaving}
|
||||
onClick={() => setDraft(addExperience(draft, newRowId("experience")))}
|
||||
>
|
||||
Добавить место работы
|
||||
</Button>
|
||||
{overlaps.length > 0 ? (
|
||||
<div className={styles["overlap-list"]}>
|
||||
<h3>Параллельные периоды</h3>
|
||||
<p>Совпадающие месяцы нужно подтвердить отдельно для каждой пары мест работы.</p>
|
||||
{overlaps.map((overlap) => {
|
||||
const id = `${prefix}-overlap-${overlap.key.replace(":", "-")}`;
|
||||
return (
|
||||
<div className={styles.overlap} key={overlap.key}>
|
||||
{overlap.requiresAcknowledgement ? (
|
||||
<>
|
||||
<input
|
||||
id={id}
|
||||
type="checkbox"
|
||||
checked={overlap.acknowledged}
|
||||
disabled={isSaving}
|
||||
aria-describedby={
|
||||
issue("experience.overlaps") ? `${id}-error` : undefined
|
||||
}
|
||||
onChange={(event) =>
|
||||
setDraft(
|
||||
setParallelAcknowledgement(
|
||||
draft,
|
||||
overlap.key,
|
||||
event.currentTarget.checked,
|
||||
),
|
||||
)
|
||||
}
|
||||
/>
|
||||
<label htmlFor={id}>
|
||||
Подтверждаю, что места работы {overlap.firstIndex + 1} и{" "}
|
||||
{overlap.secondIndex + 1} действительно шли параллельно:{" "}
|
||||
{formatPeriod(overlap.firstPeriod)} и {formatPeriod(overlap.secondPeriod)}
|
||||
.
|
||||
</label>
|
||||
</>
|
||||
) : (
|
||||
<p>
|
||||
Параллельная работа в местах {overlap.firstIndex + 1} и{" "}
|
||||
{overlap.secondIndex + 1} подтверждена ранее:{" "}
|
||||
{formatPeriod(overlap.firstPeriod)} и {formatPeriod(overlap.secondPeriod)}.
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
<ErrorText id={`${prefix}-experience-overlaps-error`}>
|
||||
{issue("experience.overlaps")}
|
||||
</ErrorText>
|
||||
</div>
|
||||
) : null}
|
||||
</fieldset>
|
||||
|
||||
<fieldset className={styles.group}>
|
||||
<legend>Специализация и навыки</legend>
|
||||
<p className={styles["group-description"]}>
|
||||
Самооценка остается заявлением кандидата. Подтвержденная категория появляется только
|
||||
после оценки.
|
||||
</p>
|
||||
{draft.roles.map((item, index) => {
|
||||
const base = `roles.${index}`;
|
||||
const specializationId = fieldId(`${base}.specialization`);
|
||||
const gradeId = fieldId(`${base}.self_assessed_grade`);
|
||||
return (
|
||||
<div className={styles.item} key={item.id}>
|
||||
<div className={styles["item-header"]}>
|
||||
<h3>Роль {index + 1}</h3>
|
||||
<Button
|
||||
variant="quiet"
|
||||
aria-label={`Удалить роль ${index + 1}`}
|
||||
disabled={isSaving}
|
||||
onClick={() => setDraft(removeItem(draft, "roles", item.id))}
|
||||
>
|
||||
Удалить
|
||||
</Button>
|
||||
</div>
|
||||
<div className={styles.grid}>
|
||||
<Field
|
||||
id={specializationId}
|
||||
label="Специализация"
|
||||
error={issue(`${base}.specialization`)}
|
||||
suggestion={item.source}
|
||||
>
|
||||
<select
|
||||
id={specializationId}
|
||||
value={item.specialization}
|
||||
aria-invalid={Boolean(issue(`${base}.specialization`))}
|
||||
aria-describedby={describedBy(
|
||||
specializationId,
|
||||
issue(`${base}.specialization`),
|
||||
Boolean(item.source),
|
||||
)}
|
||||
onChange={(event) =>
|
||||
setDraft(
|
||||
updateRoleDraft(draft, item.id, {
|
||||
specialization: event.currentTarget.value as Specialization | "",
|
||||
}),
|
||||
)
|
||||
}
|
||||
>
|
||||
<option value="">Выберите специализацию</option>
|
||||
{specializations.map((option) => (
|
||||
<option key={option.value} value={option.value}>
|
||||
{option.label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</Field>
|
||||
<Field
|
||||
id={gradeId}
|
||||
label="Моя оценка уровня"
|
||||
error={issue(`${base}.self_assessed_grade`)}
|
||||
suggestion={item.source}
|
||||
>
|
||||
<select
|
||||
id={gradeId}
|
||||
value={item.self_assessed_grade ?? ""}
|
||||
aria-invalid={Boolean(issue(`${base}.self_assessed_grade`))}
|
||||
aria-describedby={describedBy(
|
||||
gradeId,
|
||||
issue(`${base}.self_assessed_grade`),
|
||||
Boolean(item.source),
|
||||
)}
|
||||
onChange={(event) =>
|
||||
setDraft(
|
||||
updateRoleDraft(draft, item.id, {
|
||||
self_assessed_grade: (event.currentTarget.value ||
|
||||
null) as Grade | null,
|
||||
}),
|
||||
)
|
||||
}
|
||||
>
|
||||
<option value="">Не указывать</option>
|
||||
{grades.map((option) => (
|
||||
<option key={option.value} value={option.value}>
|
||||
{option.label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</Field>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
<Button
|
||||
variant="secondary"
|
||||
disabled={draft.roles.length >= 9 || isSaving}
|
||||
onClick={() => setDraft(addRole(draft, newRowId("role")))}
|
||||
>
|
||||
Добавить специализацию
|
||||
</Button>
|
||||
|
||||
<div className={styles.list}>
|
||||
<h3>Технологии и инструменты</h3>
|
||||
{draft.stack.map((item, index) => {
|
||||
const field = `stack.${index}.tag`;
|
||||
const id = fieldId(field);
|
||||
return (
|
||||
<div className={styles["list-row"]} key={item.id}>
|
||||
<Field
|
||||
id={id}
|
||||
label={`Навык ${index + 1}`}
|
||||
error={issue(field)}
|
||||
suggestion={item.source}
|
||||
>
|
||||
<input
|
||||
id={id}
|
||||
value={item.tag}
|
||||
maxLength={50}
|
||||
aria-invalid={Boolean(issue(field))}
|
||||
aria-describedby={describedBy(id, issue(field), Boolean(item.source))}
|
||||
onChange={(event) =>
|
||||
setDraft(
|
||||
updateStackDraft(draft, item.id, { tag: event.currentTarget.value }),
|
||||
)
|
||||
}
|
||||
/>
|
||||
</Field>
|
||||
<Button
|
||||
variant="quiet"
|
||||
aria-label={`Удалить навык ${index + 1}`}
|
||||
disabled={isSaving}
|
||||
onClick={() => setDraft(removeItem(draft, "stack", item.id))}
|
||||
>
|
||||
Удалить
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
<Button
|
||||
variant="secondary"
|
||||
disabled={draft.stack.length >= 30 || isSaving}
|
||||
onClick={() => setDraft(addStack(draft, newRowId("stack")))}
|
||||
>
|
||||
Добавить навык
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<div className={styles.list}>
|
||||
<h3>Гибкие навыки</h3>
|
||||
{draft.softSkills.map((item, index) => {
|
||||
const field = `softSkills.${index}.skill`;
|
||||
const id = fieldId(field);
|
||||
return (
|
||||
<div className={styles["list-row"]} key={item.id}>
|
||||
<Field
|
||||
id={id}
|
||||
label={`Гибкий навык ${index + 1}`}
|
||||
error={issue(field)}
|
||||
suggestion={item.source}
|
||||
>
|
||||
<input
|
||||
id={id}
|
||||
value={item.skill}
|
||||
maxLength={50}
|
||||
aria-invalid={Boolean(issue(field))}
|
||||
aria-describedby={describedBy(id, issue(field), Boolean(item.source))}
|
||||
onChange={(event) =>
|
||||
setDraft(
|
||||
updateSoftSkillDraft(draft, item.id, {
|
||||
skill: event.currentTarget.value,
|
||||
}),
|
||||
)
|
||||
}
|
||||
/>
|
||||
</Field>
|
||||
<Button
|
||||
variant="quiet"
|
||||
aria-label={`Удалить гибкий навык ${index + 1}`}
|
||||
disabled={isSaving}
|
||||
onClick={() => setDraft(removeItem(draft, "softSkills", item.id))}
|
||||
>
|
||||
Удалить
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
<Button
|
||||
variant="secondary"
|
||||
disabled={draft.softSkills.length >= 10 || isSaving}
|
||||
onClick={() => setDraft(addSoftSkill(draft, newRowId("soft-skill")))}
|
||||
>
|
||||
Добавить гибкий навык
|
||||
</Button>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<fieldset className={styles.group}>
|
||||
<legend>Условия работы</legend>
|
||||
<Field
|
||||
id={fieldId("terms.location")}
|
||||
label="Желаемое место работы"
|
||||
error={issue("terms.location")}
|
||||
suggestion={draft.terms.location.source}
|
||||
>
|
||||
<input
|
||||
id={fieldId("terms.location")}
|
||||
maxLength={100}
|
||||
value={draft.terms.location.value}
|
||||
aria-invalid={Boolean(issue("terms.location"))}
|
||||
aria-describedby={describedBy(
|
||||
fieldId("terms.location"),
|
||||
issue("terms.location"),
|
||||
Boolean(draft.terms.location.source),
|
||||
)}
|
||||
onChange={(event) =>
|
||||
setDraft({
|
||||
...draft,
|
||||
terms: {
|
||||
...draft.terms,
|
||||
location: updateFieldDraft(draft.terms.location, event.currentTarget.value),
|
||||
},
|
||||
})
|
||||
}
|
||||
/>
|
||||
</Field>
|
||||
<Field
|
||||
id={fieldId("terms.relocation")}
|
||||
label="Готовность к переезду"
|
||||
error={issue("terms.relocation")}
|
||||
suggestion={draft.terms.relocation.source}
|
||||
>
|
||||
<select
|
||||
id={fieldId("terms.relocation")}
|
||||
value={
|
||||
draft.terms.relocation.value === null ? "" : String(draft.terms.relocation.value)
|
||||
}
|
||||
aria-invalid={Boolean(issue("terms.relocation"))}
|
||||
aria-describedby={describedBy(
|
||||
fieldId("terms.relocation"),
|
||||
issue("terms.relocation"),
|
||||
Boolean(draft.terms.relocation.source),
|
||||
)}
|
||||
onChange={(event) =>
|
||||
setDraft({
|
||||
...draft,
|
||||
terms: {
|
||||
...draft.terms,
|
||||
relocation: updateFieldDraft(
|
||||
draft.terms.relocation,
|
||||
event.currentTarget.value === ""
|
||||
? null
|
||||
: event.currentTarget.value === "true",
|
||||
),
|
||||
},
|
||||
})
|
||||
}
|
||||
>
|
||||
<option value="">Не указывать</option>
|
||||
<option value="true">Да</option>
|
||||
<option value="false">Нет</option>
|
||||
</select>
|
||||
</Field>
|
||||
<div className={styles.grid}>
|
||||
<Field
|
||||
id={fieldId("terms.salaryMinimum.amount")}
|
||||
label="Минимальная зарплата, рублей в месяц"
|
||||
error={issue("terms.salaryMinimum.amount")}
|
||||
suggestion={draft.terms.salaryMinimum.source}
|
||||
description="Сумма должна быть кратна 1000."
|
||||
>
|
||||
<input
|
||||
id={fieldId("terms.salaryMinimum.amount")}
|
||||
type="number"
|
||||
inputMode="numeric"
|
||||
min={1000}
|
||||
max={100000000}
|
||||
step={1000}
|
||||
value={draft.terms.salaryMinimum.amount}
|
||||
aria-invalid={Boolean(issue("terms.salaryMinimum.amount"))}
|
||||
aria-describedby={describedBy(
|
||||
fieldId("terms.salaryMinimum.amount"),
|
||||
issue("terms.salaryMinimum.amount"),
|
||||
Boolean(draft.terms.salaryMinimum.source),
|
||||
true,
|
||||
)}
|
||||
onChange={(event) =>
|
||||
setDraft(updateSalaryDraft(draft, { amount: event.currentTarget.value }))
|
||||
}
|
||||
/>
|
||||
<SourceLabel status={draft.terms.salaryMinimum.status} />
|
||||
</Field>
|
||||
<Field
|
||||
id={fieldId("terms.salaryMinimum.tax_basis")}
|
||||
label="Сумма до или после налога"
|
||||
error={issue("terms.salaryMinimum.tax_basis")}
|
||||
suggestion={draft.terms.salaryMinimum.source}
|
||||
>
|
||||
<select
|
||||
id={fieldId("terms.salaryMinimum.tax_basis")}
|
||||
value={draft.terms.salaryMinimum.tax_basis}
|
||||
aria-invalid={Boolean(issue("terms.salaryMinimum.tax_basis"))}
|
||||
aria-describedby={describedBy(
|
||||
fieldId("terms.salaryMinimum.tax_basis"),
|
||||
issue("terms.salaryMinimum.tax_basis"),
|
||||
Boolean(draft.terms.salaryMinimum.source),
|
||||
)}
|
||||
onChange={(event) =>
|
||||
setDraft(
|
||||
updateSalaryDraft(draft, {
|
||||
tax_basis: event.currentTarget.value as "net" | "gross" | "",
|
||||
}),
|
||||
)
|
||||
}
|
||||
>
|
||||
<option value="">Выберите</option>
|
||||
<option value="gross">До налога</option>
|
||||
<option value="net">После налога</option>
|
||||
</select>
|
||||
</Field>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<section className={styles.categories} aria-labelledby={`${prefix}-categories-title`}>
|
||||
<h2 id={`${prefix}-categories-title`}>Подтвержденные категории</h2>
|
||||
<p>Эти результаты устанавливает оценка. Их нельзя изменить в профиле.</p>
|
||||
{draft.confirmedCategories.length > 0 ? (
|
||||
<ul>
|
||||
{draft.confirmedCategories.map((category) => (
|
||||
<li key={`${category.specialization}-${category.grade}-${category.attempt_id}`}>
|
||||
{specializations.find((option) => option.value === category.specialization)
|
||||
?.label ?? category.specialization}
|
||||
,{" "}
|
||||
{grades.find((option) => option.value === category.grade)?.label ??
|
||||
category.grade}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
) : (
|
||||
<p>Подтвержденных категорий пока нет.</p>
|
||||
)}
|
||||
</section>
|
||||
</fieldset>
|
||||
|
||||
<div className={styles.actions}>
|
||||
<SavingStatus state={savingState} />
|
||||
<Button type="submit" isBusy={isSaving}>
|
||||
{isSaving ? "Сохраняем профиль..." : "Сохранить профиль"}
|
||||
</Button>
|
||||
</div>
|
||||
</form>
|
||||
);
|
||||
}
|
||||
|
||||
function formatPeriod(period: { started_on: string; ended_on: string | null }): string {
|
||||
return `${period.started_on} - ${period.ended_on ?? "сейчас"}`;
|
||||
}
|
||||
Reference in new issue
Block a user