Skip to content

Commit

Permalink
feat: Hide page elements based on query param
Browse files Browse the repository at this point in the history
* Hides global promo, nav menu and secondary menu if query param kivaAppReferral=true exists

GD-139
  • Loading branch information
Eddie Ferrer committed Oct 12, 2021
1 parent 628e0f5 commit fce519b
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 12 deletions.
13 changes: 13 additions & 0 deletions src/api/localResolvers/kivaAppReferral.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export default () => {
return {
resolvers: {
Query: {
isKivaAppReferral(obj, args) {
// Takes an argument of the query param value
// and returns a boolean if it is present and equal to true
return args?.kivaAppReferralQueryParam === 'true';
},
}
},
};
};
1 change: 1 addition & 0 deletions src/api/localSchema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ extend type Query {
autolending: Autolending
verificationLightbox: VerificationLightbox
hasEverLoggedIn: Boolean
isKivaAppReferral(kivaAppReferralQueryParam: String): Boolean
}

extend type My {
Expand Down
2 changes: 1 addition & 1 deletion src/components/WwwFrame/LendMenu/TheLendMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export default {
},
methods: {
onOpen() {
this.$refs.mega.onOpen();
this.$refs?.mega?.onOpen?.();
},
onClose() {
this.$refs.list.onClose();
Expand Down
2 changes: 1 addition & 1 deletion src/components/WwwFrame/TheHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ export default {
},
onLendMenuShow() {
if (this.mgHighlightInNavVersion !== 'shown') {
this.$refs.lendMenu.onOpen();
this.$refs?.lendMenu?.onOpen?.();
}
this.$kvTrackEvent('TopNav', 'hover-Lend-menu', 'Lend');
},
Expand Down
49 changes: 39 additions & 10 deletions src/components/WwwFrame/WwwPage.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<template>
<div class="www-page">
<the-banner-area />
<the-header
:hide-search-in-header="hideSearchInHeader"
:theme="headerTheme"
/>
<slot name="secondary"></slot>
<template v-if="!isKivaAppReferral">
<the-banner-area />
<the-header
:hide-search-in-header="hideSearchInHeader"
:theme="headerTheme"
/>
<slot name="secondary"></slot>
</template>
<main :class="mainClasses">
<slot name="tertiary"></slot>
<slot></slot>
Expand All @@ -21,8 +23,10 @@
</template>

<script>
import _get from 'lodash/get';
import hasEverLoggedInQuery from '@/graphql/query/shared/hasEverLoggedIn.graphql';
import isKivaAppReferralQuery from '@/graphql/query/shared/isKivaAppReferral.graphql';
import logReadQueryError from '@/util/logReadQueryError';
import { fetchAllExpSettings } from '@/util/experimentPreFetch';
import appInstallMixin from '@/plugins/app-install-mixin';
import CookieBanner from '@/components/WwwFrame/CookieBanner';
Expand Down Expand Up @@ -68,15 +72,40 @@ export default {
default: '',
},
},
data() {
return {
isKivaAppReferral: false
};
},
apollo: {
preFetch(config, client, args) {
preFetch(config, client, { route }) {
return Promise.all([
client.query({ query: hasEverLoggedInQuery }),
fetchAllExpSettings(config, client, {
query: _get(args, 'route.query'),
path: _get(args, 'route.path')
query: route?.query,
path: route?.path
}),
client.query({
query: isKivaAppReferralQuery,
variables: {
kivaAppReferralQueryParam: route?.query?.kivaAppReferral,
},
})
]);
},
},
created() {
let referralData = {};
try {
referralData = this.apollo.readQuery({
query: isKivaAppReferralQuery,
variables: {
kivaAppReferralQueryParam: this.$route?.query?.kivaAppReferral,
},
});
this.isKivaAppReferral = referralData?.isKivaAppReferral || false;
} catch (e) {
logReadQueryError(e, 'WwwPage isKivaAppReferralQuery');
}
},
computed: {
Expand Down
3 changes: 3 additions & 0 deletions src/graphql/query/shared/isKivaAppReferral.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
query isKivaAppReferral($kivaAppReferralQueryParam: String) {
isKivaAppReferral(kivaAppReferralQueryParam: $kivaAppReferralQueryParam) @client
}

0 comments on commit fce519b

Please sign in to comment.