@kanda-libs/ks-component-ts 0.2.256 → 0.2.258

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/library.css CHANGED
@@ -797,6 +797,12 @@ input[type="number"]::-webkit-inner-spin-button,
797
797
  line-height: 24px;
798
798
  }
799
799
 
800
+ .text-16-20-em {
801
+ font-weight: 600;
802
+ font-size: 16px;
803
+ line-height: 20px;
804
+ }
805
+
800
806
  .text-16-18 {
801
807
  font-weight: 400;
802
808
  font-size: 16px;
@@ -827,6 +833,13 @@ input[type="number"]::-webkit-inner-spin-button,
827
833
  line-height: 18px;
828
834
  }
829
835
 
836
+ .text-10-17-em-up {
837
+ font-weight: 600;
838
+ font-size: 10px;
839
+ line-height: 17px;
840
+ text-transform: uppercase;
841
+ }
842
+
830
843
  .text-10-14-em {
831
844
  font-weight: 600;
832
845
  font-size: 10px;
@@ -1163,14 +1176,22 @@ input[type="number"]::-webkit-inner-spin-button,
1163
1176
  margin-bottom: 12px;
1164
1177
  }
1165
1178
 
1166
- .mt-6 {
1167
- margin-top: 24px;
1168
- }
1169
-
1170
1179
  .mb-6 {
1171
1180
  margin-bottom: 24px;
1172
1181
  }
1173
1182
 
1183
+ .mr-4 {
1184
+ margin-right: 16px;
1185
+ }
1186
+
1187
+ .ml-6 {
1188
+ margin-left: 24px;
1189
+ }
1190
+
1191
+ .mt-6 {
1192
+ margin-top: 24px;
1193
+ }
1194
+
1174
1195
  .mt-2 {
1175
1196
  margin-top: 8px;
1176
1197
  }
@@ -1219,10 +1240,6 @@ input[type="number"]::-webkit-inner-spin-button,
1219
1240
  margin-top: -12px;
1220
1241
  }
1221
1242
 
1222
- .mr-4 {
1223
- margin-right: 16px;
1224
- }
1225
-
1226
1243
  .-mt-1 {
1227
1244
  margin-top: -4px;
1228
1245
  }
@@ -1447,6 +1464,10 @@ input[type="number"]::-webkit-inner-spin-button,
1447
1464
  display: none;
1448
1465
  }
1449
1466
 
1467
+ .h-full {
1468
+ height: 100%;
1469
+ }
1470
+
1450
1471
  .h-screen {
1451
1472
  height: 100vh;
1452
1473
  }
@@ -1474,10 +1495,6 @@ input[type="number"]::-webkit-inner-spin-button,
1474
1495
  height: 40px;
1475
1496
  }
1476
1497
 
1477
- .h-full {
1478
- height: 100%;
1479
- }
1480
-
1481
1498
  .h-table {
1482
1499
  height: 696px;
1483
1500
  }
@@ -1590,6 +1607,10 @@ input[type="number"]::-webkit-inner-spin-button,
1590
1607
  max-height: 256px;
1591
1608
  }
1592
1609
 
1610
+ .min-h-30 {
1611
+ min-height: 120px;
1612
+ }
1613
+
1593
1614
  .min-h-20 {
1594
1615
  min-height: 80px;
1595
1616
  }
@@ -1602,14 +1623,14 @@ input[type="number"]::-webkit-inner-spin-button,
1602
1623
  min-height: 100%;
1603
1624
  }
1604
1625
 
1605
- .w-screen {
1606
- width: 100vw;
1607
- }
1608
-
1609
1626
  .w-full {
1610
1627
  width: 100%;
1611
1628
  }
1612
1629
 
1630
+ .w-screen {
1631
+ width: 100vw;
1632
+ }
1633
+
1613
1634
  .w-2\/6 {
1614
1635
  width: 33.333333%;
1615
1636
  }
@@ -1811,6 +1832,10 @@ input[type="number"]::-webkit-inner-spin-button,
1811
1832
  flex-shrink: 1;
1812
1833
  }
1813
1834
 
1835
+ .flex-grow {
1836
+ flex-grow: 1;
1837
+ }
1838
+
1814
1839
  .basis-1\/3 {
1815
1840
  flex-basis: 33.333333%;
1816
1841
  }
@@ -1995,6 +2020,10 @@ input[type="number"]::-webkit-inner-spin-button,
1995
2020
  align-items: center;
1996
2021
  }
1997
2022
 
2023
+ .items-stretch {
2024
+ align-items: stretch;
2025
+ }
2026
+
1998
2027
  .justify-start {
1999
2028
  justify-content: flex-start;
2000
2029
  }
@@ -2015,6 +2044,15 @@ input[type="number"]::-webkit-inner-spin-button,
2015
2044
  justify-items: center;
2016
2045
  }
2017
2046
 
2047
+ .gap-x-1 {
2048
+ -moz-column-gap: 4px;
2049
+ column-gap: 4px;
2050
+ }
2051
+
2052
+ .gap-y-1 {
2053
+ row-gap: 4px;
2054
+ }
2055
+
2018
2056
  .gap-x-2 {
2019
2057
  -moz-column-gap: 8px;
2020
2058
  column-gap: 8px;
@@ -2064,6 +2102,10 @@ input[type="number"]::-webkit-inner-spin-button,
2064
2102
  word-break: break-all;
2065
2103
  }
2066
2104
 
2105
+ .rounded-xl {
2106
+ border-radius: 0.75rem;
2107
+ }
2108
+
2067
2109
  .rounded-3xl {
2068
2110
  border-radius: 1.5rem;
2069
2111
  }
@@ -2096,10 +2138,6 @@ input[type="number"]::-webkit-inner-spin-button,
2096
2138
  border-radius: 0.25rem !important;
2097
2139
  }
2098
2140
 
2099
- .rounded-xl {
2100
- border-radius: 0.75rem;
2101
- }
2102
-
2103
2141
  .rounded-b-xl {
2104
2142
  border-bottom-right-radius: 0.75rem;
2105
2143
  border-bottom-left-radius: 0.75rem;
@@ -2128,14 +2166,14 @@ input[type="number"]::-webkit-inner-spin-button,
2128
2166
  border-bottom-left-radius: 0.5rem;
2129
2167
  }
2130
2168
 
2131
- .border-2 {
2132
- border-width: 2px;
2133
- }
2134
-
2135
2169
  .border {
2136
2170
  border-width: 1px;
2137
2171
  }
2138
2172
 
2173
+ .border-2 {
2174
+ border-width: 2px;
2175
+ }
2176
+
2139
2177
  .\!border-0 {
2140
2178
  border-width: 0px !important;
2141
2179
  }
@@ -2176,6 +2214,11 @@ input[type="number"]::-webkit-inner-spin-button,
2176
2214
  border-style: dashed;
2177
2215
  }
2178
2216
 
2217
+ .border-neutral-300 {
2218
+ --tw-border-opacity: 1;
2219
+ border-color: rgb(224 231 240 / var(--tw-border-opacity));
2220
+ }
2221
+
2179
2222
  .border-turquoise-300 {
2180
2223
  --tw-border-opacity: 1;
2181
2224
  border-color: rgb(39 222 191 / var(--tw-border-opacity));
@@ -2190,11 +2233,6 @@ input[type="number"]::-webkit-inner-spin-button,
2190
2233
  border-color: rgb(233 63 63 / var(--tw-border-opacity));
2191
2234
  }
2192
2235
 
2193
- .border-neutral-300 {
2194
- --tw-border-opacity: 1;
2195
- border-color: rgb(224 231 240 / var(--tw-border-opacity));
2196
- }
2197
-
2198
2236
  .border-neutral-200 {
2199
2237
  --tw-border-opacity: 1;
2200
2238
  border-color: rgb(237 241 247 / var(--tw-border-opacity));
@@ -2245,6 +2283,11 @@ input[type="number"]::-webkit-inner-spin-button,
2245
2283
  border-color: rgb(229 245 255 / var(--tw-border-opacity));
2246
2284
  }
2247
2285
 
2286
+ .bg-neutral-100 {
2287
+ --tw-bg-opacity: 1;
2288
+ background-color: rgb(247 249 252 / var(--tw-bg-opacity));
2289
+ }
2290
+
2248
2291
  .bg-turquoise-200 {
2249
2292
  --tw-bg-opacity: 1;
2250
2293
  background-color: rgb(193 244 233 / var(--tw-bg-opacity));
@@ -2255,11 +2298,6 @@ input[type="number"]::-webkit-inner-spin-button,
2255
2298
  background-color: rgb(39 222 191 / var(--tw-bg-opacity));
2256
2299
  }
2257
2300
 
2258
- .bg-neutral-100 {
2259
- --tw-bg-opacity: 1;
2260
- background-color: rgb(247 249 252 / var(--tw-bg-opacity));
2261
- }
2262
-
2263
2301
  .bg-neutral-000 {
2264
2302
  --tw-bg-opacity: 1;
2265
2303
  background-color: rgb(255 255 255 / var(--tw-bg-opacity));
@@ -2438,6 +2476,10 @@ input[type="number"]::-webkit-inner-spin-button,
2438
2476
  object-fit: contain;
2439
2477
  }
2440
2478
 
2479
+ .p-4 {
2480
+ padding: 16px;
2481
+ }
2482
+
2441
2483
  .p-2 {
2442
2484
  padding: 8px;
2443
2485
  }
@@ -2450,10 +2492,6 @@ input[type="number"]::-webkit-inner-spin-button,
2450
2492
  padding: 12px;
2451
2493
  }
2452
2494
 
2453
- .p-4 {
2454
- padding: 16px;
2455
- }
2456
-
2457
2495
  .p-1\.5 {
2458
2496
  padding: 6px;
2459
2497
  }
@@ -2470,6 +2508,11 @@ input[type="number"]::-webkit-inner-spin-button,
2470
2508
  padding: 32px;
2471
2509
  }
2472
2510
 
2511
+ .py-4 {
2512
+ padding-top: 16px;
2513
+ padding-bottom: 16px;
2514
+ }
2515
+
2473
2516
  .px-4 {
2474
2517
  padding-left: 16px;
2475
2518
  padding-right: 16px;
@@ -2500,11 +2543,6 @@ input[type="number"]::-webkit-inner-spin-button,
2500
2543
  padding-bottom: 4px;
2501
2544
  }
2502
2545
 
2503
- .py-4 {
2504
- padding-top: 16px;
2505
- padding-bottom: 16px;
2506
- }
2507
-
2508
2546
  .px-3 {
2509
2547
  padding-left: 12px;
2510
2548
  padding-right: 12px;
@@ -2590,6 +2628,14 @@ input[type="number"]::-webkit-inner-spin-button,
2590
2628
  padding-bottom: 20px;
2591
2629
  }
2592
2630
 
2631
+ .pr-4 {
2632
+ padding-right: 16px;
2633
+ }
2634
+
2635
+ .pb-2 {
2636
+ padding-bottom: 8px;
2637
+ }
2638
+
2593
2639
  .pt-1 {
2594
2640
  padding-top: 4px;
2595
2641
  }
@@ -2602,10 +2648,6 @@ input[type="number"]::-webkit-inner-spin-button,
2602
2648
  padding-top: 0;
2603
2649
  }
2604
2650
 
2605
- .pr-4 {
2606
- padding-right: 16px;
2607
- }
2608
-
2609
2651
  .\!pr-7 {
2610
2652
  padding-right: 28px !important;
2611
2653
  }
@@ -2735,29 +2777,29 @@ input[type="number"]::-webkit-inner-spin-button,
2735
2777
  color: rgb(156 173 196 / var(--tw-text-opacity));
2736
2778
  }
2737
2779
 
2738
- .text-neutral-800 {
2780
+ .text-neutral-700 {
2739
2781
  --tw-text-opacity: 1;
2740
- color: rgb(45 61 83 / var(--tw-text-opacity));
2782
+ color: rgb(71 90 118 / var(--tw-text-opacity));
2741
2783
  }
2742
2784
 
2743
- .text-neutral-900 {
2785
+ .text-neutral-600 {
2744
2786
  --tw-text-opacity: 1;
2745
- color: rgb(13 27 46 / var(--tw-text-opacity));
2787
+ color: rgb(108 129 157 / var(--tw-text-opacity));
2746
2788
  }
2747
2789
 
2748
- .text-red-200 {
2790
+ .text-neutral-800 {
2749
2791
  --tw-text-opacity: 1;
2750
- color: rgb(233 63 63 / var(--tw-text-opacity));
2792
+ color: rgb(45 61 83 / var(--tw-text-opacity));
2751
2793
  }
2752
2794
 
2753
- .text-neutral-600 {
2795
+ .text-neutral-900 {
2754
2796
  --tw-text-opacity: 1;
2755
- color: rgb(108 129 157 / var(--tw-text-opacity));
2797
+ color: rgb(13 27 46 / var(--tw-text-opacity));
2756
2798
  }
2757
2799
 
2758
- .text-neutral-700 {
2800
+ .text-red-200 {
2759
2801
  --tw-text-opacity: 1;
2760
- color: rgb(71 90 118 / var(--tw-text-opacity));
2802
+ color: rgb(233 63 63 / var(--tw-text-opacity));
2761
2803
  }
2762
2804
 
2763
2805
  .text-neutral-200 {
@@ -4324,6 +4366,10 @@ input[type="checkbox"][disabled]:checked ~ .label-checked-disabled\:bg-neutral-3
4324
4366
  width: auto;
4325
4367
  }
4326
4368
 
4369
+ .md\:min-w-96 {
4370
+ min-width: 384px;
4371
+ }
4372
+
4327
4373
  .md\:min-w-20 {
4328
4374
  min-width: 80px;
4329
4375
  }
@@ -4332,6 +4378,10 @@ input[type="checkbox"][disabled]:checked ~ .label-checked-disabled\:bg-neutral-3
4332
4378
  flex-direction: row;
4333
4379
  }
4334
4380
 
4381
+ .md\:border-r {
4382
+ border-right-width: 1px;
4383
+ }
4384
+
4335
4385
  .md\:py-1\.5 {
4336
4386
  padding-top: 6px;
4337
4387
  padding-bottom: 6px;
@@ -4342,6 +4392,10 @@ input[type="checkbox"][disabled]:checked ~ .label-checked-disabled\:bg-neutral-3
4342
4392
  padding-bottom: 4px;
4343
4393
  }
4344
4394
 
4395
+ .md\:pb-0 {
4396
+ padding-bottom: 0;
4397
+ }
4398
+
4345
4399
  .md\:pt-1 {
4346
4400
  padding-top: 4px;
4347
4401
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kanda-libs/ks-component-ts",
3
- "version": "0.2.256",
3
+ "version": "0.2.258",
4
4
  "description": "Kanda form component library",
5
5
  "main": "dist/index.esm.js",
6
6
  "module": "dist/index.esm.js",
@@ -52,6 +52,7 @@
52
52
  "@types/react-dom": "^17.0.11",
53
53
  "@types/react-highlight-words": "^0.16.4",
54
54
  "@types/react-input-autosize": "^2.2.1",
55
+ "@types/react-router-dom": "^5.3.3",
55
56
  "@types/react-slick": "^0.23.10",
56
57
  "@types/react-table": "^7.7.0",
57
58
  "@typescript-eslint/eslint-plugin": "^5.14.0",
@@ -135,6 +136,7 @@
135
136
  "react-loading-skeleton": "^3.1.0",
136
137
  "react-number-format": "^4.6.4",
137
138
  "react-range": "^1.8.14",
139
+ "react-router-dom": "^5.2.0",
138
140
  "react-slick": "^0.29.0",
139
141
  "react-table": "^7.7.0",
140
142
  "react-textarea-autosize": "^8.4.0",
@@ -0,0 +1,37 @@
1
+ import type { SkeletonLoaderProps } from "@kanda-libs/ks-design-library";
2
+
3
+ export const CLASS_NAMES = {
4
+ title: "mb-6 block text-neutral-700 text-sm",
5
+ wrapper: {
6
+ base: "p-4 border border-solid border-neutral-300 rounded-xl md:min-w-96 min-h-30 cursor-pointer",
7
+ muted:
8
+ "p-4 bg-neutral-100 rounded-xl md:min-w-96 min-h-30 cursor-pointer flex flex-col items-stretch justify-stretch",
9
+ },
10
+ price: {
11
+ base: "text-16-20-em",
12
+ muted: "text-neutral-600 text-16-20-em",
13
+ },
14
+ innerWrapper: "flex flex-col md:flex-row items-start justify-center",
15
+ credit:
16
+ "py-4 flex flex-col items-start justify-start h-full pr-4 mr-4 uppercase md:border-r border-solid border-neutral-300 h-full pb-2 md:pb-0",
17
+ terms: "flex flex-row items-center justify-center flex-grow",
18
+ termsInnerWrapper: "grid grid-cols-2 gap-x-1 gap-y-1 flex-grow",
19
+ termsValues: "flex flex-row items-center gap-x-2",
20
+ termsLoading:
21
+ "w-full text-left flex flex-col items-start justify-start h-full",
22
+ termsLabel: "text-10-17-em-up block uppercase text-neutral-600",
23
+ termsValue: "text-16-20-em text-neutral-600",
24
+ termsItem: "text-left",
25
+ checkbox: "ml-6",
26
+ };
27
+
28
+ export const TERMS_PRICE_PROPS = {
29
+ poundsClassName: CLASS_NAMES.termsValue,
30
+ centsClassName: CLASS_NAMES.termsValue,
31
+ };
32
+
33
+ export const SKELETON_PROPS: Partial<SkeletonLoaderProps> = {
34
+ width: 100,
35
+ height: 20,
36
+ isLoading: true,
37
+ };
@@ -0,0 +1,35 @@
1
+ import type { FinanceRate } from "~/generated/components/schemas";
2
+
3
+ /**
4
+ * Calculates Loan from total and payment method
5
+ */
6
+ export const getMonthlyPayment = (paymentMethod?: FinanceRate): number => {
7
+ if (!paymentMethod) return 0;
8
+
9
+ const total = paymentMethod.credit_line || 0;
10
+
11
+ const { apr = 0, duration = 0 } = paymentMethod;
12
+
13
+ const rate = apr / 100 / 12 / 100;
14
+
15
+ if (rate === 0) return Math.ceil(total / duration);
16
+
17
+ const compoundInterest = (1 + rate) ** duration;
18
+
19
+ const monthlyLoan =
20
+ (total * (rate * compoundInterest)) / (compoundInterest - 1);
21
+
22
+ return Math.ceil(monthlyLoan);
23
+ };
24
+
25
+ export const getTotalInterestFee = (
26
+ monthlyPayment: number,
27
+ paymentMethod?: FinanceRate
28
+ ): number => {
29
+ if (paymentMethod?.apr === 0) return 0;
30
+
31
+ const totalLoanCost = monthlyPayment * (paymentMethod?.duration || 0);
32
+ const totalInterestFee = totalLoanCost - (paymentMethod?.credit_line || 0);
33
+
34
+ return totalInterestFee;
35
+ };
@@ -0,0 +1,141 @@
1
+ import React, { type FunctionComponent } from "react";
2
+ import { Price, SkeletonLoader, Text } from "@kanda-libs/ks-design-library";
3
+ import type { GroupedFinanceRate } from "./types";
4
+ import { CLASS_NAMES, SKELETON_PROPS, TERMS_PRICE_PROPS } from "./constants";
5
+ import { FieldHandle } from "..";
6
+
7
+ export interface CreditLineProps {
8
+ name?: string;
9
+ title?: string;
10
+ financeOptionGroup?: GroupedFinanceRate;
11
+ isLoading?: boolean;
12
+ muted?: boolean;
13
+ selected?: boolean;
14
+ selectable?: boolean;
15
+ onSelect?: (name: string) => void;
16
+ }
17
+
18
+ const CreditLine: FunctionComponent<CreditLineProps> = function ({
19
+ name,
20
+ title,
21
+ financeOptionGroup,
22
+ isLoading = false,
23
+ muted = false,
24
+ selected = false,
25
+ selectable = false,
26
+ onSelect = () => {},
27
+ }) {
28
+ const classKey = muted ? "muted" : "base";
29
+
30
+ return (
31
+ <div
32
+ role="button"
33
+ tabIndex={0}
34
+ className={CLASS_NAMES.wrapper[classKey]}
35
+ onClick={() => {
36
+ onSelect(name as string);
37
+ }}
38
+ onKeyUp={() => {
39
+ onSelect(name as string);
40
+ }}
41
+ >
42
+ {title && <Text className={CLASS_NAMES.title} text={title} />}
43
+ <div className={CLASS_NAMES.innerWrapper}>
44
+ {isLoading && (
45
+ <div className={CLASS_NAMES.credit}>
46
+ <SkeletonLoader {...SKELETON_PROPS} />
47
+ <SkeletonLoader {...SKELETON_PROPS} />
48
+ </div>
49
+ )}
50
+ {!isLoading && (
51
+ <div className={CLASS_NAMES.credit}>
52
+ <Text text="Max credit line" className={CLASS_NAMES.termsLabel} />
53
+ <div>
54
+ <Price
55
+ amount={financeOptionGroup?.creditLine}
56
+ isLoading={isLoading}
57
+ poundsClassName={CLASS_NAMES.price[classKey]}
58
+ centsClassName={CLASS_NAMES.price[classKey]}
59
+ />
60
+ </div>
61
+ </div>
62
+ )}
63
+ {isLoading && (
64
+ <div className={CLASS_NAMES.termsLoading}>
65
+ <SkeletonLoader {...SKELETON_PROPS} />
66
+ <SkeletonLoader {...SKELETON_PROPS} />
67
+ </div>
68
+ )}
69
+ {!isLoading && (
70
+ <div className={CLASS_NAMES.terms}>
71
+ <div className={CLASS_NAMES.termsInnerWrapper}>
72
+ <div className={CLASS_NAMES.termsItem}>
73
+ <Text text="Term" className={CLASS_NAMES.termsLabel} />
74
+ <Text
75
+ text={`${[
76
+ financeOptionGroup?.minDuration,
77
+ financeOptionGroup?.maxDuration,
78
+ ].join(" - ")} months`}
79
+ className={CLASS_NAMES.termsValue}
80
+ />
81
+ </div>
82
+ <div className={CLASS_NAMES.termsItem}>
83
+ <Text
84
+ text="Monthly payment"
85
+ className={CLASS_NAMES.termsLabel}
86
+ />
87
+ <div className={CLASS_NAMES.termsValues}>
88
+ <Price
89
+ amount={financeOptionGroup?.minMonthlyPayment}
90
+ {...TERMS_PRICE_PROPS}
91
+ />
92
+ <Text text=" - " className={CLASS_NAMES.termsLabel} />
93
+ <Price
94
+ amount={financeOptionGroup?.maxMonthlyPayment}
95
+ {...TERMS_PRICE_PROPS}
96
+ />
97
+ </div>
98
+ </div>
99
+ <div className={CLASS_NAMES.termsItem}>
100
+ <Text text="Interest rate" className={CLASS_NAMES.termsLabel} />
101
+ <Text
102
+ text={`${(financeOptionGroup?.apr || 0) / 100}% APR`}
103
+ className={CLASS_NAMES.termsValue}
104
+ />
105
+ </div>
106
+ <div className={CLASS_NAMES.termsItem}>
107
+ <Text
108
+ text="Total interest fee"
109
+ className={CLASS_NAMES.termsLabel}
110
+ />
111
+ <div className={CLASS_NAMES.termsValues}>
112
+ <Price
113
+ amount={financeOptionGroup?.minInterest}
114
+ {...TERMS_PRICE_PROPS}
115
+ />
116
+ {financeOptionGroup?.minInterest !==
117
+ financeOptionGroup?.maxInterest && (
118
+ <>
119
+ <Text text=" - " className={CLASS_NAMES.termsLabel} />
120
+ <Price
121
+ amount={financeOptionGroup?.maxInterest}
122
+ {...TERMS_PRICE_PROPS}
123
+ />
124
+ </>
125
+ )}
126
+ </div>
127
+ </div>
128
+ </div>
129
+ {!muted && selectable && (
130
+ <div className={CLASS_NAMES.checkbox}>
131
+ <FieldHandle.RadioCheck name={name} checked={selected} />
132
+ </div>
133
+ )}
134
+ </div>
135
+ )}
136
+ </div>
137
+ </div>
138
+ );
139
+ };
140
+
141
+ export default CreditLine;
@@ -0,0 +1,11 @@
1
+ export interface GroupedFinanceRate {
2
+ apr: number;
3
+ name: string;
4
+ creditLine: number;
5
+ minDuration: number;
6
+ maxDuration: number;
7
+ minMonthlyPayment: number;
8
+ maxMonthlyPayment: number;
9
+ minInterest: number;
10
+ maxInterest: number;
11
+ }
@@ -109,21 +109,14 @@ const Form: FunctionComponent<FormProps> = function ({
109
109
  (errors: StringIndexedObject, event?: React.BaseSyntheticEvent): void => {
110
110
  const paths = getErrorObjectKeys(errors);
111
111
  const obj = createErrorObject(paths, errors, getValues);
112
- console.log("Form Error", {
113
- element_id: id,
114
- info: {
115
- form: {
116
- [id]: obj,
117
- },
118
- },
119
- });
120
112
  logEvent("form-error", {
121
113
  element_id: id,
122
- info: {
123
- form: {
124
- [id]: obj,
125
- },
126
- },
114
+ // DEV_NOTE: removed info - discussion needed for handling in future
115
+ // info: {
116
+ // form: {
117
+ // [id]: obj,
118
+ // },
119
+ // },
127
120
  });
128
121
  flush();
129
122
  if (!onError) return;
@@ -136,11 +129,12 @@ const Form: FunctionComponent<FormProps> = function ({
136
129
  (values: StringIndexedObject, event?: React.BaseSyntheticEvent): void => {
137
130
  logEvent("form-submitted", {
138
131
  element_id: id,
139
- info: {
140
- form: {
141
- [id]: values,
142
- },
143
- },
132
+ // DEV_NOTE: removed info - discussion needed for handling in future
133
+ // info: {
134
+ // form: {
135
+ // [id]: values,
136
+ // },
137
+ // },
144
138
  });
145
139
  flush();
146
140
  onSubmit(values, event);
@@ -0,0 +1,27 @@
1
+ import React, { type FunctionComponent } from "react";
2
+ import { useForm } from "react-hook-form";
3
+ import { Form } from "~/components";
4
+ import type { StringIndexedObject } from "~/types";
5
+
6
+ export interface MultiStepFormWrapperProps {
7
+ name: string;
8
+ page: string;
9
+ form: ReturnType<typeof useForm>;
10
+ onSubmit: (data: StringIndexedObject) => void;
11
+ children: JSX.Element | JSX.Element[];
12
+ }
13
+
14
+ const MultiStepFormWrapper: FunctionComponent<MultiStepFormWrapperProps> =
15
+ function ({ name, page, form, onSubmit, children }) {
16
+ return (
17
+ <Form
18
+ id={["multi-step-form", name, page].join("-")}
19
+ form={form}
20
+ onSubmit={onSubmit}
21
+ >
22
+ {children}
23
+ </Form>
24
+ );
25
+ };
26
+
27
+ export default MultiStepFormWrapper;