'use client'
import { useParams, useRouter } from 'next/navigation'
import { useVacancy } from '@/hooks/useVacancy'
import { VacancyRead } from '@/types/api'
import {
ArrowLeft,
MapPin,
Clock,
Banknote,
Building,
Users,
Calendar,
Phone,
Mail,
Globe,
FileText
} from 'lucide-react'
import ResumeUploadForm from '@/components/ResumeUploadForm'
import ModeGuard from '@/components/ModeGuard'
export default function VacancyPage() {
return (
)
}
function VacancyPageContent() {
const params = useParams()
const router = useRouter()
const vacancyId = parseInt(params.id as string)
const { data: vacancy, isLoading, error } = useVacancy(vacancyId)
const formatSalary = (vacancy: VacancyRead) => {
if (!vacancy.salary_from && !vacancy.salary_to) return 'Зарплата не указана'
const currency = vacancy.salary_currency === 'RUR' ? '₽' : vacancy.salary_currency
if (vacancy.salary_from && vacancy.salary_to) {
return `${ vacancy.salary_from.toLocaleString() } - ${ vacancy.salary_to.toLocaleString() } ${ currency }`
}
if (vacancy.salary_from) {
return `от ${ vacancy.salary_from.toLocaleString() } ${ currency }`
}
if (vacancy.salary_to) {
return `до ${ vacancy.salary_to.toLocaleString() } ${ currency }`
}
}
const getExperienceText = (experience: string) => {
const mapping = {
noExperience: 'Без опыта',
between1And3: '1-3 года',
between3And6: '3-6 лет',
moreThan6: 'Более 6 лет'
}
return mapping[experience as keyof typeof mapping] || experience
}
const getEmploymentText = (employment: string) => {
const mapping = {
full: 'Полная занятость',
part: 'Частичная занятость',
project: 'Проектная работа',
volunteer: 'Волонтерство',
probation: 'Стажировка'
}
return mapping[employment as keyof typeof mapping] || employment
}
const getScheduleText = (schedule: string) => {
const mapping = {
fullDay: 'Полный день',
shift: 'Сменный график',
flexible: 'Гибкий график',
remote: 'Удаленная работа',
flyInFlyOut: 'Вахтовый метод'
}
return mapping[schedule as keyof typeof mapping] || schedule
}
const formatNullableField = (value: string | null | undefined) => {
if (!value || value === 'null') return 'Не указано'
return value
}
if (isLoading) {
return (
)
}
if (error || !vacancy) {
return (
Не удалось загрузить информацию о вакансии
)
}
return (
{/* Header */ }
{ vacancy.premium && (
Premium
) }
{/* Main Content */ }
{/* Left Column - Vacancy Details */ }
{/* Title and Company */ }
{ vacancy.title }
{formatNullableField(vacancy.company_name)}
{ formatSalary(vacancy) }
{formatNullableField(vacancy.area_name)}
{ getExperienceText(vacancy.experience) }
{ getEmploymentText(vacancy.employment_type) }
{ formatNullableField(getScheduleText(vacancy.schedule)) }
{ vacancy.published_at && (
Опубликовано { new Date(vacancy.published_at).toLocaleDateString('ru-RU') }
) }
{/* Description */ }
Описание вакансии
{ formatNullableField(vacancy.description) }
{/* Key Skills */ }
{ vacancy.key_skills && (
Ключевые навыки
{ formatNullableField(vacancy.key_skills) }
) }
{/* Company Description */ }
{ vacancy.company_description && (
О компании
{ formatNullableField(vacancy.company_description) }
) }
{/* Location Details */ }
{ ( vacancy.address || vacancy.metro_stations ) && (
Местоположение
{ vacancy.address && (
{ formatNullableField(vacancy.address) }
) }
{ vacancy.metro_stations && (
Метро:
{ formatNullableField(vacancy.metro_stations) }
) }
) }
{/* Right Column - Application Form and Contact Info */ }
{/* Contact Information */ }
{ ( vacancy.contacts_name || vacancy.contacts_email || vacancy.contacts_phone || vacancy.url ) && (
Контактная информация
{ vacancy.contacts_name && (
{ formatNullableField(vacancy.contacts_name) }
) }
{ vacancy.contacts_email && (
) }
{ vacancy.contacts_phone && (
) }
{ vacancy.url && (
) }
) }
{/* Application Form */ }
)
}