hl-core 0.0.8 → 0.0.9-beta.2

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 (63) hide show
  1. package/api/index.ts +142 -101
  2. package/api/interceptors.ts +17 -13
  3. package/components/Button/Btn.vue +1 -1
  4. package/components/Button/ScrollButtons.vue +2 -2
  5. package/components/Complex/MessageBlock.vue +26 -0
  6. package/components/Complex/Page.vue +1 -1
  7. package/components/Dialog/Dialog.vue +9 -39
  8. package/components/Dialog/FamilyDialog.vue +7 -4
  9. package/components/Form/FormBlock.vue +90 -42
  10. package/components/Form/FormSection.vue +4 -1
  11. package/components/Form/FormToggle.vue +1 -2
  12. package/components/Form/ManagerAttachment.vue +197 -0
  13. package/components/Form/ProductConditionsBlock.vue +68 -14
  14. package/components/Input/Datepicker.vue +45 -0
  15. package/components/Input/FileInput.vue +2 -3
  16. package/components/Input/FormInput.vue +31 -7
  17. package/components/Input/PanelInput.vue +7 -2
  18. package/components/Input/RoundedInput.vue +2 -2
  19. package/components/Input/RoundedSelect.vue +137 -0
  20. package/components/Layout/Drawer.vue +4 -2
  21. package/components/Layout/Header.vue +40 -4
  22. package/components/Layout/Loader.vue +1 -1
  23. package/components/Layout/SettingsPanel.vue +51 -13
  24. package/components/Menu/MenuHover.vue +30 -0
  25. package/components/Menu/MenuNav.vue +29 -13
  26. package/components/Menu/MenuNavItem.vue +6 -3
  27. package/components/Pages/Anketa.vue +59 -33
  28. package/components/Pages/Auth.vue +139 -46
  29. package/components/Pages/Documents.vue +7 -7
  30. package/components/Pages/InvoiceInfo.vue +30 -0
  31. package/components/Pages/MemberForm.vue +544 -293
  32. package/components/Pages/ProductAgreement.vue +4 -2
  33. package/components/Pages/ProductConditions.vue +673 -75
  34. package/components/Panel/PanelHandler.vue +304 -0
  35. package/components/Panel/PanelSelectItem.vue +1 -1
  36. package/components/Transitions/SlideTransition.vue +5 -0
  37. package/components/Utilities/Chip.vue +27 -0
  38. package/components/Utilities/JsonViewer.vue +27 -0
  39. package/composables/axios.ts +1 -1
  40. package/composables/classes.ts +223 -101
  41. package/composables/constants.ts +26 -51
  42. package/composables/index.ts +80 -2
  43. package/composables/styles.ts +15 -3
  44. package/configs/i18n.ts +17 -0
  45. package/layouts/default.vue +6 -6
  46. package/locales/kz.json +585 -0
  47. package/locales/ru.json +587 -0
  48. package/nuxt.config.ts +13 -1
  49. package/package.json +43 -11
  50. package/pages/500.vue +2 -2
  51. package/pages/Token.vue +51 -0
  52. package/plugins/helperFunctionsPlugins.ts +6 -0
  53. package/plugins/storePlugin.ts +0 -1
  54. package/plugins/vuetifyPlugin.ts +8 -1
  55. package/store/data.store.ts +2649 -0
  56. package/store/form.store.ts +1 -1
  57. package/store/member.store.ts +164 -52
  58. package/store/{rules.js → rules.ts} +65 -34
  59. package/types/enum.ts +83 -0
  60. package/types/env.d.ts +10 -0
  61. package/types/index.ts +262 -5
  62. package/store/data.store.js +0 -2482
  63. package/store/messages.ts +0 -429
@@ -1,5 +1,5 @@
1
1
  import { defineStore } from 'pinia';
2
- import { FormStoreClass } from '@/composables/classes';
2
+ import { FormStoreClass } from '../composables/classes';
3
3
 
4
4
  export const useFormStore = defineStore('forms', {
5
5
  state: () => ({
@@ -4,6 +4,7 @@ import { useFormStore } from './form.store';
4
4
  import { ErrorHandler } from '../composables';
5
5
  import { AxiosError } from 'axios';
6
6
  import { Member } from '../composables/classes';
7
+ import { MemberAppCodes, MemberCodes, StoreMembers } from '../types/enum';
7
8
 
8
9
  export const useMemberStore = defineStore('members', {
9
10
  state: () => ({
@@ -12,7 +13,8 @@ export const useMemberStore = defineStore('members', {
12
13
  formStore: useFormStore(),
13
14
  }),
14
15
  actions: {
15
- isStatementEditible(whichForm: string, showToaster: boolean = false) {
16
+ isStatementEditible(whichForm: keyof typeof StoreMembers | 'productConditionsForm', showToaster: boolean = false) {
17
+ if (!this.validateInitiator(false)) return false;
16
18
  if (this.formStore.isDisabled[whichForm as keyof typeof this.formStore.isDisabled] === true) {
17
19
  if (showToaster) this.dataStore.showToaster('error', this.dataStore.t('toaster.viewErrorText'), 2000);
18
20
  return false;
@@ -26,17 +28,31 @@ export const useMemberStore = defineStore('members', {
26
28
  }
27
29
  return true;
28
30
  },
29
- hasMemberData(whichForm: MemberKeys, whichIndex?: number, key: string = 'id', emptyValue: any = 0) {
30
- if (!this.validateInitiator(false)) return false;
31
+ hasMemberData(whichForm: keyof typeof StoreMembers, whichIndex?: number, key: keyof typeof this.formStore.policyholderForm = 'id', emptyValue: any = 0) {
31
32
  if (!this.isStatementEditible(whichForm)) return false;
32
- return typeof whichIndex === 'number' ? this.formStore[whichForm][whichIndex][key] != emptyValue : this.formStore[whichForm][key] != emptyValue;
33
+ return whichForm !== 'policyholderForm' && whichForm !== 'policyholdersRepresentativeForm'
34
+ ? this.formStore[whichForm][whichIndex!][key] != emptyValue
35
+ : this.formStore[whichForm][key] != emptyValue;
33
36
  },
34
- canMemberDeleted(whichForm: MemberKeys, whichIndex?: number) {
37
+ canMemberCleared(whichForm: keyof typeof StoreMembers, whichIndex?: number) {
35
38
  if (!whichForm) return false;
36
39
  if (!this.isStatementEditible(whichForm)) return false;
37
- if (!this.validateInitiator(false)) return false;
38
- if (typeof whichIndex === 'number' && whichIndex > 0) {
39
- return true;
40
+ if (whichForm !== 'policyholderForm' && whichForm !== 'policyholdersRepresentativeForm') {
41
+ return this.formStore[whichForm][whichIndex!].id === 0 && (!!this.formStore[whichForm][whichIndex!].iin || !!this.formStore[whichForm][whichIndex!].phoneNumber);
42
+ } else {
43
+ return this.formStore[whichForm].id === 0 && (!!this.formStore[whichForm].iin || !!this.formStore[whichForm].phoneNumber);
44
+ }
45
+ },
46
+ canMemberDeleted(whichForm: keyof typeof StoreMembers, whichIndex?: number) {
47
+ if (!whichForm) return false;
48
+ if (!this.isStatementEditible(whichForm)) return false;
49
+ if (typeof whichIndex === 'number') {
50
+ if (whichIndex > 0) {
51
+ return true;
52
+ }
53
+ if (whichIndex === 0) {
54
+ return this.hasMemberData(whichForm, whichIndex);
55
+ }
40
56
  }
41
57
  if (this.dataStore.isTask() && this.dataStore.isProcessEditable(this.formStore.applicationData.statusCode)) {
42
58
  if (whichForm !== this.formStore.policyholderFormKey) {
@@ -45,7 +61,7 @@ export const useMemberStore = defineStore('members', {
45
61
  }
46
62
  return false;
47
63
  },
48
- getMemberFromStore(whichForm: MemberKeys, whichIndex?: number): Member | null {
64
+ getMemberFromStore(whichForm: keyof typeof StoreMembers, whichIndex?: number): Member | null {
49
65
  switch (whichForm) {
50
66
  case this.formStore.policyholderFormKey:
51
67
  return this.formStore.policyholderForm;
@@ -61,8 +77,8 @@ export const useMemberStore = defineStore('members', {
61
77
  return null;
62
78
  }
63
79
  },
64
- getMemberFromApplication(whichForm: MemberKeys, whichIndex?: number) {
65
- const id = typeof whichIndex === 'number' ? this.formStore[whichForm][whichIndex].id : this.formStore[whichForm].id;
80
+ getMemberFromApplication(whichForm: keyof typeof StoreMembers, whichIndex?: number) {
81
+ const id = whichForm !== 'policyholderForm' && whichForm !== 'policyholdersRepresentativeForm' ? this.formStore[whichForm][whichIndex!].id : this.formStore[whichForm].id;
66
82
  switch (whichForm) {
67
83
  case this.formStore.policyholderFormKey:
68
84
  return this.formStore.applicationData.clientApp;
@@ -82,57 +98,53 @@ export const useMemberStore = defineStore('members', {
82
98
  }
83
99
  }
84
100
  },
85
- getMemberClass(whichForm: MemberKeys) {
86
- if (!whichForm) return false;
101
+ getMemberCode(whichForm: keyof typeof StoreMembers) {
87
102
  switch (whichForm) {
88
103
  case this.formStore.policyholderFormKey:
89
- return new PolicyholderForm();
104
+ return MemberCodes.Client;
90
105
  case this.formStore.insuredFormKey:
91
- return new InsuredForm();
106
+ return MemberCodes.Insured;
92
107
  case this.formStore.beneficiaryFormKey:
93
- return new BeneficiaryForm();
108
+ return MemberCodes.Beneficiary;
94
109
  case this.formStore.beneficialOwnerFormKey:
95
- return new BeneficialOwnerForm();
110
+ return MemberCodes.BeneficialOwner;
96
111
  case this.formStore.policyholdersRepresentativeFormKey:
97
- return new PolicyholdersRepresentativeForm();
98
- default:
99
- return false;
112
+ return MemberCodes.Spokesman;
100
113
  }
101
114
  },
102
- getMemberCode(whichForm: MemberKeys) {
115
+ getMemberApplicationCode(whichForm: keyof typeof StoreMembers) {
103
116
  switch (whichForm) {
104
117
  case this.formStore.policyholderFormKey:
105
- return 'Client';
118
+ return MemberAppCodes.clientApp;
106
119
  case this.formStore.insuredFormKey:
107
- return 'Insured';
120
+ return MemberAppCodes.insuredApp;
108
121
  case this.formStore.beneficiaryFormKey:
109
- return 'Beneficiary';
122
+ return MemberAppCodes.beneficiaryApp;
110
123
  case this.formStore.beneficialOwnerFormKey:
111
- return 'BeneficialOwner';
124
+ return MemberAppCodes.beneficialOwnerApp;
112
125
  case this.formStore.policyholdersRepresentativeFormKey:
113
- return 'Spokesman';
126
+ return MemberAppCodes.spokesmanApp;
114
127
  }
115
128
  },
116
- clearMember(whichForm: MemberKeys, whichIndex?: number) {
129
+ clearMember(whichForm: keyof typeof StoreMembers, whichIndex?: number) {
117
130
  if (!whichForm) return false;
118
131
  if (!this.isStatementEditible(whichForm)) return false;
119
- if (!this.validateInitiator()) return false;
120
132
  if (whichForm === this.formStore.policyholderFormKey || whichForm === this.formStore.policyholdersRepresentativeFormKey) {
121
- this.formStore[whichForm].resetMember();
133
+ //@ts-ignore
134
+ this.formStore[whichForm] = new Member();
122
135
  }
123
- if (typeof whichIndex === 'number') {
136
+ if (whichForm !== 'policyholderForm' && whichForm !== 'policyholdersRepresentativeForm') {
124
137
  if (this.formStore[whichForm].length === 1) {
125
- this.formStore[whichForm][whichIndex].resetMember();
138
+ this.formStore[whichForm][whichIndex!] = new Member();
126
139
  } else {
127
- this.formStore[whichForm].splice(whichIndex, 1);
140
+ this.formStore[whichForm].splice(whichIndex!, 1);
128
141
  }
129
142
  }
130
143
  return true;
131
144
  },
132
- async deleteMember(taskId: string, whichForm: MemberKeys, whichIndex?: number) {
145
+ async deleteMember(taskId: string, whichForm: keyof typeof StoreMembers, whichIndex?: number, refetch: boolean = true) {
133
146
  if (!whichForm) return false;
134
147
  if (!this.isStatementEditible(whichForm)) return false;
135
- if (!this.validateInitiator()) return false;
136
148
  try {
137
149
  const memberCode = this.getMemberCode(whichForm);
138
150
  const memberData = this.getMemberFromApplication(whichForm, whichIndex);
@@ -142,20 +154,117 @@ export const useMemberStore = defineStore('members', {
142
154
  await this.dataStore.api.deleteMember(memberCode, this.formStore.applicationData.processInstanceId);
143
155
  }
144
156
  } else {
145
- if (memberData) await this.dataStore.api.deleteMember(memberCode, memberData.id as number);
157
+ if (memberData) {
158
+ if (whichForm === this.formStore.insuredFormKey) {
159
+ await this.dataStore.deleteInsuredLogic();
160
+ }
161
+ await this.dataStore.api.deleteMember(memberCode, memberData.id as number);
162
+ }
146
163
  }
147
- if (memberData) await this.dataStore.getApplicationData(taskId, true, true, true, false);
148
- return this.clearMember(whichForm, whichIndex);
164
+ const cleared = this.clearMember(whichForm, whichIndex);
165
+ if (memberData && refetch) await this.dataStore.getApplicationData(taskId, true, true, true, true);
166
+ return cleared;
149
167
  } catch (err) {
150
168
  console.log(err);
151
169
  return ErrorHandler(err);
152
170
  }
153
171
  },
154
- addMember(whichForm: MemberKeys) {
172
+ async transferPolicyholder(to: MultipleMember) {
173
+ if (!to) return false;
174
+ if (!this.validateInitiator()) return false;
175
+ const fromMember = this.formStore.policyholderForm;
176
+ const successTranser = ref<boolean>(false);
177
+ const toIndex = ref<number | null>(null);
178
+ const taskId = useRoute().params.taskId as string;
179
+ const deletedBefore = ref<boolean>(false);
180
+
181
+ if (this.dataStore.members[this.getMemberApplicationCode(to)!].isMultiple === false) {
182
+ if (this.formStore[to][0].id !== 0 && this.formStore[to][0].iin !== fromMember.iin) {
183
+ deletedBefore.value = await this.deleteMember(taskId, to, 0, false);
184
+ }
185
+ this.formStore[to][0] = fromMember;
186
+ toIndex.value = 0;
187
+ successTranser.value = true;
188
+ } else {
189
+ if (this.formStore[to].every((member: Member) => member.id !== 0)) {
190
+ this.formStore[to].push(fromMember);
191
+ toIndex.value = this.formStore[to].length - 1;
192
+ successTranser.value = true;
193
+ } else {
194
+ const index = this.formStore[to].findIndex((member: Member) => member.id === 0);
195
+ if (index !== -1) {
196
+ this.formStore[to][index] = fromMember;
197
+ toIndex.value = index;
198
+ successTranser.value = true;
199
+ } else {
200
+ this.formStore[to].push(fromMember);
201
+ toIndex.value = this.formStore[to].length - 1;
202
+ successTranser.value = true;
203
+ }
204
+ }
205
+ }
206
+
207
+ if (successTranser.value === true) {
208
+ if (toIndex.value !== null && taskId !== '0' && this.formStore.applicationData.processInstanceId !== 0) {
209
+ if (
210
+ typeof this.formStore[to][toIndex.value].id !== 'number' ||
211
+ (typeof this.formStore[to][toIndex.value].id === 'number' && Number(this.formStore[to][toIndex.value].id) > 0 === false)
212
+ ) {
213
+ return false;
214
+ }
215
+ const hasSaved = await this.dataStore.saveMember(this.formStore[to][toIndex.value], this.getMemberCode(to)!, this.getMemberFromApplication(to, toIndex.value));
216
+ if (hasSaved) {
217
+ await this.dataStore.getApplicationData(taskId, false, true, true, deletedBefore.value);
218
+ this.dataStore.showToaster('warning', this.dataStore.t('toaster.formFieldEmptyWarning'));
219
+ this.dataStore.showToaster('success', this.dataStore.t('toaster.successSaved'));
220
+ return true;
221
+ } else {
222
+ this.dataStore.showToaster('error', this.dataStore.t('error.memberSave'));
223
+ return false;
224
+ }
225
+ } else {
226
+ return true;
227
+ }
228
+ } else {
229
+ this.dataStore.showToaster('error', this.dataStore.t('error.memberCopy'));
230
+ return false;
231
+ }
232
+ },
233
+ async retransferPolicyholder(from: MultipleMember) {
234
+ if (!from) return false;
235
+ if (!this.validateInitiator()) return false;
236
+ const client = this.formStore.policyholderForm;
237
+ const index = this.formStore[from].findIndex((member: Member) => member.id === client.id);
238
+ const taskId = useRoute().params.taskId as string;
239
+ if (index !== -1) {
240
+ const fromCode = this.getMemberApplicationCode(from);
241
+ const fromMember = this.formStore[from][index];
242
+ const applicationList = this.formStore.applicationData[fromCode!];
243
+ const fromIndex = applicationList && applicationList.length ? applicationList.findIndex((member: any) => member.insisId === fromMember.id) : null;
244
+ if (fromMember.id !== 0 && fromIndex !== -1) {
245
+ await this.deleteMember(taskId, from, index);
246
+ } else {
247
+ this.clearMember(from, index);
248
+ }
249
+ } else {
250
+ // @ts-ignore
251
+ this.formStore[from] = [new Member()];
252
+ }
253
+ },
254
+ addMember(whichForm: keyof typeof StoreMembers) {
155
255
  if (!whichForm) return false;
156
256
  if (!this.isStatementEditible(whichForm)) return false;
157
- if (!this.validateInitiator()) return false;
158
- this.formStore[whichForm].push(this.getMemberClass(whichForm));
257
+ if (whichForm === 'policyholderForm' || whichForm === 'policyholdersRepresentativeForm') return false;
258
+ const limit = this.dataStore.members[this.getMemberApplicationCode(whichForm)!].limit;
259
+ if (typeof limit === 'number') {
260
+ if (this.formStore[whichForm].length < limit) {
261
+ this.formStore[whichForm].push(new Member());
262
+ } else {
263
+ this.dataStore.showToaster('error', this.dataStore.t('toaster.membersLimit', { text: limit }));
264
+ }
265
+ } else {
266
+ this.formStore[whichForm].push(new Member());
267
+ }
159
268
  },
160
269
  async getOtpStatus(iin: string, phone: string, processInstanceId: string | number | null = null) {
161
270
  try {
@@ -190,16 +299,22 @@ export const useMemberStore = defineStore('members', {
190
299
  };
191
300
  const otpResponse = await this.dataStore.api.checkOtp(otpData);
192
301
  if (otpResponse !== null) {
193
- if ('errMessage' in otpResponse && otpResponse.errMessage !== null) {
302
+ if ('errMessage' in otpResponse && otpResponse.errMessage) {
194
303
  this.dataStore.showToaster('error', otpResponse.errMessage, 3000);
195
304
  return false;
196
305
  }
197
- if ('status' in otpResponse && !!otpResponse.status) {
306
+ if ('status' in otpResponse && !!otpResponse.status && otpResponse.statusName) {
198
307
  // TODO Доработать и менять значение hasAgreement.value => true
199
308
  this.dataStore.showToaster(otpResponse.status !== 2 ? 'error' : 'success', otpResponse.statusName, 3000);
200
309
  if (otpResponse.status === 2) {
310
+ member.otpCode = null;
201
311
  return true;
202
312
  }
313
+ if (otpResponse.status === 4 || otpResponse.status === 5) {
314
+ member.otpCode = null;
315
+ member.otpTokenId = null;
316
+ return false;
317
+ }
203
318
  }
204
319
  }
205
320
  return false;
@@ -213,7 +328,7 @@ export const useMemberStore = defineStore('members', {
213
328
  async sendOtp(member: Member, processInstanceId: string | number | null = null, onInit: boolean = false) {
214
329
  if (!this.validateInitiator()) return null;
215
330
  this.dataStore.isLoading = true;
216
- let otpStatus: boolean = false;
331
+ let otpStatus: boolean | null = null;
217
332
  let otpResponse: SendOtpResponse = {};
218
333
  try {
219
334
  if (member.iin && member.phoneNumber && member.iin.length === useMask().iin.length && member.phoneNumber.length === useMask().phone.length) {
@@ -239,32 +354,29 @@ export const useMemberStore = defineStore('members', {
239
354
  );
240
355
  this.dataStore.isLoading = false;
241
356
  if (!!otpResponse) {
242
- if ('errMessage' in otpResponse && otpResponse.errMessage !== null) {
357
+ if ('errMessage' in otpResponse && otpResponse.errMessage) {
243
358
  this.dataStore.showToaster('error', otpResponse.errMessage, 3000);
244
- return { otpStatus };
359
+ return { otpStatus: false };
245
360
  }
246
361
  if ('result' in otpResponse && otpResponse.result === null) {
247
362
  if ('statusName' in otpResponse && !!otpResponse.statusName) {
248
363
  this.dataStore.showToaster('error', otpResponse.statusName, 3000);
249
- return { otpStatus };
364
+ return { otpStatus: false };
250
365
  }
251
366
  if ('status' in otpResponse && !!otpResponse.status) {
252
- this.dataStore.showToaster('error', otpResponse.status, 3000);
253
- return { otpStatus };
367
+ this.dataStore.showToaster('error', String(otpResponse.status), 3000);
368
+ return { otpStatus: false };
254
369
  }
255
370
  }
256
371
  if ('tokenId' in otpResponse && otpResponse.tokenId) {
257
372
  member.otpTokenId = otpResponse.tokenId;
258
373
  this.dataStore.showToaster('success', this.dataStore.t('toaster.successOtp'), 3000);
259
374
  }
260
- } else {
261
- this.dataStore.showToaster('error', this.dataStore.t('error.noOtpResponse'), 3000);
262
- return { otpStatus };
263
375
  }
264
376
  }
265
377
  } else {
266
378
  if (onInit === false) {
267
- this.dataStore.showToaster('error', this.dataStore.t('toaster.errorFormField').replace('{text}', 'Номер телефона, ИИН'));
379
+ this.dataStore.showToaster('error', this.dataStore.t('toaster.errorFormField', { text: 'Номер телефона, ИИН' }));
268
380
  this.dataStore.isLoading = false;
269
381
  }
270
382
  }
@@ -1,39 +1,50 @@
1
- import { t } from './messages';
1
+ import { i18n } from '../configs/i18n';
2
2
  import { formatDate } from '../composables';
3
3
 
4
+ const t = i18n.t;
5
+
4
6
  export const rules = {
5
- recalculationMultiply: [v => (v !== null && v !== '' && v >= 100) || t('toaster.valueShouldBeHigher').replace('{text}', '100')],
6
- recalculationAdditive: [
7
- v =>
8
- (v !== null && v !== '' && v <= 100 && v >= 0) ||
9
- t('toaster.valueShouldBeBetween', {
10
- floor: 0,
11
- ceil: 100,
12
- }),
13
- ],
14
- required: [v => !!v || t('rules.required')],
7
+ recalculationMultiply: [(v: any) => (v !== null && v !== '' && v >= 100) || t('toaster.valueShouldBeHigher', { text: '100' })],
8
+ recalculationAdditive: [(v: any) => (v !== null && v !== '' && v <= 100 && v >= 0) || t('toaster.valueShouldBeBetween', { floor: '0', ceil: '100' })],
9
+ required: [(v: any) => !!v || t('rules.required')],
15
10
  objectRequired: [
16
- v => {
11
+ (v: any) => {
17
12
  if (!!v && 'nameRu' in v && v.nameRu != null) {
18
13
  return true;
19
14
  }
20
15
  return t('rules.required');
21
16
  },
22
17
  ],
18
+ agentDataRequired: [
19
+ (v: any) => {
20
+ if (!!v && 'fullName' in v && v.fullName != null) {
21
+ return true;
22
+ }
23
+ return t('rules.required');
24
+ },
25
+ ],
23
26
  noResident: [
24
- v => {
25
- if (!!v && 'nameRu' in v && v.nameRu == 'Нерезидент') {
27
+ (v: any) => {
28
+ if (!!v && 'nameRu' in v && v.nameRu === 'Нерезидент') {
26
29
  return t('rules.noResident');
27
30
  }
28
- if (!!v && 'nameRu' in v && v.nameRu != null) {
31
+ if (!!v && 'nameRu' in v && !!v.nameRu) {
29
32
  return true;
30
33
  }
31
34
  return t('rules.required');
32
35
  },
33
36
  ],
34
- cyrillic: [v => v === null || /^[\u0400-\u04FF ]+$/.test(v) || t('rules.cyrillic')],
37
+ cyrillic: [(v: any) => v === null || /^[\u0400-\u04FF ]+$/.test(v) || t('rules.cyrillic')],
38
+ cyrillicNonRequired: [
39
+ (v: any) => {
40
+ if (!v) return true;
41
+ else {
42
+ return /^[\u0400-\u04FF ]+$/.test(v) || t('rules.cyrillic');
43
+ }
44
+ },
45
+ ],
35
46
  email: [
36
- v => {
47
+ (v: any) => {
37
48
  if (v === '' || v === null) {
38
49
  return true;
39
50
  } else {
@@ -49,11 +60,11 @@ export const rules = {
49
60
  }
50
61
  },
51
62
  ],
52
- numbers: [v => /^[0-9]+$/.test(v) || t('rules.numbers')],
53
- numbersSymbols: [v => /^([0-9])|(\W|_)+$/.test(v) || t('rules.numbersSymbols')],
54
- ageExceeds: [v => v < 50 || t('rules.ageExceeds')],
63
+ numbers: [(v: any) => /^[0-9]+$/.test(v) || t('rules.numbers')],
64
+ numbersSymbols: [(v: any) => /^([0-9])|(\W|_)+$/.test(v) || t('rules.numbersSymbols')],
65
+ ageExceeds: [(v: any) => v < 50 || t('rules.ageExceeds')],
55
66
  sums: [
56
- v => {
67
+ (v: any) => {
57
68
  let str = v.replace(/\s/g, '');
58
69
  if (/^[0-9]+$/.test(str)) {
59
70
  return true;
@@ -62,16 +73,16 @@ export const rules = {
62
73
  },
63
74
  ],
64
75
  iinRight: [
65
- v => {
76
+ (v: any) => {
66
77
  if (v.length !== useMask().iin.length) {
67
78
  return t('rules.iinRight');
68
79
  }
69
80
  return true;
70
81
  },
71
82
  ],
72
- onlySymbols: [v => !/^\d+$/.test(v) || t('rules.onlySymbols')],
83
+ onlySymbols: [(v: any) => !/^\d+$/.test(v) || t('rules.onlySymbols')],
73
84
  phoneFormat: [
74
- v => {
85
+ (v: any) => {
75
86
  if (v === null || v == '') {
76
87
  return true;
77
88
  }
@@ -83,7 +94,7 @@ export const rules = {
83
94
  },
84
95
  ],
85
96
  date: [
86
- v => {
97
+ (v: any) => {
87
98
  if (v === null || v == '') return true;
88
99
  if (/^(0[1-9]|1[0-9]|2[0-9]|3[0-1])(-|\.)(0[1-9]|1[0-2])(-|\.)(19[0-9]{2}|20[0-9][0-9])$/.test(v)) {
89
100
  return true;
@@ -92,10 +103,12 @@ export const rules = {
92
103
  }
93
104
  },
94
105
  ],
95
- age: [v => /^\d+$/.test(v) || t('rules.age')],
106
+ age: [(v: any) => /^\d+$/.test(v) || t('rules.age')],
107
+ age18: [(v: any) => v >= 18 || t('rules.age18')],
108
+ age18ByDate: [(v: any) => Math.abs(new Date(Date.now() - new Date(formatDate(v)!).getTime()).getUTCFullYear() - 1970) >= 18 || t('rules.age18')],
96
109
  birthDate: [
97
- v => {
98
- if (new Date(formatDate(v)) > new Date(Date.now())) return t('rules.exceedDate');
110
+ (v: any) => {
111
+ if (new Date(formatDate(v)!) > new Date(Date.now())) return t('rules.exceedDate');
99
112
  if (/^(0[1-9]|1[0-9]|2[0-9]|3[0-1])(-|\.)(0[1-9]|1[0-2])(-|\.)(19[0-9]{2}|20[0-9][0-9])$/.test(v)) {
100
113
  return true;
101
114
  } else {
@@ -104,7 +117,7 @@ export const rules = {
104
117
  },
105
118
  ],
106
119
  coverPeriod: [
107
- v => {
120
+ (v: any) => {
108
121
  if (v !== null) {
109
122
  if (v < 5) {
110
123
  return t('rules.coverPeriod');
@@ -115,8 +128,20 @@ export const rules = {
115
128
  }
116
129
  },
117
130
  ],
131
+ coverPeriodFrom2to20: [
132
+ (v: any) => {
133
+ if (v !== null) {
134
+ if (v < 2 || v > 20) {
135
+ return t('productConditionsForm.coverPeriodFrom2to20');
136
+ }
137
+ return true;
138
+ } else {
139
+ return t('productConditionsForm.coverPeriodFrom2to20');
140
+ }
141
+ },
142
+ ],
118
143
  coverPeriodFrom3to20: [
119
- v => {
144
+ (v: any) => {
120
145
  if (v !== null) {
121
146
  if (v < 3 || v > 20) {
122
147
  return t('productConditionsForm.coverPeriodFrom3to20');
@@ -128,7 +153,7 @@ export const rules = {
128
153
  },
129
154
  ],
130
155
  requestedSumInsuredMycar: [
131
- v => {
156
+ (v: any) => {
132
157
  if (v !== null) {
133
158
  if (v.replace(/\s/g, '') > 60000000) {
134
159
  return t('rules.requestedSumInsuredMycar');
@@ -138,7 +163,7 @@ export const rules = {
138
163
  },
139
164
  ],
140
165
  ageMycar: [
141
- v => {
166
+ (v: any) => {
142
167
  if (v !== null) {
143
168
  let n = Number(v);
144
169
  if (n <= 21 || n >= 65) {
@@ -148,6 +173,12 @@ export const rules = {
148
173
  }
149
174
  },
150
175
  ],
151
- policyholderAgeLimit: [v => v >= 18 || t('rules.policyholderAgeLimit')],
152
- beneficiaryAgeLimit: [v => v <= 15 || t('rules.beneficiaryAgeLimit')],
176
+ policyholderAgeLimit: [(v: any) => v >= 18 || t('rules.policyholderAgeLimit')],
177
+ beneficiaryAgeLimit: [(v: any) => v <= 15 || t('rules.beneficiaryAgeLimit')],
178
+ guaranteedPeriodLimit(v: any, termAnnuityPayments: any) {
179
+ if (Number(v) > Number(termAnnuityPayments)) {
180
+ return t('rules.guaranteedPeriodLimit');
181
+ }
182
+ return true;
183
+ },
153
184
  };
package/types/enum.ts ADDED
@@ -0,0 +1,83 @@
1
+ export enum StoreMembers {
2
+ policyholderForm = 'policyholderForm',
3
+ insuredForm = 'insuredForm',
4
+ beneficiaryForm = 'beneficiaryForm',
5
+ beneficialOwnerForm = 'beneficialOwnerForm',
6
+ policyholdersRepresentativeForm = 'policyholdersRepresentativeForm',
7
+ }
8
+
9
+ export enum Actions {
10
+ accept = 'accept',
11
+ rejectclient = 'rejectclient',
12
+ reject = 'reject',
13
+ return = 'return',
14
+ claim = 'claim',
15
+ sign = 'sign',
16
+ pay = 'pay',
17
+ register = 'register',
18
+ send = 'send',
19
+ affiliate = 'affiliate',
20
+ }
21
+
22
+ export enum PostActions {
23
+ font = 'font',
24
+ route = 'route',
25
+ onRouteChange = 'onRouteChange',
26
+ applicationCreated = 'applicationCreated',
27
+ clipboard = 'clipboard',
28
+ toHomePage = 'toHomePage',
29
+ toStatementHistory = 'toStatementHistory',
30
+ toAuth = 'toAuth',
31
+ DOMevent = 'DOMevent',
32
+ Error401 = 'Error401',
33
+ Error500 = 'Error500',
34
+ iframeLoaded = 'iframeLoaded',
35
+ }
36
+
37
+ export enum Roles {
38
+ Manager = 'Manager',
39
+ Admin = 'Admin',
40
+ Underwriter = 'Underwriter',
41
+ Agent = 'Agent',
42
+ Compliance = 'Compliance',
43
+ AgentMycar = 'AgentMycar',
44
+ Analyst = 'Analyst',
45
+ UPK = 'UPK',
46
+ FinCenter = 'FinCenter',
47
+ Supervisor = 'Supervisor',
48
+ Support = 'Support',
49
+ ManagerHalykBank = 'ManagerHalykBank',
50
+ ServiceManager = 'ServiceManager',
51
+ DRNSJ = 'DRNSJ',
52
+ }
53
+
54
+ export enum Statuses {
55
+ StartForm = 'StartForm',
56
+ EditForm = 'EditForm',
57
+ EditBeneficiaryForm = 'EditBeneficiaryForm',
58
+ DocumentsSignedFrom = 'DocumentsSignedFrom',
59
+ UnderwriterForm = 'UnderwriterForm',
60
+ AffilationResolutionForm = 'AffilationResolutionForm',
61
+ Completed = 'Completed',
62
+ InsurancePremiumOnlinePaid = 'InsurancePremiumOnlinePaid',
63
+ ContractSignedFrom = 'ContractSignedFrom',
64
+ WaitingInsurancePremiumForm = 'WaitingInsurancePremiumForm',
65
+ CheckFinCenterForm = 'CheckFinCenterForm',
66
+ RegistryFinCenterForm = 'RegistryFinCenterForm',
67
+ }
68
+
69
+ export enum MemberCodes {
70
+ Client = 'Client',
71
+ Insured = 'Insured',
72
+ Beneficiary = 'Beneficiary',
73
+ BeneficialOwner = 'BeneficialOwner',
74
+ Spokesman = 'Spokesman',
75
+ }
76
+
77
+ export enum MemberAppCodes {
78
+ clientApp = 'clientApp',
79
+ insuredApp = 'insuredApp',
80
+ beneficiaryApp = 'beneficiaryApp',
81
+ beneficialOwnerApp = 'beneficialOwnerApp',
82
+ spokesmanApp = 'spokesmanApp',
83
+ }
package/types/env.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ /// <reference types="vite/client" />
2
+
3
+ interface ImportMetaEnv {
4
+ readonly VITE_MODE: EnvModes;
5
+ readonly VITE_PRODUCT?: Projects;
6
+ }
7
+
8
+ interface ImportMeta {
9
+ readonly env: ImportMetaEnv;
10
+ }