Fix 7 frontend bugs found during audit
- Fix breadcrumb group name fetch using existing /api/categories/<id>/groups
- Fix diagramModalLabel → diagramModalTitle DOM ID mismatch
- Replace bootstrap.Modal.getInstance() with classList.remove('active') for modal close
- Escape single quotes in brand/model names in breadcrumb onclick handlers
- Implement editAftermarket() form population in admin panel
- Handle VIN decoder response wrapper in landing page
- Fetch models count from API instead of hardcoded '13K+'
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -849,9 +849,28 @@ async function openAftermarketModal(id = null) {
|
||||
openModal('aftermarketModal');
|
||||
}
|
||||
|
||||
function editAftermarket(id) {
|
||||
// TODO: Fetch and populate for edit
|
||||
openAftermarketModal(id);
|
||||
async function editAftermarket(id) {
|
||||
await openAftermarketModal(id);
|
||||
try {
|
||||
const res = await fetch(`/api/aftermarket?search=&per_page=200`);
|
||||
const data = await res.json();
|
||||
const items = data.data || data;
|
||||
const item = items.find(a => a.id === id);
|
||||
if (item) {
|
||||
document.getElementById('aftermarketId').value = item.id;
|
||||
document.getElementById('aftermarketPartNumber').value = item.part_number || '';
|
||||
document.getElementById('aftermarketName').value = item.name || '';
|
||||
document.getElementById('aftermarketNameEs').value = item.name_es || '';
|
||||
document.getElementById('aftermarketQuality').value = item.quality_tier || 'standard';
|
||||
document.getElementById('aftermarketPrice').value = item.price_usd || '';
|
||||
document.getElementById('aftermarketWarranty').value = item.warranty_months || '';
|
||||
if (item.oem_part_id) document.getElementById('aftermarketOemPart').value = item.oem_part_id;
|
||||
if (item.manufacturer_id) document.getElementById('aftermarketManufacturer').value = item.manufacturer_id;
|
||||
document.getElementById('aftermarketModalTitle').textContent = 'Editar Parte Aftermarket';
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Error loading aftermarket for edit:', e);
|
||||
}
|
||||
}
|
||||
|
||||
async function saveAftermarket() {
|
||||
|
||||
Reference in New Issue
Block a user