@smvtech/x-flux 1.1.7 → 1.1.8
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/dist/index.d.mts +23 -15
- package/dist/index.d.ts +23 -15
- package/dist/index.js +65 -6
- package/dist/index.mjs +65 -6
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -75,6 +75,11 @@ declare enum VALIDATION_STATUS {
|
|
|
75
75
|
UNFIXABLE = "UNFIXABLE",
|
|
76
76
|
MISSING = "MISSING"
|
|
77
77
|
}
|
|
78
|
+
declare enum FIX_TYPE {
|
|
79
|
+
AUTO = "auto",
|
|
80
|
+
MANUAL = "manual",
|
|
81
|
+
NONE = "none"
|
|
82
|
+
}
|
|
78
83
|
declare const QuestionnaireSchema: z.ZodObject<{
|
|
79
84
|
questionsWithRank: z.ZodArray<z.ZodObject<{
|
|
80
85
|
id: z.ZodString;
|
|
@@ -240,19 +245,19 @@ declare const ApplicationSchema: z.ZodObject<{
|
|
|
240
245
|
validation_name: z.ZodString;
|
|
241
246
|
error_text: z.ZodString;
|
|
242
247
|
result: z.ZodBoolean;
|
|
243
|
-
fix_type: z.
|
|
248
|
+
fix_type: z.ZodNativeEnum<typeof FIX_TYPE>;
|
|
244
249
|
time_saved: z.ZodNumber;
|
|
245
250
|
}, "strip", z.ZodTypeAny, {
|
|
246
251
|
validation_name: string;
|
|
247
252
|
error_text: string;
|
|
248
253
|
result: boolean;
|
|
249
|
-
fix_type:
|
|
254
|
+
fix_type: FIX_TYPE;
|
|
250
255
|
time_saved: number;
|
|
251
256
|
}, {
|
|
252
257
|
validation_name: string;
|
|
253
258
|
error_text: string;
|
|
254
259
|
result: boolean;
|
|
255
|
-
fix_type:
|
|
260
|
+
fix_type: FIX_TYPE;
|
|
256
261
|
time_saved: number;
|
|
257
262
|
}>, "many">>;
|
|
258
263
|
created_at: z.ZodString;
|
|
@@ -281,7 +286,7 @@ declare const ApplicationSchema: z.ZodObject<{
|
|
|
281
286
|
validation_name: string;
|
|
282
287
|
error_text: string;
|
|
283
288
|
result: boolean;
|
|
284
|
-
fix_type:
|
|
289
|
+
fix_type: FIX_TYPE;
|
|
285
290
|
time_saved: number;
|
|
286
291
|
}[] | undefined;
|
|
287
292
|
}, {
|
|
@@ -308,7 +313,7 @@ declare const ApplicationSchema: z.ZodObject<{
|
|
|
308
313
|
validation_name: string;
|
|
309
314
|
error_text: string;
|
|
310
315
|
result: boolean;
|
|
311
|
-
fix_type:
|
|
316
|
+
fix_type: FIX_TYPE;
|
|
312
317
|
time_saved: number;
|
|
313
318
|
}[] | undefined;
|
|
314
319
|
}>;
|
|
@@ -382,19 +387,19 @@ declare const AnswerSchema: z.ZodObject<{
|
|
|
382
387
|
validation_name: z.ZodString;
|
|
383
388
|
error_text: z.ZodString;
|
|
384
389
|
result: z.ZodBoolean;
|
|
385
|
-
fix_type: z.
|
|
390
|
+
fix_type: z.ZodNativeEnum<typeof FIX_TYPE>;
|
|
386
391
|
time_saved: z.ZodNumber;
|
|
387
392
|
}, "strip", z.ZodTypeAny, {
|
|
388
393
|
validation_name: string;
|
|
389
394
|
error_text: string;
|
|
390
395
|
result: boolean;
|
|
391
|
-
fix_type:
|
|
396
|
+
fix_type: FIX_TYPE;
|
|
392
397
|
time_saved: number;
|
|
393
398
|
}, {
|
|
394
399
|
validation_name: string;
|
|
395
400
|
error_text: string;
|
|
396
401
|
result: boolean;
|
|
397
|
-
fix_type:
|
|
402
|
+
fix_type: FIX_TYPE;
|
|
398
403
|
time_saved: number;
|
|
399
404
|
}>, "many">>;
|
|
400
405
|
created_by: z.ZodString;
|
|
@@ -422,7 +427,7 @@ declare const AnswerSchema: z.ZodObject<{
|
|
|
422
427
|
validation_name: string;
|
|
423
428
|
error_text: string;
|
|
424
429
|
result: boolean;
|
|
425
|
-
fix_type:
|
|
430
|
+
fix_type: FIX_TYPE;
|
|
426
431
|
time_saved: number;
|
|
427
432
|
}[] | undefined;
|
|
428
433
|
}, {
|
|
@@ -447,7 +452,7 @@ declare const AnswerSchema: z.ZodObject<{
|
|
|
447
452
|
validation_name: string;
|
|
448
453
|
error_text: string;
|
|
449
454
|
result: boolean;
|
|
450
|
-
fix_type:
|
|
455
|
+
fix_type: FIX_TYPE;
|
|
451
456
|
time_saved: number;
|
|
452
457
|
}[] | undefined;
|
|
453
458
|
}>;
|
|
@@ -4031,19 +4036,19 @@ declare const VisaOrderSchema: z__default.ZodObject<{
|
|
|
4031
4036
|
validation_name: z__default.ZodString;
|
|
4032
4037
|
error_text: z__default.ZodString;
|
|
4033
4038
|
result: z__default.ZodBoolean;
|
|
4034
|
-
fix_type: z__default.
|
|
4039
|
+
fix_type: z__default.ZodNativeEnum<typeof FIX_TYPE>;
|
|
4035
4040
|
time_saved: z__default.ZodNumber;
|
|
4036
4041
|
}, "strip", z__default.ZodTypeAny, {
|
|
4037
4042
|
validation_name: string;
|
|
4038
4043
|
error_text: string;
|
|
4039
4044
|
result: boolean;
|
|
4040
|
-
fix_type:
|
|
4045
|
+
fix_type: FIX_TYPE;
|
|
4041
4046
|
time_saved: number;
|
|
4042
4047
|
}, {
|
|
4043
4048
|
validation_name: string;
|
|
4044
4049
|
error_text: string;
|
|
4045
4050
|
result: boolean;
|
|
4046
|
-
fix_type:
|
|
4051
|
+
fix_type: FIX_TYPE;
|
|
4047
4052
|
time_saved: number;
|
|
4048
4053
|
}>, "many">>;
|
|
4049
4054
|
}, "strip", z__default.ZodTypeAny, {
|
|
@@ -4609,7 +4614,7 @@ declare const VisaOrderSchema: z__default.ZodObject<{
|
|
|
4609
4614
|
validation_name: string;
|
|
4610
4615
|
error_text: string;
|
|
4611
4616
|
result: boolean;
|
|
4612
|
-
fix_type:
|
|
4617
|
+
fix_type: FIX_TYPE;
|
|
4613
4618
|
time_saved: number;
|
|
4614
4619
|
}[] | undefined;
|
|
4615
4620
|
qc_terms_and_conditions?: string | null | undefined;
|
|
@@ -5214,7 +5219,7 @@ declare const VisaOrderSchema: z__default.ZodObject<{
|
|
|
5214
5219
|
validation_name: string;
|
|
5215
5220
|
error_text: string;
|
|
5216
5221
|
result: boolean;
|
|
5217
|
-
fix_type:
|
|
5222
|
+
fix_type: FIX_TYPE;
|
|
5218
5223
|
time_saved: number;
|
|
5219
5224
|
}[] | undefined;
|
|
5220
5225
|
qc_terms_and_conditions?: string | null | undefined;
|
|
@@ -5329,6 +5334,7 @@ type ValidationItem = {
|
|
|
5329
5334
|
error_text: string;
|
|
5330
5335
|
time_saved: number;
|
|
5331
5336
|
validation_name: string;
|
|
5337
|
+
fix_type: FIX_TYPE;
|
|
5332
5338
|
};
|
|
5333
5339
|
type ValidationResultGroup = {
|
|
5334
5340
|
timeSaved: number;
|
|
@@ -5361,6 +5367,7 @@ type TEDCFlowContext = {
|
|
|
5361
5367
|
acceptOrderQCTermsAndConditions: () => Promise<void>;
|
|
5362
5368
|
runAllValidations: () => Promise<void>;
|
|
5363
5369
|
runApplicantValidations: (applicationId: string) => Promise<void>;
|
|
5370
|
+
applyAutoFix: (applicationId: string, answerId: string) => Promise<void>;
|
|
5364
5371
|
};
|
|
5365
5372
|
type TEDCFlowProviderProps = {
|
|
5366
5373
|
children: ReactNode;
|
|
@@ -5461,6 +5468,7 @@ declare const EDCFlow: {
|
|
|
5461
5468
|
acceptOrderQCTermsAndConditions: () => Promise<void>;
|
|
5462
5469
|
runAllValidations: () => Promise<void>;
|
|
5463
5470
|
runApplicantValidations: (applicationId: string) => Promise<void>;
|
|
5471
|
+
applyAutoFix: (applicationId: string, answerId: string) => Promise<void>;
|
|
5464
5472
|
};
|
|
5465
5473
|
};
|
|
5466
5474
|
|
package/dist/index.d.ts
CHANGED
|
@@ -75,6 +75,11 @@ declare enum VALIDATION_STATUS {
|
|
|
75
75
|
UNFIXABLE = "UNFIXABLE",
|
|
76
76
|
MISSING = "MISSING"
|
|
77
77
|
}
|
|
78
|
+
declare enum FIX_TYPE {
|
|
79
|
+
AUTO = "auto",
|
|
80
|
+
MANUAL = "manual",
|
|
81
|
+
NONE = "none"
|
|
82
|
+
}
|
|
78
83
|
declare const QuestionnaireSchema: z.ZodObject<{
|
|
79
84
|
questionsWithRank: z.ZodArray<z.ZodObject<{
|
|
80
85
|
id: z.ZodString;
|
|
@@ -240,19 +245,19 @@ declare const ApplicationSchema: z.ZodObject<{
|
|
|
240
245
|
validation_name: z.ZodString;
|
|
241
246
|
error_text: z.ZodString;
|
|
242
247
|
result: z.ZodBoolean;
|
|
243
|
-
fix_type: z.
|
|
248
|
+
fix_type: z.ZodNativeEnum<typeof FIX_TYPE>;
|
|
244
249
|
time_saved: z.ZodNumber;
|
|
245
250
|
}, "strip", z.ZodTypeAny, {
|
|
246
251
|
validation_name: string;
|
|
247
252
|
error_text: string;
|
|
248
253
|
result: boolean;
|
|
249
|
-
fix_type:
|
|
254
|
+
fix_type: FIX_TYPE;
|
|
250
255
|
time_saved: number;
|
|
251
256
|
}, {
|
|
252
257
|
validation_name: string;
|
|
253
258
|
error_text: string;
|
|
254
259
|
result: boolean;
|
|
255
|
-
fix_type:
|
|
260
|
+
fix_type: FIX_TYPE;
|
|
256
261
|
time_saved: number;
|
|
257
262
|
}>, "many">>;
|
|
258
263
|
created_at: z.ZodString;
|
|
@@ -281,7 +286,7 @@ declare const ApplicationSchema: z.ZodObject<{
|
|
|
281
286
|
validation_name: string;
|
|
282
287
|
error_text: string;
|
|
283
288
|
result: boolean;
|
|
284
|
-
fix_type:
|
|
289
|
+
fix_type: FIX_TYPE;
|
|
285
290
|
time_saved: number;
|
|
286
291
|
}[] | undefined;
|
|
287
292
|
}, {
|
|
@@ -308,7 +313,7 @@ declare const ApplicationSchema: z.ZodObject<{
|
|
|
308
313
|
validation_name: string;
|
|
309
314
|
error_text: string;
|
|
310
315
|
result: boolean;
|
|
311
|
-
fix_type:
|
|
316
|
+
fix_type: FIX_TYPE;
|
|
312
317
|
time_saved: number;
|
|
313
318
|
}[] | undefined;
|
|
314
319
|
}>;
|
|
@@ -382,19 +387,19 @@ declare const AnswerSchema: z.ZodObject<{
|
|
|
382
387
|
validation_name: z.ZodString;
|
|
383
388
|
error_text: z.ZodString;
|
|
384
389
|
result: z.ZodBoolean;
|
|
385
|
-
fix_type: z.
|
|
390
|
+
fix_type: z.ZodNativeEnum<typeof FIX_TYPE>;
|
|
386
391
|
time_saved: z.ZodNumber;
|
|
387
392
|
}, "strip", z.ZodTypeAny, {
|
|
388
393
|
validation_name: string;
|
|
389
394
|
error_text: string;
|
|
390
395
|
result: boolean;
|
|
391
|
-
fix_type:
|
|
396
|
+
fix_type: FIX_TYPE;
|
|
392
397
|
time_saved: number;
|
|
393
398
|
}, {
|
|
394
399
|
validation_name: string;
|
|
395
400
|
error_text: string;
|
|
396
401
|
result: boolean;
|
|
397
|
-
fix_type:
|
|
402
|
+
fix_type: FIX_TYPE;
|
|
398
403
|
time_saved: number;
|
|
399
404
|
}>, "many">>;
|
|
400
405
|
created_by: z.ZodString;
|
|
@@ -422,7 +427,7 @@ declare const AnswerSchema: z.ZodObject<{
|
|
|
422
427
|
validation_name: string;
|
|
423
428
|
error_text: string;
|
|
424
429
|
result: boolean;
|
|
425
|
-
fix_type:
|
|
430
|
+
fix_type: FIX_TYPE;
|
|
426
431
|
time_saved: number;
|
|
427
432
|
}[] | undefined;
|
|
428
433
|
}, {
|
|
@@ -447,7 +452,7 @@ declare const AnswerSchema: z.ZodObject<{
|
|
|
447
452
|
validation_name: string;
|
|
448
453
|
error_text: string;
|
|
449
454
|
result: boolean;
|
|
450
|
-
fix_type:
|
|
455
|
+
fix_type: FIX_TYPE;
|
|
451
456
|
time_saved: number;
|
|
452
457
|
}[] | undefined;
|
|
453
458
|
}>;
|
|
@@ -4031,19 +4036,19 @@ declare const VisaOrderSchema: z__default.ZodObject<{
|
|
|
4031
4036
|
validation_name: z__default.ZodString;
|
|
4032
4037
|
error_text: z__default.ZodString;
|
|
4033
4038
|
result: z__default.ZodBoolean;
|
|
4034
|
-
fix_type: z__default.
|
|
4039
|
+
fix_type: z__default.ZodNativeEnum<typeof FIX_TYPE>;
|
|
4035
4040
|
time_saved: z__default.ZodNumber;
|
|
4036
4041
|
}, "strip", z__default.ZodTypeAny, {
|
|
4037
4042
|
validation_name: string;
|
|
4038
4043
|
error_text: string;
|
|
4039
4044
|
result: boolean;
|
|
4040
|
-
fix_type:
|
|
4045
|
+
fix_type: FIX_TYPE;
|
|
4041
4046
|
time_saved: number;
|
|
4042
4047
|
}, {
|
|
4043
4048
|
validation_name: string;
|
|
4044
4049
|
error_text: string;
|
|
4045
4050
|
result: boolean;
|
|
4046
|
-
fix_type:
|
|
4051
|
+
fix_type: FIX_TYPE;
|
|
4047
4052
|
time_saved: number;
|
|
4048
4053
|
}>, "many">>;
|
|
4049
4054
|
}, "strip", z__default.ZodTypeAny, {
|
|
@@ -4609,7 +4614,7 @@ declare const VisaOrderSchema: z__default.ZodObject<{
|
|
|
4609
4614
|
validation_name: string;
|
|
4610
4615
|
error_text: string;
|
|
4611
4616
|
result: boolean;
|
|
4612
|
-
fix_type:
|
|
4617
|
+
fix_type: FIX_TYPE;
|
|
4613
4618
|
time_saved: number;
|
|
4614
4619
|
}[] | undefined;
|
|
4615
4620
|
qc_terms_and_conditions?: string | null | undefined;
|
|
@@ -5214,7 +5219,7 @@ declare const VisaOrderSchema: z__default.ZodObject<{
|
|
|
5214
5219
|
validation_name: string;
|
|
5215
5220
|
error_text: string;
|
|
5216
5221
|
result: boolean;
|
|
5217
|
-
fix_type:
|
|
5222
|
+
fix_type: FIX_TYPE;
|
|
5218
5223
|
time_saved: number;
|
|
5219
5224
|
}[] | undefined;
|
|
5220
5225
|
qc_terms_and_conditions?: string | null | undefined;
|
|
@@ -5329,6 +5334,7 @@ type ValidationItem = {
|
|
|
5329
5334
|
error_text: string;
|
|
5330
5335
|
time_saved: number;
|
|
5331
5336
|
validation_name: string;
|
|
5337
|
+
fix_type: FIX_TYPE;
|
|
5332
5338
|
};
|
|
5333
5339
|
type ValidationResultGroup = {
|
|
5334
5340
|
timeSaved: number;
|
|
@@ -5361,6 +5367,7 @@ type TEDCFlowContext = {
|
|
|
5361
5367
|
acceptOrderQCTermsAndConditions: () => Promise<void>;
|
|
5362
5368
|
runAllValidations: () => Promise<void>;
|
|
5363
5369
|
runApplicantValidations: (applicationId: string) => Promise<void>;
|
|
5370
|
+
applyAutoFix: (applicationId: string, answerId: string) => Promise<void>;
|
|
5364
5371
|
};
|
|
5365
5372
|
type TEDCFlowProviderProps = {
|
|
5366
5373
|
children: ReactNode;
|
|
@@ -5461,6 +5468,7 @@ declare const EDCFlow: {
|
|
|
5461
5468
|
acceptOrderQCTermsAndConditions: () => Promise<void>;
|
|
5462
5469
|
runAllValidations: () => Promise<void>;
|
|
5463
5470
|
runApplicantValidations: (applicationId: string) => Promise<void>;
|
|
5471
|
+
applyAutoFix: (applicationId: string, answerId: string) => Promise<void>;
|
|
5464
5472
|
};
|
|
5465
5473
|
};
|
|
5466
5474
|
|
package/dist/index.js
CHANGED
|
@@ -130,6 +130,12 @@ var VALIDATION_STATUS = /* @__PURE__ */ ((VALIDATION_STATUS2) => {
|
|
|
130
130
|
VALIDATION_STATUS2["MISSING"] = "MISSING";
|
|
131
131
|
return VALIDATION_STATUS2;
|
|
132
132
|
})(VALIDATION_STATUS || {});
|
|
133
|
+
var FIX_TYPE = /* @__PURE__ */ ((FIX_TYPE2) => {
|
|
134
|
+
FIX_TYPE2["AUTO"] = "auto";
|
|
135
|
+
FIX_TYPE2["MANUAL"] = "manual";
|
|
136
|
+
FIX_TYPE2["NONE"] = "none";
|
|
137
|
+
return FIX_TYPE2;
|
|
138
|
+
})(FIX_TYPE || {});
|
|
133
139
|
var QuestionnaireSchema = z2__namespace.object({
|
|
134
140
|
questionsWithRank: z2__namespace.array(z2__namespace.object({ id: z2__namespace.string(), rank: z2__namespace.number() })),
|
|
135
141
|
questionMap: z2__namespace.record(
|
|
@@ -177,7 +183,7 @@ var ApplicationSchema = z2__namespace.object({
|
|
|
177
183
|
validation_name: z2__namespace.string(),
|
|
178
184
|
error_text: z2__namespace.string(),
|
|
179
185
|
result: z2__namespace.boolean(),
|
|
180
|
-
fix_type: z2__namespace.
|
|
186
|
+
fix_type: z2__namespace.nativeEnum(FIX_TYPE),
|
|
181
187
|
time_saved: z2__namespace.number()
|
|
182
188
|
})).optional(),
|
|
183
189
|
created_at: z2__namespace.string(),
|
|
@@ -219,7 +225,7 @@ var AnswerSchema = z2__namespace.object({
|
|
|
219
225
|
validation_name: z2__namespace.string(),
|
|
220
226
|
error_text: z2__namespace.string(),
|
|
221
227
|
result: z2__namespace.boolean(),
|
|
222
|
-
fix_type: z2__namespace.
|
|
228
|
+
fix_type: z2__namespace.nativeEnum(FIX_TYPE),
|
|
223
229
|
time_saved: z2__namespace.number()
|
|
224
230
|
})).optional(),
|
|
225
231
|
created_by: z2__namespace.string(),
|
|
@@ -582,7 +588,8 @@ function getValidationErrors(validations) {
|
|
|
582
588
|
const item = {
|
|
583
589
|
error_text: v.error_text || "",
|
|
584
590
|
time_saved: v.time_saved || 0,
|
|
585
|
-
validation_name: v.validation_name || ""
|
|
591
|
+
validation_name: v.validation_name || "",
|
|
592
|
+
fix_type: v.fix_type || ""
|
|
586
593
|
};
|
|
587
594
|
if (v.result === false) {
|
|
588
595
|
if (v.fix_type === "none") {
|
|
@@ -628,7 +635,8 @@ function getValidationResult(question) {
|
|
|
628
635
|
const answerRequiredItem = {
|
|
629
636
|
error_text: isDocument ? "Please upload the required document" : "Answer cannot be empty",
|
|
630
637
|
time_saved: 0,
|
|
631
|
-
validation_name: "answer_required"
|
|
638
|
+
validation_name: "answer_required",
|
|
639
|
+
fix_type: "none" /* NONE */
|
|
632
640
|
};
|
|
633
641
|
return {
|
|
634
642
|
status: "MISSING" /* MISSING */,
|
|
@@ -850,6 +858,22 @@ var updateOrderQCTermsAndConditions = async (orderId) => {
|
|
|
850
858
|
const response = await client.patch(`/visa_orders/update-order-qc-terms-conditions/${orderId}`);
|
|
851
859
|
return { data: response.data.data };
|
|
852
860
|
};
|
|
861
|
+
var mapFixableDocument = async (answerId) => {
|
|
862
|
+
const client = getClient();
|
|
863
|
+
const response = await client.post(`/edc/map-fixable-doc/${answerId}`);
|
|
864
|
+
const rawData = response.data.data;
|
|
865
|
+
const transformedAnswer = formatAnswerFromResponse(
|
|
866
|
+
rawData.answer,
|
|
867
|
+
rawData.answer?.visa_order_id
|
|
868
|
+
);
|
|
869
|
+
return {
|
|
870
|
+
data: {
|
|
871
|
+
answer: transformedAnswer,
|
|
872
|
+
docId: rawData.docId,
|
|
873
|
+
signedUrl: rawData.signedUrl ?? null
|
|
874
|
+
}
|
|
875
|
+
};
|
|
876
|
+
};
|
|
853
877
|
var EDCFlowContext = react.createContext(void 0);
|
|
854
878
|
var EDCFlowProvider = ({ children, orderId }) => {
|
|
855
879
|
const [order, setOrder] = react.useState(null);
|
|
@@ -1017,6 +1041,40 @@ var EDCFlowProvider = ({ children, orderId }) => {
|
|
|
1017
1041
|
},
|
|
1018
1042
|
[questionnaire, refreshApplicant, order, dynamicQuestionMap]
|
|
1019
1043
|
);
|
|
1044
|
+
const applyAutoFix = react.useCallback(
|
|
1045
|
+
async (applicationId, answerId) => {
|
|
1046
|
+
if (!questionnaire || !order) return;
|
|
1047
|
+
try {
|
|
1048
|
+
const { data } = await mapFixableDocument(answerId);
|
|
1049
|
+
if (data.docId && data.signedUrl) {
|
|
1050
|
+
setDocIdToS3Url((prev) => ({
|
|
1051
|
+
...prev,
|
|
1052
|
+
[data.docId]: data.signedUrl
|
|
1053
|
+
}));
|
|
1054
|
+
}
|
|
1055
|
+
setApplicants((prev) => {
|
|
1056
|
+
const currentApplicant = prev[applicationId];
|
|
1057
|
+
if (!currentApplicant) return prev;
|
|
1058
|
+
const applicantWithUpdatedAnswer = updateApplicantWithAnswer(
|
|
1059
|
+
currentApplicant,
|
|
1060
|
+
data.answer.visa_questions_id,
|
|
1061
|
+
data.answer,
|
|
1062
|
+
questionnaire
|
|
1063
|
+
);
|
|
1064
|
+
return {
|
|
1065
|
+
...prev,
|
|
1066
|
+
[applicationId]: applicantWithUpdatedAnswer
|
|
1067
|
+
};
|
|
1068
|
+
});
|
|
1069
|
+
setSuccess("Document auto-fixed successfully");
|
|
1070
|
+
} catch (err) {
|
|
1071
|
+
console.error("Failed to apply auto fix:", err);
|
|
1072
|
+
setError("Failed to apply auto fix");
|
|
1073
|
+
throw err;
|
|
1074
|
+
}
|
|
1075
|
+
},
|
|
1076
|
+
[questionnaire, order]
|
|
1077
|
+
);
|
|
1020
1078
|
const deleteApplicantById = react.useCallback(async (application_id) => {
|
|
1021
1079
|
if (!questionnaire || !order) return;
|
|
1022
1080
|
try {
|
|
@@ -1196,7 +1254,8 @@ var EDCFlowProvider = ({ children, orderId }) => {
|
|
|
1196
1254
|
getS3UrlForAsset,
|
|
1197
1255
|
acceptOrderQCTermsAndConditions,
|
|
1198
1256
|
runAllValidations: runAllValidationsHandler,
|
|
1199
|
-
runApplicantValidations: runApplicantValidationsHandler
|
|
1257
|
+
runApplicantValidations: runApplicantValidationsHandler,
|
|
1258
|
+
applyAutoFix
|
|
1200
1259
|
};
|
|
1201
1260
|
return /* @__PURE__ */ jsxRuntime.jsx(EDCFlowContext.Provider, { value, children });
|
|
1202
1261
|
};
|
|
@@ -1683,7 +1742,7 @@ z2__namespace.default.object({
|
|
|
1683
1742
|
validation_name: z2__namespace.default.string(),
|
|
1684
1743
|
error_text: z2__namespace.default.string(),
|
|
1685
1744
|
result: z2__namespace.default.boolean(),
|
|
1686
|
-
fix_type: z2__namespace.default.
|
|
1745
|
+
fix_type: z2__namespace.default.nativeEnum(FIX_TYPE),
|
|
1687
1746
|
time_saved: z2__namespace.default.number()
|
|
1688
1747
|
})).optional()
|
|
1689
1748
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -104,6 +104,12 @@ var VALIDATION_STATUS = /* @__PURE__ */ ((VALIDATION_STATUS2) => {
|
|
|
104
104
|
VALIDATION_STATUS2["MISSING"] = "MISSING";
|
|
105
105
|
return VALIDATION_STATUS2;
|
|
106
106
|
})(VALIDATION_STATUS || {});
|
|
107
|
+
var FIX_TYPE = /* @__PURE__ */ ((FIX_TYPE2) => {
|
|
108
|
+
FIX_TYPE2["AUTO"] = "auto";
|
|
109
|
+
FIX_TYPE2["MANUAL"] = "manual";
|
|
110
|
+
FIX_TYPE2["NONE"] = "none";
|
|
111
|
+
return FIX_TYPE2;
|
|
112
|
+
})(FIX_TYPE || {});
|
|
107
113
|
var QuestionnaireSchema = z2.object({
|
|
108
114
|
questionsWithRank: z2.array(z2.object({ id: z2.string(), rank: z2.number() })),
|
|
109
115
|
questionMap: z2.record(
|
|
@@ -151,7 +157,7 @@ var ApplicationSchema = z2.object({
|
|
|
151
157
|
validation_name: z2.string(),
|
|
152
158
|
error_text: z2.string(),
|
|
153
159
|
result: z2.boolean(),
|
|
154
|
-
fix_type: z2.
|
|
160
|
+
fix_type: z2.nativeEnum(FIX_TYPE),
|
|
155
161
|
time_saved: z2.number()
|
|
156
162
|
})).optional(),
|
|
157
163
|
created_at: z2.string(),
|
|
@@ -193,7 +199,7 @@ var AnswerSchema = z2.object({
|
|
|
193
199
|
validation_name: z2.string(),
|
|
194
200
|
error_text: z2.string(),
|
|
195
201
|
result: z2.boolean(),
|
|
196
|
-
fix_type: z2.
|
|
202
|
+
fix_type: z2.nativeEnum(FIX_TYPE),
|
|
197
203
|
time_saved: z2.number()
|
|
198
204
|
})).optional(),
|
|
199
205
|
created_by: z2.string(),
|
|
@@ -556,7 +562,8 @@ function getValidationErrors(validations) {
|
|
|
556
562
|
const item = {
|
|
557
563
|
error_text: v.error_text || "",
|
|
558
564
|
time_saved: v.time_saved || 0,
|
|
559
|
-
validation_name: v.validation_name || ""
|
|
565
|
+
validation_name: v.validation_name || "",
|
|
566
|
+
fix_type: v.fix_type || ""
|
|
560
567
|
};
|
|
561
568
|
if (v.result === false) {
|
|
562
569
|
if (v.fix_type === "none") {
|
|
@@ -602,7 +609,8 @@ function getValidationResult(question) {
|
|
|
602
609
|
const answerRequiredItem = {
|
|
603
610
|
error_text: isDocument ? "Please upload the required document" : "Answer cannot be empty",
|
|
604
611
|
time_saved: 0,
|
|
605
|
-
validation_name: "answer_required"
|
|
612
|
+
validation_name: "answer_required",
|
|
613
|
+
fix_type: "none" /* NONE */
|
|
606
614
|
};
|
|
607
615
|
return {
|
|
608
616
|
status: "MISSING" /* MISSING */,
|
|
@@ -824,6 +832,22 @@ var updateOrderQCTermsAndConditions = async (orderId) => {
|
|
|
824
832
|
const response = await client.patch(`/visa_orders/update-order-qc-terms-conditions/${orderId}`);
|
|
825
833
|
return { data: response.data.data };
|
|
826
834
|
};
|
|
835
|
+
var mapFixableDocument = async (answerId) => {
|
|
836
|
+
const client = getClient();
|
|
837
|
+
const response = await client.post(`/edc/map-fixable-doc/${answerId}`);
|
|
838
|
+
const rawData = response.data.data;
|
|
839
|
+
const transformedAnswer = formatAnswerFromResponse(
|
|
840
|
+
rawData.answer,
|
|
841
|
+
rawData.answer?.visa_order_id
|
|
842
|
+
);
|
|
843
|
+
return {
|
|
844
|
+
data: {
|
|
845
|
+
answer: transformedAnswer,
|
|
846
|
+
docId: rawData.docId,
|
|
847
|
+
signedUrl: rawData.signedUrl ?? null
|
|
848
|
+
}
|
|
849
|
+
};
|
|
850
|
+
};
|
|
827
851
|
var EDCFlowContext = createContext(void 0);
|
|
828
852
|
var EDCFlowProvider = ({ children, orderId }) => {
|
|
829
853
|
const [order, setOrder] = useState(null);
|
|
@@ -991,6 +1015,40 @@ var EDCFlowProvider = ({ children, orderId }) => {
|
|
|
991
1015
|
},
|
|
992
1016
|
[questionnaire, refreshApplicant, order, dynamicQuestionMap]
|
|
993
1017
|
);
|
|
1018
|
+
const applyAutoFix = useCallback(
|
|
1019
|
+
async (applicationId, answerId) => {
|
|
1020
|
+
if (!questionnaire || !order) return;
|
|
1021
|
+
try {
|
|
1022
|
+
const { data } = await mapFixableDocument(answerId);
|
|
1023
|
+
if (data.docId && data.signedUrl) {
|
|
1024
|
+
setDocIdToS3Url((prev) => ({
|
|
1025
|
+
...prev,
|
|
1026
|
+
[data.docId]: data.signedUrl
|
|
1027
|
+
}));
|
|
1028
|
+
}
|
|
1029
|
+
setApplicants((prev) => {
|
|
1030
|
+
const currentApplicant = prev[applicationId];
|
|
1031
|
+
if (!currentApplicant) return prev;
|
|
1032
|
+
const applicantWithUpdatedAnswer = updateApplicantWithAnswer(
|
|
1033
|
+
currentApplicant,
|
|
1034
|
+
data.answer.visa_questions_id,
|
|
1035
|
+
data.answer,
|
|
1036
|
+
questionnaire
|
|
1037
|
+
);
|
|
1038
|
+
return {
|
|
1039
|
+
...prev,
|
|
1040
|
+
[applicationId]: applicantWithUpdatedAnswer
|
|
1041
|
+
};
|
|
1042
|
+
});
|
|
1043
|
+
setSuccess("Document auto-fixed successfully");
|
|
1044
|
+
} catch (err) {
|
|
1045
|
+
console.error("Failed to apply auto fix:", err);
|
|
1046
|
+
setError("Failed to apply auto fix");
|
|
1047
|
+
throw err;
|
|
1048
|
+
}
|
|
1049
|
+
},
|
|
1050
|
+
[questionnaire, order]
|
|
1051
|
+
);
|
|
994
1052
|
const deleteApplicantById = useCallback(async (application_id) => {
|
|
995
1053
|
if (!questionnaire || !order) return;
|
|
996
1054
|
try {
|
|
@@ -1170,7 +1228,8 @@ var EDCFlowProvider = ({ children, orderId }) => {
|
|
|
1170
1228
|
getS3UrlForAsset,
|
|
1171
1229
|
acceptOrderQCTermsAndConditions,
|
|
1172
1230
|
runAllValidations: runAllValidationsHandler,
|
|
1173
|
-
runApplicantValidations: runApplicantValidationsHandler
|
|
1231
|
+
runApplicantValidations: runApplicantValidationsHandler,
|
|
1232
|
+
applyAutoFix
|
|
1174
1233
|
};
|
|
1175
1234
|
return /* @__PURE__ */ jsx(EDCFlowContext.Provider, { value, children });
|
|
1176
1235
|
};
|
|
@@ -1657,7 +1716,7 @@ z2__default.object({
|
|
|
1657
1716
|
validation_name: z2__default.string(),
|
|
1658
1717
|
error_text: z2__default.string(),
|
|
1659
1718
|
result: z2__default.boolean(),
|
|
1660
|
-
fix_type: z2__default.
|
|
1719
|
+
fix_type: z2__default.nativeEnum(FIX_TYPE),
|
|
1661
1720
|
time_saved: z2__default.number()
|
|
1662
1721
|
})).optional()
|
|
1663
1722
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smvtech/x-flux",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.8",
|
|
4
4
|
"description": "x-flux - A powerful React package for managing effective document collection flows, visa questionnaires, travellers, and applications",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|