@kiva/kv-components 3.107.0 → 3.107.2

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.
Files changed (177) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/components/.storybook/main.js +85 -0
  3. package/dist/components/.storybook/package.json +3 -0
  4. package/dist/components/.storybook/preview.js +61 -0
  5. package/dist/components/.storybook/tailwind.css +5 -0
  6. package/dist/components/KvAccordionItem.vue +130 -0
  7. package/dist/components/KvActivityRow.vue +33 -0
  8. package/dist/components/KvBorrowerImage.vue +179 -0
  9. package/dist/components/KvButton.vue +287 -0
  10. package/dist/components/KvCarousel.vue +297 -0
  11. package/dist/components/KvCartModal.vue +365 -0
  12. package/dist/components/KvCheckbox.vue +203 -0
  13. package/dist/components/KvChip.vue +54 -0
  14. package/dist/components/KvClassicLoanCard.vue +527 -0
  15. package/dist/components/KvCommentsAdd.vue +135 -0
  16. package/dist/components/KvCommentsContainer.vue +84 -0
  17. package/dist/components/KvCommentsHeartButton.vue +70 -0
  18. package/dist/components/KvCommentsList.vue +68 -0
  19. package/dist/components/KvCommentsListItem.vue +241 -0
  20. package/dist/components/KvCommentsReplyButton.vue +52 -0
  21. package/dist/components/KvContentfulImg.vue +273 -0
  22. package/dist/components/KvCountdownTimer.vue +59 -0
  23. package/dist/components/KvExpandable.vue +84 -0
  24. package/dist/components/KvExpandableQuestion.vue +120 -0
  25. package/dist/components/KvFlag.vue +120 -0
  26. package/dist/components/KvGrid.vue +28 -0
  27. package/dist/components/KvImpactDashboardHeader.vue +40 -0
  28. package/dist/components/KvInlineActivityCard.vue +55 -0
  29. package/dist/components/KvInlineActivityFeed.vue +38 -0
  30. package/dist/components/KvIntroductionLoanCard.vue +446 -0
  31. package/dist/components/KvLendAmountButton.vue +65 -0
  32. package/dist/components/KvLendCta.vue +451 -0
  33. package/dist/components/KvLightbox.vue +334 -0
  34. package/dist/components/KvLineGraph.vue +128 -0
  35. package/dist/components/KvLoadingPlaceholder.vue +38 -0
  36. package/dist/components/KvLoadingSpinner.vue +81 -0
  37. package/dist/components/KvLoanActivities.vue +268 -0
  38. package/dist/components/KvLoanBookmark.vue +39 -0
  39. package/dist/components/KvLoanCallouts.vue +53 -0
  40. package/dist/components/KvLoanProgressGroup.vue +76 -0
  41. package/dist/components/KvLoanTag.vue +88 -0
  42. package/dist/components/KvLoanTeamPick.vue +44 -0
  43. package/dist/components/KvLoanUse.vue +92 -0
  44. package/dist/components/KvMap.vue +599 -0
  45. package/dist/components/KvMaterialIcon.vue +47 -0
  46. package/dist/components/KvPageContainer.vue +15 -0
  47. package/dist/components/KvPagination.vue +198 -0
  48. package/dist/components/KvPieChart.vue +257 -0
  49. package/dist/components/KvPopper.vue +178 -0
  50. package/dist/components/KvProgressBar.vue +149 -0
  51. package/dist/components/KvRadio.vue +198 -0
  52. package/dist/components/KvSelect.vue +114 -0
  53. package/dist/components/KvSideSheet.vue +134 -0
  54. package/dist/components/KvSwitch.vue +143 -0
  55. package/dist/components/KvTab.vue +90 -0
  56. package/dist/components/KvTabPanel.vue +64 -0
  57. package/dist/components/KvTabs.vue +182 -0
  58. package/dist/components/KvTextInput.vue +247 -0
  59. package/dist/components/KvTextLink.vue +138 -0
  60. package/dist/components/KvThemeProvider.vue +122 -0
  61. package/dist/components/KvToast.vue +221 -0
  62. package/dist/components/KvTooltip.vue +168 -0
  63. package/dist/components/KvTreeMapChart.vue +229 -0
  64. package/dist/components/KvUserAvatar.vue +132 -0
  65. package/dist/components/KvVerticalCarousel.vue +156 -0
  66. package/dist/components/KvVotingCard.vue +160 -0
  67. package/dist/components/KvVotingCardV2.vue +154 -0
  68. package/dist/components/KvWideLoanCard.vue +432 -0
  69. package/dist/components/stories/Forms.stories.js +62 -0
  70. package/dist/components/stories/KvAccordionItem.stories.js +24 -0
  71. package/dist/components/stories/KvActivityRow.stories.js +25 -0
  72. package/dist/components/stories/KvBorrowerImage.stories.js +68 -0
  73. package/dist/components/stories/KvButton.stories.js +144 -0
  74. package/dist/components/stories/KvCarousel.stories.js +426 -0
  75. package/dist/components/stories/KvCartModal.stories.js +54 -0
  76. package/dist/components/stories/KvCheckbox.stories.js +163 -0
  77. package/dist/components/stories/KvChip.stories.js +43 -0
  78. package/dist/components/stories/KvClassicLoanCard.stories.js +480 -0
  79. package/dist/components/stories/KvCommentsAdd.stories.js +32 -0
  80. package/dist/components/stories/KvCommentsContainer.stories.js +42 -0
  81. package/dist/components/stories/KvCommentsHeartButton.stories.js +25 -0
  82. package/dist/components/stories/KvCommentsList.stories.js +39 -0
  83. package/dist/components/stories/KvCommentsListItem.stories.js +45 -0
  84. package/dist/components/stories/KvCommentsReplyButton.stories.js +21 -0
  85. package/dist/components/stories/KvContentfulImg.stories.js +196 -0
  86. package/dist/components/stories/KvCountdownTimer.stories.js +30 -0
  87. package/dist/components/stories/KvExpandableQuestion.stories.js +129 -0
  88. package/dist/components/stories/KvFlag.stories.js +36 -0
  89. package/dist/components/stories/KvGrid.stories.js +97 -0
  90. package/dist/components/stories/KvImpactDashboardHeader.stories.js +22 -0
  91. package/dist/components/stories/KvInlineActivityCard.stories.js +69 -0
  92. package/dist/components/stories/KvInlineActivityFeed.stories.js +76 -0
  93. package/dist/components/stories/KvIntroductionLoanCard.stories.js +208 -0
  94. package/dist/components/stories/KvLendAmountButton.stories.js +31 -0
  95. package/dist/components/stories/KvLendCta.stories.js +177 -0
  96. package/dist/components/stories/KvLightbox.stories.js +304 -0
  97. package/dist/components/stories/KvLineGraph.stories.js +52 -0
  98. package/dist/components/stories/KvLoadingPlaceholder.stories.js +17 -0
  99. package/dist/components/stories/KvLoadingSpinner.stories.js +52 -0
  100. package/dist/components/stories/KvLoanActivities.stories.js +104 -0
  101. package/dist/components/stories/KvLoanBookmark.stories.js +22 -0
  102. package/dist/components/stories/KvLoanCallouts.stories.js +22 -0
  103. package/dist/components/stories/KvLoanProgressGroup.stories.js +29 -0
  104. package/dist/components/stories/KvLoanTag.stories.js +61 -0
  105. package/dist/components/stories/KvLoanTeamPick.stories.js +20 -0
  106. package/dist/components/stories/KvLoanUse.stories.js +60 -0
  107. package/dist/components/stories/KvMap.stories.js +121 -0
  108. package/dist/components/stories/KvMaterialIcon.stories.js +201 -0
  109. package/dist/components/stories/KvPageContainer.stories.js +50 -0
  110. package/dist/components/stories/KvPagination.stories.js +70 -0
  111. package/dist/components/stories/KvPieChart.stories.js +47 -0
  112. package/dist/components/stories/KvProgressBar.stories.js +53 -0
  113. package/dist/components/stories/KvRadio.stories.js +140 -0
  114. package/dist/components/stories/KvSelect.stories.js +125 -0
  115. package/dist/components/stories/KvSideSheet.stories.js +50 -0
  116. package/dist/components/stories/KvSwitch.stories.js +66 -0
  117. package/dist/components/stories/KvTabs.stories.js +106 -0
  118. package/dist/components/stories/KvTextInput.stories.js +194 -0
  119. package/dist/components/stories/KvTextLink.stories.js +55 -0
  120. package/dist/components/stories/KvThemeProvider.stories.js +178 -0
  121. package/dist/components/stories/KvToast.stories.js +117 -0
  122. package/dist/components/stories/KvTooltip.stories.js +26 -0
  123. package/dist/components/stories/KvTreeMapChart.stories.js +42 -0
  124. package/dist/components/stories/KvUserAvatar.stories.js +47 -0
  125. package/dist/components/stories/KvVerticalCarousel.stories.js +168 -0
  126. package/dist/components/stories/KvVotingCard.stories.js +33 -0
  127. package/dist/components/stories/KvVotingCardV2.stories.js +89 -0
  128. package/dist/components/stories/KvWideLoanCard.stories.js +292 -0
  129. package/dist/components/stories/StyleguidePrimitives.stories.js +499 -0
  130. package/dist/components/stories/StyleguideProse.stories.js +215 -0
  131. package/dist/data/countries-borders.json +1 -0
  132. package/dist/data/ne_110m_admin_0_countries.json +1 -0
  133. package/dist/utils/Alea.js +9 -0
  134. package/dist/utils/attrs.js +7 -0
  135. package/dist/utils/carousels.js +8 -0
  136. package/dist/{attrs.js → utils/chunk-3HK4G4NT.js} +1 -0
  137. package/dist/{loanCard.js → utils/chunk-55HF2ORX.js} +1 -0
  138. package/dist/{expander.js → utils/chunk-AY3PR5S4.js} +3 -2
  139. package/dist/{carousels.js → utils/chunk-AZPWOFD5.js} +1 -0
  140. package/dist/{printing.js → utils/chunk-B5J5WLAH.js} +1 -0
  141. package/dist/{Alea.js → utils/chunk-GPSH6OPA.js} +2 -1
  142. package/dist/{scrollLock.js → utils/chunk-HIY5IW65.js} +2 -1
  143. package/dist/{treemap.js → utils/chunk-MSMZIN54.js} +1 -0
  144. package/dist/{imageUtils.js → utils/chunk-OXJCCNNW.js} +1 -0
  145. package/dist/{touchEvents.js → utils/chunk-S3MABILA.js} +3 -2
  146. package/dist/{mapUtils.js → utils/chunk-VIGEMAKO.js} +5 -4
  147. package/dist/utils/chunk-YCNMJ4YV.js +37 -0
  148. package/dist/{loanUtils.js → utils/chunk-YFEC5ODJ.js} +7 -6
  149. package/dist/utils/expander.js +9 -0
  150. package/dist/utils/imageUtils.js +9 -0
  151. package/dist/utils/index.cjs +1118 -0
  152. package/dist/utils/index.js +166 -0
  153. package/dist/utils/loanCard.js +9 -0
  154. package/dist/utils/loanUtils.js +23 -0
  155. package/dist/utils/mapUtils.js +15 -0
  156. package/dist/utils/printing.js +9 -0
  157. package/dist/utils/scrollLock.js +13 -0
  158. package/dist/{throttle.js → utils/throttle.js} +1 -0
  159. package/dist/utils/touchEvents.js +11 -0
  160. package/dist/utils/treemap.js +7 -0
  161. package/package.json +11 -7
  162. package/utils/index.js +14 -0
  163. package/index.js +0 -3
  164. /package/dist/{Alea.cjs → utils/Alea.cjs} +0 -0
  165. /package/dist/{attrs.cjs → utils/attrs.cjs} +0 -0
  166. /package/dist/{carousels.cjs → utils/carousels.cjs} +0 -0
  167. /package/dist/{chunk-HV3AUBFT.js → utils/chunk-HV3AUBFT.js} +0 -0
  168. /package/dist/{expander.cjs → utils/expander.cjs} +0 -0
  169. /package/dist/{imageUtils.cjs → utils/imageUtils.cjs} +0 -0
  170. /package/dist/{loanCard.cjs → utils/loanCard.cjs} +0 -0
  171. /package/dist/{loanUtils.cjs → utils/loanUtils.cjs} +0 -0
  172. /package/dist/{mapUtils.cjs → utils/mapUtils.cjs} +0 -0
  173. /package/dist/{printing.cjs → utils/printing.cjs} +0 -0
  174. /package/dist/{scrollLock.cjs → utils/scrollLock.cjs} +0 -0
  175. /package/dist/{throttle.cjs → utils/throttle.cjs} +0 -0
  176. /package/dist/{touchEvents.cjs → utils/touchEvents.cjs} +0 -0
  177. /package/dist/{treemap.cjs → utils/treemap.cjs} +0 -0
@@ -0,0 +1,451 @@
1
+ <template>
2
+ <div class="tw-whitespace-nowrap">
3
+ <!-- Continue to checkout button -->
4
+ <kv-ui-button
5
+ v-if="isInBasket"
6
+ variant="secondary"
7
+ class="tw-inline-flex tw-flex-1"
8
+ data-testid="bp-lend-cta-checkout-button"
9
+ :to="!externalLinks ? '/basket' : undefined"
10
+ :href="externalLinks ? '/basket' : undefined"
11
+ @click.native="clickSecondaryButton($event)"
12
+ >
13
+ {{ loanInBasketButtonText }}
14
+ </kv-ui-button>
15
+
16
+ <!-- Refunded, allSharesReserved button -->
17
+ <kv-ui-button
18
+ v-else-if="showNonActionableLoanButton"
19
+ class="tw-inline-flex tw-flex-1"
20
+ >
21
+ {{ ctaButtonText }}
22
+ </kv-ui-button>
23
+
24
+ <!-- Funded / expired -->
25
+ <div
26
+ v-else-if="isFunded"
27
+ class="tw-w-full tw-text-center tw-rounded tw-p-2"
28
+ style="background: #f1f1f1;"
29
+ >
30
+ This loan was just funded! 🎉
31
+ </div>
32
+
33
+ <kv-ui-button
34
+ v-else-if="showViewLoan"
35
+ :state="`${allSharesReserved ? 'disabled' : ''}`"
36
+ :to="!externalLinks ? readMorePath : undefined"
37
+ :href="externalLinks ? readMorePath : undefined"
38
+ class="tw-mb-0"
39
+ @click="$emit('show-loan-details')"
40
+ >
41
+ <span class="tw-flex">
42
+ View loan
43
+ <kv-material-icon
44
+ class="tw-w-3 tw-h-3 tw-align-middle"
45
+ :icon="mdiChevronRight"
46
+ />
47
+ </span>
48
+ </kv-ui-button>
49
+
50
+ <form
51
+ v-else-if="useFormSubmit"
52
+ class="tw-w-full tw-flex"
53
+ @submit.prevent="addToBasket"
54
+ >
55
+ <fieldset
56
+ class="tw-w-full tw-flex"
57
+ :disabled="isAdding"
58
+ data-testid="bp-lend-cta-select-and-button"
59
+ >
60
+ <div class="amountDropdownWrapper">
61
+ <kv-ui-select
62
+ v-if="hideShowLendDropdown && !isLessThan25"
63
+ :id="`LoanAmountDropdown_${loanId}`"
64
+ v-model="selectedOption"
65
+ class="tw-min-w-12"
66
+ style="border-radius: 14px 0 0 14px;"
67
+ aria-label="Lend amount"
68
+ @update:modelValue="trackLendAmountSelection"
69
+ @click.native.stop="clickDropdown"
70
+ >
71
+ <option
72
+ v-for="priceOption in prices"
73
+ :key="priceOption"
74
+ :value="priceOption"
75
+ >
76
+ ${{ priceOption }}
77
+ </option>
78
+ </kv-ui-select>
79
+ </div>
80
+
81
+ <!-- Lend button -->
82
+ <div :class="{ 'lendButtonWrapper': hideShowLendDropdown }">
83
+ <kv-ui-button
84
+ v-if="lendButtonVisibility && !isLessThan25"
85
+ key="lendButton"
86
+ class="tw-inline-flex tw-flex-1"
87
+ data-testid="bp-lend-cta-lend-button"
88
+ type="submit"
89
+ >
90
+ {{ ctaButtonText }}
91
+ </kv-ui-button>
92
+
93
+ <!-- Lend again/lent previously button -->
94
+ <kv-ui-button
95
+ v-else-if="showLendAgain"
96
+ key="lendAgainButton"
97
+ class="lend-again"
98
+ data-testid="bp-lend-cta-lend-again-button"
99
+ type="submit"
100
+ >
101
+ {{ primaryButtonText || 'Lend' }} again
102
+ </kv-ui-button>
103
+ </div>
104
+
105
+ <!-- Stranded loans -->
106
+ <kv-lend-amount-button
107
+ v-if="isLendAmountButton && !enableFiveDollarsNotes"
108
+ class="tw-w-full"
109
+ :loan-id="loanId"
110
+ :show-now="false"
111
+ :amount-left="unreservedAmount"
112
+ :is-adding="isAdding"
113
+ @add-to-basket="addToBasket"
114
+ />
115
+
116
+ <!-- Adding to basket button -->
117
+ <kv-ui-button
118
+ v-if="!isLoading && isAdding"
119
+ class="tw-inline-flex tw-flex-1"
120
+ >
121
+ Adding to basket
122
+ </kv-ui-button>
123
+ </fieldset>
124
+ </form>
125
+ </div>
126
+ </template>
127
+
128
+ <script>
129
+ import { mdiChevronRight } from '@mdi/js';
130
+ import KvLendAmountButton from './KvLendAmountButton.vue';
131
+ import KvUiSelect from './KvSelect.vue';
132
+ import KvUiButton from './KvButton.vue';
133
+ import KvMaterialIcon from './KvMaterialIcon.vue';
134
+ import { getLendCtaSelectedOption, getDropdownPriceArray } from '../utils/loanUtils';
135
+
136
+ export default {
137
+ name: 'KvLendCta',
138
+ components: {
139
+ KvLendAmountButton,
140
+ KvUiButton,
141
+ KvUiSelect,
142
+ KvMaterialIcon,
143
+ },
144
+ props: {
145
+ loan: {
146
+ type: Object,
147
+ default: () => ({}),
148
+ },
149
+ basketItems: {
150
+ type: Array,
151
+ default: () => ([]),
152
+ },
153
+ isLoading: {
154
+ type: Boolean,
155
+ default: true,
156
+ },
157
+ isAdding: {
158
+ type: Boolean,
159
+ default: false,
160
+ },
161
+ enableFiveDollarsNotes: {
162
+ type: Boolean,
163
+ default: false,
164
+ },
165
+ kvTrackFunction: {
166
+ type: Function,
167
+ required: true,
168
+ },
169
+ showViewLoan: {
170
+ type: Boolean,
171
+ default: false,
172
+ },
173
+ customLoanDetails: {
174
+ type: Boolean,
175
+ default: false,
176
+ },
177
+ externalLinks: {
178
+ type: Boolean,
179
+ default: false,
180
+ },
181
+ route: {
182
+ type: Object,
183
+ default: undefined,
184
+ },
185
+ userBalance: {
186
+ type: String,
187
+ default: undefined,
188
+ },
189
+ getCookie: {
190
+ type: Function,
191
+ default: undefined,
192
+ },
193
+ setCookie: {
194
+ type: Function,
195
+ default: undefined,
196
+ },
197
+ fiveDollarsSelected: {
198
+ type: Boolean,
199
+ default: false,
200
+ },
201
+ enableHugeAmount: {
202
+ type: Boolean,
203
+ default: false,
204
+ },
205
+ isVisitor: {
206
+ type: Boolean,
207
+ default: true,
208
+ },
209
+ primaryButtonText: {
210
+ type: String,
211
+ default: 'Lend',
212
+ },
213
+ secondaryButtonText: {
214
+ type: String,
215
+ default: 'Checkout now',
216
+ },
217
+ secondaryButtonHandler: {
218
+ type: Function,
219
+ default: undefined,
220
+ },
221
+ },
222
+ data() {
223
+ return {
224
+ mdiChevronRight,
225
+ selectedOption: getLendCtaSelectedOption(
226
+ this.getCookie,
227
+ this.setCookie,
228
+ this.enableFiveDollarsNotes,
229
+ this.route?.query?.utm_campaign,
230
+ this.loan?.unreservedAmount,
231
+ this.userBalance,
232
+ this.fiveDollarsSelected,
233
+ ),
234
+ };
235
+ },
236
+ computed: {
237
+ readMorePath() {
238
+ return this.customLoanDetails ? '' : `/lend/${this.loanId}`;
239
+ },
240
+ loanId() {
241
+ return this.loan?.id;
242
+ },
243
+ status() {
244
+ return this.loan?.status ?? '';
245
+ },
246
+ minNoteSize() {
247
+ return this.loan?.minNoteSize ?? '';
248
+ },
249
+ unreservedAmount() {
250
+ return this.loan?.unreservedAmount ?? '';
251
+ },
252
+ lentPreviously() {
253
+ return this.loan?.userProperties?.lentTo ?? false;
254
+ },
255
+ isInBasket() {
256
+ return this.basketItems
257
+ // eslint-disable-next-line no-underscore-dangle
258
+ ?.some((item) => item.__typename === 'LoanReservation' && item.id === this.loanId) ?? false;
259
+ },
260
+ prices() {
261
+ // We don't want to open up $5 loan shares for loans with more than $25 at this time
262
+ // If we wanted to show this interface on loans with less than 25 remaining they would see the selector
263
+ const minAmount = parseFloat(this.unreservedAmount < 25 ? this.minNoteSize : 25);
264
+ // Limit price options
265
+ return getDropdownPriceArray(
266
+ this.unreservedAmount,
267
+ this.isCompleteLoanActive,
268
+ minAmount,
269
+ this.enableFiveDollarsNotes,
270
+ this.enableHugeAmount,
271
+ this.isVisitor,
272
+ );
273
+ },
274
+ ctaButtonText() {
275
+ if (this.isCompleteLoanActive) {
276
+ return this.primaryButtonText || 'Lend';
277
+ }
278
+ switch (this.state) {
279
+ case 'loading':
280
+ return 'Loading...';
281
+ case 'refunded':
282
+ case 'expired':
283
+ default:
284
+ return this.primaryButtonText || 'Lend';
285
+ }
286
+ },
287
+ loanInBasketButtonText() {
288
+ return this.secondaryButtonText;
289
+ },
290
+ useFormSubmit() {
291
+ if (this.hideShowLendDropdown
292
+ || this.lendButtonVisibility
293
+ || this.showLendAgain
294
+ || this.state === 'lent-to'
295
+ || this.isAdding) {
296
+ return true;
297
+ }
298
+ return false;
299
+ },
300
+ state() {
301
+ if (this.isLoading) {
302
+ return 'loading';
303
+ }
304
+ if (this.isAdding) {
305
+ return 'adding';
306
+ }
307
+ if (this.isInBasket) {
308
+ return 'basketed';
309
+ }
310
+ if (this.status === 'funded' || this.status === 'refunded' || this.status === 'expired') {
311
+ return this.status;
312
+ }
313
+ if (this.allSharesReserved) {
314
+ return 'fully-reserved';
315
+ }
316
+ if (this.lentPreviously) {
317
+ return 'lent-to';
318
+ }
319
+ return 'lend';
320
+ },
321
+ lendButtonVisibility() {
322
+ return this.state === 'lend' || this.state === 'loading';
323
+ },
324
+ showNonActionableLoanButton() {
325
+ return this.state === 'refunded'
326
+ || this.state === 'expired';
327
+ },
328
+ hideShowLendDropdown() {
329
+ return this.state === 'lend' || this.state === 'lent-to';
330
+ },
331
+ allSharesReserved() {
332
+ if (parseFloat(this.unreservedAmount) === 0) {
333
+ return true;
334
+ }
335
+ return false;
336
+ },
337
+ isLessThan25() {
338
+ // For $5 dollars notes we need to show the dropdown
339
+ if (this.enableFiveDollarsNotes) return false;
340
+ return this.isAmountLessThan25(this.unreservedAmount);
341
+ },
342
+ isLentTo() {
343
+ return this.state === 'lent-to';
344
+ },
345
+ isCompleteLoanActive() {
346
+ return (this.isAmountLessThan25(this.unreservedAmount)
347
+ || this.isAmountBetween25And500(this.unreservedAmount));
348
+ },
349
+ isLendAmountButton() {
350
+ return (this.lendButtonVisibility || this.state === 'lent-to')
351
+ && this.isAmountLessThan25(this.unreservedAmount);
352
+ },
353
+ isFunded() {
354
+ return this.state === 'funded' || this.state === 'fully-reserved';
355
+ },
356
+ amountToLend() {
357
+ return this.isLessThan25 ? this.unreservedAmount : this.selectedOption;
358
+ },
359
+ showLendAgain() {
360
+ return this.isLentTo && !this.isLessThan25;
361
+ },
362
+ },
363
+ watch: {
364
+ unreservedAmount(newValue, previousValue) {
365
+ if (newValue !== previousValue && previousValue === '') {
366
+ this.selectedOption = getLendCtaSelectedOption(
367
+ this.getCookie,
368
+ this.setCookie,
369
+ this.enableFiveDollarsNotes,
370
+ this.route?.query?.utm_campaign,
371
+ newValue,
372
+ this.userBalance,
373
+ this.fiveDollarsSelected,
374
+ );
375
+ }
376
+ },
377
+ },
378
+ methods: {
379
+ async addToBasket() {
380
+ this.kvTrackFunction(
381
+ 'Lending',
382
+ 'Add to basket',
383
+ this.showLendAgain ? 'Lend again' : 'lend-button-click',
384
+ this.loanId,
385
+ this.amountToLend,
386
+ );
387
+ this.$emit('add-to-basket', this.amountToLend);
388
+ },
389
+ isAmountLessThan25(unreservedAmount) {
390
+ return unreservedAmount < 25 && unreservedAmount > 0;
391
+ },
392
+ isAmountBetween25And50(unreservedAmount) {
393
+ return unreservedAmount <= 50 && unreservedAmount > 25;
394
+ },
395
+ isAmountBetween25And500(unreservedAmount) {
396
+ return unreservedAmount < 500 && unreservedAmount >= 25;
397
+ },
398
+ trackLendAmountSelection(selectedDollarAmount) {
399
+ this.kvTrackFunction(
400
+ 'Lending',
401
+ 'Modify lend amount',
402
+ selectedDollarAmount,
403
+ this.loanId,
404
+ this.loanId,
405
+ );
406
+ },
407
+ clickDropdown() {
408
+ this.kvTrackFunction('Lending', 'click-Modify loan amount', 'open dialog', this.loanId, this.loanId);
409
+ },
410
+ clickSecondaryButton(event) {
411
+ if (this.secondaryButtonHandler) {
412
+ event.preventDefault();
413
+ event.stopPropagation();
414
+ // Custom secondary button behavior
415
+ this.secondaryButtonHandler();
416
+ } else {
417
+ // Default secondary button behavior
418
+ this.handleCheckout();
419
+ }
420
+ },
421
+ handleCheckout() {
422
+ this.kvTrackFunction(
423
+ 'Lending',
424
+ 'click-Continue-to-checkout',
425
+ 'Continue to checkout',
426
+ this.loanId,
427
+ this.loanId,
428
+ );
429
+ },
430
+ },
431
+ };
432
+
433
+ </script>
434
+
435
+ <style lang="postcss" scoped>
436
+ .amountDropdownWrapper >>> select {
437
+ border-radius: 14px 0 0 14px;
438
+ }
439
+
440
+ .lend-again >>> span {
441
+ @apply tw-px-0;
442
+ }
443
+
444
+ .lend-again >>> span {
445
+ @apply tw-px-1;
446
+ }
447
+
448
+ .lendButtonWrapper >>> span:first-child {
449
+ border-radius: 0 14px 14px 0;
450
+ }
451
+ </style>