robustness review of price calc js
This commit is contained in:
parent
e7c6a53a17
commit
27c41a6187
7 changed files with 143 additions and 24 deletions
|
|
@ -13,7 +13,8 @@ class PricingDataManager {
|
|||
// Load pricing data from API endpoint
|
||||
async loadPricingData() {
|
||||
try {
|
||||
const response = await fetch(`/offering/${this.currentOffering.provider_slug}/${this.currentOffering.service_slug}/?pricing=json`);
|
||||
const url = `/offering/${this.currentOffering.provider_slug}/${this.currentOffering.service_slug}/?pricing=json`;
|
||||
const response = await fetch(url);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to load pricing data: ${response.status} ${response.statusText}`);
|
||||
|
|
@ -21,8 +22,17 @@ class PricingDataManager {
|
|||
|
||||
const data = await response.json();
|
||||
|
||||
if (!data || typeof data !== 'object') {
|
||||
throw new Error('Invalid pricing data received from server');
|
||||
}
|
||||
|
||||
this.pricingData = data.pricing || data;
|
||||
|
||||
// Validate that we have usable pricing data
|
||||
if (!this.pricingData || Object.keys(this.pricingData).length === 0) {
|
||||
throw new Error('No pricing data available for this offering');
|
||||
}
|
||||
|
||||
// Extract addons data from the plans - addons are embedded in each plan
|
||||
this.extractAddonsData();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue