hl-core 0.0.7-beta.15 → 0.0.7-beta.16

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.
@@ -27,7 +27,7 @@ export const useDataStore = defineStore('data', {
27
27
  Toast.useToast()(msg, {
28
28
  ...ToastOptions,
29
29
  type: Types[type.toUpperCase()],
30
- timeout: typeof timeout === ('number' || 'boolean') ? timeout : ToastOptions.timeout,
30
+ timeout: type === 'error' ? 6000 : typeof timeout === 'number' ? timeout : ToastOptions.timeout,
31
31
  }),
32
32
  }),
33
33
  getters: {
@@ -38,9 +38,17 @@ export const useDataStore = defineStore('data', {
38
38
  isLifetrip: state => state.product === 'lifetrip',
39
39
  isLiferenta: state => state.product === 'liferenta',
40
40
  isPension: state => state.product === 'pension',
41
+ isGons: state => state.product === 'gons',
41
42
  isEveryFormDisabled: state => Object.values(state.formStore.isDisabled).every(i => i === true),
42
43
  },
43
44
  actions: {
45
+ isIframe() {
46
+ try {
47
+ return window.self !== window.top;
48
+ } catch (err) {
49
+ return true;
50
+ }
51
+ },
44
52
  sendToParent(action, value) {
45
53
  window.parent.postMessage({ action: action, value: value }, '*');
46
54
  },
@@ -51,7 +59,7 @@ export const useDataStore = defineStore('data', {
51
59
  }
52
60
  },
53
61
  getFilesByIIN(iin) {
54
- return this.signedDocumentList.filter(file => file.iin === iin && file.fileTypeName === 'Удостоверение личности');
62
+ return iin ? this.signedDocumentList.filter(file => file.iin === iin && file.fileTypeName === 'Удостоверение личности') : null;
55
63
  },
56
64
  async getNewAccessToken() {
57
65
  try {
@@ -151,7 +159,7 @@ export const useDataStore = defineStore('data', {
151
159
  return !!isRole;
152
160
  },
153
161
  isInitiator() {
154
- return this.isManager() || this.isAgent() || this.isAgentMycar();
162
+ return this.isManager() || this.isAgent() || this.isAgentMycar() || this.isManagerHalykBank();
155
163
  },
156
164
  isManager() {
157
165
  return this.isRole(constants.roles.manager);
@@ -193,12 +201,16 @@ export const useDataStore = defineStore('data', {
193
201
  return !!constants.editableStatuses.find(status => status === statusCode);
194
202
  },
195
203
  isTask() {
196
- return this.formStore.applicationData.processInstanceId != 0 && this.formStore.applicationData.isTask;
204
+ return this.formStore.applicationData.processInstanceId !== 0 && this.formStore.applicationData.isTask;
197
205
  },
198
- resetSelected() {
206
+ async resetSelected(route) {
199
207
  this.settings.open = false;
208
+ this.panel.open = false;
209
+ this.panelAction = null;
200
210
  this.menu.selectedItem = new MenuItem();
201
- this.router.replace({ name: this.route.name });
211
+ if (route && route.name) {
212
+ await this.router.replace({ name: route.name });
213
+ }
202
214
  },
203
215
  async logoutUser() {
204
216
  this.isLoading = true;
@@ -229,7 +241,17 @@ export const useDataStore = defineStore('data', {
229
241
  if (!['pdf', 'docx'].includes(fileType)) {
230
242
  const blob = new Blob([response], { type: `image/${fileType}` });
231
243
  const url = window.URL.createObjectURL(blob);
232
- window.open(url, '_blank', `width=${screen.width},height=${screen.height},top=70`);
244
+ const link = document.createElement('a');
245
+ link.href = url;
246
+ if (mode === 'view') {
247
+ setTimeout(() => {
248
+ window.open(url, '_blank', `width=${screen.width},height=${screen.height},top=70`);
249
+ });
250
+ } else {
251
+ link.setAttribute('download', file.fileName);
252
+ document.body.appendChild(link);
253
+ link.click();
254
+ }
233
255
  } else {
234
256
  const blob = new Blob([response], {
235
257
  type: `application/${fileType}`,
@@ -249,7 +271,7 @@ export const useDataStore = defineStore('data', {
249
271
  }
250
272
  });
251
273
  } catch (err) {
252
- this.showToaster('error', err.response.data, 5000);
274
+ ErrorHandler(err);
253
275
  } finally {
254
276
  this.isLoading = false;
255
277
  }
@@ -262,7 +284,7 @@ export const useDataStore = defineStore('data', {
262
284
  this.showToaster('error', err.response.data, 2000);
263
285
  }
264
286
  },
265
- async uploadFiles(data, load = true) {
287
+ async uploadFiles(data, load = false) {
266
288
  try {
267
289
  if (load) {
268
290
  this.isLoading = true;
@@ -270,15 +292,14 @@ export const useDataStore = defineStore('data', {
270
292
  await this.api.uploadFiles(data);
271
293
  return true;
272
294
  } catch (err) {
273
- this.showToaster('error', err.response.data, 5000);
274
- return false;
295
+ return ErrorHandler(err);
275
296
  } finally {
276
297
  if (load) {
277
298
  this.isLoading = false;
278
299
  }
279
300
  }
280
301
  },
281
- async getContragent(whichForm, whichIndex = null, load = true) {
302
+ async getContragent(member, whichForm, whichIndex, load = true) {
282
303
  if (load) {
283
304
  this.isLoading = true;
284
305
  }
@@ -289,14 +310,8 @@ export const useDataStore = defineStore('data', {
289
310
  lastName: '',
290
311
  middleName: '',
291
312
  };
292
- if (whichIndex === null) {
293
- queryData.iin = this.formStore[whichForm].iin.replace(/-/g, '');
294
- response = await this.api.getContragent(queryData);
295
- }
296
- if (whichIndex !== null) {
297
- queryData.iin = this.formStore[whichForm][whichIndex].iin.replace(/-/g, '');
298
- response = await this.api.getContragent(queryData);
299
- }
313
+ queryData.iin = member.iin.replace(/-/g, '');
314
+ response = await this.api.getContragent(queryData);
300
315
  if (response.totalItems > 0) {
301
316
  if (response.totalItems.length === 1) {
302
317
  await this.serializeContragentData(whichForm, response.items[0], whichIndex);
@@ -304,11 +319,7 @@ export const useDataStore = defineStore('data', {
304
319
  const sortedByRegistrationDate = response.items.sort((left, right) => new Date(right.registrationDate) - new Date(left.registrationDate));
305
320
  await this.serializeContragentData(whichForm, sortedByRegistrationDate[0], whichIndex);
306
321
  }
307
- if (whichIndex === null) {
308
- this.formStore[whichForm].gotFromInsis = true;
309
- } else {
310
- this.formStore[whichForm][whichIndex].gotFromInsis = true;
311
- }
322
+ member.gotFromInsis = true;
312
323
  } else {
313
324
  this.userNotFound = true;
314
325
  }
@@ -324,7 +335,7 @@ export const useDataStore = defineStore('data', {
324
335
  this.isLoading = true;
325
336
  }
326
337
  try {
327
- if (this.isAgentMycar() && whichForm == this.formStore.beneficiaryFormKey) {
338
+ if (this.isMycar && this.isAgentMycar() && whichForm === this.formStore.beneficiaryFormKey) {
328
339
  await this.serializeContragentData(whichForm, this.formStore.applicationData.beneficiaryApp[0], whichIndex);
329
340
  this.isLoading = false;
330
341
  return;
@@ -579,65 +590,29 @@ export const useDataStore = defineStore('data', {
579
590
  return false;
580
591
  }
581
592
  },
582
- async saveContragent(user, whichForm, onlySaveAction = true, whichIndex = null) {
583
- this.isLoading = true;
584
- if (whichIndex === null) {
585
- const hasInsisId = await this.alreadyInInsis(
586
- this.formStore[whichForm].iin,
587
- this.formStore[whichForm].firstName,
588
- this.formStore[whichForm].lastName,
589
- this.formStore[whichForm].middleName,
590
- );
591
- if (hasInsisId !== false) {
592
- user.id = hasInsisId;
593
- const [{ value: data }, { value: contacts }, { value: documents }, { value: address }] = await Promise.allSettled([
594
- this.api.getContrAgentData(user.id),
595
- this.api.getContrAgentContacts(user.id),
596
- this.api.getContrAgentDocuments(user.id),
597
- this.api.getContrAgentAddress(user.id),
598
- ]);
599
- this.formStore[whichForm].response = {};
600
- if (data && data.length) {
601
- this.formStore[whichForm].response.questionnaires = data;
602
- }
603
- if (contacts && contacts.length) {
604
- this.formStore[whichForm].response.contacts = contacts;
605
- }
606
- if (documents && documents.length) {
607
- this.formStore[whichForm].response.documents = documents;
608
- }
609
- if (address && address.length) {
610
- this.formStore[whichForm].response.addresses = address;
611
- }
593
+ async saveContragent(user, whichForm, whichIndex, onlySaveAction = true) {
594
+ this.isLoading = !onlySaveAction;
595
+ const hasInsisId = await this.alreadyInInsis(user.iin, user.firstName, user.lastName, user.middleName);
596
+ if (hasInsisId !== false) {
597
+ user.id = hasInsisId;
598
+ const [{ value: data }, { value: contacts }, { value: documents }, { value: address }] = await Promise.allSettled([
599
+ this.api.getContrAgentData(user.id),
600
+ this.api.getContrAgentContacts(user.id),
601
+ this.api.getContrAgentDocuments(user.id),
602
+ this.api.getContrAgentAddress(user.id),
603
+ ]);
604
+ user.response = {};
605
+ if (data && data.length) {
606
+ user.response.questionnaires = data;
612
607
  }
613
- } else {
614
- const hasInsisId = await this.alreadyInInsis(
615
- this.formStore[whichForm][whichIndex].iin,
616
- this.formStore[whichForm][whichIndex].firstName,
617
- this.formStore[whichForm][whichIndex].lastName,
618
- this.formStore[whichForm][whichIndex].middleName,
619
- );
620
- if (hasInsisId !== false) {
621
- user.id = hasInsisId;
622
- const [{ value: data }, { value: contacts }, { value: documents }, { value: address }] = await Promise.allSettled([
623
- this.api.getContrAgentData(user.id),
624
- this.api.getContrAgentContacts(user.id),
625
- this.api.getContrAgentDocuments(user.id),
626
- this.api.getContrAgentAddress(user.id),
627
- ]);
628
- this.formStore[whichForm][whichIndex].response = {};
629
- if (data && data.length) {
630
- this.formStore[whichForm][whichIndex].response.questionnaires = data;
631
- }
632
- if (contacts && contacts.length) {
633
- this.formStore[whichForm][whichIndex].response.contacts = contacts;
634
- }
635
- if (documents && documents.length) {
636
- this.formStore[whichForm][whichIndex].response.documents = documents;
637
- }
638
- if (address && address.length) {
639
- this.formStore[whichForm][whichIndex].response.addresses = address;
640
- }
608
+ if (contacts && contacts.length) {
609
+ user.response.contacts = contacts;
610
+ }
611
+ if (documents && documents.length) {
612
+ user.response.documents = documents;
613
+ }
614
+ if (address && address.length) {
615
+ user.response.addresses = address;
641
616
  }
642
617
  }
643
618
  try {
@@ -725,12 +700,8 @@ export const useDataStore = defineStore('data', {
725
700
  type: 'MOBILE',
726
701
  typeName: 'Сотовый телефон',
727
702
  value: formatPhone(user.phoneNumber),
728
- verifyType: this.formStore.otpTokenId
729
- ? 'BMG'
730
- : 'response' in user && 'contacts' in user.response
731
- ? user.response.contacts.find(i => i.type === 'MOBILE').verifyType
732
- : null,
733
- verifyDate: this.formStore.otpTokenId
703
+ verifyType: user.otpTokenId ? 'BMG' : 'response' in user && 'contacts' in user.response ? user.response.contacts.find(i => i.type === 'MOBILE').verifyType : null,
704
+ verifyDate: user.otpTokenId
734
705
  ? this.currentDate()
735
706
  : 'response' in user && 'contacts' in user.response
736
707
  ? user.response.contacts.find(i => i.type === 'MOBILE').verifyDate
@@ -817,148 +788,120 @@ export const useDataStore = defineStore('data', {
817
788
  documents: documentsData,
818
789
  addresses: addressData,
819
790
  };
820
- try {
821
- const personId = await this.api.saveContragent(data);
822
- if (personId) {
823
- await this.getContragentById(personId, whichForm, false, whichIndex);
824
- this.formStore.otpTokenId = null;
825
- }
826
- } catch (saveErr) {
827
- console.log(saveErr);
828
- if ('response' in saveErr) {
829
- this.showToaster('error', saveErr.response.data, 5000);
830
- this.isLoading = false;
831
- return false;
832
- }
791
+
792
+ const personId = await this.api.saveContragent(data);
793
+ if (personId) {
794
+ await this.getContragentById(personId, whichForm, false, whichIndex);
795
+ user.otpTokenId = null;
833
796
  }
834
797
  } catch (err) {
835
- console.log(err);
836
798
  this.isLoading = false;
837
- this.showToaster('error', this.t('toaster.error') + err?.response?.data, 2000);
838
- return false;
799
+ return ErrorHandler(err);
839
800
  }
840
801
  if (onlySaveAction) {
841
802
  this.isLoading = false;
842
803
  }
843
804
  return true;
844
805
  },
845
- async saveMember(whichForm, key, whichMember, whichIndex = null) {
806
+ async saveMember(member, whichMember, memberFromApplicaiton) {
846
807
  let data = {};
847
808
  try {
848
- if (whichIndex === null) {
849
- data = {
850
- processInstanceId: this.formStore.applicationData.processInstanceId,
851
- insisId: this.formStore[whichForm].id,
852
- iin: this.formStore[whichForm].iin.replace(/-/g, ''),
853
- longName: this.formStore[whichForm].longName,
854
- isIpdl: this.formStore[whichForm].signOfIPDL.nameRu == 'Да' ? true : false,
855
- isTerror: this.formStore[whichForm].isTerror,
856
- isIpdlCompliance: null,
857
- isTerrorCompliance: null,
858
- };
859
- data.id = this.formStore.applicationData[key] && this.formStore.applicationData[key].id ? this.formStore.applicationData[key].id : null;
860
- if (whichMember == 'Client') {
861
- data.isInsured = this.formStore.isPolicyholderInsured;
862
- data.isActOwnBehalf = this.formStore.isActOwnBehalf;
863
- data.profession = this.formStore[whichForm].job;
864
- data.position = this.formStore[whichForm].jobPosition;
865
- data.jobName = this.formStore[whichForm].jobPlace;
866
- data.familyStatusId = this.formStore[whichForm].familyStatus.id;
867
- }
868
- if (whichMember == 'Spokesman') {
869
- if (!!this.formStore.applicationData.spokesmanApp && this.formStore.applicationData.spokesmanApp.iin !== data.iin) {
870
- delete data.id;
871
- await this.api.deleteMember('Spokesman', this.formStore.applicationData.processInstanceId);
872
- }
873
- data.migrationCard = this.formStore[whichForm].migrationCard;
874
- data.migrationCardIssueDate = formatDate(this.formStore[whichForm].migrationCardIssueDate);
875
- data.migrationCardExpireDate = formatDate(this.formStore[whichForm].migrationCardExpireDate);
876
- data.confirmDocType = this.formStore[whichForm].confirmDocType;
877
- data.confirmDocNumber = this.formStore[whichForm].confirmDocNumber;
878
- data.confirmDocIssueDate = formatDate(this.formStore[whichForm].migrationCardIssueDate);
879
- data.confirmDocExpireDate = formatDate(this.formStore[whichForm].migrationCardExpireDate);
880
- data.clientLongName = this.formStore.applicationData.clientApp.longName;
881
- data.notaryLongName = this.formStore[whichForm].notaryLongName;
882
- data.notaryLicenseNumber = this.formStore[whichForm].notaryLicenseNumber;
883
- data.notaryLicenseDate = formatDate(this.formStore[whichForm].notaryLicenseDate);
884
- data.notaryLicenseIssuer = this.formStore[whichForm].notaryLicenseIssuer;
885
- data.jurLongName = this.formStore[whichForm].jurLongName;
886
- data.fullNameRod = this.formStore[whichForm].fullNameRod;
887
- data.confirmDocTypeKz = this.formStore[whichForm].confirmDocTypeKz;
888
- data.confirmDocTypeRod = this.formStore[whichForm].confirmDocTypeRod;
889
- data.isNotary = this.formStore[whichForm].isNotary;
890
- }
891
- }
892
- if (whichIndex !== null) {
893
- data = {
894
- processInstanceId: this.formStore.applicationData.processInstanceId,
895
- insisId: this.formStore[whichForm][whichIndex].id,
896
- iin: this.formStore[whichForm][whichIndex].iin.replace(/-/g, ''),
897
- longName: this.formStore[whichForm][whichIndex].longName,
898
- isIpdl: this.formStore[whichForm][whichIndex].signOfIPDL.nameRu == 'Да' ? true : false,
899
- isTerror: this.formStore[whichForm][whichIndex].isTerror,
900
- isIpdlCompliance: null,
901
- isTerrorCompliance: null,
902
- };
903
- data.id =
904
- this.formStore.applicationData[key] && this.formStore.applicationData[key][whichIndex] && this.formStore.applicationData[key][whichIndex].id
905
- ? this.formStore.applicationData[key][whichIndex].id
906
- : null;
907
- if (whichMember == 'Insured') {
908
- if (
909
- this.formStore.applicationData &&
910
- this.formStore.applicationData.insuredApp &&
911
- this.formStore.applicationData.insuredApp.length &&
912
- this.formStore.applicationData.insuredApp.every(i => i.iin !== data.iin) &&
913
- data.id !== null
914
- ) {
915
- await this.api.deleteMember('Insured', data.id);
916
- delete data.id;
917
- }
918
- data.isDisability = this.formStore.isPolicyholderInsured ? false : this.formStore[whichForm][whichIndex].isDisability.nameRu == 'Да';
919
- data.disabilityGroupId = data.isDisability ? this.formStore[whichForm][whichIndex].disabilityGroupId.id : null;
920
- data.profession = this.formStore[whichForm][whichIndex].job;
921
- data.position = this.formStore[whichForm][whichIndex].jobPosition;
922
- data.jobName = this.formStore[whichForm][whichIndex].jobPlace;
923
- data.familyStatusId = this.formStore[whichForm][whichIndex].familyStatus.id;
924
- }
925
- if (whichMember == 'Beneficiary') {
926
- if (
927
- this.formStore.applicationData &&
928
- this.formStore.applicationData.beneficiaryApp &&
929
- this.formStore.applicationData.beneficiaryApp.length &&
930
- this.formStore.applicationData.beneficiaryApp.every(i => i.iin !== data.iin) &&
931
- data.id !== null
932
- ) {
933
- await this.api.deleteMember('Beneficiary', data.id);
934
- delete data.id;
935
- }
936
- data.familyStatusId = this.formStore[whichForm][whichIndex].familyStatus.id == 0 ? null : this.formStore[whichForm][whichIndex].familyStatus.id;
937
- data.percentage = Number(this.formStore[whichForm][whichIndex].percentageOfPayoutAmount);
938
- data.relationId = this.formStore[whichForm][whichIndex].relationDegree.ids;
939
- data.relationName = this.formStore[whichForm][whichIndex].relationDegree.nameRu;
940
- }
941
- if (whichMember == 'BeneficialOwner') {
942
- if (data.id === 0) {
943
- data.id = null;
944
- }
945
- if (
946
- this.formStore.applicationData &&
947
- this.formStore.applicationData.beneficialOwnerApp &&
948
- this.formStore.applicationData.beneficialOwnerApp.length &&
949
- this.formStore.applicationData.beneficialOwnerApp.every(i => i.iin !== data.iin) &&
950
- data.id !== null
951
- ) {
952
- await this.api.deleteMember('BeneficialOwner', data.id);
953
- delete data.id;
954
- }
955
- data.familyStatusId = this.formStore[whichForm][whichIndex].familyStatus.id;
956
- }
809
+ data = {
810
+ processInstanceId: this.formStore.applicationData.processInstanceId,
811
+ insisId: member.id,
812
+ iin: member.iin.replace(/-/g, ''),
813
+ longName: member.longName,
814
+ isIpdl: member.signOfIPDL.nameRu == 'Да' ? true : false,
815
+ isTerror: member.isTerror,
816
+ isIpdlCompliance: null,
817
+ isTerrorCompliance: null,
818
+ };
819
+ data.id = memberFromApplicaiton && memberFromApplicaiton.id ? memberFromApplicaiton.id : null;
820
+ if (whichMember === 'Client') {
821
+ data.isInsured = this.formStore.isPolicyholderInsured;
822
+ data.isActOwnBehalf = this.formStore.isActOwnBehalf;
823
+ data.profession = member.job;
824
+ data.position = member.jobPosition;
825
+ data.jobName = member.jobPlace;
826
+ data.familyStatusId = member.familyStatus.id;
827
+ }
828
+ if (whichMember === 'Spokesman') {
829
+ if (!!memberFromApplicaiton && memberFromApplicaiton.iin !== data.iin) {
830
+ delete data.id;
831
+ await this.api.deleteMember('Spokesman', this.formStore.applicationData.processInstanceId);
832
+ }
833
+ data.migrationCard = member.migrationCard;
834
+ data.migrationCardIssueDate = formatDate(member.migrationCardIssueDate);
835
+ data.migrationCardExpireDate = formatDate(member.migrationCardExpireDate);
836
+ data.confirmDocType = member.confirmDocType;
837
+ data.confirmDocNumber = member.confirmDocNumber;
838
+ data.confirmDocIssueDate = formatDate(member.migrationCardIssueDate);
839
+ data.confirmDocExpireDate = formatDate(member.migrationCardExpireDate);
840
+ data.clientLongName = this.formStore.applicationData.clientApp.longName;
841
+ data.notaryLongName = member.notaryLongName;
842
+ data.notaryLicenseNumber = member.notaryLicenseNumber;
843
+ data.notaryLicenseDate = formatDate(member.notaryLicenseDate);
844
+ data.notaryLicenseIssuer = member.notaryLicenseIssuer;
845
+ data.jurLongName = member.jurLongName;
846
+ data.fullNameRod = member.fullNameRod;
847
+ data.confirmDocTypeKz = member.confirmDocTypeKz;
848
+ data.confirmDocTypeRod = member.confirmDocTypeRod;
849
+ data.isNotary = member.isNotary;
850
+ }
851
+ if (whichMember === 'Insured') {
852
+ if (
853
+ this.formStore.applicationData &&
854
+ this.formStore.applicationData.insuredApp &&
855
+ this.formStore.applicationData.insuredApp.length &&
856
+ this.formStore.applicationData.insuredApp.every(i => i.iin !== data.iin) &&
857
+ data.id !== null
858
+ ) {
859
+ await this.api.deleteMember('Insured', data.id);
860
+ delete data.id;
861
+ }
862
+ data.isDisability = this.formStore.isPolicyholderInsured ? false : member.isDisability.nameRu == 'Да';
863
+ data.disabilityGroupId = data.isDisability ? member.disabilityGroupId.id : null;
864
+ data.profession = member.job;
865
+ data.position = member.jobPosition;
866
+ data.jobName = member.jobPlace;
867
+ data.familyStatusId = member.familyStatus.id;
868
+ }
869
+ if (whichMember === 'Beneficiary') {
870
+ if (
871
+ this.formStore.applicationData &&
872
+ this.formStore.applicationData.beneficiaryApp &&
873
+ this.formStore.applicationData.beneficiaryApp.length &&
874
+ this.formStore.applicationData.beneficiaryApp.every(i => i.iin !== data.iin) &&
875
+ data.id !== null
876
+ ) {
877
+ await this.api.deleteMember('Beneficiary', data.id);
878
+ delete data.id;
879
+ }
880
+ data.familyStatusId = member.familyStatus.id == 0 ? null : member.familyStatus.id;
881
+ data.percentage = Number(member.percentageOfPayoutAmount);
882
+ data.relationId = member.relationDegree.ids;
883
+ data.relationName = member.relationDegree.nameRu;
884
+ }
885
+ if (whichMember === 'BeneficialOwner') {
886
+ if (data.id === 0) {
887
+ data.id = null;
888
+ }
889
+ if (
890
+ this.formStore.applicationData &&
891
+ this.formStore.applicationData.beneficialOwnerApp &&
892
+ this.formStore.applicationData.beneficialOwnerApp.length &&
893
+ this.formStore.applicationData.beneficialOwnerApp.every(i => i.iin !== data.iin) &&
894
+ data.id !== null
895
+ ) {
896
+ await this.api.deleteMember('BeneficialOwner', data.id);
897
+ delete data.id;
898
+ }
899
+ data.familyStatusId = member.familyStatus.id;
957
900
  }
958
901
  await this.api.setMember(whichMember, data);
959
902
  return true;
960
903
  } catch (err) {
961
- console.log(err);
904
+ return ErrorHandler(err, err.response?.data?.errors && Object.values(err.response?.data?.errors).join(' -> '));
962
905
  }
963
906
  },
964
907
  searchFromList(whichForm, searchIt, whichIndex = null) {
@@ -999,7 +942,7 @@ export const useDataStore = defineStore('data', {
999
942
  this.showToaster('success', this.t('toaster.successSaved'), 2000);
1000
943
  return anketaToken;
1001
944
  } catch (error) {
1002
- this.showToaster('error', this.t('toaster.undefinedError'), 1000);
945
+ ErrorHandler(err);
1003
946
  } finally {
1004
947
  this.isLoading = false;
1005
948
  }
@@ -1053,33 +996,31 @@ export const useDataStore = defineStore('data', {
1053
996
  async getAdditionalTaxCountries() {
1054
997
  return await this.getFromApi('addTaxCountries', 'getAdditionalTaxCountries');
1055
998
  },
1056
- async getStates(key) {
999
+ async getStates(key, member) {
1057
1000
  await this.getFromApi('states', 'getStates');
1058
- if (key && this.contragent[key] && this.contragent[key].ids !== null) {
1059
- return this.states.filter(i => i.code === this.contragent[key].ids);
1001
+ if (key && member[key] && member[key].ids !== null) {
1002
+ return this.states.filter(i => i.code === member[key].ids);
1060
1003
  }
1061
1004
  return this.states;
1062
1005
  },
1063
- async getRegions(key) {
1006
+ async getRegions(key, member) {
1064
1007
  await this.getFromApi('regions', 'getRegions');
1065
- if (key && this.contragent[key] && this.contragent[key].ids !== null) {
1066
- return this.regions.filter(i => i.code === this.contragent[key].ids);
1008
+ if (key && member[key] && member[key].ids !== null) {
1009
+ return this.regions.filter(i => i.code === member[key].ids);
1067
1010
  }
1068
- let registrationProvince = this.contragent.registrationProvince;
1069
- if (registrationProvince.ids !== null) {
1070
- return this.regions.filter(i => i.code === registrationProvince.ids);
1011
+ if (member.registrationProvince.ids !== null) {
1012
+ return this.regions.filter(i => i.code === member.registrationProvince.ids);
1071
1013
  } else {
1072
1014
  return this.regions;
1073
1015
  }
1074
1016
  },
1075
- async getCities(key) {
1017
+ async getCities(key, member) {
1076
1018
  await this.getFromApi('cities', 'getCities');
1077
- if (key && this.contragent[key] && this.contragent[key].ids !== null) {
1078
- return this.cities.filter(i => i.code === this.contragent[key].ids);
1019
+ if (key && member[key] && member[key].ids !== null) {
1020
+ return this.cities.filter(i => i.code === member[key].ids);
1079
1021
  }
1080
- let registrationProvince = this.contragent.registrationProvince;
1081
- if (registrationProvince.ids !== null) {
1082
- return this.cities.filter(i => i.code === registrationProvince.ids);
1022
+ if (member.registrationProvince.ids !== null) {
1023
+ return this.cities.filter(i => i.code === member.registrationProvince.ids);
1083
1024
  } else {
1084
1025
  return this.cities;
1085
1026
  }
@@ -1118,15 +1059,13 @@ export const useDataStore = defineStore('data', {
1118
1059
  },
1119
1060
  async getSectorCodeList() {
1120
1061
  await this.getFromApi('economySectorCode', 'getSectorCode');
1121
- if (this.economySectorCode[1].ids != '500003.9') {
1122
- this.economySectorCode = this.economySectorCode.reverse();
1123
- }
1124
1062
  return this.economySectorCode;
1125
1063
  },
1126
1064
  async getFamilyStatuses() {
1127
1065
  return await this.getFromApi('familyStatuses', 'getFamilyStatuses');
1128
1066
  },
1129
1067
  async getRelationTypes() {
1068
+ // TODO Remove this & add filtering in openPanel method
1130
1069
  await this.getFromApi('relations', 'getRelationTypes');
1131
1070
  const filteredRelations = this.relations.filter(i => Number(i.ids) >= 6 && Number(i.ids) <= 15);
1132
1071
  const otherRelations = this.relations.filter(i => Number(i.ids) < 6 || Number(i.ids) > 15);
@@ -1274,107 +1213,6 @@ export const useDataStore = defineStore('data', {
1274
1213
  this.isLoading = false;
1275
1214
  }
1276
1215
  },
1277
- async getOtpStatus(iin, phone, processInstanceId = null) {
1278
- try {
1279
- const otpData = {
1280
- iin: iin.replace(/-/g, ''),
1281
- phoneNumber: formatPhone(phone),
1282
- type: 'AgreementOtp',
1283
- };
1284
- return await this.api.getOtpStatus(
1285
- processInstanceId !== null && processInstanceId != 0
1286
- ? {
1287
- ...otpData,
1288
- processInstanceId: processInstanceId,
1289
- }
1290
- : otpData,
1291
- );
1292
- } catch (err) {
1293
- console.log(err);
1294
- this.showToaster('error', err.response.data, 3000);
1295
- }
1296
- },
1297
- async sendOtp(iin, phone, processInstanceId = null, onInit = false) {
1298
- this.isLoading = true;
1299
- let otpStatus = false;
1300
- let otpResponse = {};
1301
- try {
1302
- if (iin && iin.length === 15 && phone && phone.length === 18) {
1303
- const status = await this.getOtpStatus(iin, phone, processInstanceId);
1304
- if (status === true) {
1305
- this.showToaster('success', this.t('toaster.hasSuccessOtp'), 3000);
1306
- otpStatus = true;
1307
- this.isLoading = false;
1308
- return { otpStatus, otpResponse };
1309
- } else if (status === false && onInit === false) {
1310
- const otpData = {
1311
- iin: iin.replace(/-/g, ''),
1312
- phoneNumber: formatPhone(phone),
1313
- type: 'AgreementOtp',
1314
- };
1315
- otpResponse = await this.api.sendOtp(
1316
- processInstanceId !== null && processInstanceId != 0
1317
- ? {
1318
- ...otpData,
1319
- processInstanceId: processInstanceId,
1320
- }
1321
- : otpData,
1322
- );
1323
- this.isLoading = false;
1324
- if (!!otpResponse) {
1325
- if ('errMessage' in otpResponse && otpResponse.errMessage !== null) {
1326
- this.showToaster('error', otpResponse.errMessage, 3000);
1327
- return { otpStatus };
1328
- }
1329
- if ('result' in otpResponse && otpResponse.result === null) {
1330
- if ('statusName' in otpResponse && !!otpResponse.statusName) {
1331
- this.showToaster('error', otpResponse.statusName, 3000);
1332
- return { otpStatus };
1333
- }
1334
- if ('status' in otpResponse && !!otpResponse.status) {
1335
- this.showToaster('error', otpResponse.status, 3000);
1336
- return { otpStatus };
1337
- }
1338
- }
1339
- if ('tokenId' in otpResponse && otpResponse.tokenId) {
1340
- this.contragent.otpTokenId = otpResponse.tokenId;
1341
- this.showToaster('success', this.t('toaster.successOtp'), 3000);
1342
- }
1343
- } else {
1344
- this.showToaster('error', this.t('toaster.undefinedError'), 3000);
1345
- return { otpStatus };
1346
- }
1347
- }
1348
- } else {
1349
- if (onInit === false) {
1350
- this.showToaster(
1351
- 'error',
1352
- this.t('toaster.errorFormField', {
1353
- text: 'Номер телефона, ИИН',
1354
- }),
1355
- );
1356
- this.isLoading = false;
1357
- }
1358
- }
1359
- return { otpStatus, otpResponse };
1360
- } catch (err) {
1361
- this.isLoading = false;
1362
- if ('response' in err) {
1363
- if ('statusName' in err.response.data && !!err.response.data.statusName) {
1364
- this.showToaster('error', this.t('toaster.phoneNotFoundInBMG'), 3000);
1365
- return { otpStatus };
1366
- }
1367
- if ('status' in err.response.data && !!err.response.data.status) {
1368
- this.showToaster('error', err.response.data.status, 3000);
1369
- return { otpStatus };
1370
- }
1371
- }
1372
- } finally {
1373
- this.isLoading = false;
1374
- }
1375
- this.isLoading = false;
1376
- return { otpStatus, otpResponse };
1377
- },
1378
1216
  async getProcessList() {
1379
1217
  this.isLoading = true;
1380
1218
  try {
@@ -1593,17 +1431,17 @@ export const useDataStore = defineStore('data', {
1593
1431
  console.log(err);
1594
1432
  }
1595
1433
  } catch (err) {
1596
- this.showToaster('error', this.t('toaster.undefinedError'), 5000);
1434
+ ErrorHandler(err);
1597
1435
  console.log(err, 'error');
1598
1436
  }
1599
1437
  this.isLoading = false;
1600
1438
  },
1601
- async startApplication(whichForm) {
1439
+ async startApplication(member) {
1602
1440
  try {
1603
1441
  const data = {
1604
- clientId: this.formStore[whichForm].id,
1605
- iin: this.formStore[whichForm].iin.replace(/-/g, ''),
1606
- longName: this.formStore[whichForm].longName,
1442
+ clientId: member.id,
1443
+ iin: member.iin.replace(/-/g, ''),
1444
+ longName: member.longName,
1607
1445
  processCode: this.processCode,
1608
1446
  policyId: 0,
1609
1447
  };
@@ -1611,11 +1449,7 @@ export const useDataStore = defineStore('data', {
1611
1449
  this.sendToParent(constants.postActions.applicationCreated, response.processInstanceId);
1612
1450
  return response.processInstanceId;
1613
1451
  } catch (err) {
1614
- console.log(err);
1615
- if ('response' in err && err.response.data) {
1616
- this.showToaster('error', err.response.data, 0);
1617
- }
1618
- return null;
1452
+ return ErrorHandler(err);
1619
1453
  }
1620
1454
  },
1621
1455
  async getApplicationData(taskId, onlyGet = true, setMembersField = true, fetchMembers = true, setProductConditions = true) {
@@ -2013,7 +1847,7 @@ export const useDataStore = defineStore('data', {
2013
1847
  4000,
2014
1848
  );
2015
1849
  } else {
2016
- this.showToaster('error', this.t('toaster.undefinedError'), 2000);
1850
+ ErrorHandler(err);
2017
1851
  }
2018
1852
  } catch (err) {
2019
1853
  console.log(err);
@@ -2218,7 +2052,7 @@ export const useDataStore = defineStore('data', {
2218
2052
  this.isLoading = false;
2219
2053
  return false;
2220
2054
  },
2221
- async getContragentFromGBDFL(iin, phoneNumber, whichForm, whichIndex = null) {
2055
+ async getContragentFromGBDFL(iin, phoneNumber, whichForm, whichIndex) {
2222
2056
  this.isLoading = true;
2223
2057
  try {
2224
2058
  const data = {
@@ -2242,13 +2076,9 @@ export const useDataStore = defineStore('data', {
2242
2076
  }
2243
2077
  const { person } = parseXML(gbdResponse.content, true, 'person');
2244
2078
  const { responseInfo } = parseXML(gbdResponse.content, true, 'responseInfo');
2245
- if (whichIndex === null) {
2079
+ if (typeof whichIndex !== 'number') {
2246
2080
  if (this.formStore[whichForm].gosPersonData !== null && this.formStore[whichForm].gosPersonData.iin !== iin.replace(/-/g, '')) {
2247
- if (whichForm === this.formStore.policyholdersRepresentativeFormKey) {
2248
- this.formStore[whichForm].resetMember(false);
2249
- } else {
2250
- this.formStore[whichForm].resetForm(false);
2251
- }
2081
+ this.formStore[whichForm].resetForm(false);
2252
2082
  }
2253
2083
  this.formStore[whichForm].gosPersonData = person;
2254
2084
  } else {
@@ -2258,8 +2088,8 @@ export const useDataStore = defineStore('data', {
2258
2088
  this.formStore[whichForm][whichIndex].gosPersonData = person;
2259
2089
  }
2260
2090
 
2261
- await this.getContragent(whichForm, whichIndex, false);
2262
- if (whichIndex === null) {
2091
+ await this.getContragent(typeof whichIndex === 'number' ? this.formStore[whichForm][whichIndex] : this.formStore[whichForm], whichForm, whichIndex, false);
2092
+ if (typeof whichIndex !== 'number') {
2263
2093
  this.formStore[whichForm].verifyDate = responseInfo.responseDate;
2264
2094
  this.formStore[whichForm].verifyType = 'GBDFL';
2265
2095
  } else {
@@ -2528,134 +2358,43 @@ export const useDataStore = defineStore('data', {
2528
2358
  if (economySectorCode) this.formStore[whichForm][whichIndex].economySectorCode = economySectorCode;
2529
2359
  }
2530
2360
  },
2531
- async getOtpStatus(iin, phone, processInstanceId = null) {
2532
- try {
2533
- const otpData = {
2534
- iin: iin.replace(/-/g, ''),
2535
- phoneNumber: formatPhone(phone),
2536
- type: 'AgreementOtp',
2537
- };
2538
- return await api.getOtpStatus(
2539
- processInstanceId !== null && processInstanceId != 0
2540
- ? {
2541
- ...otpData,
2542
- processInstanceId: processInstanceId,
2543
- }
2544
- : otpData,
2545
- );
2546
- } catch (err) {
2547
- console.log(err);
2548
- this.showToaster('error', err.response.data, 3000);
2361
+ hasJobSection(whichForm) {
2362
+ switch (whichForm) {
2363
+ case this.formStore.beneficiaryFormKey:
2364
+ case this.formStore.beneficialOwnerFormKey:
2365
+ case this.formStore.policyholdersRepresentativeFormKey:
2366
+ return false;
2367
+ default:
2368
+ return true;
2549
2369
  }
2550
2370
  },
2551
- async sendOtp(iin, phone, processInstanceId = null, onInit = false) {
2552
- this.isLoading = true;
2553
- let otpStatus = false;
2554
- let otpResponse = {};
2555
- try {
2556
- if (iin && iin.length === 15 && phone && phone.length === 18) {
2557
- const status = await this.getOtpStatus(iin, phone, processInstanceId);
2558
- if (status === true) {
2559
- this.showToaster('success', this.t('toaster.hasSuccessOtp'), 3000);
2560
- otpStatus = true;
2561
- this.isLoading = false;
2562
- return { otpStatus, otpResponse };
2563
- } else if (status === false && onInit === false) {
2564
- const otpData = {
2565
- iin: iin.replace(/-/g, ''),
2566
- phoneNumber: formatPhone(phone),
2567
- type: 'AgreementOtp',
2568
- };
2569
- otpResponse = await api.sendOtp(
2570
- processInstanceId !== null && processInstanceId != 0
2571
- ? {
2572
- ...otpData,
2573
- processInstanceId: processInstanceId,
2574
- }
2575
- : otpData,
2576
- );
2577
- this.isLoading = false;
2578
- if (!!otpResponse) {
2579
- if ('errMessage' in otpResponse && otpResponse.errMessage !== null) {
2580
- this.showToaster('error', otpResponse.errMessage, 3000);
2581
- return { otpStatus };
2582
- }
2583
- if ('result' in otpResponse && otpResponse.result === null) {
2584
- if ('statusName' in otpResponse && !!otpResponse.statusName) {
2585
- this.showToaster('error', otpResponse.statusName, 3000);
2586
- return { otpStatus };
2587
- }
2588
- if ('status' in otpResponse && !!otpResponse.status) {
2589
- this.showToaster('error', otpResponse.status, 3000);
2590
- return { otpStatus };
2591
- }
2592
- }
2593
- if ('tokenId' in otpResponse && otpResponse.tokenId) {
2594
- this.formStore.otpTokenId = otpResponse.tokenId;
2595
- this.showToaster('success', this.t('toaster.successOtp'), 3000);
2596
- }
2597
- } else {
2598
- this.showToaster('error', this.t('toaster.undefinedError'), 3000);
2599
- return { otpStatus };
2600
- }
2601
- }
2602
- } else {
2603
- if (onInit === false) {
2604
- this.showToaster('error', this.t('toaster.errorFormField', { text: 'Номер телефона, ИИН' }));
2605
- this.isLoading = false;
2606
- }
2607
- }
2608
- return { otpStatus, otpResponse };
2609
- } catch (err) {
2610
- this.isLoading = false;
2611
- if ('response' in err) {
2612
- if ('statusName' in err.response.data && !!err.response.data.statusName) {
2613
- this.showToaster('error', this.t('toaster.phoneNotFoundInBMG'), 3000);
2614
- return { otpStatus };
2615
- }
2616
- if ('status' in err.response.data && !!err.response.data.status) {
2617
- this.showToaster('error', err.response.data.status, 3000);
2618
- return { otpStatus };
2619
- }
2620
- }
2621
- } finally {
2622
- this.isLoading = false;
2371
+ hasBirthSection(whichForm) {
2372
+ if (this.isGons) return false;
2373
+ switch (whichForm) {
2374
+ case this.formStore.beneficiaryFormKey:
2375
+ return false;
2376
+ default:
2377
+ return true;
2623
2378
  }
2624
- this.isLoading = false;
2625
- return { otpStatus, otpResponse };
2626
2379
  },
2627
- async checkOtp(otpToken, phone, code) {
2628
- try {
2629
- this.isLoading = true;
2630
- const otpData = {
2631
- tokenId: otpToken,
2632
- phoneNumber: formatPhone(phone),
2633
- code: code,
2634
- };
2635
- const otpResponse = await this.api.checkOtp(otpData);
2636
- if (otpResponse !== null) {
2637
- if ('errMessage' in otpResponse && otpResponse.errMessage !== null) {
2638
- this.showToaster('error', otpResponse.errMessage, 3000);
2639
- return false;
2640
- }
2641
- if ('status' in otpResponse && !!otpResponse.status) {
2642
- // TODO Доработать и менять значение hasAgreement.value => true
2643
- this.showToaster(otpResponse.status !== 2 ? 'error' : 'success', otpResponse.statusName, 3000);
2644
- if (otpResponse.status === 2) {
2645
- return true;
2646
- }
2647
- }
2648
- }
2649
- return false;
2650
- } catch (err) {
2651
- console.log(err);
2652
- if ('response' in err) {
2653
- this.showToaster('error', err.response.data, 3000);
2654
- }
2655
- } finally {
2656
- this.isLoading = false;
2380
+ hasPlaceSection(whichForm) {
2381
+ switch (whichForm) {
2382
+ default:
2383
+ return true;
2384
+ }
2385
+ },
2386
+ hasDocumentSection(whichForm) {
2387
+ switch (whichForm) {
2388
+ default:
2389
+ return true;
2390
+ }
2391
+ },
2392
+ hasContactSection(whichForm) {
2393
+ if (this.isGons) return false;
2394
+ switch (whichForm) {
2395
+ default:
2396
+ return true;
2657
2397
  }
2658
- return null;
2659
2398
  },
2660
2399
  },
2661
2400
  });