import { useId } from "react"; import type { NeedFormValues } from "../../../entities/need"; import { Card, Mono, Tag } from "../../../shared/ui"; import { describeSalary, pendingSuggestionCount } from "../model/steps"; import styles from "./need-editor.module.css"; const specializationLabels: Readonly> = { backend: "Backend", frontend: "Frontend", mobile: "Мобильная разработка", network_engineer: "Сетевые технологии", devops_sre: "DevOps/SRE", data_analyst: "Аналитика данных", ds_ml: "DS/ML", information_security: "Информационная безопасность", qa: "QA", }; const gradeLabels: Readonly> = { intern: "Стажер", junior: "Junior", middle: "Middle", senior: "Senior", }; type NeedSummaryProps = { values: NeedFormValues; }; /** * A live card of the need as it stands in the form, shaped like the cards the * employer later reads in search: the role and grade tag, the stack chips, and * the salary in mono. It reads the draft only and sends nothing. */ export function NeedSummary({ values }: NeedSummaryProps) { const headingId = useId(); const specialization = values.specialization.status === "unknown" ? null : (specializationLabels[values.specialization.value] ?? values.specialization.value); const grade = values.grade.status === "unknown" ? null : (gradeLabels[values.grade.value] ?? values.grade.value); const pending = pendingSuggestionCount(values); const title = values.title.trim(); return (

Сводка потребности

{title === "" ? "Название не задано" : title}

{specialization || grade ? ( {[specialization, grade].filter(Boolean).join(" · ")} ) : ( Роль не выбрана )} {pending > 0 ? {`Ждут подтверждения: ${pending}`} : null}
{values.salary.status === "unknown" ? (

Вилка не указана

) : (

{describeSalary(values.salary.value)}

)}
Обязательные
{values.requiredSkills.length === 0 ? ( Не указаны ) : ( {values.requiredSkills.map((skill, index) => ( {skill.name} ))} )}
{values.desiredSkills.length > 0 ? (
Желательные
{values.desiredSkills.map((skill, index) => ( {skill.name} ))}
) : null}
Задач
{values.tasks.length}
); }