@coopenomics/desktop 2025.5.5-2 → 2025.5.13

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.
Files changed (50) hide show
  1. package/package.json +5 -5
  2. package/src/entities/Registrator/model/store.ts +15 -11
  3. package/src/features/Agreementer/SignAgreementDialog/model/index.ts +5 -3
  4. package/src/features/Agreementer/SignAgreementDialog/ui/SignAgreementDialog.vue +1 -1
  5. package/src/features/Decision/AuthorizeAndExecDecision/model/index.ts +6 -9
  6. package/src/features/Decision/CreateProject/model/index.ts +1 -1
  7. package/src/features/Decision/VoteAgainstDecision/model/index.ts +14 -2
  8. package/src/features/Decision/VoteForDecision/model/index.ts +9 -5
  9. package/src/features/FreeDecision/CreateProject/model/index.ts +1 -1
  10. package/src/features/Meet/CloseMeetWithDecision/model/index.ts +13 -13
  11. package/src/features/Meet/CreateMeet/model/index.ts +1 -1
  12. package/src/features/Meet/RestartMeet/model/index.ts +6 -3
  13. package/src/features/Request/AcceptRequest/api/index.ts +3 -10
  14. package/src/features/Request/ConfirmRecieveOnRequest/api/index.ts +4 -9
  15. package/src/features/Request/ConfirmSupplyOnRequest/api/index.ts +6 -11
  16. package/src/features/Request/ConfirmSupplyOnRequest/ui/ConfirmSupplyOnRequestButton.vue +1 -1
  17. package/src/features/Request/CreateChildOrder/model/index.ts +35 -30
  18. package/src/features/Request/CreateChildOrder/ui/CreateChildOrderButton/CreateChildOrderButton.vue +20 -15
  19. package/src/features/Request/DisputeOnRequest/api/index.ts +19 -24
  20. package/src/features/Request/DisputeOnRequest/ui/DisputeOnRequestButton.vue +1 -1
  21. package/src/features/Request/RecieveOnRequest/api/index.ts +6 -11
  22. package/src/features/Request/RecieveOnRequest/ui/RecieveOnRequestButton.vue +1 -1
  23. package/src/features/Request/SupplyOnRequest/api/index.ts +18 -27
  24. package/src/features/Union/AddCooperative/ui/AddCooperativeForm.vue +7 -5
  25. package/src/features/User/CreateUser/api/index.ts +28 -10
  26. package/src/features/User/CreateUser/model/index.ts +39 -31
  27. package/src/pages/Cooperative/ListOfAgenda/ui/ListOfAgendaQuestions.vue +8 -8
  28. package/src/pages/Cooperative/ListOfParticipants/ui/ListOfParticipantsPage.vue +3 -3
  29. package/src/pages/Registrator/SignUp/EmailInput.vue +0 -7
  30. package/src/pages/Union/ConnectionAgreement/ConnectionAgreementPage.vue +1 -1
  31. package/src/processes/process-decisions/index.ts +32 -29
  32. package/src/processes/select-branch/index.ts +1 -1
  33. package/src/shared/api/indexDB.ts +0 -1
  34. package/src/shared/lib/document/model/const.ts +30 -0
  35. package/src/shared/lib/document/model/entity.ts +33 -21
  36. package/src/shared/lib/document/model/index.ts +1 -1
  37. package/src/shared/lib/document/model/types.ts +2 -3
  38. package/src/shared/lib/types/document/index.ts +11 -13
  39. package/src/shared/lib/types/user/IUserData.ts +5 -6
  40. package/src/shared/lib/types/user/index.ts +1 -11
  41. package/src/shared/store/index.ts +9 -5
  42. package/src/shared/ui/BaseDocument/BaseDocument.vue +43 -42
  43. package/src/shared/ui/ComplexDocument/ComplexDocument.vue +7 -5
  44. package/src/shared/ui/ZodForm/ZodForm.vue +1 -1
  45. package/src/widgets/Cooperative/Documents/ListOfDocuments/ui/DocumentsTable.vue +2 -2
  46. package/src/widgets/Meets/MeetDetailsVoting/model.ts +4 -4
  47. package/src/widgets/Participants/ui/ParticipantCard.vue +3 -3
  48. package/src/widgets/Participants/ui/ParticipantDetails.vue +6 -6
  49. package/src/widgets/Participants/ui/ParticipantsTable.vue +3 -3
  50. package/src/widgets/Questions/ui/QuestionsTable/QuestionsTable.vue +8 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coopenomics/desktop",
3
- "version": "2025.5.5-2",
3
+ "version": "2025.5.13",
4
4
  "description": "A Desktop Project",
5
5
  "productName": "Desktop App",
6
6
  "author": "Alex Ant <dacom.dark.sun@gmail.com>",
@@ -24,8 +24,8 @@
24
24
  "start": "node -r ./alias-resolver.js dist/ssr/index.js"
25
25
  },
26
26
  "dependencies": {
27
- "@coopenomics/controller": "2025.5.5-2",
28
- "@coopenomics/sdk": "2025.5.5-2",
27
+ "@coopenomics/controller": "2025.5.13",
28
+ "@coopenomics/sdk": "2025.5.13",
29
29
  "@dicebear/collection": "^9.0.1",
30
30
  "@dicebear/core": "^9.0.1",
31
31
  "@fortawesome/fontawesome-svg-core": "^6.5.2",
@@ -49,7 +49,7 @@
49
49
  "@wharfkit/wallet-plugin-privatekey": "^1.1.0",
50
50
  "axios": "^1.2.1",
51
51
  "compression": "^1.7.4",
52
- "cooptypes": "2025.5.5-2",
52
+ "cooptypes": "2025.5.13",
53
53
  "dompurify": "^3.1.7",
54
54
  "dotenv": "^16.4.5",
55
55
  "email-regex": "^5.0.0",
@@ -101,5 +101,5 @@
101
101
  "npm": ">= 6.13.4",
102
102
  "yarn": ">= 1.21.1"
103
103
  },
104
- "gitHead": "3ea4cd6d73dc3904c4884927336614f76f6a0eb7"
104
+ "gitHead": "a09959d75164067d5a5a507a3554787d88ed45d3"
105
105
  }
@@ -1,9 +1,12 @@
1
1
  import { defineStore } from 'pinia';
2
2
  import { computed, reactive } from 'vue';
3
3
  import { IGeneratedAccount } from 'src/shared/lib/types/user';
4
- import { type ICreateUserData } from 'src/shared/lib/types/user/IUserData';
4
+ import { type IRegisterAccount } from 'src/shared/lib/types/user/IUserData';
5
5
  import type { Cooperative } from 'cooptypes';
6
6
  import { useSystemStore } from 'src/entities/System/model';
7
+ import type { IDocument, ISignatureInfo } from 'src/shared/lib/types/document';
8
+ import { Zeus } from '@coopenomics/sdk';
9
+ import { AccountTypes } from 'src/entities/Account/types';
7
10
 
8
11
  const namespace = 'registrator';
9
12
 
@@ -15,8 +18,10 @@ const initialAccountState: IGeneratedAccount = {
15
18
  };
16
19
 
17
20
  // Начальное состояние для userData
18
- const initialUserDataState: ICreateUserData = {
19
- type: 'individual',
21
+ const initialUserDataState: IRegisterAccount = {
22
+ email: '',
23
+ username: '',
24
+ type: AccountTypes.individual,
20
25
  individual_data: {
21
26
  first_name: '',
22
27
  last_name: '',
@@ -24,10 +29,9 @@ const initialUserDataState: ICreateUserData = {
24
29
  birthdate: '',
25
30
  full_address: '',
26
31
  phone: '',
27
- email: '',
28
32
  },
29
33
  organization_data: {
30
- type: 'coop',
34
+ type: Zeus.OrganizationType.COOP,
31
35
  short_name: '',
32
36
  full_name: '',
33
37
  represented_by: {
@@ -42,7 +46,6 @@ const initialUserDataState: ICreateUserData = {
42
46
  full_address: '',
43
47
  fact_address: '',
44
48
  phone: '',
45
- email: '',
46
49
  details: {
47
50
  kpp: '',
48
51
  inn: '',
@@ -66,8 +69,7 @@ const initialUserDataState: ICreateUserData = {
66
69
  middle_name: '',
67
70
  birthdate: '',
68
71
  phone: '',
69
- email: '',
70
- country: 'Russia',
72
+ country: Zeus.Country.Russia,
71
73
  city: '',
72
74
  full_address: '',
73
75
  details: {
@@ -89,11 +91,13 @@ const initialUserDataState: ICreateUserData = {
89
91
  };
90
92
 
91
93
  // Начальное состояние для любого документа
92
- const initialDocumentState = {
94
+ const initialDocumentState: IDocument = {
93
95
  hash: '',
94
96
  meta: {} as Cooperative.Document.IMetaDocument,
95
- public_key: '',
96
- signature: '',
97
+ meta_hash: '',
98
+ version: '',
99
+ doc_hash: '',
100
+ signatures: [] as ISignatureInfo[],
97
101
  };
98
102
 
99
103
  // Начальное состояние для payment
@@ -1,18 +1,20 @@
1
1
  import { DigitalDocument, type IGeneratedDocument } from 'src/shared/lib/document';
2
2
  import { api } from '../api';
3
3
  import { useSystemStore } from 'src/entities/System/model';
4
+ import { useSessionStore } from 'src/entities/Session/model';
4
5
 
5
6
  export const useSignAgreement = () => {
6
7
  const { info } = useSystemStore()
8
+ const { username } = useSessionStore()
7
9
 
8
- const signAgreement = async(username: string, agreement_type: string, agreement: IGeneratedDocument) => {
10
+ const signAgreement = async(agreement_type: string, agreement: IGeneratedDocument) => {
9
11
  const document = new DigitalDocument(agreement);
10
- await document.sign();
12
+ await document.sign(username);
11
13
 
12
14
  if (!document.signedDocument)
13
15
  throw new Error('Ошибка подписи документа')
14
16
 
15
-
17
+ // Проверяем типы и преобразуем документ
16
18
  await api.sendAgreement({
17
19
  coopname: info.coopname,
18
20
  administrator: info.coopname,
@@ -55,7 +55,7 @@ const sign = async () => {
55
55
 
56
56
  try {
57
57
  isSubmitting.value = true
58
- await signAgreement(session.username, props.agreement.type, agreementOnSign.value)
58
+ await signAgreement(props.agreement.type, agreementOnSign.value)
59
59
  await useWalletStore().loadUserWallet({coopname: info.coopname, username: session.username})
60
60
  isSubmitting.value = false
61
61
  show.value = false
@@ -29,21 +29,18 @@ export function useAuthorizeAndExecDecision() {
29
29
  throw new Error('Ошибка при генерации документа решения');
30
30
  }
31
31
 
32
- const signed_hash_of_document = useGlobalStore().signDigest(document.hash);
33
-
34
- const chainDocument: Cooperative.Document.IChainDocument = {
35
- hash: document.hash,
36
- meta: JSON.stringify(document.meta),
37
- signature: signed_hash_of_document.signature,
38
- public_key: signed_hash_of_document.public_key,
39
- };
32
+ const rawDocument = new DigitalDocument(document)
33
+ const signedDocument = await rawDocument.sign<any>(username)
40
34
 
41
35
  const authorizeData: SovietContract.Actions.Decisions.Authorize.IAuthorize =
42
36
  {
43
37
  coopname: info.coopname,
44
38
  chairman: session.username,
45
39
  decision_id,
46
- document: chainDocument,
40
+ document: {
41
+ ...signedDocument,
42
+ meta: JSON.stringify(signedDocument.meta),
43
+ },
47
44
  };
48
45
 
49
46
  const execData: SovietContract.Actions.Decisions.Exec.IExec = {
@@ -24,7 +24,7 @@ export function useCreateProjectOfFreeDecision() {
24
24
 
25
25
  const { signDocument } = useSignDocument()
26
26
 
27
- const signedDocument = await signDocument(generatedDocument)
27
+ const signedDocument = await signDocument(generatedDocument, username)
28
28
 
29
29
  await publishProjectOfFreeDecision({
30
30
  coopname: coopname,
@@ -2,13 +2,25 @@ import { TransactResult } from '@wharfkit/session';
2
2
  import { SovietContract } from 'cooptypes';
3
3
  import { useSessionStore } from 'src/entities/Session';
4
4
  import { useGlobalStore } from 'src/shared/store';
5
+ import { useSystemStore } from 'src/entities/System/model';
6
+ import { client } from 'src/shared/api/client';
5
7
 
6
8
  export function useVoteAgainstDecision() {
9
+ const { info } = useSystemStore()
10
+
7
11
  async function voteAgainstDecision(
8
- data: SovietContract.Actions.Decisions.VoteAgainst.IVoteAgainstDecision
12
+ decision_id: number
9
13
  ): Promise<TransactResult | undefined> {
10
14
  const session = useSessionStore();
11
15
 
16
+ // Создаем подпись голоса с помощью SDK Vote
17
+ const voteData = await client.Vote.voteAgainst(
18
+ info.coopname,
19
+ session.username,
20
+ decision_id
21
+ );
22
+
23
+ // Отправляем транзакцию с подписанными данными
12
24
  const result = useGlobalStore().transact({
13
25
  account: SovietContract.contractName.production,
14
26
  name: SovietContract.Actions.Decisions.VoteAgainst.actionName,
@@ -18,7 +30,7 @@ export function useVoteAgainstDecision() {
18
30
  permission: 'active',
19
31
  },
20
32
  ],
21
- data,
33
+ data: voteData,
22
34
  });
23
35
 
24
36
  return result;
@@ -3,6 +3,7 @@ import { SovietContract } from 'cooptypes';
3
3
  import { useSessionStore } from 'src/entities/Session';
4
4
  import { useGlobalStore } from 'src/shared/store';
5
5
  import { useSystemStore } from 'src/entities/System/model';
6
+ import { client } from 'src/shared/api/client';
6
7
 
7
8
  export function useVoteForDecision() {
8
9
  const { info } = useSystemStore()
@@ -12,6 +13,13 @@ export function useVoteForDecision() {
12
13
  ): Promise<TransactResult | undefined> {
13
14
  const session = useSessionStore();
14
15
 
16
+ // Создаем подпись голоса с помощью SDK Vote
17
+ const voteData = await client.Vote.voteFor(
18
+ info.coopname,
19
+ session.username,
20
+ decision_id
21
+ );
22
+ // Отправляем транзакцию с подписанными данными
15
23
  const result = useGlobalStore().transact({
16
24
  account: SovietContract.contractName.production,
17
25
  name: SovietContract.Actions.Decisions.VoteFor.actionName,
@@ -21,11 +29,7 @@ export function useVoteForDecision() {
21
29
  permission: 'active',
22
30
  },
23
31
  ],
24
- data: {
25
- member: session.username,
26
- coopname: info.coopname,
27
- decision_id: decision_id,
28
- },
32
+ data: voteData,
29
33
  });
30
34
 
31
35
  return result;
@@ -27,7 +27,7 @@ export function useCreateProjectOfFreeDecision() {
27
27
 
28
28
  const { signDocument } = useSignDocument()
29
29
 
30
- const signedDocument = await signDocument(generatedDocument)
30
+ const signedDocument = await signDocument(generatedDocument, username)
31
31
 
32
32
  await publishProjectOfFreeDecision({
33
33
  coopname: coopname,
@@ -14,14 +14,14 @@ interface ICloseMeetWithDecisionInput {
14
14
 
15
15
  export async function signBySecretaryOnAnnualGeneralMeetWithDecision(data: ICloseMeetWithDecisionInput): Promise<ISignBySecretaryResult> {
16
16
  const { signDocument } = useSignDocument()
17
-
17
+
18
18
  const variables: Mutations.Meet.GenerateAnnualGeneralMeetDecisionDocument.IInput = {
19
- data: {
19
+ data: {
20
20
  coopname: data.coopname,
21
21
  username: data.username,
22
22
  }
23
23
  }
24
-
24
+
25
25
  // Генерируем документ решения
26
26
  const { [Mutations.Meet.GenerateAnnualGeneralMeetDecisionDocument.name]: generatedDocument } = await client.Mutation(
27
27
  Mutations.Meet.GenerateAnnualGeneralMeetDecisionDocument.mutation,
@@ -29,9 +29,9 @@ export async function signBySecretaryOnAnnualGeneralMeetWithDecision(data: IClos
29
29
  variables
30
30
  }
31
31
  )
32
-
32
+
33
33
  // Подписываем документ
34
- const signedDocument = await signDocument(generatedDocument)
34
+ const signedDocument = await signDocument(generatedDocument, data.username)
35
35
 
36
36
  const variables2: Mutations.Meet.SignBySecretaryOnAnnualGeneralMeet.IInput = {
37
37
  data: {
@@ -48,15 +48,15 @@ export async function signBySecretaryOnAnnualGeneralMeetWithDecision(data: IClos
48
48
  variables: variables2
49
49
  }
50
50
  )
51
-
51
+
52
52
  return result
53
53
  }
54
54
 
55
55
  export async function signByPresiderOnAnnualGeneralMeetWithDecision(data: ICloseMeetWithDecisionInput): Promise<ISignByPresiderResult> {
56
56
  const { signDocument } = useSignDocument()
57
-
57
+
58
58
  const variables: Mutations.Meet.GenerateAnnualGeneralMeetDecisionDocument.IInput = {
59
- data: {
59
+ data: {
60
60
  coopname: data.coopname,
61
61
  username: data.username,
62
62
  }
@@ -68,16 +68,16 @@ export async function signByPresiderOnAnnualGeneralMeetWithDecision(data: IClose
68
68
  variables
69
69
  }
70
70
  )
71
-
71
+
72
72
  // Подписываем документ
73
- const signedDocument = await signDocument(generatedDocument)
74
-
73
+ const signedDocument = await signDocument(generatedDocument, data.username)
74
+
75
75
  const variables2: Mutations.Meet.SignByPresiderOnAnnualGeneralMeet.IInput = {
76
76
  data: {
77
77
  coopname: data.coopname,
78
78
  hash: data.hash,
79
79
  username: data.username,
80
- presider_decision: signedDocument
80
+ presider_decision: signedDocument
81
81
  }
82
82
  }
83
83
  // Закрываем собрание с подписанным решением председателя
@@ -87,6 +87,6 @@ export async function signByPresiderOnAnnualGeneralMeetWithDecision(data: IClose
87
87
  variables: variables2
88
88
  }
89
89
  )
90
-
90
+
91
91
  return result
92
92
  }
@@ -43,7 +43,7 @@ export async function createMeetWithAgenda(data: ICreateMeetWithAgendaInput): Pr
43
43
  username: data.username
44
44
  })
45
45
  // Подписываем документ
46
- const signedDocument = await signDocument(generatedDocument)
46
+ const signedDocument = await signDocument(generatedDocument, data.username)
47
47
 
48
48
  // Создаем собрание
49
49
  const result = await createMeet({
@@ -1,7 +1,9 @@
1
1
  import { client } from 'src/shared/api/client';
2
2
  import { Mutations } from '@coopenomics/sdk';
3
3
  import { generateAgenda } from 'src/features/Meet/GenerateAgenda/model'
4
- import { useSignDocument } from 'src/shared/lib/document'
4
+ import { DigitalDocument } from 'src/shared/lib/document'
5
+ import { useSessionStore } from 'src/entities/Session';
6
+ import type { Cooperative } from 'cooptypes';
5
7
 
6
8
  export type IRestartMeetInput = Mutations.Meet.RestartAnnualGeneralMeet.IInput['data'];
7
9
  export type IRestartMeetResult = Mutations.Meet.RestartAnnualGeneralMeet.IOutput[typeof Mutations.Meet.RestartAnnualGeneralMeet.name];
@@ -33,14 +35,15 @@ export async function restartMeet(data: IRestartMeetInput): Promise<IRestartMeet
33
35
  }
34
36
 
35
37
  export async function restartMeetWithProposal(data: IRestartMeetWithProposalInput): Promise<IRestartMeetResult> {
36
- const { signDocument } = useSignDocument()
38
+ const { username } = useSessionStore()
37
39
  // Генерируем документ повестки
38
40
  const generatedDocument = await generateAgenda({
39
41
  coopname: data.coopname,
40
42
  username: data.username
41
43
  })
42
44
  // Подписываем документ
43
- const signedDocument = await signDocument(generatedDocument)
45
+ const rawDocument = new DigitalDocument(generatedDocument)
46
+ const signedDocument = await rawDocument.sign<Cooperative.Registry.AnnualGeneralMeetingAgenda.Meta>(username)
44
47
 
45
48
  // Перезапускаем собрание
46
49
  const result = await restartMeet({
@@ -4,22 +4,15 @@ import { transact } from 'src/shared/api';
4
4
  import { ContractsList } from 'src/shared/config';
5
5
  import { useRequestStore } from 'src/entities/Request/model/stores';
6
6
  import { IUpdateOneRequest } from 'src/entities/Request';
7
- import { IDocument } from 'src/shared/lib/types/document';
8
7
  import { MarketContract } from 'cooptypes';
8
+ import { fakeDocument } from 'src/shared/lib/document/model/const';
9
9
 
10
10
  async function acceptRequest(
11
11
  params: IAcceptRequest
12
12
  ): Promise<TransactResult | undefined> {
13
13
  //TODO здесь нужно получить подписанный документ (заявление на взнос имуществом) и подставить
14
14
  //сейчас установлены фейковые данные
15
- const document = {
16
- hash: '33CBC662E606F23F332B442BAB84F2D05BD498B66EF61BC918740606B05BD565',
17
- public_key: 'PUB_K1_8YWRWjCdUQubPoHzT5ndvfhGKDf1ZL7v7Ge9iHoLtNp7wnVfG1',
18
- signature: 'SIG_K1_KWeGQ48n78ybpkuVDf1M7nuGnT8pkPXFbYYMUXtFTFv2dEReMEmwW89r19dKmAVSFZwHTdxdqkB3ZQJeAS9CcQwb92E398',
19
- meta: '',
20
- } as IDocument;
21
-
22
- console.log(params)
15
+ const document = fakeDocument
23
16
 
24
17
  const result = await transact({
25
18
  account: ContractsList.Marketplace,
@@ -34,7 +27,7 @@ async function acceptRequest(
34
27
  username: params.username,
35
28
  coopname: params.coopname,
36
29
  exchange_id: params.request_id,
37
- document,
30
+ document: {...document, meta: JSON.stringify(document.meta)},
38
31
  } as MarketContract.Actions.AcceptRequest.IAcceptRequest,
39
32
  });
40
33
 
@@ -6,19 +6,14 @@ import { useRequestStore } from 'src/entities/Request/model/stores';
6
6
  import { IUpdateOneRequest } from 'src/entities/Request';
7
7
  import { IDocument } from 'src/shared/lib/types/document';
8
8
  import { MarketContract } from 'cooptypes';
9
-
9
+ import { fakeDocument } from 'src/shared/lib/document/model/const';
10
10
  async function confirmRecieve(
11
11
  params: IConfirmRecieveOnRequest
12
12
  ): Promise<TransactResult | undefined> {
13
13
  //TODO здесь нужно получить подписанный документ (акт приёма-передачи) и подставить
14
- const document = {
15
- hash: '33CBC662E606F23F332B442BAB84F2D05BD498B66EF61BC918740606B05BD565',
16
- public_key: 'PUB_K1_8YWRWjCdUQubPoHzT5ndvfhGKDf1ZL7v7Ge9iHoLtNp7wnVfG1',
17
- signature: 'SIG_K1_KWeGQ48n78ybpkuVDf1M7nuGnT8pkPXFbYYMUXtFTFv2dEReMEmwW89r19dKmAVSFZwHTdxdqkB3ZQJeAS9CcQwb92E398',
18
- meta: '',
19
- } as IDocument;
14
+ const document: IDocument = fakeDocument
20
15
 
21
- const result = await transact({
16
+ const result = await transact({
22
17
  account: ContractsList.Marketplace,
23
18
  name: MarketContract.Actions.ConfirmReceive.actionName,
24
19
  authorization: [
@@ -31,7 +26,7 @@ async function confirmRecieve(
31
26
  username: params.username,
32
27
  coopname: params.coopname,
33
28
  exchange_id: params.request_id,
34
- document,
29
+ document: {...document, meta: JSON.stringify(document.meta)},
35
30
  } as MarketContract.Actions.ConfirmReceive.IConfirmReceive,
36
31
  });
37
32
 
@@ -4,19 +4,14 @@ import { transact } from 'src/shared/api';
4
4
  import { ContractsList } from 'src/shared/config';
5
5
  import { useRequestStore } from 'src/entities/Request/model/stores';
6
6
  import { IUpdateOneRequest } from 'src/entities/Request';
7
- import { IDocument } from 'src/shared/lib/types/document';
8
7
  import { MarketContract } from 'cooptypes';
8
+ import { fakeDocument } from 'src/shared/lib/document/model/const';
9
9
 
10
- async function confirmSupplyOnRequest(
10
+ async function confirmSupply(
11
11
  params: IConfirmSupplyOnRequest
12
12
  ): Promise<TransactResult | undefined> {
13
- //TODO получить подписанный акт имущественного взноса из кошелька
14
- const document = {
15
- hash: '33CBC662E606F23F332B442BAB84F2D05BD498B66EF61BC918740606B05BD565',
16
- public_key: 'PUB_K1_8YWRWjCdUQubPoHzT5ndvfhGKDf1ZL7v7Ge9iHoLtNp7wnVfG1',
17
- signature: 'SIG_K1_KWeGQ48n78ybpkuVDf1M7nuGnT8pkPXFbYYMUXtFTFv2dEReMEmwW89r19dKmAVSFZwHTdxdqkB3ZQJeAS9CcQwb92E398',
18
- meta: '',
19
- } as IDocument;
13
+ //TODO здесь нужно получить подписанный документ (товарная накладная) и подставить
14
+ const document = fakeDocument;
20
15
 
21
16
  const result = await transact({
22
17
  account: ContractsList.Marketplace,
@@ -31,7 +26,7 @@ async function confirmSupplyOnRequest(
31
26
  username: params.username,
32
27
  coopname: params.coopname,
33
28
  exchange_id: params.request_id,
34
- document,
29
+ document: {...document, meta: JSON.stringify(document.meta)},
35
30
  } as MarketContract.Actions.ConfirmSupply.IConfirmSupply,
36
31
  });
37
32
 
@@ -45,5 +40,5 @@ async function confirmSupplyOnRequest(
45
40
  }
46
41
 
47
42
  export const api = {
48
- confirmSupplyOnRequest,
43
+ confirmSupply,
49
44
  };
@@ -24,7 +24,7 @@ q-btn(color="green" @click="supply") Подписать акт передачи
24
24
 
25
25
  const supply = async () => {
26
26
  try {
27
- await api.confirmSupplyOnRequest({
27
+ await api.confirmSupply({
28
28
  coopname: props.coopname,
29
29
  username: props.username,
30
30
  request_id: props.requestId,
@@ -1,47 +1,52 @@
1
1
  import { Mutations } from '@coopenomics/sdk';
2
- import { useRequestStore } from 'src/entities/Request/model/stores';
3
- import { api } from '../api';
4
- import { client } from 'src/shared/api/client';
2
+ // import { useRequestStore } from 'src/entities/Request/model/stores';
3
+ // import { api } from '../api';
4
+ // import { client } from 'src/shared/api/client';
5
+ // import { DigitalDocument } from 'src/shared/lib/document';
6
+ // import type { Cooperative } from 'cooptypes';
5
7
 
6
8
  export * from './types'
7
9
 
8
10
  export function useCreateChildOrder() {
9
11
  async function createChildOrder(
10
12
  //TODO перевести id на хэши
13
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
11
14
  data: Mutations.Cooplace.GenerateReturnByAssetStatement.IInput['data'] & {parent_id: number}
12
15
  ): Promise<Mutations.Cooplace.CreateChildOrder.IOutput[typeof Mutations.Cooplace.CreateChildOrder.name]> {
13
16
 
14
- const returnByAssetStatement = await api.generateReturnByAssetStatement({
15
- coopname: data.coopname,
16
- username: data.username,
17
- request: data.request,
18
- })
17
+ // const returnByAssetStatement = await api.generateReturnByAssetStatement({
18
+ // coopname: data.coopname,
19
+ // username: data.username,
20
+ // request: data.request,
21
+ // })
19
22
 
20
- const document = await client.Document.signDocument(returnByAssetStatement)
23
+ // const document = new DigitalDocument(returnByAssetStatement)
24
+ // const signedDocument = await document.sign<Cooperative.Registry.ReturnByAssetStatement.Meta>(data.username)
21
25
 
22
26
  //TODO здесь же нужно передать распоряжение на использование средств цифрового кошелька
23
27
 
24
- const result = await api.createChildOrder({
25
- coopname: data.coopname,
26
- data: '',
27
- meta: '',
28
- parent_id: data.parent_id,
29
- product_lifecycle_secs: 0,
30
- program_id: data.request.program_id,
31
- unit_cost: data.request.unit_cost,
32
- units: data.request.units,
33
- username: data.username,
34
- document
35
- })
36
-
37
- const requestsStore = useRequestStore();
38
- requestsStore.loadUserChildOrders({
39
- coopname: data.coopname,
40
- username: data.username,
41
- });
42
-
43
-
44
- return result;
28
+ // const result = await api.createChildOrder({
29
+ // coopname: data.coopname,
30
+ // data: '',
31
+ // meta: '',
32
+ // parent_id: data.parent_id,
33
+ // product_lifecycle_secs: 0,
34
+ // program_id: data.request.program_id,
35
+ // unit_cost: data.request.unit_cost,
36
+ // units: data.request.units,
37
+ // username: data.username,
38
+ // document: signedDocument,
39
+ // })
40
+
41
+ // const requestsStore = useRequestStore();
42
+ // requestsStore.loadUserChildOrders({
43
+ // coopname: data.coopname,
44
+ // username: data.username,
45
+ // });
46
+
47
+
48
+ // return result;
49
+ return {} as any
45
50
  }
46
51
  return { createChildOrder };
47
52
  }
@@ -4,9 +4,11 @@
4
4
  import type { ICreateChildOrderProps } from '../../model'
5
5
  import { withDefaults } from 'vue'
6
6
  import { useRouter } from 'vue-router'
7
- import { client } from 'src/shared/api/client'
7
+ import { useSessionStore } from 'src/entities/Session'
8
+ import { DigitalDocument } from 'src/shared/lib/document'
8
9
 
9
10
  const router = useRouter()
11
+ const { username } = useSessionStore()
10
12
  const props = withDefaults(defineProps<ICreateChildOrderProps>(), {})
11
13
 
12
14
  const createOrder = async () => {
@@ -28,21 +30,24 @@
28
30
  username: props.username
29
31
  })
30
32
 
31
- const signedDocument = await client.Document.signDocument(document)
33
+ // Создаем документ и подписываем его
34
+ const digitalDocument = new DigitalDocument(document)
35
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
36
+ const signedDocument = await digitalDocument.sign(username)
32
37
 
33
- await api.createChildOrder({
34
- coopname: props.coopname,
35
- username: props.username,
36
- parent_id: Number(props.offer.id),
37
- program_id: Number(props.offer.program_id),
38
- units: props.units,
39
- unit_cost: props.offer.unit_cost,
40
- data: '',
41
- document: signedDocument,
42
- meta: '',
43
- product_lifecycle_secs: 100
44
- })
45
- SuccessAlert('Заказ создан')
38
+ // await api.createChildOrder({
39
+ // coopname: props.coopname,
40
+ // username: props.username,
41
+ // parent_id: Number(props.offer.id),
42
+ // program_id: Number(props.offer.program_id),
43
+ // units: props.units,
44
+ // unit_cost: props.offer.unit_cost,
45
+ // data: '',
46
+ // document: {...signedDocument, meta: JSON.stringify(signedDocument.meta)},
47
+ // meta: '',
48
+ // product_lifecycle_secs: 100
49
+ // })
50
+ SuccessAlert('Заказ НЕ создан')
46
51
  router.push({ name: 'marketplace-user-supplies' }) //TODO роутинг
47
52
  } catch (e: any) {
48
53
  FailAlert(e.message)