Files
resugen-frontend/src/stores/vacancies.js
2026-04-12 15:55:04 +03:00

161 lines
4.4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { defineStore } from 'pinia'
// Моковые детальные данные для существующих вакансий
const mockVacancyDetails = {
1: {
offer_name: 'Senior Frontend Developer',
employer_name: 'TechCorp',
salary_from: '250000',
salary_to: '350000',
area_name: 'Москва',
experience: 'От 3 до 6 лет',
schedule: 'Полный день',
employment: 'Полная занятость',
key_skills: 'Vue.js, React, TypeScript, Tailwind CSS, Webpack, Vite',
},
2: {
offer_name: 'Python Backend Engineer',
employer_name: 'DataSystems',
salary_from: '200000',
salary_to: '280000',
area_name: 'Санкт-Петербург',
experience: 'От 1 года до 3 лет',
schedule: 'Удаленная работа',
employment: 'Проектная работа',
key_skills: 'Python, Django, FastAPI, PostgreSQL, Redis, Docker',
},
3: {
offer_name: 'Product Manager',
employer_name: 'StartupX',
salary_from: '180000',
salary_to: '250000',
area_name: 'Москва',
experience: 'От 3 до 6 лет',
schedule: 'Гибкий график',
employment: 'Полная занятость',
key_skills: 'Agile, Scrum, Product Roadmap, User Stories, Jira, Confluence',
},
}
const mockVacancies = [
{
id: 1,
title: 'Senior Frontend Developer',
company: 'TechCorp',
source: 'hh.ru',
url: 'https://hh.ru/vacancy/123',
createdAt: '2026-04-01',
status: 'Активна',
},
{
id: 2,
title: 'Python Backend Engineer',
company: 'DataSystems',
source: 'hh.ru',
url: 'https://hh.ru/vacancy/456',
createdAt: '2026-03-28',
status: 'Активна',
},
{
id: 3,
title: 'Product Manager',
company: 'StartupX',
source: 'hh.ru',
url: 'https://hh.ru/vacancy/789',
createdAt: '2026-03-20',
status: 'В архиве',
},
]
export const useVacanciesStore = defineStore('vacancies', {
state: () => ({
vacancies: [...mockVacancies],
details: { ...mockVacancyDetails },
nextId: 4,
}),
actions: {
// Создать пустой объект полей
createEmptyFields() {
return {
offer_name: '',
employer_name: '',
salary_from: '',
salary_to: '',
area_name: '',
experience: '',
schedule: '',
employment: '',
key_skills: '',
}
},
// Получить детальные поля вакансии
getVacancyDetails(id) {
return this.details[id] || this.createEmptyFields()
},
// Сохранить (создать или обновить)
saveVacancy(id, data) {
const { offer_name, employer_name, salary_from, salary_to, area_name, experience, schedule, employment, key_skills, url, status } = data
if (id && this.vacancies.find(v => v.id === id)) {
// Обновление существующей
const vacancy = this.vacancies.find(v => v.id === id)
vacancy.title = offer_name
vacancy.company = employer_name
if (url !== undefined) vacancy.url = url
if (status !== undefined) vacancy.status = status
vacancy.updatedAt = new Date().toISOString().split('T')[0]
this.details[id] = {
offer_name,
employer_name,
salary_from,
salary_to,
area_name,
experience,
schedule,
employment,
key_skills,
}
return id
} else {
// Создание новой
const newId = this.nextId++
const newVacancy = {
id: newId,
title: offer_name,
company: employer_name,
source: 'Ручной ввод',
url: url || '',
createdAt: new Date().toISOString().split('T')[0],
status: status || 'Активна',
}
this.vacancies.push(newVacancy)
this.details[newId] = {
offer_name,
employer_name,
salary_from,
salary_to,
area_name,
experience,
schedule,
employment,
key_skills,
}
return newId
}
},
deleteVacancy(id) {
this.vacancies = this.vacancies.filter(v => v.id !== id)
delete this.details[id]
},
},
persist: {
key: 'vacancies-storage',
storage: localStorage,
},
})