@@ -18,6 +18,8 @@ import { StorageUsageType } from "../types/index"
1818
1919const ISSERVER = typeof window === "undefined"
2020
21+ const VERSION = "1.0"
22+
2123export const priceEstimatorStore = reactive ( {
2224 /* State */
2325
@@ -35,7 +37,6 @@ export const priceEstimatorStore = reactive({
3537 /* Generic Helper */
3638
3739 async initializePriceEstimatorStore ( ) {
38- console . log ( "initializing" )
3940 this . isInitializingPriseEstimator = true
4041
4142 await this . getCatalogueAPI ( )
@@ -48,8 +49,7 @@ export const priceEstimatorStore = reactive({
4849 const savedJson = localStorage . getItem ( "hunt-cloud-estimator-state" )
4950 if ( savedJson ) {
5051 const state = JSON . parse ( savedJson )
51- console . log ( "state" , state )
52- if ( state . labs && Array . isArray ( state . labs ) ) {
52+ if ( state . labs && Array . isArray ( state . labs ) && state . version == VERSION ) {
5353 this . labs = [ ]
5454
5555 for ( const lab of state . labs as LabCard [ ] ) {
@@ -87,10 +87,13 @@ export const priceEstimatorStore = reactive({
8787 }
8888 }
8989 saved = true
90+ } else {
91+ alert ( "Failed to load the state of price estimator: Missing information" )
9092 }
9193 }
9294 } catch ( err ) {
9395 console . error ( "Failed to load state:" , err )
96+ alert ( "Failed to load the state of price estimator" )
9497 }
9598 }
9699
@@ -112,7 +115,6 @@ export const priceEstimatorStore = reactive({
112115 } )
113116
114117 const machinesPromise = pricesApi . getMachineTypes ( ) . then ( ( machine : MachineType [ ] ) => {
115- console . log ( "machine" , machine )
116118 this . catalogue . machinePrices = machine
117119 } )
118120
@@ -133,6 +135,7 @@ export const priceEstimatorStore = reactive({
133135 try {
134136 const stateToSave = {
135137 labs : this . labs ,
138+ version : VERSION ,
136139 }
137140 localStorage . setItem ( "hunt-cloud-estimator-state" , JSON . stringify ( stateToSave ) )
138141 } catch ( err ) {
@@ -216,7 +219,6 @@ export const priceEstimatorStore = reactive({
216219 getLabComputePriceSum ( labId : number ) {
217220 const lab = this . labs . find ( ( l ) => l . id === labId )
218221 if ( ! lab ) {
219- console . log ( "Lab not found" )
220222 return { monthlyCostTotal : 0 , yearlyCostTotal : 0 }
221223 }
222224
@@ -518,7 +520,6 @@ export const priceEstimatorStore = reactive({
518520 this . labs . forEach ( ( lab ) => {
519521 const type = lab . subscription as "1Y" | "3Y"
520522 const priceItem = this . catalogue . labPrices . find ( ( p ) => p [ "service.commitment" ] === type )
521- console . log ( summary . labSubscriptions [ type ] )
522523 summary . labSubscriptions [ type ] . units += 1
523524 if ( priceItem ) {
524525 summary . labSubscriptions [ type ] . price += priceItem [ "price.nok.ex.vat" ]
@@ -543,9 +544,7 @@ export const priceEstimatorStore = reactive({
543544 // Get total storages from labs
544545
545546 const storageSum = this . calculateTotalStorageCost ( )
546- console . log ( "SUMMARY" , storageSum )
547547 summary . allStorage = storageSum
548- console . log ( "FINAL SUMMARY" , summary )
549548 return summary
550549 } ,
551550
@@ -573,7 +572,7 @@ export const priceEstimatorStore = reactive({
573572 } ) )
574573
575574 const exportData = {
576- version : "1.0" ,
575+ version : VERSION ,
577576 labs : labsToExport ,
578577 }
579578
0 commit comments