apply company info

This commit is contained in:
2025-06-20 12:41:06 +02:00
parent cb19b8b21c
commit 843af814fd
3 changed files with 205 additions and 4 deletions

View File

@@ -135,6 +135,18 @@ function initializeSteps() {
</div>
`;
stepsContainer.appendChild(authStep);
// Add Apply Company Information step
const companyStep = document.createElement('div');
companyStep.className = 'step-item';
companyStep.innerHTML = `
<div class="step-icon"><i class="fas fa-building"></i></div>
<div class="step-content">
<h5>Apply Company Information</h5>
<p class="step-status">Configuring company details...</p>
</div>
`;
stepsContainer.appendChild(companyStep);
}
async function startLaunch(data) {
@@ -478,9 +490,67 @@ async function startLaunch(data) {
`;
authStep.querySelector('.step-content').appendChild(authDetails);
// Step 11: Apply Company Information
await updateStep(11, 'Apply Company Information', 'Configuring company details...');
const companyResult = await applyCompanyInformation(`https://${data.webAddresses[0]}`, data.company);
if (!companyResult.success) {
throw new Error(`Company information application failed: ${companyResult.error}`);
}
// Update the company step to show success
const companyStep = document.querySelectorAll('.step-item')[10];
companyStep.classList.remove('active');
companyStep.classList.add('completed');
companyStep.querySelector('.step-status').textContent = 'Successfully applied company information';
// Add company details
const companyDetails = document.createElement('div');
companyDetails.className = 'mt-3';
companyDetails.innerHTML = `
<div class="card">
<div class="card-body">
<h6 class="card-title mb-3">Company Information Applied</h6>
<div class="table-responsive">
<table class="table table-sm">
<thead>
<tr>
<th>Property</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>Company Name</td>
<td>${data.company.name || 'Not set'}</td>
</tr>
<tr>
<td>Industry</td>
<td>${data.company.industry || 'Not set'}</td>
</tr>
<tr>
<td>Email</td>
<td>${data.company.email || 'Not set'}</td>
</tr>
<tr>
<td>Website</td>
<td>${data.company.website || 'Not set'}</td>
</tr>
<tr>
<td>Address</td>
<td>${data.company.streetAddress || 'Not set'}, ${data.company.city || ''}, ${data.company.state || ''} ${data.company.zipCode || ''}</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
`;
companyStep.querySelector('.step-content').appendChild(companyDetails);
} catch (error) {
console.error('Launch failed:', error);
await updateStep(10, 'Instance Authentication', `Error: ${error.message}`);
await updateStep(11, 'Apply Company Information', `Error: ${error.message}`);
showError(error.message);
}
}
@@ -1086,8 +1156,8 @@ function updateStep(stepNumber, title, description) {
document.getElementById('currentStep').textContent = title;
document.getElementById('stepDescription').textContent = description;
// Calculate progress based on total number of steps (10 steps total)
const totalSteps = 10;
// Calculate progress based on total number of steps (11 steps total)
const totalSteps = 11;
const progress = ((stepNumber - 1) / (totalSteps - 1)) * 100;
const progressBar = document.getElementById('launchProgress');
progressBar.style.width = `${progress}%`;
@@ -1491,4 +1561,42 @@ async function authenticateInstance(instanceUrl, instanceId) {
error: error.message
};
}
}
async function applyCompanyInformation(instanceUrl, company) {
try {
console.log('Applying company information to:', instanceUrl);
const response = await fetch('/api/admin/apply-company-information', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRF-Token': document.querySelector('meta[name="csrf-token"]').content
},
body: JSON.stringify({
instance_url: instanceUrl,
company_data: company
})
});
if (!response.ok) {
const errorText = await response.text();
throw new Error(`Failed to apply company information: ${errorText}`);
}
const result = await response.json();
console.log('Company information applied successfully:', result);
return {
success: true,
message: result.message,
data: result.data
};
} catch (error) {
console.error('Error applying company information:', error);
return {
success: false,
error: error.message
};
}
}