{{ t.title }}
+{{ t.message }}
+${d.description.replace(/\n/g, '
')}
` : '', - client_taker: null, hu: linkedHuIds, - stimated_start_date: meta.estimatedStart || null, - stimated_end_date: meta.estimatedEnd || null, - }), + endpoint = '/api/epicdevelopment/create/' + body = JSON.stringify({ + initiative: String(d.projectId), + name: d.title, + description: d.description ? `${d.description.replace(/\n/g, '
')}
` : '', + stimated_start_date: meta.estimatedStart || null, + stimated_end_date: meta.estimatedEnd || null, + client_taker: Number(meta.clientTaker) || null, + hu: linkedHuIds, + status: false, }) - if (res.ok) { - d.syncStatus = 'pushed'; await dbSaveDraft(d) - } else { - d.syncStatus = 'draft'; await dbSaveDraft(d) - } } else { - // Push HU individual - const res = await fetch('/api/userstorys/create/', { - method: 'POST', headers, - body: JSON.stringify({ - initiative: String(d.projectId), title: d.title, - description: d.description ? `${d.description.replace(/\n/g, '
')}
` : '', - criterios_aceptacion: d.acceptanceCriteria ? `${d.acceptanceCriteria.replace(/\n/g, '
')}
` : '', - story_points: '', - priority: d.priority === 'Alta' ? '1' : d.priority === 'Baja' ? '3' : '2', - sprint: '', asignado_a: [], client_taker: null, - characterization_hu: '', has_impairment: false, - epic_development: null, feature: '', - initial_date: null, end_date: null, - }), + // Push HU + endpoint = '/api/userstorys/create/' + body = JSON.stringify({ + initiative: String(d.projectId), title: d.title, + description: d.description ? `${d.description.replace(/\n/g, '
')}
` : '', + criterios_aceptacion: d.acceptanceCriteria ? `${d.acceptanceCriteria.replace(/\n/g, '
')}
` : '', + story_points: String(d.story_points ?? ''), + priority: d.priority === 'Alta' ? '1' : d.priority === 'Baja' ? '3' : '2', + sprint: '', asignado_a: [], client_taker: null, + characterization_hu: '', has_impairment: false, + epic_development: null, feature: '', + initial_date: null, end_date: null, }) - if (res.ok) { + } + + const res = await fetch(endpoint, { method: 'POST', headers, body }) + if (res.ok) { + if (d.type !== 'E') { const created = await res.json() d.kappaId = created.id || undefined - d.syncStatus = 'pushed' - await dbSaveDraft(d) - } else { - d.syncStatus = 'draft'; await dbSaveDraft(d) } + d.syncStatus = 'pushed' + await dbSaveDraft(d) + showToast('success', d.type === 'E' ? 'Épica creada en KAPPA' : 'HU creada en KAPPA', d.title.slice(0, 100)) + } else { + const errorText = await res.text().catch(() => 'Error desconocido') + console.error(`[Alpha] Error push a KAPPA (${endpoint}): ${res.status} — ${errorText}`) + showToast('error', 'Error al crear en KAPPA', errorText.slice(0, 300)) + d.syncStatus = 'draft' + await dbSaveDraft(d) } - } catch { - d.syncStatus = 'draft'; await dbSaveDraft(d) + } catch (e: any) { + console.error('[Alpha] Error en pushDraft:', e) + showToast('error', 'Error de red', e.message) + d.syncStatus = 'draft' + await dbSaveDraft(d) } finally { pushingDraftId.value = null await loadDrafts() @@ -420,7 +428,10 @@ const statusLabel = (status: unknown) => {