@@ -19,21 +19,21 @@ const props = defineProps({
19
19
productSize: { type: String , required: true },
20
20
isFlavorsLoading: { type: Boolean , default: false },
21
21
});
22
- const { isFlavorsLoading , plans } = toRefs (props);
22
+ const { isFlavorsLoading } = toRefs (props);
23
23
24
24
const emits = defineEmits ([" update:periods" , " update:product-size" ]);
25
25
26
26
const cloudStore = useCloudStore ();
27
27
const instancesStore = useInstancesStore ();
28
- const { provider , authData } = storeToRefs (useCloudStore () );
28
+ const { provider , authData , plan } = storeToRefs (cloudStore );
29
29
const [options , setOptions ] = inject (" useOptions" )();
30
30
31
31
const images = computed (() => {
32
32
const { templates } = provider .value .publicData ;
33
33
const images = {};
34
34
35
35
Object .entries (templates ?? {}).forEach (([key , value ]) => {
36
- if (cloudStore . plan .meta .hidedOs ? .includes (key)) return ;
36
+ if (plan . value .meta .hidedOs ? .includes (key)) return ;
37
37
if (value .is_public !== false ) {
38
38
images[key] = value;
39
39
}
@@ -42,10 +42,6 @@ const images = computed(() => {
42
42
return images;
43
43
});
44
44
45
- const plan = computed (() => {
46
- return cloudStore .plan ;
47
- });
48
-
49
45
emits (" update:periods" , getPeriods (props .productSize , props .plans ));
50
46
watch (
51
47
() => props .productSize ,
65
61
}
66
62
);
67
63
68
- function getProduct (size , plan = cloudStore . plan ) {
69
- const isDynamic = cloudStore . plan .kind === " DYNAMIC" ;
70
- const products = Object .values (plan .products );
64
+ function getProduct (size ) {
65
+ const isDynamic = plan . value .kind === " DYNAMIC" ;
66
+ const products = Object .values (plan .value . products );
71
67
const product = products .find (
72
68
({ title, period }) =>
73
69
title === size && (getTarification (period) === props .mode || isDynamic)
@@ -80,11 +76,10 @@ async function setProduct(value) {
80
76
emits (" update:product-size" , value);
81
77
82
78
await nextTick ();
83
- const plan = cloudStore .plan ;
84
79
85
- if (! plan) return ;
86
- const resources = getProduct (value, plan ) ?? {};
87
- const minDisk = (plan .meta .minDiskSize ?? {})[options .disk .type ];
80
+ if (! plan . value ) return ;
81
+ const resources = getProduct (value) ?? {};
82
+ const minDisk = (plan .value . meta .minDiskSize ?? {})[options .disk .type ];
88
83
89
84
setOptions (" cpu.size" , resources .cpu ?? 0 );
90
85
setOptions (" ram.size" , (resources .ram ?? 0 ) / 1024 );
0 commit comments