@socotra/ec-react-components 2.8.0-next.2 → 2.8.0-next.4

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.ts CHANGED
@@ -3,6 +3,7 @@ import { AccountRequest } from '@socotra/ec-react-schemas';
3
3
  import { AccountResponse } from '@socotra/ec-react-schemas';
4
4
  import { ConstraintEvaluationResponse } from '@socotra/ec-react-schemas';
5
5
  import { CoverageTermsConfigRecord } from '@socotra/ec-react-schemas';
6
+ import { CreditDistributionRequest } from '@socotra/ec-react-schemas';
6
7
  import { CurrencyType } from '@socotra/ec-react-schemas';
7
8
  import { DataModel } from '@socotra/ec-react-schemas';
8
9
  import { DataTypeConfigRecord } from '@socotra/ec-react-schemas';
@@ -38,7 +39,7 @@ export declare const AccountForm: {
38
39
  * `DraftTransactionForm` is a form for updating a transaction on an issued policy. It requires a transaction in a `draft` state, a `transactionSnapshot`, `paramsChangeInstruction` (created when the transaction is created), and data types / product model / coverage terms from the tenant data model.
39
40
  */
40
41
  export declare const DraftTransactionForm: {
41
- ({ transactionSnapshot, handleSubmit, paramsChangeInstruction, modifyChangeInstruction, preventFormResetOnDisabled, disabled, hideSubmitButton, validateOnSubmit, isSubmitting, submitButtonText, id, dataTypes, productModel, coverageTerms, titles, }: Props_7): JSX_2.Element;
42
+ ({ transactionSnapshot, handleSubmit, paramsChangeInstruction, modifyChangeInstruction, preventFormResetOnDisabled, disabled, hideSubmitButton, validateOnSubmit, isSubmitting, submitButtonText, id, dataTypes, productModel, coverageTerms, titles, }: Props_8): JSX_2.Element;
42
43
  displayName: string;
43
44
  };
44
45
 
@@ -50,8 +51,11 @@ export declare const ElementForm: {
50
51
  displayName: string;
51
52
  };
52
53
 
54
+ /**
55
+ * Apply a payment to an existing invoice form
56
+ */
53
57
  export declare const ExistingPaymentForm: {
54
- (): JSX_2.Element;
58
+ ({ accountLocator, invoiceLocator, balance, currency, validateOnSubmit, hideSubmitButton, submitButtonText, handleSubmit, isSubmitting, disabled, id, titles, }: Props_6): JSX_2.Element;
55
59
  displayName: string;
56
60
  };
57
61
 
@@ -71,7 +75,7 @@ declare type GetPaymentFormDefaultFieldsProps = {
71
75
  * `InitializedTransactionForm` is a form for updating a transaction on an issued policy. It requires a transaction in an `initialized` state, the current `segment`, and data types / product model / coverage terms from the tenant data model.
72
76
  */
73
77
  export declare const InitializedTransactionForm: {
74
- ({ elementResponse, handleSubmit, paramsChangeInstruction, preventFormResetOnDisabled, disabled, hideSubmitButton, validateOnSubmit, isSubmitting, submitButtonText, id, dataTypes, productModel, coverageTerms, titles, }: Props_6): JSX_2.Element;
78
+ ({ elementResponse, handleSubmit, paramsChangeInstruction, preventFormResetOnDisabled, disabled, hideSubmitButton, validateOnSubmit, isSubmitting, submitButtonText, id, dataTypes, productModel, coverageTerms, titles, getEvaluatedConstraints, dependencyMap, }: Props_7): JSX_2.Element;
75
79
  displayName: string;
76
80
  };
77
81
 
@@ -220,6 +224,44 @@ declare type Props_2 = {
220
224
  * ID for the form wrapper
221
225
  * */
222
226
  id?: string;
227
+ /**
228
+ * The dependency map for the quote's constraints (if any)
229
+ *
230
+ * This map must be provided to enable the form to evaluate constraints, retrieved by
231
+ *
232
+ * @example
233
+ * const dependencyMap = await fetch(`/policy/${tenantLocator}/quotes/${locator}/constraints/dependency`, {
234
+ * method: "GET",
235
+ * headers: {
236
+ * Authorization: `Bearer ${token}`,
237
+ * "Content-Type": "application/json",
238
+ * }
239
+ * });
240
+ */
241
+ dependencyMap?: QuoteDependencyMapResponse;
242
+ /**
243
+ * Evaluates constraints for the quote to determine the values of other fields
244
+ *
245
+ * This function must be provided to enable the form to evaluate constraints
246
+ *
247
+ * @param {object} request - The request object containing the quote locator
248
+ * @param {string} tenantLocator - The tenant locator
249
+ * @param {string} locator - The locator of the element to evaluate constraints for
250
+ * @example
251
+ * const getEvaluatedConstraints = async (request: EvaluateConstraintsRequest, tenantLocator: string, locator: string) => {
252
+ * const response = await fetch(`/policy/${tenantLocator}/quotes/${locator}/constraints/evaluate`, {
253
+ * method: "POST",
254
+ * body: JSON.stringify(request),
255
+ * headers: {
256
+ * Authorization: `Bearer ${token}`,
257
+ * "Content-Type": "application/json",
258
+ * }
259
+ * });
260
+ * const data = await response.json();
261
+ * return data;
262
+ * }
263
+ */
264
+ getEvaluatedConstraints?: (request: EvaluateConstraintsRequest, tenantLocator: string, locator: string) => Promise<ConstraintEvaluationResponse | undefined>;
223
265
  /**
224
266
  * Titles for the form
225
267
  */
@@ -420,6 +462,61 @@ declare type Props_5 = {
420
462
  };
421
463
 
422
464
  declare type Props_6 = {
465
+ /**
466
+ * Account locator
467
+ */
468
+ accountLocator: string;
469
+ /**
470
+ * Invoice locator
471
+ */
472
+ invoiceLocator: string;
473
+ /**
474
+ * The currency of the invoice
475
+ */
476
+ currency: CurrencyType;
477
+ /**
478
+ * Account balance
479
+ */
480
+ balance: number;
481
+ /**
482
+ * The function to call when the form is submitted. It will create an CreditDistributionRequest from the form data.
483
+ */
484
+ handleSubmit: (data: CreditDistributionRequest) => void;
485
+ /**
486
+ * Set to true when the form is submitting to set fields to readonly and disable the submit button
487
+ */
488
+ isSubmitting?: boolean;
489
+ /**
490
+ * Disables the form
491
+ */
492
+ disabled?: boolean;
493
+ /**
494
+ * Hides the submit button
495
+ */
496
+ hideSubmitButton?: boolean;
497
+ /**
498
+ * Whether to validate the form on submit
499
+ */
500
+ validateOnSubmit?: boolean;
501
+ /**
502
+ * The text to display on the submit button
503
+ */
504
+ submitButtonText?: string;
505
+ /**
506
+ * ID for the form wrapper
507
+ * */
508
+ id?: string;
509
+ /**
510
+ * Titles
511
+ */
512
+ titles?: {
513
+ formTitle?: string;
514
+ balance?: string;
515
+ amountToApply?: string;
516
+ };
517
+ };
518
+
519
+ declare type Props_7 = {
423
520
  /**
424
521
  * The transaction snapshot object
425
522
  */
@@ -477,6 +574,44 @@ declare type Props_6 = {
477
574
  * ID for the form wrapper
478
575
  * */
479
576
  id?: string;
577
+ /**
578
+ * The dependency map for the quote's constraints (if any)
579
+ *
580
+ * This map must be provided to enable the form to evaluate constraints, retrieved by
581
+ *
582
+ * @example
583
+ * const dependencyMap = await fetch(`/policy/${tenantLocator}/quotes/${locator}/constraints/dependency`, {
584
+ * method: "GET",
585
+ * headers: {
586
+ * Authorization: `Bearer ${token}`,
587
+ * "Content-Type": "application/json",
588
+ * }
589
+ * });
590
+ */
591
+ dependencyMap?: QuoteDependencyMapResponse;
592
+ /**
593
+ * Evaluates constraints for the quote to determine the values of other fields
594
+ *
595
+ * This function must be provided to enable the form to evaluate constraints
596
+ *
597
+ * @param {object} request - The request object containing the quote locator
598
+ * @param {string} tenantLocator - The tenant locator
599
+ * @param {string} locator - The locator of the element to evaluate constraints for
600
+ * @example
601
+ * const getEvaluatedConstraints = async (request: EvaluateConstraintsRequest, tenantLocator: string, locator: string) => {
602
+ * const response = await fetch(`/policy/${tenantLocator}/quotes/${locator}/constraints/evaluate`, {
603
+ * method: "POST",
604
+ * body: JSON.stringify(request),
605
+ * headers: {
606
+ * Authorization: `Bearer ${token}`,
607
+ * "Content-Type": "application/json",
608
+ * }
609
+ * });
610
+ * const data = await response.json();
611
+ * return data;
612
+ * }
613
+ */
614
+ getEvaluatedConstraints?: (request: EvaluateConstraintsRequest, tenantLocator: string, locator: string) => Promise<ConstraintEvaluationResponse | undefined>;
480
615
  /**
481
616
  * Form titles
482
617
  */
@@ -486,7 +621,7 @@ declare type Props_6 = {
486
621
  };
487
622
  };
488
623
 
489
- declare type Props_7 = {
624
+ declare type Props_8 = {
490
625
  /**
491
626
  * The transaction snapshot object
492
627
  */
@@ -560,7 +695,7 @@ declare type Props_7 = {
560
695
  * QuoteForm is a form for updating a quote. It required a product data model, custom data types, and quote object to render the form.
561
696
  */
562
697
  export declare const QuoteForm: {
563
- ({ quote, dataModel, dataTypes, disabled, handleSubmit, isSubmitting, preventFormResetOnDisabled, validateOnSubmit, hideSubmitButton, submitButtonText, id, titles, }: Props_2): JSX_2.Element;
698
+ ({ quote, dataModel, dataTypes, disabled, handleSubmit, isSubmitting, preventFormResetOnDisabled, validateOnSubmit, hideSubmitButton, submitButtonText, id, titles, getEvaluatedConstraints, dependencyMap, }: Props_2): JSX_2.Element;
564
699
  displayName: string;
565
700
  };
566
701