@socotra/ec-react-components 2.8.0-next.3 → 2.8.0-next.5

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
@@ -4,6 +4,7 @@ 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
6
  import { CreditDistributionRequest } from '@socotra/ec-react-schemas';
7
+ import { CreditDistributionReverseRequest } from '@socotra/ec-react-schemas';
7
8
  import { CurrencyType } from '@socotra/ec-react-schemas';
8
9
  import { DataModel } from '@socotra/ec-react-schemas';
9
10
  import { DataTypeConfigRecord } from '@socotra/ec-react-schemas';
@@ -23,6 +24,7 @@ import { ProductConfig } from '@socotra/ec-react-schemas';
23
24
  import { QuoteDependencyMapResponse } from '@socotra/ec-react-schemas';
24
25
  import { QuoteRequest } from '@socotra/ec-react-schemas';
25
26
  import { QuoteResponse } from '@socotra/ec-react-schemas';
27
+ import { ReversalTypeConfigRecord } from '@socotra/ec-react-schemas';
26
28
  import { SegmentResponse } from '@socotra/ec-react-schemas';
27
29
  import { TransactionMethodEnum } from '@socotra/ec-react-schemas';
28
30
  import { TransactionSnapshotResponse } from '@socotra/ec-react-schemas';
@@ -39,7 +41,7 @@ export declare const AccountForm: {
39
41
  * `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.
40
42
  */
41
43
  export declare const DraftTransactionForm: {
42
- ({ transactionSnapshot, handleSubmit, paramsChangeInstruction, modifyChangeInstruction, preventFormResetOnDisabled, disabled, hideSubmitButton, validateOnSubmit, isSubmitting, submitButtonText, id, dataTypes, productModel, coverageTerms, titles, }: Props_8): JSX_2.Element;
44
+ ({ transactionSnapshot, handleSubmit, paramsChangeInstruction, modifyChangeInstruction, preventFormResetOnDisabled, disabled, hideSubmitButton, validateOnSubmit, isSubmitting, submitButtonText, id, dataTypes, productModel, coverageTerms, titles, }: Props_9): JSX_2.Element;
43
45
  displayName: string;
44
46
  };
45
47
 
@@ -75,7 +77,7 @@ declare type GetPaymentFormDefaultFieldsProps = {
75
77
  * `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.
76
78
  */
77
79
  export declare const InitializedTransactionForm: {
78
- ({ elementResponse, handleSubmit, paramsChangeInstruction, preventFormResetOnDisabled, disabled, hideSubmitButton, validateOnSubmit, isSubmitting, submitButtonText, id, dataTypes, productModel, coverageTerms, titles, }: Props_7): JSX_2.Element;
80
+ ({ elementResponse, handleSubmit, paramsChangeInstruction, preventFormResetOnDisabled, disabled, hideSubmitButton, validateOnSubmit, isSubmitting, submitButtonText, id, dataTypes, productModel, coverageTerms, titles, getEvaluatedConstraints, dependencyMap, }: Props_8): JSX_2.Element;
79
81
  displayName: string;
80
82
  };
81
83
 
@@ -224,6 +226,44 @@ declare type Props_2 = {
224
226
  * ID for the form wrapper
225
227
  * */
226
228
  id?: string;
229
+ /**
230
+ * The dependency map for the quote's constraints (if any)
231
+ *
232
+ * This map must be provided to enable the form to evaluate constraints, retrieved by
233
+ *
234
+ * @example
235
+ * const dependencyMap = await fetch(`/policy/${tenantLocator}/quotes/${locator}/constraints/dependency`, {
236
+ * method: "GET",
237
+ * headers: {
238
+ * Authorization: `Bearer ${token}`,
239
+ * "Content-Type": "application/json",
240
+ * }
241
+ * });
242
+ */
243
+ dependencyMap?: QuoteDependencyMapResponse;
244
+ /**
245
+ * Evaluates constraints for the quote to determine the values of other fields
246
+ *
247
+ * This function must be provided to enable the form to evaluate constraints
248
+ *
249
+ * @param {object} request - The request object containing the quote locator
250
+ * @param {string} tenantLocator - The tenant locator
251
+ * @param {string} locator - The locator of the element to evaluate constraints for
252
+ * @example
253
+ * const getEvaluatedConstraints = async (request: EvaluateConstraintsRequest, tenantLocator: string, locator: string) => {
254
+ * const response = await fetch(`/policy/${tenantLocator}/quotes/${locator}/constraints/evaluate`, {
255
+ * method: "POST",
256
+ * body: JSON.stringify(request),
257
+ * headers: {
258
+ * Authorization: `Bearer ${token}`,
259
+ * "Content-Type": "application/json",
260
+ * }
261
+ * });
262
+ * const data = await response.json();
263
+ * return data;
264
+ * }
265
+ */
266
+ getEvaluatedConstraints?: (request: EvaluateConstraintsRequest, tenantLocator: string, locator: string) => Promise<ConstraintEvaluationResponse | undefined>;
227
267
  /**
228
268
  * Titles for the form
229
269
  */
@@ -479,6 +519,57 @@ declare type Props_6 = {
479
519
  };
480
520
 
481
521
  declare type Props_7 = {
522
+ /**
523
+ * Amount to reverse
524
+ */
525
+ amount: number;
526
+ /**
527
+ * The currency of the invoice
528
+ */
529
+ currency: CurrencyType;
530
+ /**
531
+ * The reversal types retrieved from data model
532
+ */
533
+ reversalTypes: ReversalTypeConfigRecord;
534
+ /**
535
+ * The function to call when the form is submitted. It will create an CreditDistributionReverseRequest from the form data.
536
+ */
537
+ handleSubmit: (data: CreditDistributionReverseRequest) => void;
538
+ /**
539
+ * Set to true when the form is submitting to set fields to readonly and disable the submit button
540
+ */
541
+ isSubmitting?: boolean;
542
+ /**
543
+ * Disables the form
544
+ */
545
+ disabled?: boolean;
546
+ /**
547
+ * Hides the submit button
548
+ */
549
+ hideSubmitButton?: boolean;
550
+ /**
551
+ * Whether to validate the form on submit
552
+ */
553
+ validateOnSubmit?: boolean;
554
+ /**
555
+ * The text to display on the submit button
556
+ */
557
+ submitButtonText?: string;
558
+ /**
559
+ * ID for the form wrapper
560
+ * */
561
+ id?: string;
562
+ /**
563
+ * Titles
564
+ */
565
+ titles?: {
566
+ formTitle?: string;
567
+ reversalType?: string;
568
+ amountToReverse?: string;
569
+ };
570
+ };
571
+
572
+ declare type Props_8 = {
482
573
  /**
483
574
  * The transaction snapshot object
484
575
  */
@@ -536,6 +627,44 @@ declare type Props_7 = {
536
627
  * ID for the form wrapper
537
628
  * */
538
629
  id?: string;
630
+ /**
631
+ * The dependency map for the quote's constraints (if any)
632
+ *
633
+ * This map must be provided to enable the form to evaluate constraints, retrieved by
634
+ *
635
+ * @example
636
+ * const dependencyMap = await fetch(`/policy/${tenantLocator}/quotes/${locator}/constraints/dependency`, {
637
+ * method: "GET",
638
+ * headers: {
639
+ * Authorization: `Bearer ${token}`,
640
+ * "Content-Type": "application/json",
641
+ * }
642
+ * });
643
+ */
644
+ dependencyMap?: QuoteDependencyMapResponse;
645
+ /**
646
+ * Evaluates constraints for the quote to determine the values of other fields
647
+ *
648
+ * This function must be provided to enable the form to evaluate constraints
649
+ *
650
+ * @param {object} request - The request object containing the quote locator
651
+ * @param {string} tenantLocator - The tenant locator
652
+ * @param {string} locator - The locator of the element to evaluate constraints for
653
+ * @example
654
+ * const getEvaluatedConstraints = async (request: EvaluateConstraintsRequest, tenantLocator: string, locator: string) => {
655
+ * const response = await fetch(`/policy/${tenantLocator}/quotes/${locator}/constraints/evaluate`, {
656
+ * method: "POST",
657
+ * body: JSON.stringify(request),
658
+ * headers: {
659
+ * Authorization: `Bearer ${token}`,
660
+ * "Content-Type": "application/json",
661
+ * }
662
+ * });
663
+ * const data = await response.json();
664
+ * return data;
665
+ * }
666
+ */
667
+ getEvaluatedConstraints?: (request: EvaluateConstraintsRequest, tenantLocator: string, locator: string) => Promise<ConstraintEvaluationResponse | undefined>;
539
668
  /**
540
669
  * Form titles
541
670
  */
@@ -545,7 +674,7 @@ declare type Props_7 = {
545
674
  };
546
675
  };
547
676
 
548
- declare type Props_8 = {
677
+ declare type Props_9 = {
549
678
  /**
550
679
  * The transaction snapshot object
551
680
  */
@@ -619,7 +748,15 @@ declare type Props_8 = {
619
748
  * QuoteForm is a form for updating a quote. It required a product data model, custom data types, and quote object to render the form.
620
749
  */
621
750
  export declare const QuoteForm: {
622
- ({ quote, dataModel, dataTypes, disabled, handleSubmit, isSubmitting, preventFormResetOnDisabled, validateOnSubmit, hideSubmitButton, submitButtonText, id, titles, }: Props_2): JSX_2.Element;
751
+ ({ quote, dataModel, dataTypes, disabled, handleSubmit, isSubmitting, preventFormResetOnDisabled, validateOnSubmit, hideSubmitButton, submitButtonText, id, titles, getEvaluatedConstraints, dependencyMap, }: Props_2): JSX_2.Element;
752
+ displayName: string;
753
+ };
754
+
755
+ /**
756
+ * Apply a payment to an existing invoice form
757
+ */
758
+ export declare const ReversePaymentForm: {
759
+ ({ amount, reversalTypes, currency, validateOnSubmit, hideSubmitButton, submitButtonText, handleSubmit, isSubmitting, disabled, id, titles, }: Props_7): JSX_2.Element;
623
760
  displayName: string;
624
761
  };
625
762