hl-core 0.0.8-beta.21 → 0.0.8-beta.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/api/index.ts CHANGED
@@ -13,7 +13,10 @@ export class ApiClass {
13
13
 
14
14
  private async axiosCall<T>(config: AxiosRequestConfig): Promise<T> {
15
15
  const dataStore = useDataStore();
16
- if ((dataStore.isBridge && !this.baseURL) || (!dataStore.isEFO && !dataStore.isAML && !dataStore.isLKA && (!this.baseURL || !this.productUrl))) {
16
+ if (dataStore.isBridge && !this.baseURL) {
17
+ console.error('No Axios baseURL');
18
+ }
19
+ if (!dataStore.isBridge && !dataStore.isCalculator && (!this.baseURL || !this.productUrl)) {
17
20
  console.error('No Axios baseURL or productURL');
18
21
  }
19
22
  const { data } = await useAxios(this.baseURL).request<T>(config);
@@ -455,18 +458,18 @@ export class ApiClass {
455
458
  });
456
459
  }
457
460
 
458
- async calculateWithoutApplication(data: RecalculationDataType): Promise<RecalculationResponseType> {
461
+ async calculateWithoutApplication(data: RecalculationDataType, product = this.productUrl): Promise<RecalculationResponseType> {
459
462
  return this.axiosCall({
460
463
  method: Methods.POST,
461
- url: `/${this.productUrl}/api/Application/Calculate`,
464
+ url: `/${product}/api/Application/Calculate`,
462
465
  data: data,
463
466
  });
464
467
  }
465
468
 
466
- async getDefaultCalculationData(): Promise<RecalculationDataType> {
469
+ async getDefaultCalculationData(product = this.productUrl): Promise<RecalculationDataType> {
467
470
  return this.axiosCall({
468
471
  method: Methods.GET,
469
- url: `/${this.productUrl}/api/Application/DefaultCalculatorValues`,
472
+ url: `/${product}/api/Application/DefaultCalculatorValues`,
470
473
  });
471
474
  }
472
475
 
@@ -4,7 +4,9 @@ export default function (axios: AxiosInstance) {
4
4
  axios.interceptors.request.use(
5
5
  request => {
6
6
  const dataStore = useDataStore();
7
- request.headers.Authorization = `Bearer ${dataStore.accessToken}`;
7
+ if (dataStore.accessToken) {
8
+ request.headers.Authorization = `Bearer ${dataStore.accessToken}`;
9
+ }
8
10
  return request;
9
11
  },
10
12
  error => {
@@ -17,19 +19,21 @@ export default function (axios: AxiosInstance) {
17
19
  },
18
20
  error => {
19
21
  const dataStore = useDataStore();
20
- const router = useRouter();
21
- if (error.response.status === 401) {
22
- dataStore.$reset();
23
- localStorage.clear();
24
- if (dataStore.isBridge) {
25
- router.push({ name: 'Auth', query: { error: 401 } });
26
- } else {
27
- dataStore.sendToParent(constants.postActions.Error401, 401);
22
+ if (!dataStore.isCalculator) {
23
+ const router = useRouter();
24
+ if (error.response.status === 401) {
25
+ dataStore.$reset();
26
+ localStorage.clear();
27
+ if (dataStore.isBridge) {
28
+ router.push({ name: 'Auth', query: { error: 401 } });
29
+ } else {
30
+ dataStore.sendToParent(constants.postActions.Error401, 401);
31
+ }
28
32
  }
29
- }
30
- if (error.response.status >= 500) {
31
- if (router.currentRoute.value.name !== 'Auth') {
32
- dataStore.showToaster('error', error.stack, 5000);
33
+ if (error.response.status >= 500) {
34
+ if (router.currentRoute.value.name !== 'Auth') {
35
+ dataStore.showToaster('error', error.stack, 5000);
36
+ }
33
37
  }
34
38
  }
35
39
  return Promise.reject(error);
@@ -74,7 +74,7 @@
74
74
  <v-btn
75
75
  v-if="secondQuestionList && secondQuestionList.length && firstPanel"
76
76
  icon="mdi mdi-close"
77
- class="ml-3 !absolute"
77
+ class="ml-3 !absolute z-10"
78
78
  @click="
79
79
  firstPanel = false;
80
80
  secondPanel = false;
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <section class="flex flex-col gap-4 px-[10px]">
3
3
  <v-form ref="vForm" @submit="submitForm" class="max-h-[82svh] overflow-y-scroll">
4
- <base-form-section v-if="$dataStore.isGons" :title="$t('productConditionsForm.requestedProductConditions')" :class="[$libStyles.textSimple]">
4
+ <base-form-section v-if="whichProduct === 'gons'" :title="$t('productConditionsForm.requestedProductConditions')" :class="[$libStyles.textSimple]">
5
5
  <base-form-text-section
6
6
  class="mb-4"
7
7
  title="Инвалидность I или II группы по причине несчастного случая, начиная с третьего года по любой причине, с освобождением от уплаты страховых взносов"
@@ -87,7 +87,7 @@
87
87
  ></base-panel-input>
88
88
  </base-form-section>
89
89
  <base-form-section :title="$t('generalConditions')">
90
- <div v-if="isRecalculation && $route.params.taskId === '0'">
90
+ <div v-if="isRecalculation && ($route.params.taskId === '0' || $dataStore.isCalculator)">
91
91
  <base-form-input
92
92
  v-model="productConditionsForm.signDate"
93
93
  :maska="$maska.date"
@@ -122,7 +122,7 @@
122
122
  :readonly="isDisabled"
123
123
  :clearable="!isDisabled"
124
124
  :rules="coverPeriodRule"
125
- :label="$t($dataStore.isGons ? 'productConditionsForm.coverPeriodFrom3to20' : 'productConditionsForm.coverPeriod')"
125
+ :label="$t(whichProduct === 'gons' ? 'productConditionsForm.coverPeriodFrom3to20' : 'productConditionsForm.coverPeriod')"
126
126
  ></base-form-input>
127
127
  <base-panel-input
128
128
  v-if="hasPaymentPeriod"
@@ -207,9 +207,9 @@
207
207
  </div>
208
208
  </base-form-section>
209
209
  </v-form>
210
- <base-btn v-if="isRecalculation && hasCalculated" :btn="$libStyles.greenLightBtn" :text="$t('buttons.toStatement')" @click="toStatement"></base-btn>
210
+ <base-btn v-if="!$dataStore.isCalculator && isRecalculation && hasCalculated" :btn="$libStyles.greenLightBtn" :text="$t('buttons.toStatement')" @click="toStatement"></base-btn>
211
211
  <base-btn
212
- v-if="!isDisabled && isTask && ($dataStore.isInitiator() || $dataStore.isUnderwriter())"
212
+ v-if="$dataStore.isCalculator ? true : !isDisabled && isTask && ($dataStore.isInitiator() || $dataStore.isUnderwriter())"
213
213
  :loading="isCalculating"
214
214
  :text="$t('buttons.calculate')"
215
215
  @click="submitForm"
@@ -261,6 +261,10 @@ export default defineComponent({
261
261
  type: Boolean,
262
262
  default: false,
263
263
  },
264
+ product: {
265
+ type: String,
266
+ default: false,
267
+ },
264
268
  },
265
269
  setup(props) {
266
270
  const vForm = ref<any>();
@@ -270,6 +274,7 @@ export default defineComponent({
270
274
  const dataStore = useDataStore();
271
275
  const memberStore = useMemberStore();
272
276
 
277
+ const whichProduct = ref<string>(dataStore.isCalculator ? props.product : dataStore.product!);
273
278
  const isCalculating = ref<boolean>(false);
274
279
  const isPanelLoading = ref<boolean>(false);
275
280
  const isPanelOpen = ref<boolean>(false);
@@ -291,7 +296,7 @@ export default defineComponent({
291
296
  return formStore.applicationData.statusCode === 'UnderwriterForm';
292
297
  }
293
298
  });
294
- const isDisabled = computed(() => !memberStore.isStatementEditible(formStore.productConditionsFormKey));
299
+ const isDisabled = computed(() => (dataStore.isCalculator ? false : !memberStore.isStatementEditible(formStore.productConditionsFormKey)));
295
300
  const isTask = computed(() => (route.params.taskId === '0' && props.isRecalculation === true) || dataStore.isTask());
296
301
  const isRecalculationDisabled = computed(() => formStore.isDisabled.recalculationForm);
297
302
  const isUnderwriterRole = computed(() => dataStore.isUnderwriter() || dataStore.isAdmin() || dataStore.isSupport());
@@ -299,65 +304,65 @@ export default defineComponent({
299
304
  const requestedSumInsured = computed(() => (!!productConditionsForm.requestedSumInsured ? dataStore.rules.required.concat(dataStore.rules.sums) : []));
300
305
  const hasCalculated = computed(() => !!productConditionsForm.requestedSumInsured && !!productConditionsForm.insurancePremiumPerMonth);
301
306
  const hasProcessIndexRate = computed(() => {
302
- if (dataStore.isGons || dataStore.isKazyna) {
307
+ if (whichProduct.value === 'gons' || whichProduct.value === 'halykkazyna') {
303
308
  return false;
304
309
  }
305
310
  return true;
306
311
  });
307
312
  const hasPaymentPeriod = computed(() => {
308
- if (dataStore.isKazyna) {
313
+ if (whichProduct.value === 'halykkazyna') {
309
314
  return false;
310
315
  }
311
316
  return true;
312
317
  });
313
318
  const hasRequestedSumInsuredInDollar = computed(() => {
314
- if (dataStore.isKazyna) {
319
+ if (whichProduct.value === 'halykkazyna') {
315
320
  return true;
316
321
  }
317
322
  return false;
318
323
  });
319
324
  const hasInsurancePremiumPerMonthInDollar = computed(() => {
320
- if (dataStore.isKazyna) {
325
+ if (whichProduct.value === 'halykkazyna') {
321
326
  return true;
322
327
  }
323
328
  return false;
324
329
  });
325
330
  const hasCurrency = computed(() => {
326
- if (dataStore.isKazyna) {
331
+ if (whichProduct.value === 'halykkazyna') {
327
332
  return true;
328
333
  }
329
334
  return false;
330
335
  });
331
336
  const hasAdbMultiply = computed(() => {
332
- if (dataStore.isGons) {
337
+ if (whichProduct.value === 'gons') {
333
338
  return false;
334
339
  }
335
340
  return true;
336
341
  });
337
342
  const hasAdbAdditive = computed(() => {
338
- if (dataStore.isGons) {
343
+ if (whichProduct.value === 'gons') {
339
344
  return false;
340
345
  }
341
346
  return true;
342
347
  });
343
348
  const hasRiskGroup = computed(() => {
344
- if (dataStore.isGons) {
349
+ if (whichProduct.value === 'gons') {
345
350
  return false;
346
351
  }
347
352
  return true;
348
353
  });
349
354
  const coverPeriodRule = computed(() => {
350
355
  const baseCondition = dataStore.rules.required.concat(dataStore.rules.numbers);
351
- if (dataStore.isGons) {
356
+ if (whichProduct.value === 'gons') {
352
357
  return baseCondition.concat(dataStore.rules.coverPeriodFrom3to20);
353
358
  }
354
- if (dataStore.isKazyna) {
359
+ if (whichProduct.value === 'halykkazyna') {
355
360
  return baseCondition.concat(dataStore.rules.coverPeriodFrom2to20);
356
361
  }
357
362
  return baseCondition;
358
363
  });
359
364
  const currencySymbolsAddTerm = computed(() => {
360
- if (dataStore.isKazyna) {
365
+ if (whichProduct.value === 'halykkazyna') {
361
366
  return constants.currencySymbols.usd;
362
367
  }
363
368
  return constants.currencySymbols.kzt;
@@ -593,8 +598,13 @@ export default defineComponent({
593
598
 
594
599
  onMounted(async () => {
595
600
  if (props.isRecalculation === true) {
596
- if (route.params.taskId === '0' && productConditionsForm.requestedSumInsured === null && productConditionsForm.insurancePremiumPerMonth === null) {
597
- const defaultData = await dataStore.getDefaultCalculationData(true);
601
+ if (
602
+ (dataStore.isCalculator || route.params.taskId === '0') &&
603
+ productConditionsForm.requestedSumInsured === null &&
604
+ productConditionsForm.insurancePremiumPerMonth === null
605
+ ) {
606
+ // @ts-ignore
607
+ const defaultData = await dataStore.getDefaultCalculationData(true, whichProduct.value);
598
608
  if (!defaultData) {
599
609
  dataStore.showToaster('error', 'Отсутствуют базовые данные');
600
610
  return;
@@ -616,7 +626,7 @@ export default defineComponent({
616
626
  if (!!productConditionsForm.requestedSumInsured) {
617
627
  whichSum.value = 'requestedSumInsured';
618
628
  }
619
- if (dataStore.isKazyna) {
629
+ if (whichProduct.value === 'halykkazyna') {
620
630
  const kazynaPaymentPeriod = dataStore.processPaymentPeriod.find(i => i.code === 'single');
621
631
  if (kazynaPaymentPeriod) productConditionsForm.paymentPeriod = kazynaPaymentPeriod;
622
632
  await dataStore.getCurrencies();
@@ -666,6 +676,7 @@ export default defineComponent({
666
676
  // State
667
677
  formStore,
668
678
  vForm,
679
+ whichProduct,
669
680
  productConditionsForm,
670
681
  additionalTerms,
671
682
  isCalculating,
@@ -60,6 +60,7 @@ export const constants = Object.freeze({
60
60
  postActions: {
61
61
  font: 'font',
62
62
  route: 'route',
63
+ onRouteChange: 'onRouteChange',
63
64
  applicationCreated: 'applicationCreated',
64
65
  clipboard: 'clipboard',
65
66
  toHomePage: 'toHomePage',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hl-core",
3
- "version": "0.0.8-beta.21",
3
+ "version": "0.0.8-beta.22",
4
4
  "license": "MIT",
5
5
  "private": false,
6
6
  "main": "nuxt.config.ts",
@@ -42,6 +42,7 @@ export const useDataStore = defineStore('data', {
42
42
  isPension: state => state.product === 'pension',
43
43
  isGons: state => state.product === 'gons',
44
44
  isKazyna: state => state.product === 'halykkazyna',
45
+ isCalculator: state => state.product === 'calculator',
45
46
  isComplianceWindow: state => state.product === 'compliance',
46
47
  isEveryFormDisabled: state => Object.values(state.formStore.isDisabled).every(i => i === true),
47
48
  },
@@ -1331,10 +1332,10 @@ export const useDataStore = defineStore('data', {
1331
1332
  console.log(err);
1332
1333
  }
1333
1334
  },
1334
- async getDefaultCalculationData(showLoader = false) {
1335
+ async getDefaultCalculationData(showLoader = false, product = null) {
1335
1336
  this.isLoading = showLoader;
1336
1337
  try {
1337
- const calculationData = await this.api.getDefaultCalculationData();
1338
+ const calculationData = await this.api.getDefaultCalculationData(this.isCalculator ? product : undefined);
1338
1339
  return calculationData;
1339
1340
  } catch (err) {
1340
1341
  ErrorHandler(err);
@@ -1342,7 +1343,7 @@ export const useDataStore = defineStore('data', {
1342
1343
  this.isLoading = false;
1343
1344
  }
1344
1345
  },
1345
- async calculateWithoutApplication(showLoader = false) {
1346
+ async calculateWithoutApplication(showLoader = false, product = null) {
1346
1347
  this.isLoading = showLoader;
1347
1348
  try {
1348
1349
  const calculationData = {
@@ -1359,16 +1360,16 @@ export const useDataStore = defineStore('data', {
1359
1360
  paymentPeriodId: this.formStore.productConditionsForm.paymentPeriod.id,
1360
1361
  addCovers: this.formStore.additionalInsuranceTermsWithout,
1361
1362
  };
1362
- if (this.isKazyna) {
1363
+ if (this.isKazyna || product === 'halykkazyna') {
1363
1364
  calculationData.premiumInCurrency = getNumber(this.formStore.productConditionsForm.insurancePremiumPerMonthInDollar);
1364
1365
  calculationData.amountInCurrency = getNumber(this.formStore.productConditionsForm.requestedSumInsuredInDollar);
1365
1366
  calculationData.currencyExchangeRate = this.currencies.usd;
1366
1367
  }
1367
- const calculationResponse = await this.api.calculateWithoutApplication(calculationData);
1368
+ const calculationResponse = await this.api.calculateWithoutApplication(calculationData, this.isCalculator ? product : undefined);
1368
1369
  this.formStore.productConditionsForm.requestedSumInsured = this.getNumberWithSpaces(calculationResponse.amount);
1369
1370
  this.formStore.productConditionsForm.insurancePremiumPerMonth = this.getNumberWithSpaces(calculationResponse.premium);
1370
1371
  this.formStore.additionalInsuranceTermsWithout = calculationResponse.addCovers;
1371
- if (this.isKazyna) {
1372
+ if (this.isKazyna || product === 'halykkazyna') {
1372
1373
  this.formStore.productConditionsForm.requestedSumInsuredInDollar = this.getNumberWithSpaces(calculationResponse.amountInCurrency);
1373
1374
  this.formStore.productConditionsForm.insurancePremiumPerMonthInDollar = this.getNumberWithSpaces(calculationResponse.premiumInCurrency);
1374
1375
  }