update payment plan settings
This commit is contained in:
@@ -593,6 +593,9 @@ async function startLaunch(data) {
|
||||
// Save instance data
|
||||
await updateStep(10, 'Saving Instance Data', 'Storing instance information...');
|
||||
try {
|
||||
// Get the launch data from sessionStorage to access pricing tier info
|
||||
const launchData = JSON.parse(sessionStorage.getItem('instanceLaunchData') || '{}');
|
||||
|
||||
const instanceData = {
|
||||
name: data.instanceName,
|
||||
port: data.port,
|
||||
@@ -603,7 +606,8 @@ async function startLaunch(data) {
|
||||
repository: data.repository,
|
||||
branch: data.branch,
|
||||
deployed_version: dockerComposeResult.latest_tag || dockerComposeResult.commit_hash || 'unknown',
|
||||
deployed_branch: data.branch
|
||||
deployed_branch: data.branch,
|
||||
payment_plan: launchData.pricingTier?.name || 'Basic' // Use the selected pricing tier name
|
||||
};
|
||||
console.log('Saving instance data:', instanceData);
|
||||
const saveResult = await saveInstanceData(instanceData);
|
||||
@@ -2046,28 +2050,45 @@ async function saveInstanceData(instanceData) {
|
||||
|
||||
if (existingInstance) {
|
||||
console.log('Instance already exists:', instanceData.port);
|
||||
// Update existing instance with new data
|
||||
const updateResponse = await fetch('/api/admin/save-instance', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-CSRF-Token': document.querySelector('meta[name="csrf-token"]').content
|
||||
},
|
||||
body: JSON.stringify({
|
||||
name: instanceData.port,
|
||||
port: instanceData.port,
|
||||
domains: instanceData.domains,
|
||||
stack_id: instanceData.stack_id || '',
|
||||
stack_name: instanceData.stack_name,
|
||||
status: instanceData.status,
|
||||
repository: instanceData.repository,
|
||||
branch: instanceData.branch,
|
||||
deployed_version: instanceData.deployed_version,
|
||||
deployed_branch: instanceData.deployed_branch,
|
||||
payment_plan: instanceData.payment_plan || 'Basic'
|
||||
})
|
||||
});
|
||||
|
||||
if (!updateResponse.ok) {
|
||||
const errorText = await updateResponse.text();
|
||||
console.error('Error updating instance:', errorText);
|
||||
throw new Error(`Failed to update instance data: ${updateResponse.status} ${updateResponse.statusText}`);
|
||||
}
|
||||
|
||||
const updateResult = await updateResponse.json();
|
||||
console.log('Instance updated:', updateResult);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
data: {
|
||||
name: instanceData.port,
|
||||
company: 'loading...',
|
||||
rooms_count: 0,
|
||||
conversations_count: 0,
|
||||
data_size: 0.0,
|
||||
payment_plan: 'Basic',
|
||||
main_url: `https://${instanceData.domains[0]}`,
|
||||
status: 'inactive',
|
||||
port: instanceData.port,
|
||||
stack_id: instanceData.stack_id || '', // Use empty string if null
|
||||
stack_name: instanceData.stack_name,
|
||||
repository: instanceData.repository,
|
||||
branch: instanceData.branch
|
||||
}
|
||||
data: updateResult.data
|
||||
};
|
||||
}
|
||||
|
||||
// If instance doesn't exist, create it
|
||||
const response = await fetch('/instances/add', {
|
||||
const response = await fetch('/api/admin/save-instance', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
@@ -2075,18 +2096,16 @@ async function saveInstanceData(instanceData) {
|
||||
},
|
||||
body: JSON.stringify({
|
||||
name: instanceData.port,
|
||||
company: 'loading...',
|
||||
rooms_count: 0,
|
||||
conversations_count: 0,
|
||||
data_size: 0.0,
|
||||
payment_plan: 'Basic',
|
||||
main_url: `https://${instanceData.domains[0]}`,
|
||||
status: 'inactive',
|
||||
port: instanceData.port,
|
||||
stack_id: instanceData.stack_id || '', // Use empty string if null
|
||||
domains: instanceData.domains,
|
||||
stack_id: instanceData.stack_id || '',
|
||||
stack_name: instanceData.stack_name,
|
||||
status: instanceData.status,
|
||||
repository: instanceData.repository,
|
||||
branch: instanceData.branch
|
||||
branch: instanceData.branch,
|
||||
deployed_version: instanceData.deployed_version,
|
||||
deployed_branch: instanceData.deployed_branch,
|
||||
payment_plan: instanceData.payment_plan || 'Basic'
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user