This commit is contained in:
14 changed files with 987 additions and 0 deletions

15
assets/admin.css Normal file
View File

@@ -0,0 +1,15 @@
#wzhf .card{background:#fff;border:1px solid #e5e7eb;border-radius:12px;padding:16px;margin-bottom:16px;box-shadow:0 1px 2px rgba(0,0,0,.04)}
#wzhf .grid{display:grid;grid-template-columns:1fr 1fr;gap:16px}
#wzhf label{display:block;font-weight:600;margin-bottom:6px}
#wzhf input[type=text],#wzhf input[type=number],#wzhf select,#wzhf input[type=password]{width:100%;max-width:560px}
#wzhf .tabs{display:flex;gap:6px;margin-bottom:12px;flex-wrap:wrap}
#wzhf .tabs a{padding:8px 12px;border-radius:8px;border:1px solid #e5e7eb;text-decoration:none}
#wzhf .tabs a.active{background:#2271b1;color:#fff;border-color:#2271b1}
#wzhf .muted{color:#6b7280}
#wzhf .status-pill{display:inline-block;padding:4px 8px;border-radius:9999px;font-size:12px;border:1px solid #e5e7eb}
#wzhf .status-ok{background:#ecfdf5;color:#065f46;border-color:#a7f3d0}
#wzhf .status-bad{background:#fef2f2;color:#991b1b;border-color:#fecaca}
#wzhf .mono{font-family:ui-monospace,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace}
#wzhf .tools-grid{display:grid;grid-template-columns:1fr 1fr;gap:16px}
#wzhf .result{margin-top:8px;font-size:12px;color:#065f46}
#wzhf .error{color:#991b1b}

23
assets/admin.js Normal file
View File

@@ -0,0 +1,23 @@
jQuery(function($){
// Tabs
$('#wzhf .tabs a').on('click', function(e){ e.preventDefault(); var tab=$(this).data('tab'); $('#wzhf .tabs a').removeClass('active'); $(this).addClass('active'); $('#wzhf .tab').hide(); $('#wzhf .tab[data-tab="'+tab+'"]').show(); history.replaceState(null,'','#'+tab); });
var hash=location.hash.replace('#',''); if(hash && $('#wzhf .tabs a[data-tab="'+hash+'"]').length){ $('#wzhf .tabs a[data-tab="'+hash+'"]').trigger('click'); } else { $('#wzhf .tabs a').first().trigger('click'); }
function postTool(op, payload, outEl){
$(outEl).removeClass('error').text('Running...');
fetch(WZHF.rest, {method:'POST', headers:{'Content-Type':'application/json','X-WP-Nonce':WZHF.nonce}, body: JSON.stringify(Object.assign({op:op}, payload||{}))})
.then(r=>r.json().then(data=>({ok:r.ok,status:r.status,data})))
.then(res=>{ if(res.ok){ $(outEl).text('✔ ' + (res.data.message || 'OK')); } else { $(outEl).addClass('error').text('✖ ' + (res.data && (res.data.error||res.data.message) || ('HTTP '+res.status))); } })
.catch(err=>{ $(outEl).addClass('error').text('✖ ' + err); });
}
$(document).on('click','#btn-reset-map', function(e){ e.preventDefault(); var id=parseInt($('#tool-order-id').val(),10)||0; if(!id) return alert('Укажи Order ID'); postTool('reset_map', {order_id:id}, '#res-reset-map'); });
$(document).on('click','#btn-resend-so', function(e){ e.preventDefault(); var id=parseInt($('#tool-order-id').val(),10)||0; if(!id) return alert('Укажи Order ID'); postTool('resend_so', {order_id:id}, '#res-resend-so'); });
});
$(document).on('click','#btn-patch-so-address', function(e){
e.preventDefault();
var id=parseInt($('#tool-order-id').val(),10)||0;
if(!id) return alert('Укажи Order ID');
postTool('patch_so_address', {order_id:id}, '#res-patch-so');
});