Skip to content

Commit

Permalink
Merge pull request #5156 from kiva/CORE-1729-fe-iwd-thanks-page
Browse files Browse the repository at this point in the history
feat: added flag for IWD to thanks page, created working stories
  • Loading branch information
dyersituations authored Feb 6, 2024
2 parents 5832a73 + 9c92884 commit 96b6caa
Show file tree
Hide file tree
Showing 8 changed files with 305 additions and 11 deletions.
6 changes: 3 additions & 3 deletions .storybook/mixins/apollo-story-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ export default ({
loading = false,
} = {}) => {
// Add to basket button expects basketAddInterstitial
const queryData = { ...queryResult, data: { ...queryResult.data, basketAddInterstitial: {} } };
const queryData = { ...queryResult.data, data: { ...queryResult.data, basketAddInterstitial: {} } };

return {
provide: {
apollo: {
mutate() {
return loading ? new Promise(() => {}) : Promise.resolve(mutationResult);
return loading ? new Promise(() => { }) : Promise.resolve(mutationResult);
},
readQuery() {
return queryData;
Expand All @@ -22,7 +22,7 @@ export default ({
};
},
query() {
return loading ? new Promise(() => {}) : Promise.resolve(queryData);
return loading ? new Promise(() => { }) : Promise.resolve(queryData);
},
readFragment() {
return fragmentResult;
Expand Down
233 changes: 233 additions & 0 deletions .storybook/mock-data/thanks-page-data-mock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,233 @@
export const maleLoanData = {
"data": {
"shop": {
"id": "1",
"receipt": {
"id": "123",
"transactionTime": "2024-02-05T18:30:29Z",
"credits": {
"values": [
{
"id": 123,
"creditType": "kiva_credit",
"amount": null
}
]
},
"totals": {
"bonusAppliedTotal": "0.00",
"itemTotal": "30.00",
"donationTotal": "5.00",
"kivaCardTotal": "0.00",
"depositTotals": {
"depositTotal": "30.00",
"kivaCreditAdded": "0.00",
"kivaCreditUsed": "0.00"
},
"freeTrialAppliedTotal": "0.00",
"kivaCreditAppliedTotal": "30.00",
"redemptionCodeAppliedTotal": "0.00",
"universalCodeAppliedTotal": "0.00"
},
"hasFreeCredits": false,
"items": {
"totalCount": 2,
"values": [
{
"id": 123,
"price": "25.00",
"basketItemType": "loan_reservation",
"loan": {
"name": "Bob",
"id": 123,
"image": {
"id": 123,
"url": "https://www-0.development.kiva.org/img/s100/cd9161b3e5d58f77cf650ad9d7a37413.jpg",
"default": "https://res.cloudinary.com/kiva/w_480,h_300,c_fill,g_faces/a_ignore,fl_progressive,q_auto:best,f_auto/remote/cd9161b3e5d58f77cf650ad9d7a37413.jpg",
"hash": "cd9161b3e5d58f77cf650ad9d7a37413"
},
"use": "to acquire high-quality seeds, fertilizer, and agricultural chemicals that will aid in increasing his crop yields.",
"plannedExpirationDate": "2024-02-26T20:50:17Z",
"geocode": {
"city": "Litein",
"country": {
"name": "Kenya"
}
},
"loanAmount": "325.00",
"loanFundraisingInfo": {
"fundedAmount": "175.00",
"reservedAmount": "0.00"
},
"distributionModel": "fieldPartner",
"inPfp": false,
"gender": "male"
},
"team": {
"id": 123,
"teamPublicId": "team_canada",
"name": "Team CANADA"
}
},
{
"id": 123,
"price": "5.00",
"basketItemType": "donation"
}
]
}
}
},
"my": {
"id": "123",
"autoDeposit": null,
"teams": {
"values": [
{
"id": 123,
"team": {
"id": 123,
"teamPublicId": "team_canada",
"name": "Team CANADA"
}
},
]
},
"lender": {
"id": 123,
"name": "John"
},
"userAccount": {
"id": 123,
"firstName": "John",
"lastName": "Smith",
"email": "john@kiva.org",
"inviterName": "john123",
"public": true
},
"loans": {
"totalCount": 1
}
},
}
}

export const femaleLoanData = {
"data": {
"shop": {
"id": "1",
"receipt": {
"id": "123",
"transactionTime": "2024-02-05T18:30:29Z",
"credits": {
"values": [
{
"id": 123,
"creditType": "kiva_credit",
"amount": null
}
]
},
"totals": {
"bonusAppliedTotal": "0.00",
"itemTotal": "30.00",
"donationTotal": "5.00",
"kivaCardTotal": "0.00",
"depositTotals": {
"depositTotal": "30.00",
"kivaCreditAdded": "0.00",
"kivaCreditUsed": "0.00"
},
"freeTrialAppliedTotal": "0.00",
"kivaCreditAppliedTotal": "30.00",
"redemptionCodeAppliedTotal": "0.00",
"universalCodeAppliedTotal": "0.00"
},
"hasFreeCredits": false,
"items": {
"totalCount": 2,
"values": [
{
"id": 123,
"price": "25.00",
"basketItemType": "loan_reservation",
"loan": {
"name": "Jane",
"id": 123,
"image": {
"id": 123,
"url": "https://www-0.development.kiva.org/img/s100/9839704fb7123e37d4eb398c499cef31.jpg",
"default": "https://res.cloudinary.com/kiva/w_480,h_300,c_fill,g_faces/a_ignore,fl_progressive,q_auto:best,f_auto/remote/9839704fb7123e37d4eb398c499cef31.jpg",
"hash": "9839704fb7123e37d4eb398c499cef31"
},
"use": "to invest in raw materials to ensure she can do weaving work consistently and increase her income potential.",
"plannedExpirationDate": "2024-03-20T21:22:52Z",
"geocode": {
"city": "Rongkwang",
"country": {
"name": "Thailand"
}
},
"loanAmount": "1725.00",
"loanFundraisingInfo": {
"fundedAmount": "275.00",
"reservedAmount": "0.00"
},
"distributionModel": "fieldPartner",
"inPfp": false,
"gender": "female"
},
"team": {
"id": 123,
"teamPublicId": "team_canada",
"name": "Team CANADA"
}
},
{
"id": 123,
"price": "5.00",
"basketItemType": "donation"
}
]
}
}
},
"my": {
"id": "123",
"autoDeposit": null,
"teams": {
"values": [
{
"id": 123,
"team": {
"id": 123,
"teamPublicId": "team_canada",
"name": "Team CANADA"
}
},
]
},
"lender": {
"id": 123,
"name": "John"
},
"userAccount": {
"id": 123,
"firstName": "John",
"lastName": "Smith",
"email": "john@kiva.org",
"inviterName": "john123",
"public": true
},
"loans": {
"totalCount": 1
}
},
}
};

export const iwdExperiment = {
id: 'Experiment:iwd_header_2024',
version: 'b'
};

3 changes: 3 additions & 0 deletions .storybook/stories/DonationNudgeLightbox.stories.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import DonationNudgeLightbox from '@/components/Checkout/DonationNudge/DonationNudgeLightbox.vue';
import cookieStoreStoryMixin from '../mixins/cookie-store-story-mixin';
import apolloStoryMixin from '../mixins/apollo-story-mixin';

export default {
title: 'Components/Donation Nudge Lightbox',
Expand All @@ -11,6 +13,7 @@ export default {
export const Default = (args, { argTypes }) => ({
props: Object.keys(argTypes),
components: { DonationNudgeLightbox },
mixins: [cookieStoreStoryMixin(), apolloStoryMixin()],
template: `
<donation-nudge-lightbox
:loan-count="1"
Expand Down
19 changes: 15 additions & 4 deletions .storybook/stories/EcoChallengeLightbox.stories.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import EcoChallengeLightbox from '@/components/Lightboxes/EcoChallengeLightbox.vue';
import cookieStoreStoryMixin from '../mixins/cookie-store-story-mixin';
import apolloStoryMixin from '../mixins/apollo-story-mixin';

const ecoChallengeMilestoneValues = {
'sustainable-agriculture': [
Expand Down Expand Up @@ -43,18 +45,19 @@ const ecoChallengeMilestoneValues = {
function allCombinations(obj) {
let combos = [[]]
for (const [key, values] of Object.entries(obj)) {
combos = combos.flatMap((combo) =>
values.map((value) => ([...combo, value ]))
)
combos = combos.flatMap((combo) =>
values.map((value) => ([...combo, value]))
)
}
return combos
}
}

const allMilestoneCombinations = allCombinations(ecoChallengeMilestoneValues);

export default {
title: 'Components/Eco Challenge Lightbox',
component: EcoChallengeLightbox,
mixins: [cookieStoreStoryMixin(), apolloStoryMixin()],
args: {
progresses: [],
visible: true
Expand All @@ -64,6 +67,7 @@ export default {
export const EcoChallengeLightboxCombo0 = (args, { argTypes }) => ({
props: Object.keys(argTypes),
components: { EcoChallengeLightbox },
mixins: [cookieStoreStoryMixin(), apolloStoryMixin()],
template: `
<eco-challenge-lightbox
:visible="visible"
Expand All @@ -79,6 +83,7 @@ EcoChallengeLightboxCombo0.args = {
export const EcoChallengeLightboxCombo1 = (args, { argTypes }) => ({
props: Object.keys(argTypes),
components: { EcoChallengeLightbox },
mixins: [cookieStoreStoryMixin(), apolloStoryMixin()],
template: `
<eco-challenge-lightbox
:visible="visible"
Expand All @@ -94,6 +99,7 @@ EcoChallengeLightboxCombo1.args = {
export const EcoChallengeLightboxCombo2 = (args, { argTypes }) => ({
props: Object.keys(argTypes),
components: { EcoChallengeLightbox },
mixins: [cookieStoreStoryMixin(), apolloStoryMixin()],
template: `
<eco-challenge-lightbox
:visible="visible"
Expand All @@ -109,6 +115,7 @@ EcoChallengeLightboxCombo2.args = {
export const EcoChallengeLightboxCombo3 = (args, { argTypes }) => ({
props: Object.keys(argTypes),
components: { EcoChallengeLightbox },
mixins: [cookieStoreStoryMixin(), apolloStoryMixin()],
template: `
<eco-challenge-lightbox
:visible="visible"
Expand All @@ -125,6 +132,7 @@ EcoChallengeLightboxCombo3.args = {
export const EcoChallengeLightboxCombo4 = (args, { argTypes }) => ({
props: Object.keys(argTypes),
components: { EcoChallengeLightbox },
mixins: [cookieStoreStoryMixin(), apolloStoryMixin()],
template: `
<eco-challenge-lightbox
:visible="visible"
Expand All @@ -140,6 +148,7 @@ EcoChallengeLightboxCombo4.args = {
export const EcoChallengeLightboxCombo5 = (args, { argTypes }) => ({
props: Object.keys(argTypes),
components: { EcoChallengeLightbox },
mixins: [cookieStoreStoryMixin(), apolloStoryMixin()],
template: `
<eco-challenge-lightbox
:visible="visible"
Expand All @@ -155,6 +164,7 @@ EcoChallengeLightboxCombo5.args = {
export const EcoChallengeLightboxCombo6 = (args, { argTypes }) => ({
props: Object.keys(argTypes),
components: { EcoChallengeLightbox },
mixins: [cookieStoreStoryMixin(), apolloStoryMixin()],
template: `
<eco-challenge-lightbox
:visible="visible"
Expand All @@ -170,6 +180,7 @@ EcoChallengeLightboxCombo6.args = {
export const EcoChallengeLightboxCombo7 = (args, { argTypes }) => ({
props: Object.keys(argTypes),
components: { EcoChallengeLightbox },
mixins: [cookieStoreStoryMixin(), apolloStoryMixin()],
template: `
<eco-challenge-lightbox
:visible="visible"
Expand Down
4 changes: 3 additions & 1 deletion .storybook/stories/KvSocialShareButton.stories.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import KvSocialShareButton from '@/components/Kv/KvSocialShareButton';
import apolloStoryMixin from '../mixins/apollo-story-mixin';

export default {
title: 'Kv/KvSocialShareButton',
Expand All @@ -22,11 +23,12 @@ export default {
};


export const Default= (args, { argTypes }) => ({
export const Default = (args, { argTypes }) => ({
props: Object.keys(argTypes),
components: {
KvSocialShareButton,
},
mixins: [apolloStoryMixin()],
template: `
<kv-social-share-button
:modal-title="modalTitle"
Expand Down
Loading

0 comments on commit 96b6caa

Please sign in to comment.