@coopenomics/desktop 2025.11.10-alpha-2 → 2025.11.11-alpha-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coopenomics/desktop",
3
- "version": "2025.11.10-alpha-2",
3
+ "version": "2025.11.11-alpha-1",
4
4
  "description": "A Desktop Project",
5
5
  "productName": "Desktop App",
6
6
  "author": "Alex Ant <dacom.dark.sun@gmail.com>",
@@ -25,9 +25,9 @@
25
25
  "start": "node -r ./alias-resolver.js dist/ssr/index.js"
26
26
  },
27
27
  "dependencies": {
28
- "@coopenomics/controller": "2025.11.10-alpha-2",
29
- "@coopenomics/notifications": "2025.11.10-alpha-2",
30
- "@coopenomics/sdk": "2025.11.10-alpha-2",
28
+ "@coopenomics/controller": "2025.11.11-alpha-1",
29
+ "@coopenomics/notifications": "2025.11.11-alpha-1",
30
+ "@coopenomics/sdk": "2025.11.11-alpha-1",
31
31
  "@dicebear/collection": "^9.0.1",
32
32
  "@dicebear/core": "^9.0.1",
33
33
  "@editorjs/code": "^2.9.3",
@@ -59,7 +59,7 @@
59
59
  "@wharfkit/wallet-plugin-privatekey": "^1.1.0",
60
60
  "axios": "^1.2.1",
61
61
  "compression": "^1.7.4",
62
- "cooptypes": "2025.11.10-alpha-2",
62
+ "cooptypes": "2025.11.11-alpha-1",
63
63
  "dompurify": "^3.1.7",
64
64
  "dotenv": "^16.4.5",
65
65
  "email-regex": "^5.0.0",
@@ -123,5 +123,5 @@
123
123
  "npm": ">= 6.13.4",
124
124
  "yarn": ">= 1.21.1"
125
125
  },
126
- "gitHead": "e914a117682b30c65a8fe762148bb579aa50d62d"
126
+ "gitHead": "5b3c9c90552b081e0a4532048329454c0e43132a"
127
127
  }
@@ -0,0 +1 @@
1
+ export * from './model'
@@ -0,0 +1,2 @@
1
+ export { useConnectionAgreementStore } from './store'
2
+ export type { ITariff, IConnectionAgreementState } from './types'
@@ -0,0 +1,187 @@
1
+ import { defineStore } from 'pinia'
2
+ import { ref } from 'vue'
3
+ import { DigitalDocument } from 'src/shared/lib/document'
4
+ import { useSessionStore } from 'src/entities/Session'
5
+ import { useLoadCooperatives } from 'src/features/Union/LoadCooperatives'
6
+ import type { ITariff, IConnectionAgreementState, ICooperativeFormData } from './types'
7
+
8
+
9
+ const namespace = 'connection-agreement'
10
+
11
+ export const useConnectionAgreementStore = defineStore(namespace, () => {
12
+ // State
13
+ const currentStep = ref<number>(1)
14
+ const selectedTariff = ref<ITariff | null>(null)
15
+ const isInitialized = ref<boolean>(false)
16
+ const document = ref<any>(null)
17
+ const signedDocument = ref<any>(null)
18
+ const formData = ref<ICooperativeFormData>({
19
+ announce: '',
20
+ initial: '',
21
+ minimum: '',
22
+ org_initial: '',
23
+ org_minimum: ''
24
+ })
25
+
26
+ // Methods
27
+ const setCurrentStep = (step: number) => {
28
+ currentStep.value = step
29
+ }
30
+
31
+ const setSelectedTariff = (tariff: ITariff | null) => {
32
+ selectedTariff.value = tariff
33
+ }
34
+
35
+ const setInitialized = (initialized: boolean) => {
36
+ isInitialized.value = initialized
37
+ }
38
+
39
+ const setDocument = (doc: any) => {
40
+ document.value = doc
41
+ }
42
+
43
+ const setSignedDocument = (doc: any) => {
44
+ signedDocument.value = doc
45
+ }
46
+
47
+ const setFormData = (data: ICooperativeFormData) => {
48
+ formData.value = data
49
+ }
50
+
51
+ // Actions
52
+ const generateDocument = async () => {
53
+ console.log('🔄 Начинаем генерацию документа')
54
+ const session = useSessionStore()
55
+ const formDataValue = formData.value
56
+ console.log('📋 Данные формы:', formDataValue)
57
+
58
+ try {
59
+ console.log('📄 Создаем новый DigitalDocument')
60
+ const newDoc = new DigitalDocument()
61
+
62
+ const params: any = {
63
+ registry_id: 50,
64
+ coopname: 'voskhod',
65
+ username: session.username
66
+ }
67
+
68
+ // Передаем данные из формы в документ, если они есть
69
+ if (formDataValue) {
70
+ params.announce = formDataValue.announce
71
+ params.initial = formDataValue.initial
72
+ params.minimum = formDataValue.minimum
73
+ params.org_initial = formDataValue.org_initial
74
+ params.org_minimum = formDataValue.org_minimum
75
+ }
76
+
77
+ console.log('🔧 Генерируем документ с параметрами:', params)
78
+
79
+ await newDoc.generate(params)
80
+
81
+ console.log('✅ Документ успешно сгенерирован')
82
+ document.value = newDoc
83
+ return newDoc
84
+ } catch (error) {
85
+ console.error('❌ Ошибка при генерации документа:', error)
86
+ throw error
87
+ }
88
+ }
89
+
90
+ const signDocument = async () => {
91
+ const session = useSessionStore()
92
+ if (!document.value) {
93
+ throw new Error('Документ не найден')
94
+ }
95
+
96
+ await document.value.sign(session.username)
97
+ signedDocument.value = document.value.signedDocument
98
+ return signedDocument.value
99
+ }
100
+
101
+ const clearSignedDocument = async () => {
102
+ // Очищаем подписанный документ
103
+ signedDocument.value = null
104
+
105
+ // Регенерируем документ заново если есть данные формы
106
+ if (formData.value) {
107
+ await generateDocument()
108
+ }
109
+ }
110
+
111
+ const reloadCooperative = async () => {
112
+ const { loadOneCooperative } = useLoadCooperatives()
113
+ const session = useSessionStore()
114
+
115
+ try {
116
+ const coop = await loadOneCooperative(session.username)
117
+ return coop
118
+ } catch (error) {
119
+ console.error('Ошибка при перезагрузке кооператива:', error)
120
+ throw error
121
+ }
122
+ }
123
+
124
+ const reset = () => {
125
+ currentStep.value = 1
126
+ selectedTariff.value = null
127
+ isInitialized.value = false
128
+ document.value = null
129
+ signedDocument.value = null
130
+ formData.value = {
131
+ announce: '',
132
+ initial: '',
133
+ minimum: '',
134
+ org_initial: '',
135
+ org_minimum: ''
136
+ }
137
+ }
138
+
139
+ const initialize = (state: Partial<IConnectionAgreementState>) => {
140
+ if (state.currentStep !== undefined) {
141
+ currentStep.value = state.currentStep
142
+ }
143
+ if (state.selectedTariff !== undefined) {
144
+ selectedTariff.value = state.selectedTariff
145
+ }
146
+ if (state.isInitialized !== undefined) {
147
+ isInitialized.value = state.isInitialized
148
+ }
149
+ if (state.document !== undefined) {
150
+ document.value = state.document
151
+ }
152
+ if (state.signedDocument !== undefined) {
153
+ signedDocument.value = state.signedDocument
154
+ }
155
+ if (state.formData !== undefined && state.formData !== null) {
156
+ formData.value = state.formData
157
+ }
158
+ }
159
+
160
+ return {
161
+ // State
162
+ currentStep,
163
+ selectedTariff,
164
+ isInitialized,
165
+ document,
166
+ signedDocument,
167
+ formData,
168
+
169
+ // Methods
170
+ setCurrentStep,
171
+ setSelectedTariff,
172
+ setInitialized,
173
+ setDocument,
174
+ setSignedDocument,
175
+ setFormData,
176
+ reset,
177
+ initialize,
178
+
179
+ // Actions
180
+ generateDocument,
181
+ signDocument,
182
+ clearSignedDocument,
183
+ reloadCooperative
184
+ }
185
+ }, {
186
+ persist: true
187
+ })
@@ -0,0 +1,25 @@
1
+ export interface ITariff {
2
+ id: string
3
+ name: string
4
+ description: string
5
+ price: string
6
+ features: string[]
7
+ additionalCosts?: string[]
8
+ }
9
+
10
+ export interface ICooperativeFormData {
11
+ announce: string
12
+ initial: string
13
+ minimum: string
14
+ org_initial: string
15
+ org_minimum: string
16
+ }
17
+
18
+ export interface IConnectionAgreementState {
19
+ currentStep: number
20
+ selectedTariff: ITariff | null
21
+ isInitialized: boolean
22
+ document?: any
23
+ signedDocument?: any
24
+ formData?: ICooperativeFormData
25
+ }
@@ -10,6 +10,7 @@ export interface HostingSubscriptionData {
10
10
  subscription_type_id: 1;
11
11
  progress: number;
12
12
  is_valid: boolean;
13
+ is_delegated: boolean;
13
14
  }
14
15
 
15
16
  /**
@@ -39,7 +40,7 @@ export function useProviderSubscriptions() {
39
40
  // Статус валидности домена для хостинг подписки (из specific_data)
40
41
  const domainValid = computed(() => {
41
42
  const specificData = hostingSubscription.value?.specific_data as SubscriptionSpecificData;
42
- return specificData?.is_valid ?? null;
43
+ return (specificData?.is_valid && specificData?.is_delegated) ?? null;
43
44
  });
44
45
 
45
46
  // Прогресс установки для хостинг подписки (из specific_data)
@@ -1,29 +1,34 @@
1
1
  <template lang="pug">
2
- Form(:handler-submit="addNow" :is-submitting="isSubmitting" :showCancel="false" :button-cancel-txt="'Отменить'" :button-submit-txt="'Отправить'" @cancel="clear").q-gutter-md
3
- //- q-input(standout="bg-teal text-white" label="Имя аккаунта" v-model="data.coopname" :rules="[val => notEmpty(val)]")
4
- q-input(standout="bg-teal text-white" hint="domovoy.com или coop.domovoy.com" label="Домен или поддомен для запуска" v-model="data.params.announce" :rules="[val => notEmpty(val), val => isDomain(val)]")
2
+ div
3
+ template(v-if="isSubmitting")
4
+ Loader(:text="'Создаем кооператив...'")
5
+ template(v-else)
6
+ Form(:handler-submit="addNow" :showCancel="false" :button-cancel-txt="'Отменить'" :button-submit-txt="'Продолжить'" @cancel="clear").q-gutter-md
7
+ //- q-input(standout="bg-teal text-white" label="Имя аккаунта" v-model="data.coopname" :rules="[val => notEmpty(val)]")
8
+ q-input(standout="bg-teal text-white" hint="domovoy.com или coop.domovoy.com" label="Домен или поддомен для запуска" v-model="data.params.announce" :rules="[val => notEmpty(val), val => isDomain(val)]")
5
9
 
6
- q-input(standout="bg-teal text-white" hint="100 RUB" label="Вступительный взнос для физлиц и ИП" v-model="data.params.initial" type="number" :min="0" :rules="[val => notEmpty(val)]")
7
- template(#append)
8
- span.text-overline {{currency}}
10
+ q-input(standout="bg-teal text-white" hint="100 RUB" label="Вступительный взнос для физлиц и ИП" v-model="data.params.initial" type="number" :min="0" :rules="[val => notEmpty(val)]")
11
+ template(#append)
12
+ span.text-overline {{currency}}
9
13
 
10
- q-input(standout="bg-teal text-white" hint="300 RUB" label="Минимальный паевый взнос для физлиц и ИП" v-model="data.params.minimum" type="number" :min="0" :rules="[val => notEmpty(val)]")
11
- template(#append)
12
- span.text-overline {{currency}}
14
+ q-input(standout="bg-teal text-white" hint="Минимальный паевый взнос для физлиц и ИП" v-model="data.params.minimum" type="number" :min="0" :rules="[val => notEmpty(val)]")
15
+ template(#append)
16
+ span.text-overline {{currency}}
13
17
 
14
- q-input(standout="bg-teal text-white" hint="1000 RUB" label="Вступительный взнос для организаций" v-model="data.params.org_initial" type="number" :min="0" :rules="[val => notEmpty(val)]")
15
- template(#append)
16
- span.text-overline {{currency}}
18
+ q-input(standout="bg-teal text-white" hint="1000 RUB" label="Вступительный взнос для организаций" v-model="data.params.org_initial" type="number" :min="0" :rules="[val => notEmpty(val)]")
19
+ template(#append)
20
+ span.text-overline {{currency}}
17
21
 
18
- q-input(standout="bg-teal text-white" hint="3000 RUB" label="Минимальный паевый взнос для организаций" v-model="data.params.org_minimum" type="number" :min="0" :rules="[val => notEmpty(val)]")
19
- template(#append)
20
- span.text-overline {{currency}}
22
+ q-input(standout="bg-teal text-white" hint="3000 RUB" label="Минимальный паевый взнос для организаций" v-model="data.params.org_minimum" type="number" :min="0" :rules="[val => notEmpty(val)]")
23
+ template(#append)
24
+ span.text-overline {{currency}}
21
25
 
22
26
  </template>
23
27
  <script lang="ts" setup>
24
- import { computed, ref } from 'vue';
28
+ import { computed, ref, watch } from 'vue';
25
29
  import { useAddCooperative } from '../model';
26
30
  import { Form } from 'src/shared/ui/Form';
31
+ import { Loader } from 'src/shared/ui';
27
32
  import { notEmpty, isDomain } from 'src/shared/lib/utils';
28
33
  import { useSessionStore } from 'src/entities/Session';
29
34
  import { RegistratorContract } from 'cooptypes';
@@ -41,6 +46,10 @@ const props = defineProps({
41
46
  document: {
42
47
  type: Object as () => IDocument,
43
48
  required: true,
49
+ },
50
+ cooperative: {
51
+ type: Object as () => any,
52
+ default: null,
44
53
  }
45
54
  })
46
55
 
@@ -48,17 +57,31 @@ const document = computed(() => props.document)
48
57
 
49
58
  const session = useSessionStore()
50
59
 
60
+ // Функция для извлечения числового значения из IAsset
61
+ const extractNumericValue = (asset: any): string => {
62
+ if (!asset) return ''
63
+ if (typeof asset === 'number') return asset.toString()
64
+ if (typeof asset === 'string') {
65
+ // Извлекаем число из строки типа "1000.0000 RUB" и убираем лишние нули
66
+ const match = asset.match(/^(\d+(?:\.\d+)?)/)
67
+ if (match) {
68
+ return parseFloat(match[1]).toString()
69
+ }
70
+ }
71
+ return ''
72
+ }
73
+
51
74
  const data = ref<RegistratorContract.Actions.RegisterCooperative.IRegisterCooperative>({
52
75
  coopname: session.username,
53
76
  params: {
54
77
  is_cooperative: true,
55
78
  coop_type: 'conscoop',
56
- announce: '',
79
+ announce: props.cooperative?.announce || '',
57
80
  description: '',
58
- initial: '',
59
- minimum: '',
60
- org_initial: '',
61
- org_minimum: ''
81
+ initial: extractNumericValue(props.cooperative?.initial),
82
+ minimum: extractNumericValue(props.cooperative?.minimum),
83
+ org_initial: extractNumericValue(props.cooperative?.org_initial),
84
+ org_minimum: extractNumericValue(props.cooperative?.org_minimum)
62
85
  },
63
86
  username: session.username,
64
87
  document: {
@@ -71,19 +94,34 @@ const data = ref<RegistratorContract.Actions.RegisterCooperative.IRegisterCooper
71
94
  }
72
95
  })
73
96
 
97
+ // Следим за изменениями cooperative и обновляем данные
98
+ watch(() => props.cooperative, (newCooperative) => {
99
+ if (newCooperative) {
100
+ data.value.params.announce = newCooperative.announce || ''
101
+ data.value.params.initial = extractNumericValue(newCooperative.initial)
102
+ data.value.params.minimum = extractNumericValue(newCooperative.minimum)
103
+ data.value.params.org_initial = extractNumericValue(newCooperative.org_initial)
104
+ data.value.params.org_minimum = extractNumericValue(newCooperative.org_minimum)
105
+ }
106
+ }, { immediate: true })
107
+
74
108
  const clear = () => {
75
109
  emit('finish')
76
110
  }
77
111
 
78
112
  const addNow = async () => {
79
113
  try {
114
+ isSubmitting.value = true
80
115
  data.value.document = {...document.value, meta: JSON.stringify(document.value.meta)}
81
116
  await addCooperative(data.value)
82
- SuccessAlert('Документ подписан и отправлен')
117
+ SuccessAlert('Заявка на создание кооператива отправлена!')
83
118
 
119
+ // После успешной отправки переходим к следующему шагу
84
120
  clear()
85
121
  } catch(e: any){
86
122
  FailAlert(e)
123
+ } finally {
124
+ isSubmitting.value = false
87
125
  }
88
126
  }
89
127
 
@@ -0,0 +1 @@
1
+ export * from './ui'
@@ -0,0 +1,44 @@
1
+ <template lang="pug">
2
+ div
3
+ Form(:handler-submit="saveData" :showCancel="false" :button-cancel-txt="'Отменить'" :button-submit-txt="'Продолжить'" @cancel="clear").q-gutter-md
4
+ q-input(standout="bg-teal text-white" hint="domovoy.com или coop.domovoy.com" label="Домен или поддомен для запуска" v-model="connectionAgreement.formData.announce" :rules="[val => notEmpty(val), val => isDomain(val)]")
5
+
6
+ q-input(standout="bg-teal text-white" hint="100 RUB" label="Вступительный взнос для физлиц и ИП" v-model="connectionAgreement.formData.initial" type="number" :min="0" :rules="[val => notEmpty(val)]")
7
+ template(#append)
8
+ span.text-overline RUB
9
+
10
+ q-input(standout="bg-teal text-white" label="Минимальный паевый взнос для физлиц и ИП" hint="300 RUB" v-model="connectionAgreement.formData.minimum" type="number" :min="0" :rules="[val => notEmpty(val)]")
11
+ template(#append)
12
+ span.text-overline RUB
13
+
14
+ q-input(standout="bg-teal text-white" hint="1000 RUB" label="Вступительный взнос для организаций" v-model="connectionAgreement.formData.org_initial" type="number" :min="0" :rules="[val => notEmpty(val)]")
15
+ template(#append)
16
+ span.text-overline RUB
17
+
18
+ q-input(standout="bg-teal text-white" hint="3000 RUB" label="Минимальный паевый взнос для организаций" v-model="connectionAgreement.formData.org_minimum" type="number" :min="0" :rules="[val => notEmpty(val)]")
19
+ template(#append)
20
+ span.text-overline RUB
21
+ </template>
22
+ <script lang="ts" setup>
23
+ import { Form } from 'src/shared/ui/Form';
24
+ import { notEmpty, isDomain } from 'src/shared/lib/utils';
25
+ import { useConnectionAgreementStore } from 'src/entities/ConnectionAgreement';
26
+
27
+
28
+ const emit = defineEmits(['continue'])
29
+
30
+ const connectionAgreement = useConnectionAgreementStore()
31
+
32
+ // Данные напрямую из стора (уже инициализированы с дефолтными значениями)
33
+
34
+ const clear = () => {
35
+ emit('continue')
36
+ }
37
+
38
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
39
+ const saveData = async (e?: Event) => {
40
+ console.log('📤 CooperativeDataForm: Данные формы:', connectionAgreement.formData)
41
+ // Данные уже сохранены в сторе напрямую
42
+ emit('continue', connectionAgreement.formData)
43
+ }
44
+ </script>
@@ -0,0 +1 @@
1
+ export { default as CooperativeDataForm } from './CooperativeDataForm.vue'
@@ -3,23 +3,12 @@ div.row.q-pa-md
3
3
  div.col-md-12.col-xs-12
4
4
  div(v-if="system.info.is_providered")
5
5
  ConnectionAgreementStepper(
6
- :initial-step="currentStep"
7
- :is-finish="is_finish"
8
- :signed-document="signedDocument"
9
6
  :coop="coop"
10
- :html="html"
11
7
  :domain-valid="domainValid"
12
8
  :installation-progress="installationProgress"
13
9
  :instance-status="instanceStatus"
14
10
  :subscriptions-loading="subscriptionsLoading"
15
11
  :subscriptions-error="subscriptionsError"
16
- @step-change="handleStepChange"
17
- @tariff-selected="handleTariffSelected"
18
- @tariff-deselected="handleTariffDeselected"
19
- @continue="handleContinue"
20
- @sign="sign"
21
- @finish="finish"
22
- @reload="reload"
23
12
  )
24
13
 
25
14
  div(v-else).row
@@ -39,21 +28,19 @@ div.row.q-pa-md
39
28
 
40
29
  </template>
41
30
  <script setup lang="ts">
42
- import { DigitalDocument } from 'src/shared/lib/document';
31
+ import { ref, onMounted, onUnmounted, watch } from 'vue';
43
32
  import { useSessionStore } from 'src/entities/Session';
44
33
  import { useSystemStore } from 'src/entities/System/model';
45
- import { computed, ref, onMounted, onUnmounted } from 'vue';
34
+ import { useConnectionAgreementStore } from 'src/entities/ConnectionAgreement';
46
35
  import { useLoadCooperatives } from 'src/features/Union/LoadCooperatives';
47
36
  import { useProviderSubscriptions } from 'src/features/Provider';
48
- import { Cooperative } from 'cooptypes';
49
37
  import { ConnectionAgreementStepper } from 'src/widgets/ConnectionAgreementStepper';
50
38
  import { ColorCard } from 'src/shared/ui';
51
39
 
52
-
53
40
  const session = useSessionStore()
54
41
  const system = useSystemStore()
55
- const document = ref(new DigitalDocument())
56
- const {loadOneCooperative} = useLoadCooperatives()
42
+ const connectionAgreement = useConnectionAgreementStore()
43
+ const { loadOneCooperative } = useLoadCooperatives()
57
44
  const {
58
45
  domainValid,
59
46
  installationProgress,
@@ -65,88 +52,64 @@ const {
65
52
 
66
53
  const coop = ref()
67
54
 
68
- const html = computed(() => document.value?.data?.html)
69
- const signedDocument = computed(() => document.value?.signedDocument)
70
- const is_finish = ref(false)
71
-
72
- // Управление шагом степпера
73
- const currentStep = ref(1)
74
-
75
- const handleStepChange = (step: number) => {
76
- currentStep.value = step
77
- }
55
+ // Остановка автообновления при размонтировании компонента
56
+ let stopRefresh: (() => void) | null = null
78
57
 
79
- const handleTariffSelected = (tariff: any) => {
80
- // Здесь можно сохранить выбранный тариф
81
- console.log('Selected tariff:', tariff)
58
+ const openProviderWebsite = () => {
59
+ window.open('https://цифровой-кооператив.рф', '_blank')
82
60
  }
83
61
 
84
- const handleTariffDeselected = () => {
85
- // Здесь можно обработать снятие выбора тарифа
86
- console.log('Tariff deselected')
62
+ // Загружаем кооператив
63
+ const loadCooperative = async () => {
64
+ if (system.info.is_providered) {
65
+ coop.value = await loadOneCooperative(session.username)
66
+ }
87
67
  }
88
68
 
89
- // Остановка автообновления при размонтировании компонента
90
- let stopRefresh: (() => void) | null = null
69
+ const init = async () => {
70
+ // Инициализация имеет смысл только если провайдер доступен
71
+ if (!system.info.is_providered) return
91
72
 
92
- const handleContinue = async () => {
93
- // Если документ еще не сгенерирован, генерируем его
94
- if (!document.value.data?.html && !coop.value) {
95
- await document.value.generate({
96
- registry_id: Cooperative.Registry.CoopenomicsAgreement.registry_id,
97
- coopname: 'voskhod',
98
- username: session.username,
99
- })
73
+ // Инициализируем persistent store если он еще не инициализирован
74
+ if (!connectionAgreement.isInitialized) {
75
+ connectionAgreement.setInitialized(true)
100
76
  }
101
- }
102
77
 
103
- const openProviderWebsite = () => {
104
- window.open('https://цифровой-кооператив.рф', '_blank')
78
+ // Загружаем кооператив
79
+ await loadCooperative()
80
+
81
+ // Если кооператив существует, инициализируем данные формы из него
82
+ if (coop.value) {
83
+ const formData = {
84
+ announce: coop.value.announce || '',
85
+ initial: parseFloat(coop.value.initial || '0').toString(),
86
+ minimum: parseFloat(coop.value.minimum || '0').toString(),
87
+ org_initial: parseFloat(coop.value.org_initial || '0').toString(),
88
+ org_minimum: parseFloat(coop.value.org_minimum || '0').toString()
89
+ }
90
+ connectionAgreement.setFormData(formData)
91
+ }
105
92
  }
106
93
 
107
-
108
94
  const finish = () => {
109
95
  // Эта функция имеет смысл только если провайдер доступен
110
96
  if (!system.info.is_providered) return
111
97
 
112
- is_finish.value = true
113
- reload()
114
-
115
98
  // Запускаем автообновление подписок каждую минуту
116
99
  if (!stopRefresh) {
117
100
  stopRefresh = startAutoRefresh(60000) // 1 минута
118
101
  }
119
- }
120
102
 
121
- //todo loadCooperative by username and check status
122
- const reload = async() => {
123
- // Загружаем кооператив только если провайдер доступен
124
- if (system.info.is_providered) {
125
- coop.value = await loadOneCooperative(session.username)
126
- }
103
+ // Сбрасываем persistent состояние после завершения
104
+ connectionAgreement.reset()
127
105
  }
128
106
 
129
- const init = async () => {
130
- // Инициализация имеет смысл только если провайдер доступен
131
- if (!system.info.is_providered) return
132
-
133
- coop.value = await loadOneCooperative(session.username)
134
-
135
- if (!coop.value) {
136
- await document.value.generate({
137
- registry_id: Cooperative.Registry.CoopenomicsAgreement.registry_id,
138
- coopname: 'voskhod',
139
- username: session.username,
140
- })
141
- } else {
142
- is_finish.value = true
143
- currentStep.value = 4 // Переходим на последний шаг если кооператив уже создан
107
+ // Watch за изменением шага для автоматического завершения
108
+ watch(() => connectionAgreement.currentStep, (newStep) => {
109
+ if (newStep >= 5) {
110
+ finish()
144
111
  }
145
- }
146
-
147
- const sign = async() => {
148
- await document.value.sign(session.username)
149
- }
112
+ })
150
113
 
151
114
  // Lifecycle хуки
152
115
  onMounted(() => {
@@ -165,9 +128,6 @@ onUnmounted(() => {
165
128
  }
166
129
  })
167
130
 
168
- init()
169
-
170
-
171
131
  /**
172
132
  * Здесь необходимо получить соглашение для подключения и проверить заполнено ли оно.
173
133
  *