From a88c9e5e7fb3f28f441f4aeb3fde377a3e558cde Mon Sep 17 00:00:00 2001 From: Christian Bedon Date: Mon, 11 Nov 2024 14:11:15 -0500 Subject: [PATCH 01/14] feat: typage opt-in module component --- .storybook/mock-data/receipt-data-mock.js | 15 +- .storybook/stories/ThanksBadges.stories.js | 12 +- src/components/Thanks/MyKiva/OptInModule.vue | 252 ++++++++++++++++++ .../Thanks/MyKiva/OptInNotification.vue | 78 ++++++ src/components/Thanks/MyKiva/ThanksBadges.vue | 12 + 5 files changed, 362 insertions(+), 7 deletions(-) create mode 100644 src/components/Thanks/MyKiva/OptInModule.vue create mode 100644 src/components/Thanks/MyKiva/OptInNotification.vue diff --git a/.storybook/mock-data/receipt-data-mock.js b/.storybook/mock-data/receipt-data-mock.js index faf5a1bfb8..898e3358ca 100644 --- a/.storybook/mock-data/receipt-data-mock.js +++ b/.storybook/mock-data/receipt-data-mock.js @@ -39,7 +39,8 @@ export default { "name": "Alan", "id": 1911067, "image": { - "url": "https://www-dev-kiva-org.global.ssl.fastly.net/img/s100/5e041e655faa305c49c13505d1c17cba.jpg" + "url": "https://www-dev-kiva-org.global.ssl.fastly.net/img/s100/5e041e655faa305c49c13505d1c17cba.jpg", + "hash": "5e041e655faa305c49c13505d1c17cba" }, "use": "to expand her business by purchasing more stock such as seed and manure for the expansion of her vegetable garden.", "geocode": { @@ -63,7 +64,8 @@ export default { "name": "Alan", "id": 1908530, "image": { - "url": "https://www-dev-kiva-org.global.ssl.fastly.net/img/s100/da9ac74228e39e15cc198f8165e68c20.jpg" + "url": "https://www-dev-kiva-org.global.ssl.fastly.net/img/s100/da9ac74228e39e15cc198f8165e68c20.jpg", + "hash": "da9ac74228e39e15cc198f8165e68c20" }, "use": "to buy taro roots (seedlings), banana tubers (seedlings), chemicals, a bag back sprayer, and a chainsaw.", "geocode": { @@ -87,7 +89,8 @@ export default { "name": "Barrio Concepcion Group", "id": 1907517, "image": { - "url": "https://www-dev-kiva-org.global.ssl.fastly.net/img/s100/213d4f59069e192a2a4b9ee1fb56b649.jpg" + "url": "https://www-dev-kiva-org.global.ssl.fastly.net/img/s100/213d4f59069e192a2a4b9ee1fb56b649.jpg", + "hash": "213d4f59069e192a2a4b9ee1fb56b649" }, "use": "to buy a stove with a grill, kitchen utensils, corn and firewood.", "geocode": { @@ -111,7 +114,8 @@ export default { "name": "Alan", "id": 1909791, "image": { - "url": "https://www-dev-kiva-org.global.ssl.fastly.net/img/s100/26e15431f51b540f31cd9f011cc54f31.jpg" + "url": "https://www-dev-kiva-org.global.ssl.fastly.net/img/s100/26e15431f51b540f31cd9f011cc54f31.jpg", + "hash": "26e15431f51b540f31cd9f011cc54f31" }, "use": "to buy farming inputs and improve her production in 2020 for an increased income.", "geocode": { @@ -135,7 +139,8 @@ export default { "name": "Las Victoriosas Group", "id": 1906824, "image": { - "url": "https://www-dev-kiva-org.global.ssl.fastly.net/img/s100/26342071330beb8309d17a5d262da2dd.jpg" + "url": "https://www-dev-kiva-org.global.ssl.fastly.net/img/s100/26342071330beb8309d17a5d262da2dd.jpg", + "hash": "26342071330beb8309d17a5d262da2dd" }, "use": "to buy used clothing for men, women and children in specific sizes.", "geocode": { diff --git a/.storybook/stories/ThanksBadges.stories.js b/.storybook/stories/ThanksBadges.stories.js index 68b7f9ba3a..fa64fc33cc 100644 --- a/.storybook/stories/ThanksBadges.stories.js +++ b/.storybook/stories/ThanksBadges.stories.js @@ -20,6 +20,14 @@ const story = (args = {}) => { return template; }; -export const Guest = story({ receipt: mockedReceiptData }); +const loans = mockedReceiptData.items.values?.map((item) => item?.loan).filter(loan => !!loan?.id); -export const User = story({ isGuest: false, receipt: mockedReceiptData }); +export const Guest = story({ receipt: mockedReceiptData, loans, selectedLoan: loans[0] }); + +export const UserOptedIn = story({ isGuest: false, receipt: mockedReceiptData, loans, selectedLoan: loans[0], optedIn: true }); + +export const OptedOutWithOneLoan = story({ isGuest: false, receipt: mockedReceiptData, loans: loans.slice(0, 1), selectedLoan: loans[0] }); + +export const OptedOutWithTwoLoans = story({ isGuest: false, receipt: mockedReceiptData, loans: loans.slice(0, 2), selectedLoan: loans[0] }); + +export const OptedOutWithTwoOrMoreLoans = story({ isGuest: false, receipt: mockedReceiptData, loans: loans.slice(0, 3), selectedLoan: loans[0] }); diff --git a/src/components/Thanks/MyKiva/OptInModule.vue b/src/components/Thanks/MyKiva/OptInModule.vue new file mode 100644 index 0000000000..4206cd3776 --- /dev/null +++ b/src/components/Thanks/MyKiva/OptInModule.vue @@ -0,0 +1,252 @@ + + + + + diff --git a/src/components/Thanks/MyKiva/OptInNotification.vue b/src/components/Thanks/MyKiva/OptInNotification.vue new file mode 100644 index 0000000000..237c83956b --- /dev/null +++ b/src/components/Thanks/MyKiva/OptInNotification.vue @@ -0,0 +1,78 @@ + + + + + diff --git a/src/components/Thanks/MyKiva/ThanksBadges.vue b/src/components/Thanks/MyKiva/ThanksBadges.vue index e8ac64abee..b75cafac11 100644 --- a/src/components/Thanks/MyKiva/ThanksBadges.vue +++ b/src/components/Thanks/MyKiva/ThanksBadges.vue @@ -1,5 +1,12 @@ @@ -122,7 +123,7 @@ const description = computed( () => `Want to hear how you're impacting ${borrowerName.value}'s life and more ways to help people like them?` ); -const filteredLoans = computed(() => { +const loansToDisplay = computed(() => { const loans = [...props.loans]; if (props.loans.length === 3) { const indexToRemove = loans.indexOf(loan => loan.id === props.selectedLoan.id); @@ -133,10 +134,10 @@ const filteredLoans = computed(() => { }); const marginLeftWeight = computed(() => { - if (filteredLoans.value.length === 1) { + if (loansToDisplay.value.length === 1) { return 0; } - if (filteredLoans.value.length === 2) { + if (loansToDisplay.value.length === 2) { return 6; } diff --git a/src/components/Thanks/MyKiva/OptInNotification.vue b/src/components/Thanks/MyKiva/OptInNotification.vue index 237c83956b..60e843d2e5 100644 --- a/src/components/Thanks/MyKiva/OptInNotification.vue +++ b/src/components/Thanks/MyKiva/OptInNotification.vue @@ -1,27 +1,25 @@