1
0

Добавление проектов

Добавили возможность создавания разных проектов.
This commit is contained in:
2026-01-14 10:46:38 +07:00
parent 04e88cb7fa
commit 719aecd09e
22 changed files with 996 additions and 233 deletions

View File

@@ -38,40 +38,56 @@ export const authApi = {
})
}
// ==================== DEPARTMENTS ====================
export const departmentsApi = {
getAll: () => request('/api/task', {
// ==================== PROJECTS ====================
export const projectsApi = {
// active: ID проекта для загрузки данных (опционально)
getAll: (active = null) => {
let url = '/api/project'
if (active) url += `?active=${active}`
return request(url, { credentials: 'include' })
},
// Получение данных проекта (проект + колонки + отделы) — один запрос вместо трёх
getData: (id_project) => request('/api/project', {
method: 'POST',
credentials: 'include',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ action: 'get_departments' })
})
}
// ==================== LABELS ====================
export const labelsApi = {
getAll: () => request('/api/task', {
body: JSON.stringify({ action: 'get_project_data', id_project })
}),
create: (data) => request('/api/project', {
method: 'POST',
credentials: 'include',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ action: 'get_labels' })
})
}
// ==================== COLUMNS ====================
export const columnsApi = {
getAll: () => request('/api/task', {
body: JSON.stringify({ action: 'create', ...data })
}),
update: (data) => request('/api/project', {
method: 'POST',
credentials: 'include',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ action: 'get_columns' })
body: JSON.stringify({ action: 'update', ...data })
}),
delete: (id) => request('/api/project', {
method: 'POST',
credentials: 'include',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ action: 'delete', id })
}),
setReadyColumn: (id_project, column_id) => request('/api/project', {
method: 'POST',
credentials: 'include',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ action: 'set_ready_column', id_project, column_id })
})
}
// ==================== CARDS ====================
export const cardsApi = {
// id_project: ID проекта (обязательный)
// archive: 0 = неархивные (по умолчанию), 1 = архивные, 'all' = все
getAll: (archive = 0) => request(`/api/task${archive !== 0 ? `?archive=${archive}` : ''}`, { credentials: 'include' }),
getAll: (id_project, archive = 0) => {
let url = `/api/task?id_project=${id_project}`
if (archive !== 0) url += `&archive=${archive}`
return request(url, { credentials: 'include' })
},
updateOrder: (id, column_id, to_index) => request('/api/task', {
method: 'POST',
credentials: 'include',
@@ -125,25 +141,3 @@ export const taskImageApi = {
export const usersApi = {
getAll: () => request('/api/user', { credentials: 'include' })
}
// ==================== CONFIG ====================
export const configApi = {
get: () => request('/api/user', {
method: 'POST',
credentials: 'include',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ action: 'get_config' })
})
}
// Загрузка конфига с сервера и мерж с window.APP_CONFIG
export const loadServerConfig = async () => {
try {
const result = await configApi.get()
if (result.success && result.data) {
window.APP_CONFIG = { ...window.APP_CONFIG, ...result.data }
}
} catch (error) {
console.error('Ошибка загрузки конфига:', error)
}
}