hl-core 0.0.8-beta.4 → 0.0.8-beta.40

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 (61) hide show
  1. package/api/index.ts +117 -44
  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/Page.vue +1 -1
  6. package/components/Dialog/Dialog.vue +9 -39
  7. package/components/Dialog/FamilyDialog.vue +7 -4
  8. package/components/Form/FormBlock.vue +77 -33
  9. package/components/Form/FormSection.vue +4 -1
  10. package/components/Form/FormToggle.vue +2 -3
  11. package/components/Form/ManagerAttachment.vue +197 -0
  12. package/components/Form/ProductConditionsBlock.vue +60 -10
  13. package/components/Input/Datepicker.vue +6 -2
  14. package/components/Input/FileInput.vue +2 -2
  15. package/components/Input/FormInput.vue +29 -7
  16. package/components/Input/PanelInput.vue +7 -2
  17. package/components/Input/RoundedInput.vue +2 -2
  18. package/components/Input/RoundedSelect.vue +137 -0
  19. package/components/Layout/Drawer.vue +3 -2
  20. package/components/Layout/Header.vue +40 -4
  21. package/components/Layout/Loader.vue +1 -1
  22. package/components/Layout/SettingsPanel.vue +51 -13
  23. package/components/Menu/MenuHover.vue +30 -0
  24. package/components/Menu/MenuNav.vue +29 -13
  25. package/components/Menu/MenuNavItem.vue +6 -3
  26. package/components/Pages/Anketa.vue +51 -33
  27. package/components/Pages/Auth.vue +139 -46
  28. package/components/Pages/Documents.vue +6 -6
  29. package/components/Pages/InvoiceInfo.vue +30 -0
  30. package/components/Pages/MemberForm.vue +533 -292
  31. package/components/Pages/ProductAgreement.vue +4 -2
  32. package/components/Pages/ProductConditions.vue +509 -99
  33. package/components/Panel/PanelHandler.vue +93 -20
  34. package/components/Panel/PanelSelectItem.vue +1 -1
  35. package/components/Utilities/Chip.vue +27 -0
  36. package/components/Utilities/JsonViewer.vue +27 -0
  37. package/composables/axios.ts +1 -1
  38. package/composables/classes.ts +217 -97
  39. package/composables/constants.ts +26 -52
  40. package/composables/index.ts +80 -2
  41. package/composables/styles.ts +8 -3
  42. package/configs/i18n.ts +17 -0
  43. package/layouts/default.vue +6 -6
  44. package/locales/kz.json +585 -0
  45. package/locales/ru.json +587 -0
  46. package/nuxt.config.ts +9 -1
  47. package/package.json +41 -11
  48. package/pages/500.vue +2 -2
  49. package/pages/Token.vue +51 -0
  50. package/plugins/helperFunctionsPlugins.ts +3 -0
  51. package/plugins/storePlugin.ts +0 -1
  52. package/plugins/vuetifyPlugin.ts +8 -1
  53. package/store/data.store.ts +2649 -0
  54. package/store/form.store.ts +1 -1
  55. package/store/member.store.ts +164 -52
  56. package/store/{rules.js → rules.ts} +63 -25
  57. package/types/enum.ts +83 -0
  58. package/types/env.d.ts +10 -0
  59. package/types/index.ts +211 -7
  60. package/store/data.store.js +0 -2508
  61. package/store/messages.ts +0 -434
@@ -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,20 +1,30 @@
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: [v => (v !== null && v !== '' && v <= 100 && v >= 0) || t('toaster.valueShouldBeBetween').replace('{floor}', '0').replace('{ceil}', '100')],
7
- 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')],
8
10
  objectRequired: [
9
- v => {
11
+ (v: any) => {
10
12
  if (!!v && 'nameRu' in v && v.nameRu != null) {
11
13
  return true;
12
14
  }
13
15
  return t('rules.required');
14
16
  },
15
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
+ ],
16
26
  noResident: [
17
- v => {
27
+ (v: any) => {
18
28
  if (!!v && 'nameRu' in v && v.nameRu === 'Нерезидент') {
19
29
  return t('rules.noResident');
20
30
  }
@@ -24,9 +34,17 @@ export const rules = {
24
34
  return t('rules.required');
25
35
  },
26
36
  ],
27
- 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
+ ],
28
46
  email: [
29
- v => {
47
+ (v: any) => {
30
48
  if (v === '' || v === null) {
31
49
  return true;
32
50
  } else {
@@ -42,11 +60,11 @@ export const rules = {
42
60
  }
43
61
  },
44
62
  ],
45
- numbers: [v => /^[0-9]+$/.test(v) || t('rules.numbers')],
46
- numbersSymbols: [v => /^([0-9])|(\W|_)+$/.test(v) || t('rules.numbersSymbols')],
47
- 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')],
48
66
  sums: [
49
- v => {
67
+ (v: any) => {
50
68
  let str = v.replace(/\s/g, '');
51
69
  if (/^[0-9]+$/.test(str)) {
52
70
  return true;
@@ -55,16 +73,16 @@ export const rules = {
55
73
  },
56
74
  ],
57
75
  iinRight: [
58
- v => {
76
+ (v: any) => {
59
77
  if (v.length !== useMask().iin.length) {
60
78
  return t('rules.iinRight');
61
79
  }
62
80
  return true;
63
81
  },
64
82
  ],
65
- onlySymbols: [v => !/^\d+$/.test(v) || t('rules.onlySymbols')],
83
+ onlySymbols: [(v: any) => !/^\d+$/.test(v) || t('rules.onlySymbols')],
66
84
  phoneFormat: [
67
- v => {
85
+ (v: any) => {
68
86
  if (v === null || v == '') {
69
87
  return true;
70
88
  }
@@ -76,7 +94,7 @@ export const rules = {
76
94
  },
77
95
  ],
78
96
  date: [
79
- v => {
97
+ (v: any) => {
80
98
  if (v === null || v == '') return true;
81
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)) {
82
100
  return true;
@@ -85,10 +103,12 @@ export const rules = {
85
103
  }
86
104
  },
87
105
  ],
88
- 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')],
89
109
  birthDate: [
90
- v => {
91
- 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');
92
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)) {
93
113
  return true;
94
114
  } else {
@@ -97,7 +117,7 @@ export const rules = {
97
117
  },
98
118
  ],
99
119
  coverPeriod: [
100
- v => {
120
+ (v: any) => {
101
121
  if (v !== null) {
102
122
  if (v < 5) {
103
123
  return t('rules.coverPeriod');
@@ -108,8 +128,20 @@ export const rules = {
108
128
  }
109
129
  },
110
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
+ ],
111
143
  coverPeriodFrom3to20: [
112
- v => {
144
+ (v: any) => {
113
145
  if (v !== null) {
114
146
  if (v < 3 || v > 20) {
115
147
  return t('productConditionsForm.coverPeriodFrom3to20');
@@ -121,7 +153,7 @@ export const rules = {
121
153
  },
122
154
  ],
123
155
  requestedSumInsuredMycar: [
124
- v => {
156
+ (v: any) => {
125
157
  if (v !== null) {
126
158
  if (v.replace(/\s/g, '') > 60000000) {
127
159
  return t('rules.requestedSumInsuredMycar');
@@ -131,7 +163,7 @@ export const rules = {
131
163
  },
132
164
  ],
133
165
  ageMycar: [
134
- v => {
166
+ (v: any) => {
135
167
  if (v !== null) {
136
168
  let n = Number(v);
137
169
  if (n <= 21 || n >= 65) {
@@ -141,6 +173,12 @@ export const rules = {
141
173
  }
142
174
  },
143
175
  ],
144
- policyholderAgeLimit: [v => v >= 18 || t('rules.policyholderAgeLimit')],
145
- 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
+ },
146
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
+ }