From 58f5e8d886431eb3e25b7f61c97b5a931d977012 Mon Sep 17 00:00:00 2001 From: Christian Bedon Date: Mon, 26 Jan 2026 14:14:47 -0500 Subject: [PATCH 1/7] feat: set cookie at ty page to show kiva survey in my kiva --- .../Contentful/JourneyCardCarousel.vue | 3 ++- .../Thanks/ThanksPageSingleVersion.vue | 21 +++++++++++++++++++ src/graphql/query/thanksPage.graphql | 4 ++++ src/pages/Thanks/ThanksPage.vue | 3 +++ 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/components/Contentful/JourneyCardCarousel.vue b/src/components/Contentful/JourneyCardCarousel.vue index 28530b625b6..ade27ee7d3f 100644 --- a/src/components/Contentful/JourneyCardCarousel.vue +++ b/src/components/Contentful/JourneyCardCarousel.vue @@ -290,9 +290,10 @@ const showLatestLoan = computed(() => props.postLendingNextStepsEnable && props. const showSurveyCard = computed(() => { const userPreferences = props.userInfo?.userPreferences || {}; const parsedPrefs = JSON.parse(userPreferences.preferences || '{}'); + const isFormEnabled = parsedPrefs?.myKivaSurveyEnabled ?? false; const isFormSubmitted = (parsedPrefs.savedForms || []).some(form => form.formName === MYKIVA_INPUT_FORM_KEY); - return !isFormSubmitted && props.postLendingNextStepsEnable; + return isFormEnabled && !isFormSubmitted && props.postLendingNextStepsEnable; }); const badgesData = computed(() => { diff --git a/src/components/Thanks/ThanksPageSingleVersion.vue b/src/components/Thanks/ThanksPageSingleVersion.vue index e4a8ba2ed6e..ebf994e89f1 100644 --- a/src/components/Thanks/ThanksPageSingleVersion.vue +++ b/src/components/Thanks/ThanksPageSingleVersion.vue @@ -138,6 +138,7 @@ import GoalInProgress from '#src/components/Thanks/SingleVersion/GoalInProgress' import useGoalData, { GOAL_STATUS } from '#src/composables/useGoalData'; import useBadgeData from '#src/composables/useBadgeData'; import { setGuestAssignmentCookie } from '#src/util/myKivaUtils'; +import { createUserPreferences, updateUserPreferences } from '#src/util/userPreferenceUtils'; const EVENT_CATEGORY = 'post-checkout'; @@ -198,6 +199,10 @@ const props = defineProps({ type: Array, default: () => ([]), }, + userPreferences: { + type: Object, + default: () => ({}), + }, }); const badgeAchievedIds = ref(props.badgesAchieved.map(b => b.achievementId)); @@ -416,6 +421,22 @@ onMounted(async () => { 'all-achievements-earned', ); } + + // Enable survey in My Kiva + const userPreferences = props.userPreferences || {}; + const parsedPrefs = JSON.parse(userPreferences.preferences || '{}'); + if (!parsedPrefs?.myKivaSurveyEnabled) { + if (!userPreferences?.id) { + return createUserPreferences(apollo, { myKivaSurveyEnabled: true }); + } + + updateUserPreferences( + apollo, + userPreferences, + parsedPrefs, + { myKivaSurveyEnabled: true } + ); + } }); diff --git a/src/graphql/query/thanksPage.graphql b/src/graphql/query/thanksPage.graphql index 685deaca236..f01f63bae47 100644 --- a/src/graphql/query/thanksPage.graphql +++ b/src/graphql/query/thanksPage.graphql @@ -29,6 +29,10 @@ query thanksPage { inviterName public } + userPreferences { + id + preferences + } loans { totalCount } diff --git a/src/pages/Thanks/ThanksPage.vue b/src/pages/Thanks/ThanksPage.vue index b799b9a939e..f4b15a65c21 100644 --- a/src/pages/Thanks/ThanksPage.vue +++ b/src/pages/Thanks/ThanksPage.vue @@ -15,6 +15,7 @@ :goals-v2-enabled="goalsV2Enabled" :total-loans="totalLoanCount" :tiered-achievements="achievements" + :user-preferences="userPreferences" />