diff --git a/app/templates/admin/vendor-detail.html b/app/templates/admin/vendor-detail.html index 38ae60e5..0e8e68d7 100644 --- a/app/templates/admin/vendor-detail.html +++ b/app/templates/admin/vendor-detail.html @@ -270,6 +270,16 @@ More Actions
+ + This vendor belongs to company: . + Contact info and ownership are managed at the company level. +
{% endblock %} diff --git a/static/admin/js/vendor-edit.js b/static/admin/js/vendor-edit.js index 368e50c5..e3a25965 100644 --- a/static/admin/js/vendor-edit.js +++ b/static/admin/js/vendor-edit.js @@ -213,6 +213,47 @@ function adminVendorEdit() { } finally { this.saving = false; } + }, + + // Delete vendor + async deleteVendor() { + editLog.info('Delete vendor requested'); + + const vendorName = this.vendor?.name || this.vendorCode; + if (!confirm(`Are you sure you want to delete "${vendorName}"?\n\n⚠️ WARNING: This will permanently delete:\n• All products\n• All orders\n• All customers\n• All team members\n\nThis action cannot be undone!`)) { + editLog.info('Delete cancelled by user'); + return; + } + + // Double confirmation for safety + if (!confirm(`FINAL CONFIRMATION\n\nType OK to permanently delete "${vendorName}" and ALL associated data.`)) { + editLog.info('Delete cancelled at final confirmation'); + return; + } + + this.saving = true; + try { + const url = `/admin/vendors/${this.vendorCode}?confirm=true`; + window.LogConfig.logApiCall('DELETE', url, null, 'request'); + + const response = await apiClient.delete(url); + + window.LogConfig.logApiCall('DELETE', url, response, 'response'); + + Utils.showToast('Vendor deleted successfully', 'success'); + editLog.info('Vendor deleted successfully'); + + // Redirect to vendors list + setTimeout(() => { + window.location.href = '/admin/vendors'; + }, 1500); + + } catch (error) { + window.LogConfig.logError(error, 'Delete Vendor'); + Utils.showToast(error.message || 'Failed to delete vendor', 'error'); + } finally { + this.saving = false; + } } }; }