-
-
-
+
+
+
+
+
+
+
+
+
-
-
At least one is required. Prospect ID auto-creates a merchant from prospect data.
+
A merchant will be auto-created from the prospect's contact data.
+
+
+
+
+
+
@@ -101,20 +124,62 @@ function hostingSiteNew() {
contact_phone: '',
internal_notes: '',
},
+ // Prospect search
+ prospectSearch: '',
+ prospectResults: [],
+ selectedProspect: null,
+ showProspectDropdown: false,
+
creating: false,
errorMsg: '',
+
get canCreate() {
return this.form.business_name && (this.form.prospect_id || this.form.merchant_id);
},
+
+ async searchProspects() {
+ if (this.prospectSearch.length < 2) { this.prospectResults = []; return; }
+ try {
+ var resp = await apiClient.get('/admin/prospecting/prospects?search=' + encodeURIComponent(this.prospectSearch) + '&per_page=10');
+ this.prospectResults = resp.items || [];
+ this.showProspectDropdown = true;
+ } catch (e) {
+ this.prospectResults = [];
+ }
+ },
+
+ selectProspect(prospect) {
+ this.selectedProspect = prospect;
+ this.form.prospect_id = prospect.id;
+ this.prospectSearch = prospect.business_name || prospect.domain_name;
+ this.showProspectDropdown = false;
+ // Auto-fill form from prospect
+ if (!this.form.business_name) {
+ this.form.business_name = prospect.business_name || prospect.domain_name || '';
+ }
+ if (!this.form.contact_email && prospect.primary_email) {
+ this.form.contact_email = prospect.primary_email;
+ }
+ if (!this.form.contact_phone && prospect.primary_phone) {
+ this.form.contact_phone = prospect.primary_phone;
+ }
+ },
+
+ clearProspect() {
+ this.selectedProspect = null;
+ this.form.prospect_id = null;
+ this.prospectSearch = '';
+ this.prospectResults = [];
+ },
+
async createSite() {
if (!this.canCreate) {
- this.errorMsg = 'Business name and at least one of Prospect ID or Merchant ID required';
+ this.errorMsg = 'Business name and a linked prospect or merchant are required';
return;
}
this.creating = true;
this.errorMsg = '';
try {
- // Clean nulls
var payload = {};
for (var k in this.form) {
if (this.form[k] !== null && this.form[k] !== '') payload[k] = this.form[k];
diff --git a/app/modules/hosting/templates/hosting/admin/sites.html b/app/modules/hosting/templates/hosting/admin/sites.html
index 0606902c..5e14cde3 100644
--- a/app/modules/hosting/templates/hosting/admin/sites.html
+++ b/app/modules/hosting/templates/hosting/admin/sites.html
@@ -40,11 +40,6 @@
-
-
- Create from Prospect
-