@smvtech/x-flux 1.1.15 → 1.1.17
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 +55 -41
- package/dist/index.d.ts +55 -41
- package/dist/index.js +176 -100
- package/dist/index.mjs +173 -101
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -80,6 +80,20 @@ declare enum FIX_TYPE {
|
|
|
80
80
|
MANUAL = "manual",
|
|
81
81
|
NONE = "none"
|
|
82
82
|
}
|
|
83
|
+
declare enum ANSWER_STATUS {
|
|
84
|
+
ANSWERED = "ANSWERED",
|
|
85
|
+
APPROVED = "APPROVED",
|
|
86
|
+
REJECTED = "REJECTED",
|
|
87
|
+
NA = "NA",
|
|
88
|
+
UNSTARTED = "UNSTARTED",
|
|
89
|
+
PENDING = "PENDING"
|
|
90
|
+
}
|
|
91
|
+
declare enum ASSET_STATUS {
|
|
92
|
+
ANSWERED = "ANSWERED",
|
|
93
|
+
APPROVED = "APPROVED",
|
|
94
|
+
REJECTED = "REJECTED",
|
|
95
|
+
DELETED = "DELETED"
|
|
96
|
+
}
|
|
83
97
|
declare const QuestionnaireSchema: z.ZodObject<{
|
|
84
98
|
questionsWithRank: z.ZodArray<z.ZodObject<{
|
|
85
99
|
id: z.ZodString;
|
|
@@ -368,19 +382,19 @@ declare const AnswerSchema: z.ZodObject<{
|
|
|
368
382
|
assets_id: z.ZodArray<z.ZodObject<{
|
|
369
383
|
doc_id: z.ZodString;
|
|
370
384
|
issue_reason: z.ZodNullable<z.ZodString>;
|
|
371
|
-
status: z.
|
|
385
|
+
status: z.ZodNativeEnum<typeof ASSET_STATUS>;
|
|
372
386
|
}, "strip", z.ZodTypeAny, {
|
|
373
|
-
status:
|
|
387
|
+
status: ASSET_STATUS;
|
|
374
388
|
doc_id: string;
|
|
375
389
|
issue_reason: string | null;
|
|
376
390
|
}, {
|
|
377
|
-
status:
|
|
391
|
+
status: ASSET_STATUS;
|
|
378
392
|
doc_id: string;
|
|
379
393
|
issue_reason: string | null;
|
|
380
394
|
}>, "many">;
|
|
381
395
|
answer: z.ZodArray<z.ZodString, "many">;
|
|
382
396
|
issue_reason: z.ZodNullable<z.ZodString>;
|
|
383
|
-
status: z.
|
|
397
|
+
status: z.ZodNativeEnum<typeof ANSWER_STATUS>;
|
|
384
398
|
is_deleted: z.ZodBoolean;
|
|
385
399
|
visa_order_id: z.ZodString;
|
|
386
400
|
validations: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
@@ -406,7 +420,7 @@ declare const AnswerSchema: z.ZodObject<{
|
|
|
406
420
|
created_at: z.ZodString;
|
|
407
421
|
updated_at: z.ZodString;
|
|
408
422
|
}, "strip", z.ZodTypeAny, {
|
|
409
|
-
status:
|
|
423
|
+
status: ANSWER_STATUS;
|
|
410
424
|
_id: string;
|
|
411
425
|
visa_order_id: string;
|
|
412
426
|
created_at: string;
|
|
@@ -417,7 +431,7 @@ declare const AnswerSchema: z.ZodObject<{
|
|
|
417
431
|
visa_questions_id: string;
|
|
418
432
|
traveller_id: string;
|
|
419
433
|
assets_id: {
|
|
420
|
-
status:
|
|
434
|
+
status: ASSET_STATUS;
|
|
421
435
|
doc_id: string;
|
|
422
436
|
issue_reason: string | null;
|
|
423
437
|
}[];
|
|
@@ -431,7 +445,7 @@ declare const AnswerSchema: z.ZodObject<{
|
|
|
431
445
|
time_saved: number;
|
|
432
446
|
}[] | undefined;
|
|
433
447
|
}, {
|
|
434
|
-
status:
|
|
448
|
+
status: ANSWER_STATUS;
|
|
435
449
|
_id: string;
|
|
436
450
|
visa_order_id: string;
|
|
437
451
|
created_at: string;
|
|
@@ -442,7 +456,7 @@ declare const AnswerSchema: z.ZodObject<{
|
|
|
442
456
|
visa_questions_id: string;
|
|
443
457
|
traveller_id: string;
|
|
444
458
|
assets_id: {
|
|
445
|
-
status:
|
|
459
|
+
status: ASSET_STATUS;
|
|
446
460
|
doc_id: string;
|
|
447
461
|
issue_reason: string | null;
|
|
448
462
|
}[];
|
|
@@ -5435,6 +5449,8 @@ type TUpdateAnswerPayload = {
|
|
|
5435
5449
|
answer: string;
|
|
5436
5450
|
traveller_id: string;
|
|
5437
5451
|
file?: File | Blob | string | null;
|
|
5452
|
+
autoApproveAnswers?: boolean;
|
|
5453
|
+
forceRunValidations?: boolean;
|
|
5438
5454
|
};
|
|
5439
5455
|
type TUploadProgressEvent = {
|
|
5440
5456
|
percent: number;
|
|
@@ -5459,7 +5475,24 @@ type ValidationResult = {
|
|
|
5459
5475
|
perfect: ValidationResultGroup;
|
|
5460
5476
|
totalTimeSaved: number;
|
|
5461
5477
|
} | null;
|
|
5478
|
+
type TQuestionRenderInfo = {
|
|
5479
|
+
status: ANSWER_STATUS;
|
|
5480
|
+
isRejected: boolean;
|
|
5481
|
+
rejectionReasons: string[];
|
|
5482
|
+
rejectedAssets: {
|
|
5483
|
+
doc_id: string;
|
|
5484
|
+
reason: string;
|
|
5485
|
+
}[];
|
|
5486
|
+
validationResult: ValidationResult;
|
|
5487
|
+
};
|
|
5488
|
+
type TQuestionValidationEntry = TQuestionRenderInfo & {
|
|
5489
|
+
name: string;
|
|
5490
|
+
};
|
|
5462
5491
|
|
|
5492
|
+
declare enum EDCFormMode {
|
|
5493
|
+
CREATE = "CREATE",
|
|
5494
|
+
FIX = "FIX"
|
|
5495
|
+
}
|
|
5463
5496
|
type TEDCFlowContext = {
|
|
5464
5497
|
orderId: string | null;
|
|
5465
5498
|
order: TVisaOrder | null;
|
|
@@ -5470,6 +5503,7 @@ type TEDCFlowContext = {
|
|
|
5470
5503
|
loading: boolean;
|
|
5471
5504
|
error: string | null;
|
|
5472
5505
|
success: string | null;
|
|
5506
|
+
mode: EDCFormMode;
|
|
5473
5507
|
refreshOrder: () => Promise<void>;
|
|
5474
5508
|
refreshApplicant: (application_id: string) => Promise<void>;
|
|
5475
5509
|
addApplicant: (payload: TAddTravellerPayload) => Promise<TEDCApplicant | null>;
|
|
@@ -5484,6 +5518,7 @@ type TEDCFlowContext = {
|
|
|
5484
5518
|
type TEDCFlowProviderProps = {
|
|
5485
5519
|
children: ReactNode;
|
|
5486
5520
|
orderId: string;
|
|
5521
|
+
mode?: EDCFormMode;
|
|
5487
5522
|
};
|
|
5488
5523
|
declare const EDCFlowProvider: react__default.FC<TEDCFlowProviderProps>;
|
|
5489
5524
|
declare const useEDCFlow: () => TEDCFlowContext;
|
|
@@ -5500,24 +5535,12 @@ declare function getDisplayableQuestions(questions: TEDCApplicant["questions"],
|
|
|
5500
5535
|
declare function getDisplayableDocuments(questions: TEDCApplicant["questions"], documentAnswerSources: ANSWER_SOURCE[]): TEDCApplicant["questions"];
|
|
5501
5536
|
declare function getValidationErrors(validations?: TAnswer["validations"] | null): ValidationResult;
|
|
5502
5537
|
declare function getValidationResult(question: TEDCApplicant["questions"][0]): ValidationResult;
|
|
5503
|
-
declare function validateApplicantQuestions(applicant: TEDCApplicant, questionAnswerSources: ANSWER_SOURCE[]):
|
|
5504
|
-
|
|
5505
|
-
validationResult: ValidationResult;
|
|
5506
|
-
}>;
|
|
5507
|
-
declare function validateApplicantDocuments(applicant: TEDCApplicant, documentAnswerSources: ANSWER_SOURCE[]): Array<{
|
|
5508
|
-
name: string;
|
|
5509
|
-
validationResult: ValidationResult;
|
|
5510
|
-
}>;
|
|
5538
|
+
declare function validateApplicantQuestions(applicant: TEDCApplicant, questionAnswerSources: ANSWER_SOURCE[]): TQuestionValidationEntry[];
|
|
5539
|
+
declare function validateApplicantDocuments(applicant: TEDCApplicant, documentAnswerSources: ANSWER_SOURCE[]): TQuestionValidationEntry[];
|
|
5511
5540
|
declare function validateApplicant(applicant: TEDCApplicant, questionAnswerSources: ANSWER_SOURCE[], documentAnswerSources: ANSWER_SOURCE[]): {
|
|
5512
5541
|
isComplete: boolean;
|
|
5513
|
-
questionValidations:
|
|
5514
|
-
|
|
5515
|
-
validationResult: ValidationResult;
|
|
5516
|
-
}>;
|
|
5517
|
-
documentValidations: Array<{
|
|
5518
|
-
name: string;
|
|
5519
|
-
validationResult: ValidationResult;
|
|
5520
|
-
}>;
|
|
5542
|
+
questionValidations: TQuestionValidationEntry[];
|
|
5543
|
+
documentValidations: TQuestionValidationEntry[];
|
|
5521
5544
|
applicantValidations: ValidationResult;
|
|
5522
5545
|
};
|
|
5523
5546
|
declare function validateAllApplicants(applicants: Record<string, TEDCApplicant> | TEDCApplicant[], questionAnswerSources: ANSWER_SOURCE[], documentAnswerSources: ANSWER_SOURCE[]): {
|
|
@@ -5525,14 +5548,8 @@ declare function validateAllApplicants(applicants: Record<string, TEDCApplicant>
|
|
|
5525
5548
|
applicantValidations: Array<{
|
|
5526
5549
|
applicantId: string;
|
|
5527
5550
|
applicantName: string;
|
|
5528
|
-
questionValidations:
|
|
5529
|
-
|
|
5530
|
-
validationResult: ValidationResult;
|
|
5531
|
-
}>;
|
|
5532
|
-
documentValidations: Array<{
|
|
5533
|
-
name: string;
|
|
5534
|
-
validationResult: ValidationResult;
|
|
5535
|
-
}>;
|
|
5551
|
+
questionValidations: TQuestionValidationEntry[];
|
|
5552
|
+
documentValidations: TQuestionValidationEntry[];
|
|
5536
5553
|
applicantValidations: ValidationResult;
|
|
5537
5554
|
}>;
|
|
5538
5555
|
};
|
|
@@ -5542,18 +5559,13 @@ declare function validateOrder(order: TVisaOrder | null | undefined, applicants:
|
|
|
5542
5559
|
applicantValidations: Array<{
|
|
5543
5560
|
applicantId: string;
|
|
5544
5561
|
applicantName: string;
|
|
5545
|
-
questionValidations:
|
|
5546
|
-
|
|
5547
|
-
validationResult: ValidationResult;
|
|
5548
|
-
}>;
|
|
5549
|
-
documentValidations: Array<{
|
|
5550
|
-
name: string;
|
|
5551
|
-
validationResult: ValidationResult;
|
|
5552
|
-
}>;
|
|
5562
|
+
questionValidations: TQuestionValidationEntry[];
|
|
5563
|
+
documentValidations: TQuestionValidationEntry[];
|
|
5553
5564
|
applicantValidations: ValidationResult;
|
|
5554
5565
|
}>;
|
|
5555
5566
|
};
|
|
5556
5567
|
declare function getFixTypeFromFixableItems(fixableItems: ValidationItem[]): FIX_TYPE;
|
|
5568
|
+
declare function getQuestionRenderInfo(question: TQuestionWithAnswer): TQuestionRenderInfo;
|
|
5557
5569
|
|
|
5558
5570
|
declare const initializeEDCFlow: (config: EDCConfig) => void;
|
|
5559
5571
|
declare const EDCFlow: {
|
|
@@ -5561,6 +5573,7 @@ declare const EDCFlow: {
|
|
|
5561
5573
|
Provider: react.FC<{
|
|
5562
5574
|
children: react.ReactNode;
|
|
5563
5575
|
orderId: string;
|
|
5576
|
+
mode?: EDCFormMode;
|
|
5564
5577
|
}>;
|
|
5565
5578
|
useEDCFlow: () => {
|
|
5566
5579
|
orderId: string | null;
|
|
@@ -5572,6 +5585,7 @@ declare const EDCFlow: {
|
|
|
5572
5585
|
loading: boolean;
|
|
5573
5586
|
error: string | null;
|
|
5574
5587
|
success: string | null;
|
|
5588
|
+
mode: EDCFormMode;
|
|
5575
5589
|
refreshOrder: () => Promise<void>;
|
|
5576
5590
|
refreshApplicant: (application_id: string) => Promise<void>;
|
|
5577
5591
|
addApplicant: (payload: TAddTravellerPayload) => Promise<TEDCApplicant | null>;
|
|
@@ -5585,4 +5599,4 @@ declare const EDCFlow: {
|
|
|
5585
5599
|
};
|
|
5586
5600
|
};
|
|
5587
5601
|
|
|
5588
|
-
export { ANSWER_SOURCE, APPLICATION_STATUS, APPLICATION_TAGS, AnswerSchema, type ApiResponse, ApplicationSchema, DOC_TYPES, type EDCConfig, EDCFlowProvider, FIX_TYPE, INTERNAL_ORDER_TAGS, PROCESSING_BLOCKED_ON_PAYMENT_STATUS, QUESTION_TYPE, QuestionnaireSchema, TA_QC_EXTRACTION_STATUS, type TAddTravellerPayload, type TAnswer, type TEDCApplicant, TIMELINE_STEP, type TQuestionWithAnswer, type TQuestionnaire, type TRenderRule, type TTraveller, type TUpdateAnswerPayload, type TUpdateTravellerPayload, type TUploadProgressEvent, type TVisaOrder, TimelinePaymentStatus, TravellerSchema, type UploadProgressEvent, VALIDATION_STATUS, VISA_TYPE_INTERNAL_TAGS, type ValidationItem, type ValidationResult, type ValidationResultGroup, createAllQuestionsWithAnswers, createApplicantData, EDCFlow as default, filterConditionalQuestions, formatAnswerFromResponse, formatTravellerFromResponse, getDisplayableDocuments, getDisplayableQuestions, getFixTypeFromFixableItems, getSignedUrlFromAsset, getValidationErrors, getValidationResult, getVisibleQuestions, initializeEDCFlow, updateApplicantWithAnswer, useEDCFlow, validateAllApplicants, validateApplicant, validateApplicantDocuments, validateApplicantQuestions, validateOrder };
|
|
5602
|
+
export { ANSWER_SOURCE, ANSWER_STATUS, APPLICATION_STATUS, APPLICATION_TAGS, ASSET_STATUS, AnswerSchema, type ApiResponse, ApplicationSchema, DOC_TYPES, type EDCConfig, EDCFlowProvider, EDCFormMode, FIX_TYPE, INTERNAL_ORDER_TAGS, PROCESSING_BLOCKED_ON_PAYMENT_STATUS, QUESTION_TYPE, QuestionnaireSchema, TA_QC_EXTRACTION_STATUS, type TAddTravellerPayload, type TAnswer, type TEDCApplicant, TIMELINE_STEP, type TQuestionRenderInfo, type TQuestionValidationEntry, type TQuestionWithAnswer, type TQuestionnaire, type TRenderRule, type TTraveller, type TUpdateAnswerPayload, type TUpdateTravellerPayload, type TUploadProgressEvent, type TVisaOrder, TimelinePaymentStatus, TravellerSchema, type UploadProgressEvent, VALIDATION_STATUS, VISA_TYPE_INTERNAL_TAGS, type ValidationItem, type ValidationResult, type ValidationResultGroup, createAllQuestionsWithAnswers, createApplicantData, EDCFlow as default, filterConditionalQuestions, formatAnswerFromResponse, formatTravellerFromResponse, getDisplayableDocuments, getDisplayableQuestions, getFixTypeFromFixableItems, getQuestionRenderInfo, getSignedUrlFromAsset, getValidationErrors, getValidationResult, getVisibleQuestions, initializeEDCFlow, updateApplicantWithAnswer, useEDCFlow, validateAllApplicants, validateApplicant, validateApplicantDocuments, validateApplicantQuestions, validateOrder };
|
package/dist/index.d.ts
CHANGED
|
@@ -80,6 +80,20 @@ declare enum FIX_TYPE {
|
|
|
80
80
|
MANUAL = "manual",
|
|
81
81
|
NONE = "none"
|
|
82
82
|
}
|
|
83
|
+
declare enum ANSWER_STATUS {
|
|
84
|
+
ANSWERED = "ANSWERED",
|
|
85
|
+
APPROVED = "APPROVED",
|
|
86
|
+
REJECTED = "REJECTED",
|
|
87
|
+
NA = "NA",
|
|
88
|
+
UNSTARTED = "UNSTARTED",
|
|
89
|
+
PENDING = "PENDING"
|
|
90
|
+
}
|
|
91
|
+
declare enum ASSET_STATUS {
|
|
92
|
+
ANSWERED = "ANSWERED",
|
|
93
|
+
APPROVED = "APPROVED",
|
|
94
|
+
REJECTED = "REJECTED",
|
|
95
|
+
DELETED = "DELETED"
|
|
96
|
+
}
|
|
83
97
|
declare const QuestionnaireSchema: z.ZodObject<{
|
|
84
98
|
questionsWithRank: z.ZodArray<z.ZodObject<{
|
|
85
99
|
id: z.ZodString;
|
|
@@ -368,19 +382,19 @@ declare const AnswerSchema: z.ZodObject<{
|
|
|
368
382
|
assets_id: z.ZodArray<z.ZodObject<{
|
|
369
383
|
doc_id: z.ZodString;
|
|
370
384
|
issue_reason: z.ZodNullable<z.ZodString>;
|
|
371
|
-
status: z.
|
|
385
|
+
status: z.ZodNativeEnum<typeof ASSET_STATUS>;
|
|
372
386
|
}, "strip", z.ZodTypeAny, {
|
|
373
|
-
status:
|
|
387
|
+
status: ASSET_STATUS;
|
|
374
388
|
doc_id: string;
|
|
375
389
|
issue_reason: string | null;
|
|
376
390
|
}, {
|
|
377
|
-
status:
|
|
391
|
+
status: ASSET_STATUS;
|
|
378
392
|
doc_id: string;
|
|
379
393
|
issue_reason: string | null;
|
|
380
394
|
}>, "many">;
|
|
381
395
|
answer: z.ZodArray<z.ZodString, "many">;
|
|
382
396
|
issue_reason: z.ZodNullable<z.ZodString>;
|
|
383
|
-
status: z.
|
|
397
|
+
status: z.ZodNativeEnum<typeof ANSWER_STATUS>;
|
|
384
398
|
is_deleted: z.ZodBoolean;
|
|
385
399
|
visa_order_id: z.ZodString;
|
|
386
400
|
validations: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
@@ -406,7 +420,7 @@ declare const AnswerSchema: z.ZodObject<{
|
|
|
406
420
|
created_at: z.ZodString;
|
|
407
421
|
updated_at: z.ZodString;
|
|
408
422
|
}, "strip", z.ZodTypeAny, {
|
|
409
|
-
status:
|
|
423
|
+
status: ANSWER_STATUS;
|
|
410
424
|
_id: string;
|
|
411
425
|
visa_order_id: string;
|
|
412
426
|
created_at: string;
|
|
@@ -417,7 +431,7 @@ declare const AnswerSchema: z.ZodObject<{
|
|
|
417
431
|
visa_questions_id: string;
|
|
418
432
|
traveller_id: string;
|
|
419
433
|
assets_id: {
|
|
420
|
-
status:
|
|
434
|
+
status: ASSET_STATUS;
|
|
421
435
|
doc_id: string;
|
|
422
436
|
issue_reason: string | null;
|
|
423
437
|
}[];
|
|
@@ -431,7 +445,7 @@ declare const AnswerSchema: z.ZodObject<{
|
|
|
431
445
|
time_saved: number;
|
|
432
446
|
}[] | undefined;
|
|
433
447
|
}, {
|
|
434
|
-
status:
|
|
448
|
+
status: ANSWER_STATUS;
|
|
435
449
|
_id: string;
|
|
436
450
|
visa_order_id: string;
|
|
437
451
|
created_at: string;
|
|
@@ -442,7 +456,7 @@ declare const AnswerSchema: z.ZodObject<{
|
|
|
442
456
|
visa_questions_id: string;
|
|
443
457
|
traveller_id: string;
|
|
444
458
|
assets_id: {
|
|
445
|
-
status:
|
|
459
|
+
status: ASSET_STATUS;
|
|
446
460
|
doc_id: string;
|
|
447
461
|
issue_reason: string | null;
|
|
448
462
|
}[];
|
|
@@ -5435,6 +5449,8 @@ type TUpdateAnswerPayload = {
|
|
|
5435
5449
|
answer: string;
|
|
5436
5450
|
traveller_id: string;
|
|
5437
5451
|
file?: File | Blob | string | null;
|
|
5452
|
+
autoApproveAnswers?: boolean;
|
|
5453
|
+
forceRunValidations?: boolean;
|
|
5438
5454
|
};
|
|
5439
5455
|
type TUploadProgressEvent = {
|
|
5440
5456
|
percent: number;
|
|
@@ -5459,7 +5475,24 @@ type ValidationResult = {
|
|
|
5459
5475
|
perfect: ValidationResultGroup;
|
|
5460
5476
|
totalTimeSaved: number;
|
|
5461
5477
|
} | null;
|
|
5478
|
+
type TQuestionRenderInfo = {
|
|
5479
|
+
status: ANSWER_STATUS;
|
|
5480
|
+
isRejected: boolean;
|
|
5481
|
+
rejectionReasons: string[];
|
|
5482
|
+
rejectedAssets: {
|
|
5483
|
+
doc_id: string;
|
|
5484
|
+
reason: string;
|
|
5485
|
+
}[];
|
|
5486
|
+
validationResult: ValidationResult;
|
|
5487
|
+
};
|
|
5488
|
+
type TQuestionValidationEntry = TQuestionRenderInfo & {
|
|
5489
|
+
name: string;
|
|
5490
|
+
};
|
|
5462
5491
|
|
|
5492
|
+
declare enum EDCFormMode {
|
|
5493
|
+
CREATE = "CREATE",
|
|
5494
|
+
FIX = "FIX"
|
|
5495
|
+
}
|
|
5463
5496
|
type TEDCFlowContext = {
|
|
5464
5497
|
orderId: string | null;
|
|
5465
5498
|
order: TVisaOrder | null;
|
|
@@ -5470,6 +5503,7 @@ type TEDCFlowContext = {
|
|
|
5470
5503
|
loading: boolean;
|
|
5471
5504
|
error: string | null;
|
|
5472
5505
|
success: string | null;
|
|
5506
|
+
mode: EDCFormMode;
|
|
5473
5507
|
refreshOrder: () => Promise<void>;
|
|
5474
5508
|
refreshApplicant: (application_id: string) => Promise<void>;
|
|
5475
5509
|
addApplicant: (payload: TAddTravellerPayload) => Promise<TEDCApplicant | null>;
|
|
@@ -5484,6 +5518,7 @@ type TEDCFlowContext = {
|
|
|
5484
5518
|
type TEDCFlowProviderProps = {
|
|
5485
5519
|
children: ReactNode;
|
|
5486
5520
|
orderId: string;
|
|
5521
|
+
mode?: EDCFormMode;
|
|
5487
5522
|
};
|
|
5488
5523
|
declare const EDCFlowProvider: react__default.FC<TEDCFlowProviderProps>;
|
|
5489
5524
|
declare const useEDCFlow: () => TEDCFlowContext;
|
|
@@ -5500,24 +5535,12 @@ declare function getDisplayableQuestions(questions: TEDCApplicant["questions"],
|
|
|
5500
5535
|
declare function getDisplayableDocuments(questions: TEDCApplicant["questions"], documentAnswerSources: ANSWER_SOURCE[]): TEDCApplicant["questions"];
|
|
5501
5536
|
declare function getValidationErrors(validations?: TAnswer["validations"] | null): ValidationResult;
|
|
5502
5537
|
declare function getValidationResult(question: TEDCApplicant["questions"][0]): ValidationResult;
|
|
5503
|
-
declare function validateApplicantQuestions(applicant: TEDCApplicant, questionAnswerSources: ANSWER_SOURCE[]):
|
|
5504
|
-
|
|
5505
|
-
validationResult: ValidationResult;
|
|
5506
|
-
}>;
|
|
5507
|
-
declare function validateApplicantDocuments(applicant: TEDCApplicant, documentAnswerSources: ANSWER_SOURCE[]): Array<{
|
|
5508
|
-
name: string;
|
|
5509
|
-
validationResult: ValidationResult;
|
|
5510
|
-
}>;
|
|
5538
|
+
declare function validateApplicantQuestions(applicant: TEDCApplicant, questionAnswerSources: ANSWER_SOURCE[]): TQuestionValidationEntry[];
|
|
5539
|
+
declare function validateApplicantDocuments(applicant: TEDCApplicant, documentAnswerSources: ANSWER_SOURCE[]): TQuestionValidationEntry[];
|
|
5511
5540
|
declare function validateApplicant(applicant: TEDCApplicant, questionAnswerSources: ANSWER_SOURCE[], documentAnswerSources: ANSWER_SOURCE[]): {
|
|
5512
5541
|
isComplete: boolean;
|
|
5513
|
-
questionValidations:
|
|
5514
|
-
|
|
5515
|
-
validationResult: ValidationResult;
|
|
5516
|
-
}>;
|
|
5517
|
-
documentValidations: Array<{
|
|
5518
|
-
name: string;
|
|
5519
|
-
validationResult: ValidationResult;
|
|
5520
|
-
}>;
|
|
5542
|
+
questionValidations: TQuestionValidationEntry[];
|
|
5543
|
+
documentValidations: TQuestionValidationEntry[];
|
|
5521
5544
|
applicantValidations: ValidationResult;
|
|
5522
5545
|
};
|
|
5523
5546
|
declare function validateAllApplicants(applicants: Record<string, TEDCApplicant> | TEDCApplicant[], questionAnswerSources: ANSWER_SOURCE[], documentAnswerSources: ANSWER_SOURCE[]): {
|
|
@@ -5525,14 +5548,8 @@ declare function validateAllApplicants(applicants: Record<string, TEDCApplicant>
|
|
|
5525
5548
|
applicantValidations: Array<{
|
|
5526
5549
|
applicantId: string;
|
|
5527
5550
|
applicantName: string;
|
|
5528
|
-
questionValidations:
|
|
5529
|
-
|
|
5530
|
-
validationResult: ValidationResult;
|
|
5531
|
-
}>;
|
|
5532
|
-
documentValidations: Array<{
|
|
5533
|
-
name: string;
|
|
5534
|
-
validationResult: ValidationResult;
|
|
5535
|
-
}>;
|
|
5551
|
+
questionValidations: TQuestionValidationEntry[];
|
|
5552
|
+
documentValidations: TQuestionValidationEntry[];
|
|
5536
5553
|
applicantValidations: ValidationResult;
|
|
5537
5554
|
}>;
|
|
5538
5555
|
};
|
|
@@ -5542,18 +5559,13 @@ declare function validateOrder(order: TVisaOrder | null | undefined, applicants:
|
|
|
5542
5559
|
applicantValidations: Array<{
|
|
5543
5560
|
applicantId: string;
|
|
5544
5561
|
applicantName: string;
|
|
5545
|
-
questionValidations:
|
|
5546
|
-
|
|
5547
|
-
validationResult: ValidationResult;
|
|
5548
|
-
}>;
|
|
5549
|
-
documentValidations: Array<{
|
|
5550
|
-
name: string;
|
|
5551
|
-
validationResult: ValidationResult;
|
|
5552
|
-
}>;
|
|
5562
|
+
questionValidations: TQuestionValidationEntry[];
|
|
5563
|
+
documentValidations: TQuestionValidationEntry[];
|
|
5553
5564
|
applicantValidations: ValidationResult;
|
|
5554
5565
|
}>;
|
|
5555
5566
|
};
|
|
5556
5567
|
declare function getFixTypeFromFixableItems(fixableItems: ValidationItem[]): FIX_TYPE;
|
|
5568
|
+
declare function getQuestionRenderInfo(question: TQuestionWithAnswer): TQuestionRenderInfo;
|
|
5557
5569
|
|
|
5558
5570
|
declare const initializeEDCFlow: (config: EDCConfig) => void;
|
|
5559
5571
|
declare const EDCFlow: {
|
|
@@ -5561,6 +5573,7 @@ declare const EDCFlow: {
|
|
|
5561
5573
|
Provider: react.FC<{
|
|
5562
5574
|
children: react.ReactNode;
|
|
5563
5575
|
orderId: string;
|
|
5576
|
+
mode?: EDCFormMode;
|
|
5564
5577
|
}>;
|
|
5565
5578
|
useEDCFlow: () => {
|
|
5566
5579
|
orderId: string | null;
|
|
@@ -5572,6 +5585,7 @@ declare const EDCFlow: {
|
|
|
5572
5585
|
loading: boolean;
|
|
5573
5586
|
error: string | null;
|
|
5574
5587
|
success: string | null;
|
|
5588
|
+
mode: EDCFormMode;
|
|
5575
5589
|
refreshOrder: () => Promise<void>;
|
|
5576
5590
|
refreshApplicant: (application_id: string) => Promise<void>;
|
|
5577
5591
|
addApplicant: (payload: TAddTravellerPayload) => Promise<TEDCApplicant | null>;
|
|
@@ -5585,4 +5599,4 @@ declare const EDCFlow: {
|
|
|
5585
5599
|
};
|
|
5586
5600
|
};
|
|
5587
5601
|
|
|
5588
|
-
export { ANSWER_SOURCE, APPLICATION_STATUS, APPLICATION_TAGS, AnswerSchema, type ApiResponse, ApplicationSchema, DOC_TYPES, type EDCConfig, EDCFlowProvider, FIX_TYPE, INTERNAL_ORDER_TAGS, PROCESSING_BLOCKED_ON_PAYMENT_STATUS, QUESTION_TYPE, QuestionnaireSchema, TA_QC_EXTRACTION_STATUS, type TAddTravellerPayload, type TAnswer, type TEDCApplicant, TIMELINE_STEP, type TQuestionWithAnswer, type TQuestionnaire, type TRenderRule, type TTraveller, type TUpdateAnswerPayload, type TUpdateTravellerPayload, type TUploadProgressEvent, type TVisaOrder, TimelinePaymentStatus, TravellerSchema, type UploadProgressEvent, VALIDATION_STATUS, VISA_TYPE_INTERNAL_TAGS, type ValidationItem, type ValidationResult, type ValidationResultGroup, createAllQuestionsWithAnswers, createApplicantData, EDCFlow as default, filterConditionalQuestions, formatAnswerFromResponse, formatTravellerFromResponse, getDisplayableDocuments, getDisplayableQuestions, getFixTypeFromFixableItems, getSignedUrlFromAsset, getValidationErrors, getValidationResult, getVisibleQuestions, initializeEDCFlow, updateApplicantWithAnswer, useEDCFlow, validateAllApplicants, validateApplicant, validateApplicantDocuments, validateApplicantQuestions, validateOrder };
|
|
5602
|
+
export { ANSWER_SOURCE, ANSWER_STATUS, APPLICATION_STATUS, APPLICATION_TAGS, ASSET_STATUS, AnswerSchema, type ApiResponse, ApplicationSchema, DOC_TYPES, type EDCConfig, EDCFlowProvider, EDCFormMode, FIX_TYPE, INTERNAL_ORDER_TAGS, PROCESSING_BLOCKED_ON_PAYMENT_STATUS, QUESTION_TYPE, QuestionnaireSchema, TA_QC_EXTRACTION_STATUS, type TAddTravellerPayload, type TAnswer, type TEDCApplicant, TIMELINE_STEP, type TQuestionRenderInfo, type TQuestionValidationEntry, type TQuestionWithAnswer, type TQuestionnaire, type TRenderRule, type TTraveller, type TUpdateAnswerPayload, type TUpdateTravellerPayload, type TUploadProgressEvent, type TVisaOrder, TimelinePaymentStatus, TravellerSchema, type UploadProgressEvent, VALIDATION_STATUS, VISA_TYPE_INTERNAL_TAGS, type ValidationItem, type ValidationResult, type ValidationResultGroup, createAllQuestionsWithAnswers, createApplicantData, EDCFlow as default, filterConditionalQuestions, formatAnswerFromResponse, formatTravellerFromResponse, getDisplayableDocuments, getDisplayableQuestions, getFixTypeFromFixableItems, getQuestionRenderInfo, getSignedUrlFromAsset, getValidationErrors, getValidationResult, getVisibleQuestions, initializeEDCFlow, updateApplicantWithAnswer, useEDCFlow, validateAllApplicants, validateApplicant, validateApplicantDocuments, validateApplicantQuestions, validateOrder };
|
package/dist/index.js
CHANGED
|
@@ -136,6 +136,22 @@ var FIX_TYPE = /* @__PURE__ */ ((FIX_TYPE2) => {
|
|
|
136
136
|
FIX_TYPE2["NONE"] = "none";
|
|
137
137
|
return FIX_TYPE2;
|
|
138
138
|
})(FIX_TYPE || {});
|
|
139
|
+
var ANSWER_STATUS = /* @__PURE__ */ ((ANSWER_STATUS2) => {
|
|
140
|
+
ANSWER_STATUS2["ANSWERED"] = "ANSWERED";
|
|
141
|
+
ANSWER_STATUS2["APPROVED"] = "APPROVED";
|
|
142
|
+
ANSWER_STATUS2["REJECTED"] = "REJECTED";
|
|
143
|
+
ANSWER_STATUS2["NA"] = "NA";
|
|
144
|
+
ANSWER_STATUS2["UNSTARTED"] = "UNSTARTED";
|
|
145
|
+
ANSWER_STATUS2["PENDING"] = "PENDING";
|
|
146
|
+
return ANSWER_STATUS2;
|
|
147
|
+
})(ANSWER_STATUS || {});
|
|
148
|
+
var ASSET_STATUS = /* @__PURE__ */ ((ASSET_STATUS2) => {
|
|
149
|
+
ASSET_STATUS2["ANSWERED"] = "ANSWERED";
|
|
150
|
+
ASSET_STATUS2["APPROVED"] = "APPROVED";
|
|
151
|
+
ASSET_STATUS2["REJECTED"] = "REJECTED";
|
|
152
|
+
ASSET_STATUS2["DELETED"] = "DELETED";
|
|
153
|
+
return ASSET_STATUS2;
|
|
154
|
+
})(ASSET_STATUS || {});
|
|
139
155
|
var QuestionnaireSchema = z2__namespace.object({
|
|
140
156
|
questionsWithRank: z2__namespace.array(z2__namespace.object({ id: z2__namespace.string(), rank: z2__namespace.number() })),
|
|
141
157
|
questionMap: z2__namespace.record(
|
|
@@ -213,12 +229,12 @@ var AnswerSchema = z2__namespace.object({
|
|
|
213
229
|
z2__namespace.object({
|
|
214
230
|
doc_id: z2__namespace.string(),
|
|
215
231
|
issue_reason: z2__namespace.string().nullable(),
|
|
216
|
-
status: z2__namespace.
|
|
232
|
+
status: z2__namespace.nativeEnum(ASSET_STATUS)
|
|
217
233
|
})
|
|
218
234
|
),
|
|
219
235
|
answer: z2__namespace.array(z2__namespace.string()),
|
|
220
236
|
issue_reason: z2__namespace.string().nullable(),
|
|
221
|
-
status: z2__namespace.
|
|
237
|
+
status: z2__namespace.nativeEnum(ANSWER_STATUS),
|
|
222
238
|
is_deleted: z2__namespace.boolean(),
|
|
223
239
|
visa_order_id: z2__namespace.string(),
|
|
224
240
|
validations: z2__namespace.array(z2__namespace.object({
|
|
@@ -628,7 +644,7 @@ function getValidationResult(question) {
|
|
|
628
644
|
}
|
|
629
645
|
if (question.question.is_required) {
|
|
630
646
|
const isDocument = question.question.type === "DOCUMENT" /* DOCUMENT */;
|
|
631
|
-
const hasApproved = question.answer_data?.assets_id?.find((asset) => asset.status === "APPROVED");
|
|
647
|
+
const hasApproved = question.answer_data?.assets_id?.find((asset) => asset.status === "APPROVED" /* APPROVED */);
|
|
632
648
|
const answer = question.answer_data?.answer?.[0];
|
|
633
649
|
const isAnswerEmpty = !answer || answer === "" || extractDefaultAnswer(answer) !== null;
|
|
634
650
|
if (isDocument && !hasApproved || !isDocument && isAnswerEmpty) {
|
|
@@ -659,11 +675,15 @@ function validateApplicantQuestions(applicant, questionAnswerSources) {
|
|
|
659
675
|
const displayableQuestions = getDisplayableQuestions(applicant.questions, questionAnswerSources);
|
|
660
676
|
const questionValidations = [];
|
|
661
677
|
displayableQuestions.forEach((question) => {
|
|
662
|
-
const
|
|
663
|
-
if (validationResult && (validationResult.status === "MISSING" /* MISSING */ || validationResult.status === "UNFIXABLE" /* UNFIXABLE */)) {
|
|
678
|
+
const renderInfo = getQuestionRenderInfo(question);
|
|
679
|
+
if (renderInfo.validationResult && (renderInfo.validationResult.status === "MISSING" /* MISSING */ || renderInfo.validationResult.status === "UNFIXABLE" /* UNFIXABLE */)) {
|
|
664
680
|
questionValidations.push({
|
|
665
681
|
name: question.question.question,
|
|
666
|
-
|
|
682
|
+
status: renderInfo.status,
|
|
683
|
+
isRejected: renderInfo.isRejected,
|
|
684
|
+
rejectionReasons: renderInfo.rejectionReasons,
|
|
685
|
+
rejectedAssets: renderInfo.rejectedAssets,
|
|
686
|
+
validationResult: renderInfo.validationResult
|
|
667
687
|
});
|
|
668
688
|
}
|
|
669
689
|
});
|
|
@@ -673,11 +693,15 @@ function validateApplicantDocuments(applicant, documentAnswerSources) {
|
|
|
673
693
|
const displayableDocuments = getDisplayableDocuments(applicant.questions, documentAnswerSources);
|
|
674
694
|
const documentValidations = [];
|
|
675
695
|
displayableDocuments.forEach((document) => {
|
|
676
|
-
const
|
|
677
|
-
if (validationResult && (validationResult.status === "MISSING" /* MISSING */ || validationResult.status === "UNFIXABLE" /* UNFIXABLE */)) {
|
|
696
|
+
const renderInfo = getQuestionRenderInfo(document);
|
|
697
|
+
if (renderInfo.validationResult && (renderInfo.validationResult.status === "MISSING" /* MISSING */ || renderInfo.validationResult.status === "UNFIXABLE" /* UNFIXABLE */)) {
|
|
678
698
|
documentValidations.push({
|
|
679
699
|
name: document.question.question,
|
|
680
|
-
|
|
700
|
+
status: renderInfo.status,
|
|
701
|
+
isRejected: renderInfo.isRejected,
|
|
702
|
+
rejectionReasons: renderInfo.rejectionReasons,
|
|
703
|
+
rejectedAssets: renderInfo.rejectedAssets,
|
|
704
|
+
validationResult: renderInfo.validationResult
|
|
681
705
|
});
|
|
682
706
|
}
|
|
683
707
|
});
|
|
@@ -736,6 +760,23 @@ function getFixTypeFromFixableItems(fixableItems) {
|
|
|
736
760
|
}
|
|
737
761
|
return "auto" /* AUTO */;
|
|
738
762
|
}
|
|
763
|
+
function getQuestionRenderInfo(question) {
|
|
764
|
+
const answer = question.answer_data;
|
|
765
|
+
const status = answer?.status ?? "UNSTARTED" /* UNSTARTED */;
|
|
766
|
+
let rejectionReasons = [];
|
|
767
|
+
let rejectedAssets = [];
|
|
768
|
+
if (status === "REJECTED" /* REJECTED */ && answer) {
|
|
769
|
+
rejectedAssets = answer.assets_id?.filter((a) => a.status === "REJECTED" /* REJECTED */ && a.issue_reason).map((a) => ({ doc_id: a.doc_id, reason: a.issue_reason })) ?? [];
|
|
770
|
+
rejectionReasons = rejectedAssets.length > 0 ? rejectedAssets.map((a) => a.reason) : answer.issue_reason ? [answer.issue_reason] : [];
|
|
771
|
+
}
|
|
772
|
+
return {
|
|
773
|
+
status,
|
|
774
|
+
isRejected: status === "REJECTED" /* REJECTED */,
|
|
775
|
+
rejectionReasons,
|
|
776
|
+
rejectedAssets,
|
|
777
|
+
validationResult: getValidationResult(question)
|
|
778
|
+
};
|
|
779
|
+
}
|
|
739
780
|
|
|
740
781
|
// src/api/index.ts
|
|
741
782
|
var transformApplicationData = (rawData) => {
|
|
@@ -791,6 +832,12 @@ var updateAnswer = async (applicationId, data, onProgress) => {
|
|
|
791
832
|
if (data.file) {
|
|
792
833
|
formData.append("docs", data.file);
|
|
793
834
|
}
|
|
835
|
+
if (data.autoApproveAnswers !== void 0) {
|
|
836
|
+
formData.append("autoApproveAnswers", String(data.autoApproveAnswers));
|
|
837
|
+
}
|
|
838
|
+
if (data.forceRunValidations !== void 0) {
|
|
839
|
+
formData.append("forceRunValidations", String(data.forceRunValidations));
|
|
840
|
+
}
|
|
794
841
|
const response = await client.post(`/visa_answers/upsert-answer-edc`, formData, {
|
|
795
842
|
onUploadProgress: (event) => {
|
|
796
843
|
onProgress?.({
|
|
@@ -880,8 +927,17 @@ var mapFixableDocument = async (answerId) => {
|
|
|
880
927
|
}
|
|
881
928
|
};
|
|
882
929
|
};
|
|
930
|
+
var EDCFormMode = /* @__PURE__ */ ((EDCFormMode2) => {
|
|
931
|
+
EDCFormMode2["CREATE"] = "CREATE";
|
|
932
|
+
EDCFormMode2["FIX"] = "FIX";
|
|
933
|
+
return EDCFormMode2;
|
|
934
|
+
})(EDCFormMode || {});
|
|
883
935
|
var EDCFlowContext = react.createContext(void 0);
|
|
884
|
-
var EDCFlowProvider = ({
|
|
936
|
+
var EDCFlowProvider = ({
|
|
937
|
+
children,
|
|
938
|
+
orderId,
|
|
939
|
+
mode = "CREATE" /* CREATE */
|
|
940
|
+
}) => {
|
|
885
941
|
const [order, setOrder] = react.useState(null);
|
|
886
942
|
const [questionnaire, setQuestionnaire] = react.useState(null);
|
|
887
943
|
const [dynamicQuestionMap, setDynamicQuestionMap] = react.useState({});
|
|
@@ -1019,7 +1075,11 @@ var EDCFlowProvider = ({ children, orderId }) => {
|
|
|
1019
1075
|
const currentApplicant = prev[application_id];
|
|
1020
1076
|
if (!currentApplicant) return prev;
|
|
1021
1077
|
const applicantWithUpdatedAnswer = updateApplicantWithAnswer(
|
|
1022
|
-
{
|
|
1078
|
+
{
|
|
1079
|
+
...currentApplicant,
|
|
1080
|
+
application: updatedAnswerData.application,
|
|
1081
|
+
traveller: updatedAnswerData.traveller
|
|
1082
|
+
},
|
|
1023
1083
|
updatedAnswerData.answers.visa_questions_id,
|
|
1024
1084
|
updatedAnswerData.answers,
|
|
1025
1085
|
questionnaire
|
|
@@ -1056,63 +1116,69 @@ var EDCFlowProvider = ({ children, orderId }) => {
|
|
|
1056
1116
|
},
|
|
1057
1117
|
[questionnaire, order, refreshApplicant]
|
|
1058
1118
|
);
|
|
1059
|
-
const deleteApplicantById = react.useCallback(
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1119
|
+
const deleteApplicantById = react.useCallback(
|
|
1120
|
+
async (application_id) => {
|
|
1121
|
+
if (!questionnaire || !order) return;
|
|
1122
|
+
try {
|
|
1123
|
+
await deleteApplicant(application_id);
|
|
1124
|
+
setApplicants((prev) => {
|
|
1125
|
+
const { [application_id]: _, ...updatedApplicants } = prev;
|
|
1126
|
+
const { updatedQuestionnaire, updatedApplicants: applicantsWithSideEffects } = runApplicantSideEffects(updatedApplicants, questionnaire, dynamicQuestionMap);
|
|
1127
|
+
setQuestionnaire(updatedQuestionnaire);
|
|
1128
|
+
setActiveApplicant((prevActive) => {
|
|
1129
|
+
if (prevActive === application_id) {
|
|
1130
|
+
const remainingIds = Object.keys(applicantsWithSideEffects);
|
|
1131
|
+
return remainingIds.length > 0 ? remainingIds[remainingIds.length - 1] : null;
|
|
1132
|
+
}
|
|
1133
|
+
return prevActive;
|
|
1134
|
+
});
|
|
1135
|
+
return applicantsWithSideEffects;
|
|
1073
1136
|
});
|
|
1074
|
-
|
|
1075
|
-
})
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1137
|
+
setSuccess("Applicant deleted successfully");
|
|
1138
|
+
} catch (err) {
|
|
1139
|
+
console.error("Failed to delete applicant:", err);
|
|
1140
|
+
setError("Failed to delete applicant");
|
|
1141
|
+
throw err;
|
|
1142
|
+
}
|
|
1143
|
+
},
|
|
1144
|
+
[questionnaire, order, dynamicQuestionMap]
|
|
1145
|
+
);
|
|
1083
1146
|
const refreshOrder = react.useCallback(async () => {
|
|
1084
1147
|
await fetchOrder();
|
|
1085
1148
|
}, [fetchOrder]);
|
|
1086
|
-
const getS3UrlForAsset = react.useCallback(
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
const request = (async () => {
|
|
1096
|
-
try {
|
|
1097
|
-
const s3Url = await getSignedUrlFromAsset(doc_id);
|
|
1098
|
-
setDocIdToS3Url((prev) => ({
|
|
1099
|
-
...prev,
|
|
1100
|
-
[doc_id]: s3Url
|
|
1101
|
-
}));
|
|
1102
|
-
s3UrlFetchFlightRequests.current.delete(doc_id);
|
|
1103
|
-
return s3Url;
|
|
1104
|
-
} catch (error2) {
|
|
1105
|
-
setDocIdToS3Url((prev) => ({
|
|
1106
|
-
...prev,
|
|
1107
|
-
[doc_id]: null
|
|
1108
|
-
}));
|
|
1109
|
-
s3UrlFetchFlightRequests.current.delete(doc_id);
|
|
1110
|
-
return null;
|
|
1149
|
+
const getS3UrlForAsset = react.useCallback(
|
|
1150
|
+
async (doc_id) => {
|
|
1151
|
+
if (!doc_id) return null;
|
|
1152
|
+
if (docIdToS3Url[doc_id] !== void 0) {
|
|
1153
|
+
return docIdToS3Url[doc_id];
|
|
1154
|
+
}
|
|
1155
|
+
const existingRequest = s3UrlFetchFlightRequests.current.get(doc_id);
|
|
1156
|
+
if (existingRequest) {
|
|
1157
|
+
return existingRequest;
|
|
1111
1158
|
}
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1159
|
+
const request = (async () => {
|
|
1160
|
+
try {
|
|
1161
|
+
const s3Url = await getSignedUrlFromAsset(doc_id);
|
|
1162
|
+
setDocIdToS3Url((prev) => ({
|
|
1163
|
+
...prev,
|
|
1164
|
+
[doc_id]: s3Url
|
|
1165
|
+
}));
|
|
1166
|
+
s3UrlFetchFlightRequests.current.delete(doc_id);
|
|
1167
|
+
return s3Url;
|
|
1168
|
+
} catch (error2) {
|
|
1169
|
+
setDocIdToS3Url((prev) => ({
|
|
1170
|
+
...prev,
|
|
1171
|
+
[doc_id]: null
|
|
1172
|
+
}));
|
|
1173
|
+
s3UrlFetchFlightRequests.current.delete(doc_id);
|
|
1174
|
+
return null;
|
|
1175
|
+
}
|
|
1176
|
+
})();
|
|
1177
|
+
s3UrlFetchFlightRequests.current.set(doc_id, request);
|
|
1178
|
+
return request;
|
|
1179
|
+
},
|
|
1180
|
+
[docIdToS3Url]
|
|
1181
|
+
);
|
|
1116
1182
|
const acceptOrderQCTermsAndConditions = react.useCallback(async () => {
|
|
1117
1183
|
if (!order) return;
|
|
1118
1184
|
try {
|
|
@@ -1131,11 +1197,12 @@ var EDCFlowProvider = ({ children, orderId }) => {
|
|
|
1131
1197
|
setOrder(data.order);
|
|
1132
1198
|
}
|
|
1133
1199
|
if (data.applications && data.applications.length > 0) {
|
|
1134
|
-
const applicants2 = createApplicantsFromApplications(
|
|
1135
|
-
|
|
1136
|
-
|
|
1200
|
+
const applicants2 = createApplicantsFromApplications(data.applications, questionnaire);
|
|
1201
|
+
const { updatedQuestionnaire, updatedApplicants } = runApplicantSideEffects(
|
|
1202
|
+
applicants2,
|
|
1203
|
+
questionnaire,
|
|
1204
|
+
dynamicQuestionMap
|
|
1137
1205
|
);
|
|
1138
|
-
const { updatedQuestionnaire, updatedApplicants } = runApplicantSideEffects(applicants2, questionnaire, dynamicQuestionMap);
|
|
1139
1206
|
setQuestionnaire(updatedQuestionnaire);
|
|
1140
1207
|
setApplicants(updatedApplicants);
|
|
1141
1208
|
const applicantIds = Object.keys(updatedApplicants);
|
|
@@ -1153,36 +1220,39 @@ var EDCFlowProvider = ({ children, orderId }) => {
|
|
|
1153
1220
|
setError("Failed to run all validations");
|
|
1154
1221
|
}
|
|
1155
1222
|
}, [orderId, questionnaire, dynamicQuestionMap, activeApplicant]);
|
|
1156
|
-
const runApplicantValidationsHandler = react.useCallback(
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1223
|
+
const runApplicantValidationsHandler = react.useCallback(
|
|
1224
|
+
async (applicationId) => {
|
|
1225
|
+
if (!orderId || !questionnaire) return;
|
|
1226
|
+
try {
|
|
1227
|
+
setError(null);
|
|
1228
|
+
const { data } = await runApplicantValidations(applicationId);
|
|
1229
|
+
if (data.application) {
|
|
1230
|
+
const applicant = createApplicantData(
|
|
1231
|
+
data.application.traveller,
|
|
1232
|
+
data.application.answers,
|
|
1233
|
+
questionnaire,
|
|
1234
|
+
data.application.application
|
|
1235
|
+
);
|
|
1236
|
+
if (applicant) {
|
|
1237
|
+
setApplicants((prev) => {
|
|
1238
|
+
const updatedApplicants = {
|
|
1239
|
+
...prev,
|
|
1240
|
+
[applicationId]: applicant
|
|
1241
|
+
};
|
|
1242
|
+
const { updatedQuestionnaire, updatedApplicants: applicantsWithSideEffects } = runApplicantSideEffects(updatedApplicants, questionnaire, dynamicQuestionMap);
|
|
1243
|
+
setQuestionnaire(updatedQuestionnaire);
|
|
1244
|
+
return applicantsWithSideEffects;
|
|
1245
|
+
});
|
|
1246
|
+
}
|
|
1178
1247
|
}
|
|
1248
|
+
setSuccess("Applicant validations completed successfully");
|
|
1249
|
+
} catch (err) {
|
|
1250
|
+
console.error("Failed to run applicant validations:", err);
|
|
1251
|
+
setError("Failed to run applicant validations");
|
|
1179
1252
|
}
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
setError("Failed to run applicant validations");
|
|
1184
|
-
}
|
|
1185
|
-
}, [orderId, questionnaire, dynamicQuestionMap]);
|
|
1253
|
+
},
|
|
1254
|
+
[orderId, questionnaire, dynamicQuestionMap]
|
|
1255
|
+
);
|
|
1186
1256
|
react.useEffect(() => {
|
|
1187
1257
|
if (!orderId) return;
|
|
1188
1258
|
const initialize = async () => {
|
|
@@ -1195,12 +1265,13 @@ var EDCFlowProvider = ({ children, orderId }) => {
|
|
|
1195
1265
|
fetchApplicantsForOrder()
|
|
1196
1266
|
]);
|
|
1197
1267
|
if (orderData && questionnaireData && applications) {
|
|
1198
|
-
const applicants2 = createApplicantsFromApplications(
|
|
1199
|
-
applications,
|
|
1200
|
-
questionnaireData
|
|
1201
|
-
);
|
|
1268
|
+
const applicants2 = createApplicantsFromApplications(applications, questionnaireData);
|
|
1202
1269
|
const dynamicMap = buildDynamicQuestionMap(questionnaireData);
|
|
1203
|
-
const { updatedQuestionnaire, updatedApplicants } = runApplicantSideEffects(
|
|
1270
|
+
const { updatedQuestionnaire, updatedApplicants } = runApplicantSideEffects(
|
|
1271
|
+
applicants2,
|
|
1272
|
+
questionnaireData,
|
|
1273
|
+
dynamicMap
|
|
1274
|
+
);
|
|
1204
1275
|
setQuestionnaire(updatedQuestionnaire);
|
|
1205
1276
|
setApplicants(updatedApplicants);
|
|
1206
1277
|
const ids = Object.keys(updatedApplicants);
|
|
@@ -1227,6 +1298,7 @@ var EDCFlowProvider = ({ children, orderId }) => {
|
|
|
1227
1298
|
loading,
|
|
1228
1299
|
error,
|
|
1229
1300
|
success,
|
|
1301
|
+
mode,
|
|
1230
1302
|
addApplicant: addApplicant2,
|
|
1231
1303
|
updateAnswer: updateAnswer2,
|
|
1232
1304
|
deleteApplicant: deleteApplicantById,
|
|
@@ -1748,12 +1820,15 @@ var EDCFlow = {
|
|
|
1748
1820
|
var index_default = EDCFlow;
|
|
1749
1821
|
|
|
1750
1822
|
exports.ANSWER_SOURCE = ANSWER_SOURCE;
|
|
1823
|
+
exports.ANSWER_STATUS = ANSWER_STATUS;
|
|
1751
1824
|
exports.APPLICATION_STATUS = APPLICATION_STATUS;
|
|
1752
1825
|
exports.APPLICATION_TAGS = APPLICATION_TAGS;
|
|
1826
|
+
exports.ASSET_STATUS = ASSET_STATUS;
|
|
1753
1827
|
exports.AnswerSchema = AnswerSchema;
|
|
1754
1828
|
exports.ApplicationSchema = ApplicationSchema;
|
|
1755
1829
|
exports.DOC_TYPES = DOC_TYPES;
|
|
1756
1830
|
exports.EDCFlowProvider = EDCFlowProvider;
|
|
1831
|
+
exports.EDCFormMode = EDCFormMode;
|
|
1757
1832
|
exports.FIX_TYPE = FIX_TYPE;
|
|
1758
1833
|
exports.INTERNAL_ORDER_TAGS = INTERNAL_ORDER_TAGS;
|
|
1759
1834
|
exports.PROCESSING_BLOCKED_ON_PAYMENT_STATUS = PROCESSING_BLOCKED_ON_PAYMENT_STATUS;
|
|
@@ -1774,6 +1849,7 @@ exports.formatTravellerFromResponse = formatTravellerFromResponse;
|
|
|
1774
1849
|
exports.getDisplayableDocuments = getDisplayableDocuments;
|
|
1775
1850
|
exports.getDisplayableQuestions = getDisplayableQuestions;
|
|
1776
1851
|
exports.getFixTypeFromFixableItems = getFixTypeFromFixableItems;
|
|
1852
|
+
exports.getQuestionRenderInfo = getQuestionRenderInfo;
|
|
1777
1853
|
exports.getSignedUrlFromAsset = getSignedUrlFromAsset;
|
|
1778
1854
|
exports.getValidationErrors = getValidationErrors;
|
|
1779
1855
|
exports.getValidationResult = getValidationResult;
|
package/dist/index.mjs
CHANGED
|
@@ -110,6 +110,22 @@ var FIX_TYPE = /* @__PURE__ */ ((FIX_TYPE2) => {
|
|
|
110
110
|
FIX_TYPE2["NONE"] = "none";
|
|
111
111
|
return FIX_TYPE2;
|
|
112
112
|
})(FIX_TYPE || {});
|
|
113
|
+
var ANSWER_STATUS = /* @__PURE__ */ ((ANSWER_STATUS2) => {
|
|
114
|
+
ANSWER_STATUS2["ANSWERED"] = "ANSWERED";
|
|
115
|
+
ANSWER_STATUS2["APPROVED"] = "APPROVED";
|
|
116
|
+
ANSWER_STATUS2["REJECTED"] = "REJECTED";
|
|
117
|
+
ANSWER_STATUS2["NA"] = "NA";
|
|
118
|
+
ANSWER_STATUS2["UNSTARTED"] = "UNSTARTED";
|
|
119
|
+
ANSWER_STATUS2["PENDING"] = "PENDING";
|
|
120
|
+
return ANSWER_STATUS2;
|
|
121
|
+
})(ANSWER_STATUS || {});
|
|
122
|
+
var ASSET_STATUS = /* @__PURE__ */ ((ASSET_STATUS2) => {
|
|
123
|
+
ASSET_STATUS2["ANSWERED"] = "ANSWERED";
|
|
124
|
+
ASSET_STATUS2["APPROVED"] = "APPROVED";
|
|
125
|
+
ASSET_STATUS2["REJECTED"] = "REJECTED";
|
|
126
|
+
ASSET_STATUS2["DELETED"] = "DELETED";
|
|
127
|
+
return ASSET_STATUS2;
|
|
128
|
+
})(ASSET_STATUS || {});
|
|
113
129
|
var QuestionnaireSchema = z2.object({
|
|
114
130
|
questionsWithRank: z2.array(z2.object({ id: z2.string(), rank: z2.number() })),
|
|
115
131
|
questionMap: z2.record(
|
|
@@ -187,12 +203,12 @@ var AnswerSchema = z2.object({
|
|
|
187
203
|
z2.object({
|
|
188
204
|
doc_id: z2.string(),
|
|
189
205
|
issue_reason: z2.string().nullable(),
|
|
190
|
-
status: z2.
|
|
206
|
+
status: z2.nativeEnum(ASSET_STATUS)
|
|
191
207
|
})
|
|
192
208
|
),
|
|
193
209
|
answer: z2.array(z2.string()),
|
|
194
210
|
issue_reason: z2.string().nullable(),
|
|
195
|
-
status: z2.
|
|
211
|
+
status: z2.nativeEnum(ANSWER_STATUS),
|
|
196
212
|
is_deleted: z2.boolean(),
|
|
197
213
|
visa_order_id: z2.string(),
|
|
198
214
|
validations: z2.array(z2.object({
|
|
@@ -602,7 +618,7 @@ function getValidationResult(question) {
|
|
|
602
618
|
}
|
|
603
619
|
if (question.question.is_required) {
|
|
604
620
|
const isDocument = question.question.type === "DOCUMENT" /* DOCUMENT */;
|
|
605
|
-
const hasApproved = question.answer_data?.assets_id?.find((asset) => asset.status === "APPROVED");
|
|
621
|
+
const hasApproved = question.answer_data?.assets_id?.find((asset) => asset.status === "APPROVED" /* APPROVED */);
|
|
606
622
|
const answer = question.answer_data?.answer?.[0];
|
|
607
623
|
const isAnswerEmpty = !answer || answer === "" || extractDefaultAnswer(answer) !== null;
|
|
608
624
|
if (isDocument && !hasApproved || !isDocument && isAnswerEmpty) {
|
|
@@ -633,11 +649,15 @@ function validateApplicantQuestions(applicant, questionAnswerSources) {
|
|
|
633
649
|
const displayableQuestions = getDisplayableQuestions(applicant.questions, questionAnswerSources);
|
|
634
650
|
const questionValidations = [];
|
|
635
651
|
displayableQuestions.forEach((question) => {
|
|
636
|
-
const
|
|
637
|
-
if (validationResult && (validationResult.status === "MISSING" /* MISSING */ || validationResult.status === "UNFIXABLE" /* UNFIXABLE */)) {
|
|
652
|
+
const renderInfo = getQuestionRenderInfo(question);
|
|
653
|
+
if (renderInfo.validationResult && (renderInfo.validationResult.status === "MISSING" /* MISSING */ || renderInfo.validationResult.status === "UNFIXABLE" /* UNFIXABLE */)) {
|
|
638
654
|
questionValidations.push({
|
|
639
655
|
name: question.question.question,
|
|
640
|
-
|
|
656
|
+
status: renderInfo.status,
|
|
657
|
+
isRejected: renderInfo.isRejected,
|
|
658
|
+
rejectionReasons: renderInfo.rejectionReasons,
|
|
659
|
+
rejectedAssets: renderInfo.rejectedAssets,
|
|
660
|
+
validationResult: renderInfo.validationResult
|
|
641
661
|
});
|
|
642
662
|
}
|
|
643
663
|
});
|
|
@@ -647,11 +667,15 @@ function validateApplicantDocuments(applicant, documentAnswerSources) {
|
|
|
647
667
|
const displayableDocuments = getDisplayableDocuments(applicant.questions, documentAnswerSources);
|
|
648
668
|
const documentValidations = [];
|
|
649
669
|
displayableDocuments.forEach((document) => {
|
|
650
|
-
const
|
|
651
|
-
if (validationResult && (validationResult.status === "MISSING" /* MISSING */ || validationResult.status === "UNFIXABLE" /* UNFIXABLE */)) {
|
|
670
|
+
const renderInfo = getQuestionRenderInfo(document);
|
|
671
|
+
if (renderInfo.validationResult && (renderInfo.validationResult.status === "MISSING" /* MISSING */ || renderInfo.validationResult.status === "UNFIXABLE" /* UNFIXABLE */)) {
|
|
652
672
|
documentValidations.push({
|
|
653
673
|
name: document.question.question,
|
|
654
|
-
|
|
674
|
+
status: renderInfo.status,
|
|
675
|
+
isRejected: renderInfo.isRejected,
|
|
676
|
+
rejectionReasons: renderInfo.rejectionReasons,
|
|
677
|
+
rejectedAssets: renderInfo.rejectedAssets,
|
|
678
|
+
validationResult: renderInfo.validationResult
|
|
655
679
|
});
|
|
656
680
|
}
|
|
657
681
|
});
|
|
@@ -710,6 +734,23 @@ function getFixTypeFromFixableItems(fixableItems) {
|
|
|
710
734
|
}
|
|
711
735
|
return "auto" /* AUTO */;
|
|
712
736
|
}
|
|
737
|
+
function getQuestionRenderInfo(question) {
|
|
738
|
+
const answer = question.answer_data;
|
|
739
|
+
const status = answer?.status ?? "UNSTARTED" /* UNSTARTED */;
|
|
740
|
+
let rejectionReasons = [];
|
|
741
|
+
let rejectedAssets = [];
|
|
742
|
+
if (status === "REJECTED" /* REJECTED */ && answer) {
|
|
743
|
+
rejectedAssets = answer.assets_id?.filter((a) => a.status === "REJECTED" /* REJECTED */ && a.issue_reason).map((a) => ({ doc_id: a.doc_id, reason: a.issue_reason })) ?? [];
|
|
744
|
+
rejectionReasons = rejectedAssets.length > 0 ? rejectedAssets.map((a) => a.reason) : answer.issue_reason ? [answer.issue_reason] : [];
|
|
745
|
+
}
|
|
746
|
+
return {
|
|
747
|
+
status,
|
|
748
|
+
isRejected: status === "REJECTED" /* REJECTED */,
|
|
749
|
+
rejectionReasons,
|
|
750
|
+
rejectedAssets,
|
|
751
|
+
validationResult: getValidationResult(question)
|
|
752
|
+
};
|
|
753
|
+
}
|
|
713
754
|
|
|
714
755
|
// src/api/index.ts
|
|
715
756
|
var transformApplicationData = (rawData) => {
|
|
@@ -765,6 +806,12 @@ var updateAnswer = async (applicationId, data, onProgress) => {
|
|
|
765
806
|
if (data.file) {
|
|
766
807
|
formData.append("docs", data.file);
|
|
767
808
|
}
|
|
809
|
+
if (data.autoApproveAnswers !== void 0) {
|
|
810
|
+
formData.append("autoApproveAnswers", String(data.autoApproveAnswers));
|
|
811
|
+
}
|
|
812
|
+
if (data.forceRunValidations !== void 0) {
|
|
813
|
+
formData.append("forceRunValidations", String(data.forceRunValidations));
|
|
814
|
+
}
|
|
768
815
|
const response = await client.post(`/visa_answers/upsert-answer-edc`, formData, {
|
|
769
816
|
onUploadProgress: (event) => {
|
|
770
817
|
onProgress?.({
|
|
@@ -854,8 +901,17 @@ var mapFixableDocument = async (answerId) => {
|
|
|
854
901
|
}
|
|
855
902
|
};
|
|
856
903
|
};
|
|
904
|
+
var EDCFormMode = /* @__PURE__ */ ((EDCFormMode2) => {
|
|
905
|
+
EDCFormMode2["CREATE"] = "CREATE";
|
|
906
|
+
EDCFormMode2["FIX"] = "FIX";
|
|
907
|
+
return EDCFormMode2;
|
|
908
|
+
})(EDCFormMode || {});
|
|
857
909
|
var EDCFlowContext = createContext(void 0);
|
|
858
|
-
var EDCFlowProvider = ({
|
|
910
|
+
var EDCFlowProvider = ({
|
|
911
|
+
children,
|
|
912
|
+
orderId,
|
|
913
|
+
mode = "CREATE" /* CREATE */
|
|
914
|
+
}) => {
|
|
859
915
|
const [order, setOrder] = useState(null);
|
|
860
916
|
const [questionnaire, setQuestionnaire] = useState(null);
|
|
861
917
|
const [dynamicQuestionMap, setDynamicQuestionMap] = useState({});
|
|
@@ -993,7 +1049,11 @@ var EDCFlowProvider = ({ children, orderId }) => {
|
|
|
993
1049
|
const currentApplicant = prev[application_id];
|
|
994
1050
|
if (!currentApplicant) return prev;
|
|
995
1051
|
const applicantWithUpdatedAnswer = updateApplicantWithAnswer(
|
|
996
|
-
{
|
|
1052
|
+
{
|
|
1053
|
+
...currentApplicant,
|
|
1054
|
+
application: updatedAnswerData.application,
|
|
1055
|
+
traveller: updatedAnswerData.traveller
|
|
1056
|
+
},
|
|
997
1057
|
updatedAnswerData.answers.visa_questions_id,
|
|
998
1058
|
updatedAnswerData.answers,
|
|
999
1059
|
questionnaire
|
|
@@ -1030,63 +1090,69 @@ var EDCFlowProvider = ({ children, orderId }) => {
|
|
|
1030
1090
|
},
|
|
1031
1091
|
[questionnaire, order, refreshApplicant]
|
|
1032
1092
|
);
|
|
1033
|
-
const deleteApplicantById = useCallback(
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1093
|
+
const deleteApplicantById = useCallback(
|
|
1094
|
+
async (application_id) => {
|
|
1095
|
+
if (!questionnaire || !order) return;
|
|
1096
|
+
try {
|
|
1097
|
+
await deleteApplicant(application_id);
|
|
1098
|
+
setApplicants((prev) => {
|
|
1099
|
+
const { [application_id]: _, ...updatedApplicants } = prev;
|
|
1100
|
+
const { updatedQuestionnaire, updatedApplicants: applicantsWithSideEffects } = runApplicantSideEffects(updatedApplicants, questionnaire, dynamicQuestionMap);
|
|
1101
|
+
setQuestionnaire(updatedQuestionnaire);
|
|
1102
|
+
setActiveApplicant((prevActive) => {
|
|
1103
|
+
if (prevActive === application_id) {
|
|
1104
|
+
const remainingIds = Object.keys(applicantsWithSideEffects);
|
|
1105
|
+
return remainingIds.length > 0 ? remainingIds[remainingIds.length - 1] : null;
|
|
1106
|
+
}
|
|
1107
|
+
return prevActive;
|
|
1108
|
+
});
|
|
1109
|
+
return applicantsWithSideEffects;
|
|
1047
1110
|
});
|
|
1048
|
-
|
|
1049
|
-
})
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1111
|
+
setSuccess("Applicant deleted successfully");
|
|
1112
|
+
} catch (err) {
|
|
1113
|
+
console.error("Failed to delete applicant:", err);
|
|
1114
|
+
setError("Failed to delete applicant");
|
|
1115
|
+
throw err;
|
|
1116
|
+
}
|
|
1117
|
+
},
|
|
1118
|
+
[questionnaire, order, dynamicQuestionMap]
|
|
1119
|
+
);
|
|
1057
1120
|
const refreshOrder = useCallback(async () => {
|
|
1058
1121
|
await fetchOrder();
|
|
1059
1122
|
}, [fetchOrder]);
|
|
1060
|
-
const getS3UrlForAsset = useCallback(
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
const request = (async () => {
|
|
1070
|
-
try {
|
|
1071
|
-
const s3Url = await getSignedUrlFromAsset(doc_id);
|
|
1072
|
-
setDocIdToS3Url((prev) => ({
|
|
1073
|
-
...prev,
|
|
1074
|
-
[doc_id]: s3Url
|
|
1075
|
-
}));
|
|
1076
|
-
s3UrlFetchFlightRequests.current.delete(doc_id);
|
|
1077
|
-
return s3Url;
|
|
1078
|
-
} catch (error2) {
|
|
1079
|
-
setDocIdToS3Url((prev) => ({
|
|
1080
|
-
...prev,
|
|
1081
|
-
[doc_id]: null
|
|
1082
|
-
}));
|
|
1083
|
-
s3UrlFetchFlightRequests.current.delete(doc_id);
|
|
1084
|
-
return null;
|
|
1123
|
+
const getS3UrlForAsset = useCallback(
|
|
1124
|
+
async (doc_id) => {
|
|
1125
|
+
if (!doc_id) return null;
|
|
1126
|
+
if (docIdToS3Url[doc_id] !== void 0) {
|
|
1127
|
+
return docIdToS3Url[doc_id];
|
|
1128
|
+
}
|
|
1129
|
+
const existingRequest = s3UrlFetchFlightRequests.current.get(doc_id);
|
|
1130
|
+
if (existingRequest) {
|
|
1131
|
+
return existingRequest;
|
|
1085
1132
|
}
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1133
|
+
const request = (async () => {
|
|
1134
|
+
try {
|
|
1135
|
+
const s3Url = await getSignedUrlFromAsset(doc_id);
|
|
1136
|
+
setDocIdToS3Url((prev) => ({
|
|
1137
|
+
...prev,
|
|
1138
|
+
[doc_id]: s3Url
|
|
1139
|
+
}));
|
|
1140
|
+
s3UrlFetchFlightRequests.current.delete(doc_id);
|
|
1141
|
+
return s3Url;
|
|
1142
|
+
} catch (error2) {
|
|
1143
|
+
setDocIdToS3Url((prev) => ({
|
|
1144
|
+
...prev,
|
|
1145
|
+
[doc_id]: null
|
|
1146
|
+
}));
|
|
1147
|
+
s3UrlFetchFlightRequests.current.delete(doc_id);
|
|
1148
|
+
return null;
|
|
1149
|
+
}
|
|
1150
|
+
})();
|
|
1151
|
+
s3UrlFetchFlightRequests.current.set(doc_id, request);
|
|
1152
|
+
return request;
|
|
1153
|
+
},
|
|
1154
|
+
[docIdToS3Url]
|
|
1155
|
+
);
|
|
1090
1156
|
const acceptOrderQCTermsAndConditions = useCallback(async () => {
|
|
1091
1157
|
if (!order) return;
|
|
1092
1158
|
try {
|
|
@@ -1105,11 +1171,12 @@ var EDCFlowProvider = ({ children, orderId }) => {
|
|
|
1105
1171
|
setOrder(data.order);
|
|
1106
1172
|
}
|
|
1107
1173
|
if (data.applications && data.applications.length > 0) {
|
|
1108
|
-
const applicants2 = createApplicantsFromApplications(
|
|
1109
|
-
|
|
1110
|
-
|
|
1174
|
+
const applicants2 = createApplicantsFromApplications(data.applications, questionnaire);
|
|
1175
|
+
const { updatedQuestionnaire, updatedApplicants } = runApplicantSideEffects(
|
|
1176
|
+
applicants2,
|
|
1177
|
+
questionnaire,
|
|
1178
|
+
dynamicQuestionMap
|
|
1111
1179
|
);
|
|
1112
|
-
const { updatedQuestionnaire, updatedApplicants } = runApplicantSideEffects(applicants2, questionnaire, dynamicQuestionMap);
|
|
1113
1180
|
setQuestionnaire(updatedQuestionnaire);
|
|
1114
1181
|
setApplicants(updatedApplicants);
|
|
1115
1182
|
const applicantIds = Object.keys(updatedApplicants);
|
|
@@ -1127,36 +1194,39 @@ var EDCFlowProvider = ({ children, orderId }) => {
|
|
|
1127
1194
|
setError("Failed to run all validations");
|
|
1128
1195
|
}
|
|
1129
1196
|
}, [orderId, questionnaire, dynamicQuestionMap, activeApplicant]);
|
|
1130
|
-
const runApplicantValidationsHandler = useCallback(
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1197
|
+
const runApplicantValidationsHandler = useCallback(
|
|
1198
|
+
async (applicationId) => {
|
|
1199
|
+
if (!orderId || !questionnaire) return;
|
|
1200
|
+
try {
|
|
1201
|
+
setError(null);
|
|
1202
|
+
const { data } = await runApplicantValidations(applicationId);
|
|
1203
|
+
if (data.application) {
|
|
1204
|
+
const applicant = createApplicantData(
|
|
1205
|
+
data.application.traveller,
|
|
1206
|
+
data.application.answers,
|
|
1207
|
+
questionnaire,
|
|
1208
|
+
data.application.application
|
|
1209
|
+
);
|
|
1210
|
+
if (applicant) {
|
|
1211
|
+
setApplicants((prev) => {
|
|
1212
|
+
const updatedApplicants = {
|
|
1213
|
+
...prev,
|
|
1214
|
+
[applicationId]: applicant
|
|
1215
|
+
};
|
|
1216
|
+
const { updatedQuestionnaire, updatedApplicants: applicantsWithSideEffects } = runApplicantSideEffects(updatedApplicants, questionnaire, dynamicQuestionMap);
|
|
1217
|
+
setQuestionnaire(updatedQuestionnaire);
|
|
1218
|
+
return applicantsWithSideEffects;
|
|
1219
|
+
});
|
|
1220
|
+
}
|
|
1152
1221
|
}
|
|
1222
|
+
setSuccess("Applicant validations completed successfully");
|
|
1223
|
+
} catch (err) {
|
|
1224
|
+
console.error("Failed to run applicant validations:", err);
|
|
1225
|
+
setError("Failed to run applicant validations");
|
|
1153
1226
|
}
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
setError("Failed to run applicant validations");
|
|
1158
|
-
}
|
|
1159
|
-
}, [orderId, questionnaire, dynamicQuestionMap]);
|
|
1227
|
+
},
|
|
1228
|
+
[orderId, questionnaire, dynamicQuestionMap]
|
|
1229
|
+
);
|
|
1160
1230
|
useEffect(() => {
|
|
1161
1231
|
if (!orderId) return;
|
|
1162
1232
|
const initialize = async () => {
|
|
@@ -1169,12 +1239,13 @@ var EDCFlowProvider = ({ children, orderId }) => {
|
|
|
1169
1239
|
fetchApplicantsForOrder()
|
|
1170
1240
|
]);
|
|
1171
1241
|
if (orderData && questionnaireData && applications) {
|
|
1172
|
-
const applicants2 = createApplicantsFromApplications(
|
|
1173
|
-
applications,
|
|
1174
|
-
questionnaireData
|
|
1175
|
-
);
|
|
1242
|
+
const applicants2 = createApplicantsFromApplications(applications, questionnaireData);
|
|
1176
1243
|
const dynamicMap = buildDynamicQuestionMap(questionnaireData);
|
|
1177
|
-
const { updatedQuestionnaire, updatedApplicants } = runApplicantSideEffects(
|
|
1244
|
+
const { updatedQuestionnaire, updatedApplicants } = runApplicantSideEffects(
|
|
1245
|
+
applicants2,
|
|
1246
|
+
questionnaireData,
|
|
1247
|
+
dynamicMap
|
|
1248
|
+
);
|
|
1178
1249
|
setQuestionnaire(updatedQuestionnaire);
|
|
1179
1250
|
setApplicants(updatedApplicants);
|
|
1180
1251
|
const ids = Object.keys(updatedApplicants);
|
|
@@ -1201,6 +1272,7 @@ var EDCFlowProvider = ({ children, orderId }) => {
|
|
|
1201
1272
|
loading,
|
|
1202
1273
|
error,
|
|
1203
1274
|
success,
|
|
1275
|
+
mode,
|
|
1204
1276
|
addApplicant: addApplicant2,
|
|
1205
1277
|
updateAnswer: updateAnswer2,
|
|
1206
1278
|
deleteApplicant: deleteApplicantById,
|
|
@@ -1721,4 +1793,4 @@ var EDCFlow = {
|
|
|
1721
1793
|
};
|
|
1722
1794
|
var index_default = EDCFlow;
|
|
1723
1795
|
|
|
1724
|
-
export { ANSWER_SOURCE, APPLICATION_STATUS, APPLICATION_TAGS, AnswerSchema, ApplicationSchema, DOC_TYPES, EDCFlowProvider, FIX_TYPE, INTERNAL_ORDER_TAGS, PROCESSING_BLOCKED_ON_PAYMENT_STATUS, QUESTION_TYPE, QuestionnaireSchema, TA_QC_EXTRACTION_STATUS, TIMELINE_STEP, TimelinePaymentStatus, TravellerSchema, VALIDATION_STATUS, VISA_TYPE_INTERNAL_TAGS, createAllQuestionsWithAnswers, createApplicantData, index_default as default, filterConditionalQuestions, formatAnswerFromResponse, formatTravellerFromResponse, getDisplayableDocuments, getDisplayableQuestions, getFixTypeFromFixableItems, getSignedUrlFromAsset, getValidationErrors, getValidationResult, getVisibleQuestions, initializeEDCFlow, updateApplicantWithAnswer, useEDCFlow, validateAllApplicants, validateApplicant, validateApplicantDocuments, validateApplicantQuestions, validateOrder };
|
|
1796
|
+
export { ANSWER_SOURCE, ANSWER_STATUS, APPLICATION_STATUS, APPLICATION_TAGS, ASSET_STATUS, AnswerSchema, ApplicationSchema, DOC_TYPES, EDCFlowProvider, EDCFormMode, FIX_TYPE, INTERNAL_ORDER_TAGS, PROCESSING_BLOCKED_ON_PAYMENT_STATUS, QUESTION_TYPE, QuestionnaireSchema, TA_QC_EXTRACTION_STATUS, TIMELINE_STEP, TimelinePaymentStatus, TravellerSchema, VALIDATION_STATUS, VISA_TYPE_INTERNAL_TAGS, createAllQuestionsWithAnswers, createApplicantData, index_default as default, filterConditionalQuestions, formatAnswerFromResponse, formatTravellerFromResponse, getDisplayableDocuments, getDisplayableQuestions, getFixTypeFromFixableItems, getQuestionRenderInfo, getSignedUrlFromAsset, getValidationErrors, getValidationResult, getVisibleQuestions, initializeEDCFlow, updateApplicantWithAnswer, useEDCFlow, validateAllApplicants, validateApplicant, validateApplicantDocuments, validateApplicantQuestions, validateOrder };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smvtech/x-flux",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.17",
|
|
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",
|