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
@@ -18,7 +18,7 @@ export function CandidateOnboardingPage() {
|
||||
/>
|
||||
);
|
||||
}
|
||||
if (step !== "candidate_consents" && step !== "candidate_questionnaire") {
|
||||
if (step !== "candidate_consents") {
|
||||
const destination = getOnboardingDestination(session.data.account);
|
||||
if (destination === paths.candidate.onboarding) {
|
||||
return (
|
||||
@@ -32,28 +32,19 @@ export function CandidateOnboardingPage() {
|
||||
return <Navigate to={destination} replace />;
|
||||
}
|
||||
|
||||
const stepTitle = step === "candidate_consents" ? "Согласия" : "Анкета";
|
||||
const description =
|
||||
step === "candidate_consents"
|
||||
? "Следующий сохраненный шаг - согласия кандидата. Согласие C1 уже было показано отдельно при регистрации."
|
||||
: "Следующий сохраненный шаг - анкета кандидата. После ее сохранения сервер откроет следующий этап.";
|
||||
|
||||
return (
|
||||
<Page title="Первые шаги" eyebrow="Кабинет кандидата">
|
||||
<Section title={stepTitle} description={description}>
|
||||
{step === "candidate_consents" ? (
|
||||
<>
|
||||
<p>
|
||||
Состояние шага хранится на сервере. Просмотрите согласия и выберите каждое действие
|
||||
отдельно.
|
||||
</p>
|
||||
<ButtonLink to={paths.candidate.privacy}>
|
||||
Открыть согласия и настройки приватности
|
||||
</ButtonLink>
|
||||
</>
|
||||
) : (
|
||||
<p>Этот шаг сохранен в аккаунте и будет открыт после следующего входа.</p>
|
||||
)}
|
||||
<Section
|
||||
title="Согласия"
|
||||
description="Следующий сохраненный шаг - согласия кандидата. Согласие C1 уже было показано отдельно при регистрации."
|
||||
>
|
||||
<p>
|
||||
Состояние шага хранится на сервере. Просмотрите согласия и выберите каждое действие
|
||||
отдельно.
|
||||
</p>
|
||||
<ButtonLink to={paths.candidate.privacy}>
|
||||
Открыть согласия и настройки приватности
|
||||
</ButtonLink>
|
||||
</Section>
|
||||
</Page>
|
||||
);
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
export { CompanyPage } from "./ui/company-page";
|
||||
@@ -0,0 +1,106 @@
|
||||
.directory-content {
|
||||
display: grid;
|
||||
gap: var(--space-6);
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.directory-content[hidden] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.selector {
|
||||
display: grid;
|
||||
gap: var(--space-2);
|
||||
max-width: 38rem;
|
||||
}
|
||||
|
||||
.selector label {
|
||||
font-weight: var(--font-weight-bold);
|
||||
}
|
||||
|
||||
.selector select {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
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;
|
||||
}
|
||||
|
||||
.selector select:focus-visible {
|
||||
outline: var(--line-strong) solid var(--color-accent);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
.workspace {
|
||||
display: grid;
|
||||
gap: var(--space-6);
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.workspace-state {
|
||||
display: grid;
|
||||
gap: var(--space-4);
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.refresh-row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: var(--space-2) var(--space-4);
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
color: var(--color-text-secondary);
|
||||
}
|
||||
|
||||
.verification {
|
||||
display: grid;
|
||||
gap: var(--space-3);
|
||||
}
|
||||
|
||||
.facts {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(8rem, max-content) minmax(0, 1fr);
|
||||
gap: var(--space-2) var(--space-4);
|
||||
}
|
||||
|
||||
.facts dt {
|
||||
color: var(--color-text-secondary);
|
||||
}
|
||||
|
||||
.facts dd {
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.next-step {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: var(--space-3);
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: var(--space-4);
|
||||
border: var(--line-thin) solid var(--color-divider);
|
||||
border-radius: var(--radius-m);
|
||||
}
|
||||
|
||||
.load-more {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
@media (width < 30rem) {
|
||||
.facts {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.facts dd + dt {
|
||||
padding-top: var(--space-2);
|
||||
}
|
||||
|
||||
.next-step {
|
||||
align-items: flex-start;
|
||||
flex-direction: column;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,558 @@
|
||||
import { useInfiniteQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
import {
|
||||
getGetOrganizationQueryKey,
|
||||
getListMyOrganizationsQueryKey,
|
||||
listMyOrganizations,
|
||||
useGetOrganization,
|
||||
} from "../../../shared/api/endpoints/organization/organization";
|
||||
import {
|
||||
getGetCurrentSessionQueryKey,
|
||||
useGetCurrentSession,
|
||||
} from "../../../shared/api/endpoints/identity/identity";
|
||||
import { ApiRequestError } from "../../../shared/api";
|
||||
import type { MyOrganizationList, Organization, Session } from "../../../shared/api/schemas";
|
||||
import { paths } from "../../../shared/config/paths";
|
||||
import {
|
||||
Button,
|
||||
ButtonLink,
|
||||
EmptyState,
|
||||
ErrorState,
|
||||
ForbiddenState,
|
||||
LoadingState,
|
||||
Page,
|
||||
Section,
|
||||
TrustLevel,
|
||||
} from "../../../shared/ui";
|
||||
import {
|
||||
CandidateCardPreview,
|
||||
organizationBasisLabels,
|
||||
organizationLevelLabels,
|
||||
organizationTrustLevel,
|
||||
} from "../../../entities/company";
|
||||
import { CompanyEditor } from "../../../features/edit-company";
|
||||
import styles from "./company-page.module.css";
|
||||
|
||||
const pageSize = 100;
|
||||
const directoryBaseKey = getListMyOrganizationsQueryKey({ limit: pageSize });
|
||||
|
||||
type OrganizationDirectoryItem = MyOrganizationList["items"][number];
|
||||
|
||||
function isAccessLoss(error: unknown): error is ApiRequestError {
|
||||
return (
|
||||
error instanceof ApiRequestError &&
|
||||
(error.status === 401 || error.status === 403 || error.status === 404)
|
||||
);
|
||||
}
|
||||
|
||||
function roleLabel(role: OrganizationDirectoryItem["membership"]["role"]): string {
|
||||
switch (role) {
|
||||
case "owner":
|
||||
return "Владелец";
|
||||
case "recruiter":
|
||||
return "Рекрутер";
|
||||
case "hiring_manager":
|
||||
return "Менеджер по найму";
|
||||
case "technical_expert":
|
||||
return "Технический эксперт";
|
||||
}
|
||||
}
|
||||
|
||||
function formatDate(value: string): string {
|
||||
const date = new Date(value);
|
||||
if (Number.isNaN(date.getTime())) return value;
|
||||
return new Intl.DateTimeFormat("ru-RU", {
|
||||
dateStyle: "medium",
|
||||
timeStyle: "short",
|
||||
timeZone: "UTC",
|
||||
}).format(date);
|
||||
}
|
||||
|
||||
type CompanyWorkspaceProps = {
|
||||
item: OrganizationDirectoryItem;
|
||||
isAccessDenied: boolean;
|
||||
isDirectoryFresh: boolean;
|
||||
onAccessLost: (organizationId: string, error: ApiRequestError) => void;
|
||||
onSaved: (organization: Organization) => Promise<void> | void;
|
||||
};
|
||||
|
||||
function CompanyWorkspace({
|
||||
item,
|
||||
isAccessDenied,
|
||||
isDirectoryFresh,
|
||||
onAccessLost,
|
||||
onSaved,
|
||||
}: CompanyWorkspaceProps) {
|
||||
const reportedAccessError = useRef(false);
|
||||
const owner = item.membership.role === "owner" && item.membership.state === "active";
|
||||
const organization = useGetOrganization(item.organization.id, {
|
||||
query: {
|
||||
enabled: owner && isDirectoryFresh && !isAccessDenied,
|
||||
gcTime: 0,
|
||||
staleTime: 0,
|
||||
refetchOnMount: "always",
|
||||
refetchOnWindowFocus: "always",
|
||||
retry: false,
|
||||
},
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (!organization.isError || !isAccessLoss(organization.error)) {
|
||||
if (!organization.isError) reportedAccessError.current = false;
|
||||
return;
|
||||
}
|
||||
if (reportedAccessError.current) return;
|
||||
reportedAccessError.current = true;
|
||||
onAccessLost(item.organization.id, organization.error);
|
||||
}, [item.organization.id, onAccessLost, organization.error, organization.isError]);
|
||||
|
||||
if (!owner) {
|
||||
return (
|
||||
<ForbiddenState
|
||||
title="Действия владельца недоступны"
|
||||
description="В этой версии профиль компании может открывать и менять только владелец."
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
if (isAccessDenied) return null;
|
||||
|
||||
if (organization.isError && isAccessLoss(organization.error)) {
|
||||
return <ForbiddenState error={organization.error} title="Профиль компании недоступен" />;
|
||||
}
|
||||
|
||||
const requestIsPending = !isDirectoryFresh || organization.isLoading || organization.isFetching;
|
||||
const accessError = organization.isError ? organization.error : null;
|
||||
|
||||
return (
|
||||
<div className={styles["workspace-state"]}>
|
||||
{accessError ? (
|
||||
<ErrorState
|
||||
error={accessError}
|
||||
isRetrying={organization.isFetching}
|
||||
onRetry={() => void organization.refetch()}
|
||||
/>
|
||||
) : null}
|
||||
{requestIsPending ? (
|
||||
<LoadingState
|
||||
label={
|
||||
isDirectoryFresh
|
||||
? "Проверяем доступ и загружаем профиль..."
|
||||
: "Проверяем доступ к компании..."
|
||||
}
|
||||
/>
|
||||
) : null}
|
||||
{organization.data ? (
|
||||
<div hidden={requestIsPending || organization.isError}>
|
||||
<CompanyDetails
|
||||
organization={organization.data}
|
||||
isRefreshing={organization.isFetching}
|
||||
onRefresh={() => void organization.refetch()}
|
||||
onSaved={onSaved}
|
||||
onAccessLost={onAccessLostFor(item.organization.id, onAccessLost)}
|
||||
/>
|
||||
</div>
|
||||
) : null}
|
||||
{!requestIsPending && !organization.isError && !organization.data ? (
|
||||
<EmptyState
|
||||
title="Профиль компании не найден"
|
||||
description="Обновите список компаний и выберите доступный контекст."
|
||||
/>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function onAccessLostFor(
|
||||
organizationId: string,
|
||||
onAccessLost: CompanyWorkspaceProps["onAccessLost"],
|
||||
) {
|
||||
return (error: ApiRequestError) => onAccessLost(organizationId, error);
|
||||
}
|
||||
|
||||
type CompanyDetailsProps = {
|
||||
organization: Organization;
|
||||
isRefreshing: boolean;
|
||||
onRefresh: () => void;
|
||||
onSaved: CompanyWorkspaceProps["onSaved"];
|
||||
onAccessLost: (error: ApiRequestError) => void;
|
||||
};
|
||||
|
||||
function CompanyDetails({
|
||||
organization,
|
||||
isRefreshing,
|
||||
onRefresh,
|
||||
onSaved,
|
||||
onAccessLost,
|
||||
}: CompanyDetailsProps) {
|
||||
return (
|
||||
<div className={styles.workspace}>
|
||||
<div className={styles["refresh-row"]}>
|
||||
<p>Данные профиля регулярно сверяются с сервером.</p>
|
||||
<Button variant="quiet" isBusy={isRefreshing} onClick={onRefresh}>
|
||||
Обновить профиль
|
||||
</Button>
|
||||
</div>
|
||||
<Section
|
||||
title="Статус проверки"
|
||||
description="Уровень и основание устанавливает сервер. Их нельзя изменить через форму компании."
|
||||
>
|
||||
<div className={styles.verification}>
|
||||
<TrustLevel
|
||||
level={organizationTrustLevel[organization.verification.level]}
|
||||
label={organizationLevelLabels[organization.verification.level]}
|
||||
/>
|
||||
<dl className={styles.facts}>
|
||||
<dt>Основание</dt>
|
||||
<dd>{organizationBasisLabels[organization.verification.basis]}</dd>
|
||||
<dt>Установлено</dt>
|
||||
<dd>{formatDate(organization.verification.changed_at)}</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</Section>
|
||||
<Section title="Данные компании">
|
||||
<CompanyEditor
|
||||
key={organization.id}
|
||||
organization={organization}
|
||||
onSaved={onSaved}
|
||||
onAccessLost={onAccessLost}
|
||||
/>
|
||||
</Section>
|
||||
<CandidateCardPreview card={organization.candidate_card} />
|
||||
<div className={styles["next-step"]}>
|
||||
<p>Профиль компании сохранен. Можно перейти к разделу потребностей.</p>
|
||||
<ButtonLink to={paths.employer.needs} variant="secondary">
|
||||
Перейти к потребностям
|
||||
</ButtonLink>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function CompanyPage() {
|
||||
const queryClient = useQueryClient();
|
||||
const session = useGetCurrentSession({ query: { retry: false } });
|
||||
const sessionAccountId = session.data?.account.id ?? null;
|
||||
const sessionCsrfToken = session.data?.csrf_token ?? null;
|
||||
const sessionReady = Boolean(session.data) && !session.isFetching && !session.isError;
|
||||
const directoryKey = useMemo(
|
||||
() => [...directoryBaseKey, sessionAccountId ?? "no-session"] as const,
|
||||
[sessionAccountId],
|
||||
);
|
||||
const deniedOrganizationIdsRef = useRef<ReadonlySet<string>>(new Set());
|
||||
const previousAccountIdRef = useRef<string | null>(sessionAccountId);
|
||||
const [selectedId, setSelectedId] = useState<string | null>(null);
|
||||
const [createMode, setCreateMode] = useState(false);
|
||||
const [accessRefreshing, setAccessRefreshing] = useState(false);
|
||||
const [savedTransition, setSavedTransition] = useState(false);
|
||||
const [accessDeniedOrganizationId, setAccessDeniedOrganizationId] = useState<string | null>(null);
|
||||
const [deniedOrganizationIds, setDeniedOrganizationIds] = useState<ReadonlySet<string>>(
|
||||
() => new Set(),
|
||||
);
|
||||
const isCurrentSession = useCallback(() => {
|
||||
if (!sessionAccountId || !sessionCsrfToken) return false;
|
||||
const current = queryClient.getQueryData<Session>(getGetCurrentSessionQueryKey());
|
||||
const state = queryClient.getQueryState(getGetCurrentSessionQueryKey());
|
||||
return Boolean(
|
||||
current &&
|
||||
state?.status === "success" &&
|
||||
current.account.id === sessionAccountId &&
|
||||
current.csrf_token === sessionCsrfToken,
|
||||
);
|
||||
}, [queryClient, sessionAccountId, sessionCsrfToken]);
|
||||
|
||||
useEffect(() => {
|
||||
if (previousAccountIdRef.current === sessionAccountId) return;
|
||||
previousAccountIdRef.current = sessionAccountId;
|
||||
deniedOrganizationIdsRef.current = new Set();
|
||||
setDeniedOrganizationIds(new Set());
|
||||
setSelectedId(null);
|
||||
setCreateMode(false);
|
||||
setAccessRefreshing(false);
|
||||
setSavedTransition(false);
|
||||
setAccessDeniedOrganizationId(null);
|
||||
}, [sessionAccountId]);
|
||||
|
||||
const directory = useInfiniteQuery({
|
||||
queryKey: directoryKey,
|
||||
initialPageParam: undefined as string | undefined,
|
||||
queryFn: ({ pageParam, signal }) =>
|
||||
listMyOrganizations(
|
||||
{ limit: pageSize, ...(pageParam ? { cursor: pageParam } : {}) },
|
||||
{ signal },
|
||||
),
|
||||
getNextPageParam: (lastPage) =>
|
||||
lastPage.page.has_more ? (lastPage.page.next_cursor ?? undefined) : undefined,
|
||||
gcTime: 0,
|
||||
staleTime: 0,
|
||||
refetchOnMount: "always",
|
||||
refetchOnWindowFocus: "always",
|
||||
retry: false,
|
||||
enabled: sessionReady,
|
||||
});
|
||||
const refetchDirectory = directory.refetch;
|
||||
|
||||
const items = useMemo(
|
||||
() => directory.data?.pages.flatMap((page) => page.items) ?? [],
|
||||
[directory.data],
|
||||
);
|
||||
const selectedItem =
|
||||
items.find((item) => item.organization.id === selectedId) ??
|
||||
items.find((item) => item.membership.role === "owner") ??
|
||||
items[0];
|
||||
const selectedOrganizationDenied =
|
||||
selectedItem !== undefined && deniedOrganizationIds.has(selectedItem.organization.id);
|
||||
const isRefreshingDirectory = directory.isFetching && !directory.isFetchingNextPage;
|
||||
const directoryFresh =
|
||||
sessionReady &&
|
||||
Boolean(directory.data) &&
|
||||
!directory.isError &&
|
||||
!isRefreshingDirectory &&
|
||||
!accessRefreshing &&
|
||||
!savedTransition;
|
||||
|
||||
const handleAccessLost = useCallback(
|
||||
async (organizationId: string, error: ApiRequestError) => {
|
||||
if (error.status !== 401 && error.status !== 403 && error.status !== 404) return;
|
||||
if (!isCurrentSession()) return;
|
||||
const denied = new Set(deniedOrganizationIdsRef.current);
|
||||
denied.add(organizationId);
|
||||
deniedOrganizationIdsRef.current = denied;
|
||||
setDeniedOrganizationIds(denied);
|
||||
setAccessDeniedOrganizationId(organizationId);
|
||||
setAccessRefreshing(true);
|
||||
try {
|
||||
if (organizationId !== "") {
|
||||
await queryClient.removeQueries({
|
||||
queryKey: getGetOrganizationQueryKey(organizationId),
|
||||
exact: true,
|
||||
});
|
||||
}
|
||||
if (!isCurrentSession()) return;
|
||||
const refreshed = await refetchDirectory();
|
||||
if (!isCurrentSession()) return;
|
||||
const refreshedItems = refreshed.data?.pages.flatMap((page) => page.items) ?? [];
|
||||
if (!refreshedItems.some((item) => item.organization.id === organizationId)) {
|
||||
setSelectedId(null);
|
||||
}
|
||||
} finally {
|
||||
if (isCurrentSession()) setAccessRefreshing(false);
|
||||
}
|
||||
},
|
||||
[isCurrentSession, queryClient, refetchDirectory],
|
||||
);
|
||||
|
||||
const handleCreateAccessLost = useCallback(
|
||||
async (error: ApiRequestError) => {
|
||||
if (error.status !== 401 && error.status !== 403 && error.status !== 404) return;
|
||||
if (!isCurrentSession()) return;
|
||||
setAccessRefreshing(true);
|
||||
try {
|
||||
await refetchDirectory();
|
||||
if (!isCurrentSession()) return;
|
||||
} finally {
|
||||
if (isCurrentSession()) setAccessRefreshing(false);
|
||||
}
|
||||
},
|
||||
[isCurrentSession, refetchDirectory],
|
||||
);
|
||||
|
||||
const handleRetryAccess = useCallback(
|
||||
(organizationId: string) => {
|
||||
if (!isCurrentSession()) return;
|
||||
const denied = new Set(deniedOrganizationIdsRef.current);
|
||||
denied.delete(organizationId);
|
||||
deniedOrganizationIdsRef.current = denied;
|
||||
setDeniedOrganizationIds(denied);
|
||||
if (accessDeniedOrganizationId === organizationId) setAccessDeniedOrganizationId(null);
|
||||
void queryClient.removeQueries({
|
||||
queryKey: getGetOrganizationQueryKey(organizationId),
|
||||
exact: true,
|
||||
});
|
||||
void queryClient.invalidateQueries({ queryKey: directoryKey, exact: true });
|
||||
},
|
||||
[accessDeniedOrganizationId, directoryKey, isCurrentSession, queryClient],
|
||||
);
|
||||
|
||||
const handleSaved = useCallback(
|
||||
async (organization: Organization) => {
|
||||
if (!isCurrentSession()) return;
|
||||
if (deniedOrganizationIdsRef.current.has(organization.id)) return;
|
||||
const organizationQueryKey = getGetOrganizationQueryKey(organization.id);
|
||||
const currentOrganizationQuery = queryClient.getQueryState(organizationQueryKey);
|
||||
if (
|
||||
currentOrganizationQuery?.status === "error" &&
|
||||
isAccessLoss(currentOrganizationQuery.error)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
queryClient.setQueryData(organizationQueryKey, organization);
|
||||
const alreadyInDirectory = items.some((item) => item.organization.id === organization.id);
|
||||
if (alreadyInDirectory) {
|
||||
await refetchDirectory();
|
||||
return;
|
||||
}
|
||||
setSavedTransition(true);
|
||||
try {
|
||||
const refreshed = await refetchDirectory();
|
||||
if (!isCurrentSession()) return;
|
||||
if (deniedOrganizationIdsRef.current.has(organization.id)) return;
|
||||
if (refreshed.isError) throw refreshed.error;
|
||||
const refreshedItems = refreshed.data?.pages.flatMap((page) => page.items) ?? [];
|
||||
if (!refreshedItems.some((item) => item.organization.id === organization.id)) {
|
||||
throw new Error("The saved company is not available in the refreshed directory.");
|
||||
}
|
||||
setSelectedId(organization.id);
|
||||
setCreateMode(false);
|
||||
} finally {
|
||||
if (isCurrentSession()) setSavedTransition(false);
|
||||
}
|
||||
},
|
||||
[isCurrentSession, items, queryClient, refetchDirectory],
|
||||
);
|
||||
|
||||
const isDirectoryError = sessionReady && directory.isError;
|
||||
const directoryErrorIsAccessLoss = isDirectoryError && isAccessLoss(directory.error);
|
||||
const showLoading =
|
||||
!session.isError &&
|
||||
(!session.data ||
|
||||
session.isFetching ||
|
||||
directory.isLoading ||
|
||||
isRefreshingDirectory ||
|
||||
accessRefreshing ||
|
||||
savedTransition ||
|
||||
!directory.data);
|
||||
|
||||
return (
|
||||
<Page
|
||||
title="Компания"
|
||||
eyebrow="Кабинет работодателя"
|
||||
lead="Выберите компанию, управляйте ее карточкой и проверьте, как ее увидит кандидат."
|
||||
width="wide"
|
||||
>
|
||||
{session.isError && !session.isFetching ? (
|
||||
isAccessLoss(session.error) ? (
|
||||
<ForbiddenState error={session.error} title="Текущий вход не подтвержден" />
|
||||
) : (
|
||||
<ErrorState
|
||||
error={session.error}
|
||||
isRetrying={session.isRefetching}
|
||||
onRetry={() => void session.refetch()}
|
||||
title="Не удалось проверить текущий вход"
|
||||
/>
|
||||
)
|
||||
) : null}
|
||||
{accessDeniedOrganizationId ? (
|
||||
<ForbiddenState
|
||||
title="Профиль компании недоступен"
|
||||
description="Доступ к выбранной компании закрыт. Выберите другую компанию или создайте новую."
|
||||
action={
|
||||
<Button
|
||||
variant="secondary"
|
||||
onClick={() => handleRetryAccess(accessDeniedOrganizationId)}
|
||||
>
|
||||
Проверить доступ снова
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
) : null}
|
||||
{showLoading ? (
|
||||
<LoadingState label="Загружаем список компаний и проверяем доступ..." />
|
||||
) : null}
|
||||
{isDirectoryError ? (
|
||||
directoryErrorIsAccessLoss ? (
|
||||
<ForbiddenState error={directory.error} />
|
||||
) : (
|
||||
<ErrorState
|
||||
error={directory.error}
|
||||
isRetrying={directory.isFetching}
|
||||
onRetry={() => void directory.refetch()}
|
||||
/>
|
||||
)
|
||||
) : null}
|
||||
{!directoryErrorIsAccessLoss && directory.data ? (
|
||||
<div
|
||||
className={styles["directory-content"]}
|
||||
hidden={!directoryFresh || selectedOrganizationDenied}
|
||||
>
|
||||
{items.length > 0 ? (
|
||||
<Section
|
||||
title="Ваши компании"
|
||||
description="Выбирайте только компании, в которых у вас есть активное членство."
|
||||
>
|
||||
<div className={styles.selector}>
|
||||
<label htmlFor="company-directory">Компания</label>
|
||||
<select
|
||||
id="company-directory"
|
||||
value={createMode ? "__create__" : (selectedItem?.organization.id ?? "")}
|
||||
onChange={(event) => {
|
||||
setAccessDeniedOrganizationId(null);
|
||||
if (event.currentTarget.value === "__create__") {
|
||||
setCreateMode(true);
|
||||
} else {
|
||||
setCreateMode(false);
|
||||
setSelectedId(event.currentTarget.value);
|
||||
}
|
||||
}}
|
||||
>
|
||||
{items.map((item) => (
|
||||
<option key={item.organization.id} value={item.organization.id}>
|
||||
{item.organization.name} - {roleLabel(item.membership.role)}
|
||||
</option>
|
||||
))}
|
||||
{items.some((item) => item.membership.role === "owner") ? (
|
||||
<option value="__create__">Создать еще одну компанию</option>
|
||||
) : null}
|
||||
</select>
|
||||
</div>
|
||||
{createMode ? (
|
||||
<Section title="Создать компанию">
|
||||
<CompanyEditor
|
||||
key={`create:${sessionAccountId ?? "no-session"}`}
|
||||
onSaved={handleSaved}
|
||||
onAccessLost={handleCreateAccessLost}
|
||||
/>
|
||||
<Button variant="quiet" onClick={() => setCreateMode(false)}>
|
||||
Вернуться к выбранной компании
|
||||
</Button>
|
||||
</Section>
|
||||
) : selectedItem ? (
|
||||
<CompanyWorkspace
|
||||
key={`${sessionAccountId ?? "no-session"}:${selectedItem.organization.id}`}
|
||||
item={selectedItem}
|
||||
isAccessDenied={deniedOrganizationIds.has(selectedItem.organization.id)}
|
||||
isDirectoryFresh={directoryFresh}
|
||||
onAccessLost={handleAccessLost}
|
||||
onSaved={handleSaved}
|
||||
/>
|
||||
) : null}
|
||||
</Section>
|
||||
) : (
|
||||
<Section title="Создать компанию">
|
||||
<EmptyState
|
||||
title="Компаний пока нет"
|
||||
description="Создайте компанию, чтобы заполнить карточку и показать кандидатам основные сведения."
|
||||
/>
|
||||
<CompanyEditor
|
||||
key={`create:${sessionAccountId ?? "no-session"}`}
|
||||
onSaved={handleSaved}
|
||||
onAccessLost={handleCreateAccessLost}
|
||||
/>
|
||||
</Section>
|
||||
)}
|
||||
{directory.hasNextPage ? (
|
||||
<div className={styles["load-more"]}>
|
||||
<Button
|
||||
variant="secondary"
|
||||
isBusy={directory.isFetchingNextPage}
|
||||
onClick={() => void directory.fetchNextPage()}
|
||||
>
|
||||
{directory.isFetchingNextPage ? "Загружаем компании..." : "Показать еще компании"}
|
||||
</Button>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
) : null}
|
||||
</Page>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export { ProfilePage } from "./ui/profile-page";
|
||||
@@ -0,0 +1,15 @@
|
||||
import { EditProfile } from "../../../features/edit-profile";
|
||||
import { Page } from "../../../shared/ui";
|
||||
|
||||
export function ProfilePage() {
|
||||
return (
|
||||
<Page
|
||||
title="Профиль"
|
||||
eyebrow="Кабинет кандидата"
|
||||
lead="Управляйте своими сведениями и проверяйте, какие данные подтверждены оценкой."
|
||||
width="wide"
|
||||
>
|
||||
<EditProfile />
|
||||
</Page>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export { QuestionnairePage } from "./ui/questionnaire-page";
|
||||
@@ -0,0 +1,15 @@
|
||||
import { FillQuestionnaire } from "../../../features/fill-questionnaire";
|
||||
import { Page } from "../../../shared/ui";
|
||||
|
||||
export function QuestionnairePage() {
|
||||
return (
|
||||
<Page
|
||||
title="Анкета"
|
||||
eyebrow="Кабинет кандидата"
|
||||
lead="Укажите специализации и условия поиска. Самооценка не становится подтвержденной категорией."
|
||||
width="wide"
|
||||
>
|
||||
<FillQuestionnaire />
|
||||
</Page>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user