feat(privacy): complete the publication, hiding and preview settings screen
This commit is contained in:
1 parent
c2a8d17195
commit
5edff21d2d
28 files changed
+2230
-428
No files matched your search
@@ -5,14 +5,20 @@ import type {
|
||||
CardPreview,
|
||||
CardSelfAssessment,
|
||||
CandidateExperienceBand,
|
||||
EvidenceBasis,
|
||||
EvidenceCalibrationStatus,
|
||||
EvidenceSkillCode,
|
||||
CandidateSalaryCompatibility,
|
||||
CandidateWorkFormat,
|
||||
ConsentRecord,
|
||||
HiddenOrganization,
|
||||
OrganizationEvidenceFact,
|
||||
PrivacySettings,
|
||||
Publication,
|
||||
PublicationUpdate,
|
||||
SearchStatusUpdate,
|
||||
} from "../../../shared/api/schemas";
|
||||
import type { TrustLevelValue } from "../../../shared/ui";
|
||||
|
||||
export const publishableCardFields = [
|
||||
"categories",
|
||||
@@ -196,9 +202,21 @@ export type CategoryPresentation = {
|
||||
export type SelfAssessmentPresentation = {
|
||||
specialization: string;
|
||||
declaredGrade: string | null;
|
||||
/** True only when the server says this specialization has a confirmed grade. */
|
||||
confirmed: boolean;
|
||||
confirmation: string;
|
||||
};
|
||||
|
||||
export type EvidencePresentation = {
|
||||
/** Skill and passed grade, for example "Backend: Middle". */
|
||||
title: string;
|
||||
trust: TrustLevelValue;
|
||||
trustLabel: string;
|
||||
observedYear: number;
|
||||
basisLabel: string;
|
||||
calibrationLabel: string;
|
||||
};
|
||||
|
||||
export type CandidateViewPresentation = {
|
||||
pseudonym: string;
|
||||
categories: readonly CategoryPresentation[] | null;
|
||||
@@ -207,6 +225,11 @@ export type CandidateViewPresentation = {
|
||||
experience: string | null;
|
||||
workFormats: readonly string[] | null;
|
||||
salaryCompatibility: string | null;
|
||||
/**
|
||||
* Supporting assessment facts as an organization reads them. Null while the
|
||||
* card is closed; an empty list when no visible fact supports a category.
|
||||
*/
|
||||
evidence: readonly EvidencePresentation[] | null;
|
||||
};
|
||||
|
||||
function categoryPresentation(category: CardCategory): CategoryPresentation {
|
||||
@@ -222,11 +245,53 @@ function selfAssessmentPresentation(item: CardSelfAssessment): SelfAssessmentPre
|
||||
return {
|
||||
specialization: specializationLabels[item.specialization],
|
||||
declaredGrade: item.declared_grade ? gradeLabels[item.declared_grade] : null,
|
||||
confirmed: item.confirmation_status === "confirmed",
|
||||
confirmation:
|
||||
item.confirmation_status === "confirmed" ? "Грейд подтвержден" : "Грейд не подтвержден",
|
||||
};
|
||||
}
|
||||
|
||||
const evidenceSkillLabels: Readonly<Record<EvidenceSkillCode, string>> = {
|
||||
...specializationLabels,
|
||||
...stackLabels,
|
||||
};
|
||||
|
||||
// The shape of a mark follows the strength of the confirmation, and the label
|
||||
// always names the exact meaning of the level so it never depends on the shape.
|
||||
type EvidenceTrustView = { level: TrustLevelValue; label: string };
|
||||
|
||||
const claimedEvidence: EvidenceTrustView = {
|
||||
level: "claimed",
|
||||
label: "Заявлено, не подтверждено отдельно",
|
||||
};
|
||||
|
||||
const evidenceTrust: Readonly<Record<number, EvidenceTrustView>> = {
|
||||
0: claimedEvidence,
|
||||
1: { level: "partial", label: "Онлайн-результат без подтверждения личности" },
|
||||
2: { level: "confirmed", label: "Результат привязан к подтвержденной личности" },
|
||||
3: { level: "confirmed", label: "Очная проверка" },
|
||||
};
|
||||
|
||||
export const evidenceBasisLabels: Readonly<Record<EvidenceBasis, string>> = {
|
||||
synthetic_demo: "Синтетическая демонстрация, не проверенное измерение",
|
||||
};
|
||||
|
||||
export const evidenceCalibrationLabels: Readonly<Record<EvidenceCalibrationStatus, string>> = {
|
||||
uncalibrated: "Пороги не откалиброваны",
|
||||
};
|
||||
|
||||
function evidencePresentation(fact: OrganizationEvidenceFact): EvidencePresentation {
|
||||
const trust = evidenceTrust[fact.trust] ?? claimedEvidence;
|
||||
return {
|
||||
title: `${evidenceSkillLabels[fact.skill]}: ${gradeLabels[fact.grade]}`,
|
||||
trust: trust.level,
|
||||
trustLabel: trust.label,
|
||||
observedYear: fact.observed_year,
|
||||
basisLabel: evidenceBasisLabels[fact.basis],
|
||||
calibrationLabel: evidenceCalibrationLabels[fact.calibration_status],
|
||||
};
|
||||
}
|
||||
|
||||
export function presentCandidatePreview(preview: CardPreview): CandidateViewPresentation | null {
|
||||
const card = preview.card;
|
||||
if (!card) return null;
|
||||
@@ -241,6 +306,7 @@ export function presentCandidatePreview(preview: CardPreview): CandidateViewPres
|
||||
salaryCompatibility: card.salary_compatibility
|
||||
? salaryCompatibilityLabels[card.salary_compatibility]
|
||||
: null,
|
||||
evidence: preview.evidence ? preview.evidence.items.map(evidencePresentation) : null,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -269,3 +335,49 @@ export const cardAccessLabels = {
|
||||
card_viewed: "Просмотрена карточка профиля",
|
||||
contact_read: "Открыты контактные данные",
|
||||
} as const;
|
||||
|
||||
export type PublicationClosureNotice = {
|
||||
title: string;
|
||||
points: readonly string[];
|
||||
};
|
||||
|
||||
/**
|
||||
* Explains a closed card to its owner. The text restates the server reason and
|
||||
* the contract rules: a closed card is unreadable at once, and neither a new
|
||||
* C2 nor an unhide reopens an earlier contact grant. A former company reads
|
||||
* contacts again only after a new invitation and a new C4. The notice is
|
||||
* absent while the card is published and for a card that was never published.
|
||||
*/
|
||||
export function describePublicationClosure(
|
||||
publication: Pick<Publication, "state" | "closed_reason">,
|
||||
): PublicationClosureNotice | null {
|
||||
if (publication.state === "published") return null;
|
||||
if (publication.closed_reason === "consent_revoked") {
|
||||
return {
|
||||
title: "Согласие C2 отозвано, карточка закрыта",
|
||||
points: [
|
||||
"Будущие чтения карточки компаниями закрыты сразу, без ожидания обновления поиска.",
|
||||
"Новое согласие C2 не откроет карточку само: выберите поля и включите публикацию отдельным действием.",
|
||||
"Прежний доступ к контактам не возвращается. Компании, которая уже получала контакты, нужны новое приглашение и новое согласие C4.",
|
||||
],
|
||||
};
|
||||
}
|
||||
if (publication.closed_reason === "closed_by_candidate") {
|
||||
return {
|
||||
title: "Вы закрыли карточку",
|
||||
points: [
|
||||
"Будущие чтения карточки компаниями закрыты.",
|
||||
"Повторная публикация не восстанавливает прежний доступ к контактам: компании, которая уже получала контакты, нужны новое приглашение и новое согласие C4.",
|
||||
],
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Wording about contact access that follows a hide, an unhide or a republish. */
|
||||
export const contactAccessAfterVisibilityChange =
|
||||
"Скрытие закрывает будущие чтения этой компании. Снятие скрытия и повторная публикация не восстанавливают прежний доступ к контактам: бывшей компании нужны новое приглашение и новое согласие C4.";
|
||||
|
||||
export function describeAccessOrganization(organization: { name: string } | null): string {
|
||||
return organization ? organization.name : "Организация не раскрывается";
|
||||
}
|
||||
Reference in new issue
Block a user