hl-core 0.0.8-beta.26 → 0.0.8-beta.28

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.
@@ -13,6 +13,7 @@ export const useMemberStore = defineStore('members', {
13
13
  }),
14
14
  actions: {
15
15
  isStatementEditible(whichForm: string, showToaster: boolean = false) {
16
+ if (!this.validateInitiator(false)) return false;
16
17
  if (this.formStore.isDisabled[whichForm as keyof typeof this.formStore.isDisabled] === true) {
17
18
  if (showToaster) this.dataStore.showToaster('error', this.dataStore.t('toaster.viewErrorText'), 2000);
18
19
  return false;
@@ -27,14 +28,21 @@ export const useMemberStore = defineStore('members', {
27
28
  return true;
28
29
  },
29
30
  hasMemberData(whichForm: MemberKeys, whichIndex?: number, key: string = 'id', emptyValue: any = 0) {
30
- if (!this.validateInitiator(false)) return false;
31
31
  if (!this.isStatementEditible(whichForm)) return false;
32
32
  return typeof whichIndex === 'number' ? this.formStore[whichForm][whichIndex][key] != emptyValue : this.formStore[whichForm][key] != emptyValue;
33
33
  },
34
+ canMemberCleared(whichForm: MemberKeys, whichIndex?: number) {
35
+ if (!whichForm) return false;
36
+ if (!this.isStatementEditible(whichForm)) return false;
37
+ if (typeof whichIndex === 'number') {
38
+ return this.formStore[whichForm][whichIndex].id === 0 && (!!this.formStore[whichForm][whichIndex].iin || !!this.formStore[whichForm][whichIndex].phoneNumber);
39
+ } else {
40
+ return this.formStore[whichForm].id === 0 && (!!this.formStore[whichForm].iin || !!this.formStore[whichForm].phoneNumber);
41
+ }
42
+ },
34
43
  canMemberDeleted(whichForm: MemberKeys, whichIndex?: number) {
35
44
  if (!whichForm) return false;
36
45
  if (!this.isStatementEditible(whichForm)) return false;
37
- if (!this.validateInitiator(false)) return false;
38
46
  if (typeof whichIndex === 'number') {
39
47
  if (whichIndex > 0) {
40
48
  return true;
@@ -135,7 +143,6 @@ export const useMemberStore = defineStore('members', {
135
143
  clearMember(whichForm: MemberKeys, whichIndex?: number) {
136
144
  if (!whichForm) return false;
137
145
  if (!this.isStatementEditible(whichForm)) return false;
138
- if (!this.validateInitiator()) return false;
139
146
  if (whichForm === this.formStore.policyholderFormKey || whichForm === this.formStore.policyholdersRepresentativeFormKey) {
140
147
  //@ts-ignore
141
148
  this.formStore[whichForm] = this.getMemberClass(whichForm);
@@ -152,7 +159,6 @@ export const useMemberStore = defineStore('members', {
152
159
  async deleteMember(taskId: string, whichForm: MemberKeys, whichIndex?: number, refetch: boolean = true) {
153
160
  if (!whichForm) return false;
154
161
  if (!this.isStatementEditible(whichForm)) return false;
155
- if (!this.validateInitiator()) return false;
156
162
  try {
157
163
  const memberCode = this.getMemberCode(whichForm);
158
164
  const memberData = this.getMemberFromApplication(whichForm, whichIndex);
@@ -162,10 +168,15 @@ export const useMemberStore = defineStore('members', {
162
168
  await this.dataStore.api.deleteMember(memberCode, this.formStore.applicationData.processInstanceId);
163
169
  }
164
170
  } else {
165
- if (memberData) await this.dataStore.api.deleteMember(memberCode, memberData.id as number);
171
+ if (memberData) {
172
+ if (whichForm === this.formStore.insuredFormKey) {
173
+ await this.dataStore.deleteInsuredLogic();
174
+ }
175
+ await this.dataStore.api.deleteMember(memberCode, memberData.id as number);
176
+ }
166
177
  }
167
178
  const cleared = this.clearMember(whichForm, whichIndex);
168
- if (memberData && refetch) await this.dataStore.getApplicationData(taskId, true, true, true, false);
179
+ if (memberData && refetch) await this.dataStore.getApplicationData(taskId, true, true, true, true);
169
180
  return cleared;
170
181
  } catch (err) {
171
182
  console.log(err);
@@ -179,10 +190,11 @@ export const useMemberStore = defineStore('members', {
179
190
  const successTranser = ref<boolean>(false);
180
191
  const toIndex = ref<number | null>(null);
181
192
  const taskId = useRoute().params.taskId as string;
193
+ const deletedBefore = ref<boolean>(false);
182
194
 
183
195
  if (this.dataStore.members[this.getMemberApplicationCode(to)!].isMultiple === false) {
184
196
  if (this.formStore[to][0].id !== 0 && this.formStore[to][0].iin !== fromMember.iin) {
185
- await this.deleteMember(taskId, to, 0, false);
197
+ deletedBefore.value = await this.deleteMember(taskId, to, 0, false);
186
198
  }
187
199
  this.formStore[to][0] = fromMember;
188
200
  toIndex.value = 0;
@@ -216,9 +228,9 @@ export const useMemberStore = defineStore('members', {
216
228
  }
217
229
  const hasSaved = await this.dataStore.saveMember(this.formStore[to][toIndex.value], this.getMemberCode(to), this.getMemberFromApplication(to, toIndex.value));
218
230
  if (hasSaved) {
219
- await this.dataStore.getApplicationData(taskId, false, true, true, false);
231
+ await this.dataStore.getApplicationData(taskId, false, true, true, deletedBefore.value);
232
+ this.dataStore.showToaster('warning', this.dataStore.t('toaster.formFieldEmptyWarning'));
220
233
  this.dataStore.showToaster('success', this.dataStore.t('toaster.successSaved'));
221
- this.dataStore.showToaster('warning', this.dataStore.t('toaster.formFieldEmptyWarning'), 3000);
222
234
  return true;
223
235
  } else {
224
236
  this.dataStore.showToaster('error', this.dataStore.t('error.memberSave'));
@@ -256,8 +268,16 @@ export const useMemberStore = defineStore('members', {
256
268
  addMember(whichForm: MemberKeys) {
257
269
  if (!whichForm) return false;
258
270
  if (!this.isStatementEditible(whichForm)) return false;
259
- if (!this.validateInitiator()) return false;
260
- this.formStore[whichForm].push(this.getMemberClass(whichForm));
271
+ const limit = this.dataStore.members[this.getMemberApplicationCode(whichForm)!].limit;
272
+ if (typeof limit === 'number') {
273
+ if (this.formStore[whichForm].length < limit) {
274
+ this.formStore[whichForm].push(this.getMemberClass(whichForm));
275
+ } else {
276
+ this.dataStore.showToaster('error', this.dataStore.t('toaster.membersLimit', { text: limit }));
277
+ }
278
+ } else {
279
+ this.formStore[whichForm].push(this.getMemberClass(whichForm));
280
+ }
261
281
  },
262
282
  async getOtpStatus(iin: string, phone: string, processInstanceId: string | number | null = null) {
263
283
  try {
package/types/index.ts CHANGED
@@ -334,4 +334,9 @@ declare global {
334
334
  verifyType: string;
335
335
  verifyDate: string;
336
336
  };
337
+
338
+ type ChipComponent = {
339
+ title: string;
340
+ description?: string;
341
+ };
337
342
  }