refactor(price): remove price comparison UI and catalog sync
GoMag vs ROA price comparison generated too many false positives (kits, volume discounts, special prices). Removes comparison columns, dots, badges, catalog sync endpoints, and ~950 lines of dead code. Keeps WRITE path (sync_prices_from_order) for kit pricing. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -10,8 +10,9 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||
// Kit pricing mode radio toggle
|
||||
document.querySelectorAll('input[name="kitPricingMode"]').forEach(r => {
|
||||
r.addEventListener('change', () => {
|
||||
const mode = document.querySelector('input[name="kitPricingMode"]:checked')?.value || '';
|
||||
document.getElementById('kitModeBFields').style.display =
|
||||
document.getElementById('kitModeSeparate').checked ? '' : 'none';
|
||||
(mode === 'separate_line' || mode === 'distributed') ? '' : 'none';
|
||||
});
|
||||
});
|
||||
|
||||
@@ -138,27 +139,12 @@ async function loadSettings() {
|
||||
document.querySelectorAll('input[name="kitPricingMode"]').forEach(r => {
|
||||
r.checked = r.value === kitMode;
|
||||
});
|
||||
document.getElementById('kitModeBFields').style.display = kitMode === 'separate_line' ? '' : 'none';
|
||||
document.getElementById('kitModeBFields').style.display = (kitMode === 'separate_line' || kitMode === 'distributed') ? '' : 'none';
|
||||
if (el('settKitDiscountCodmat')) el('settKitDiscountCodmat').value = data.kit_discount_codmat || '';
|
||||
if (el('settKitDiscountIdPol')) el('settKitDiscountIdPol').value = data.kit_discount_id_pol || '';
|
||||
|
||||
// Price sync
|
||||
if (el('settPriceSyncEnabled')) el('settPriceSyncEnabled').checked = data.price_sync_enabled !== "0";
|
||||
if (el('settCatalogSyncEnabled')) {
|
||||
el('settCatalogSyncEnabled').checked = data.catalog_sync_enabled === "1";
|
||||
document.getElementById('catalogSyncOptions').style.display = data.catalog_sync_enabled === "1" ? '' : 'none';
|
||||
}
|
||||
if (el('settPriceSyncSchedule')) el('settPriceSyncSchedule').value = data.price_sync_schedule || '';
|
||||
|
||||
// Load price sync status
|
||||
try {
|
||||
const psRes = await fetch('/api/price-sync/status');
|
||||
const psData = await psRes.json();
|
||||
const psEl = document.getElementById('settPriceSyncStatus');
|
||||
if (psEl && psData.last_run) {
|
||||
psEl.textContent = `Ultima: ${psData.last_run.finished_at || ''} — ${psData.last_run.updated || 0} actualizate din ${psData.last_run.matched || 0}`;
|
||||
}
|
||||
} catch {}
|
||||
} catch (err) {
|
||||
console.error('loadSettings error:', err);
|
||||
}
|
||||
@@ -187,9 +173,6 @@ async function saveSettings() {
|
||||
kit_discount_codmat: el('settKitDiscountCodmat')?.value?.trim() || '',
|
||||
kit_discount_id_pol: el('settKitDiscountIdPol')?.value?.trim() || '',
|
||||
price_sync_enabled: el('settPriceSyncEnabled')?.checked ? "1" : "0",
|
||||
catalog_sync_enabled: el('settCatalogSyncEnabled')?.checked ? "1" : "0",
|
||||
price_sync_schedule: el('settPriceSyncSchedule')?.value || '',
|
||||
gomag_products_url: '',
|
||||
};
|
||||
try {
|
||||
const res = await fetch('/api/settings', {
|
||||
@@ -211,40 +194,6 @@ async function saveSettings() {
|
||||
}
|
||||
}
|
||||
|
||||
async function startCatalogSync() {
|
||||
const btn = document.getElementById('btnCatalogSync');
|
||||
const status = document.getElementById('settPriceSyncStatus');
|
||||
btn.disabled = true;
|
||||
btn.innerHTML = '<span class="spinner-border spinner-border-sm"></span> Sincronizare...';
|
||||
try {
|
||||
const res = await fetch('/api/price-sync/start', { method: 'POST' });
|
||||
const data = await res.json();
|
||||
if (data.error) {
|
||||
status.innerHTML = `<span class="text-danger">${escHtml(data.error)}</span>`;
|
||||
btn.disabled = false;
|
||||
btn.textContent = 'Sincronizează acum';
|
||||
return;
|
||||
}
|
||||
// Poll status
|
||||
const pollInterval = setInterval(async () => {
|
||||
const sr = await fetch('/api/price-sync/status');
|
||||
const sd = await sr.json();
|
||||
if (sd.status === 'running') {
|
||||
status.textContent = sd.phase_text || 'Sincronizare în curs...';
|
||||
} else {
|
||||
clearInterval(pollInterval);
|
||||
btn.disabled = false;
|
||||
btn.textContent = 'Sincronizează acum';
|
||||
if (sd.last_run) status.textContent = `Ultima: ${sd.last_run.finished_at || ''} — ${sd.last_run.updated || 0} actualizate din ${sd.last_run.matched || 0}`;
|
||||
}
|
||||
}, 2000);
|
||||
} catch (err) {
|
||||
status.innerHTML = `<span class="text-danger">${escHtml(err.message)}</span>`;
|
||||
btn.disabled = false;
|
||||
btn.textContent = 'Sincronizează acum';
|
||||
}
|
||||
}
|
||||
|
||||
function wireAutocomplete(inputId, dropdownId) {
|
||||
const input = document.getElementById(inputId);
|
||||
const dropdown = document.getElementById(dropdownId);
|
||||
|
||||
Reference in New Issue
Block a user