Skip to content

Commit

Permalink
Merge pull request #4971 from kiva/ACK-722_team_recuitment_on_process…
Browse files Browse the repository at this point in the history
…_page

feat: support inviter param and recruitment on team process page
  • Loading branch information
eddieferrer authored Sep 20, 2023
2 parents 73eeb2c + 2518a2c commit cad124a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 6 deletions.
39 changes: 33 additions & 6 deletions src/pages/ProcessJoinTeam.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<www-page>
<kv-page-container>
<kv-grid class="tw-grid-cols-12 tw-pt-3 md:tw-pt-5 lg:tw-pt-7 tw-mb-4 md:tw-mb-6">
<kv-grid class="tw-grid-cols-12 tw-pt-5 md:tw-pt-7 lg:tw-pt-9 tw-mb-4 md:tw-mb-6">
<div
class="tw-col-span-12 md:tw-col-start-3 md:tw-col-span-8"
>
Expand All @@ -11,7 +11,7 @@
<kv-loading-spinner class="tw-mt-2" />
</div>
</div>
<div v-else>
<div v-else class="tw-text-center">
<h2 v-if="isPending">
Your request to join the {{ teamName }} team is pending. Please check back later.
</h2>
Expand Down Expand Up @@ -42,11 +42,11 @@ import KvPageContainer from '~/@kiva/kv-components/vue/KvPageContainer';
import KvGrid from '~/@kiva/kv-components/vue/KvGrid';
import KvLoadingSpinner from '~/@kiva/kv-components/vue/KvLoadingSpinner';
const userTeamMembership = gql`query userTeamMembership( $teamPublicId: String!) {
const userTeamMembership = gql`query userTeamMembership( $teamPublicId: String!, $publicId: String!) {
my {
id
userAccount {
id
id
}
}
community {
Expand All @@ -57,6 +57,11 @@ const userTeamMembership = gql`query userTeamMembership( $teamPublicId: String!)
}
name
}
lender(publicId: $publicId) {
id
name
publicId
}
}
}`;
Expand All @@ -79,6 +84,11 @@ export default {
type: Number,
default: null
},
// the public name of the inviter user in the route query
inviter: {
type: String,
default: ''
},
},
components: {
KvLoadingSpinner,
Expand All @@ -93,24 +103,28 @@ export default {
preFetchVariables({ route }) {
return {
teamPublicId: route.query.teamPublicId,
publicId: route.query.inviter ?? '',
};
},
variables() {
return {
teamPublicId: this.teamPublicId,
publicId: this.inviter ?? '',
};
},
result({ data }) {
this.userMembershipStatus = data?.community?.team?.userProperties?.membershipStatus ?? 'none';
this.teamName = data?.community?.team?.name ?? '';
this.teamId = data?.community?.team?.id ?? 0;
this.inviterRecruitmentId = data?.community?.lender?.id ?? null;
}
},
data() {
return {
userMembershipStatus: 'none',
isLoading: true,
teamName: '',
inviterRecruitmentId: null
};
},
computed: {
Expand All @@ -125,6 +139,16 @@ export default {
|| this.userMembershipStatus === 'recruited'
|| this.userMembershipStatus === 'recruitedByPromo';
},
recruitmentIdMutationVariable() {
// if teamRecruitmentId in the route query, use that value,
// otherwise, use the value we got from the apollo query
if (this.teamRecruitmentId) {
return this.teamRecruitmentId;
} if (this.inviter) {
return this.inviterRecruitmentId;
}
return null;
}
},
methods: {
memberRedirect() {
Expand All @@ -138,15 +162,17 @@ export default {
mutation: joinTeam,
variables: {
team_id: this.teamId,
team_recruitment_id: this.teamRecruitmentId,
promo_id: this.promoId
...(this.recruitmentIdMutationVariable
&& { team_recruitment_id: this.recruitmentIdMutationVariable }),
...(this.promoId && { promo_id: this.promoId }),
}
});
// get updated team membership status to determine if joined or pending
const { data: userMembershipData } = await this.apollo.query({
query: userTeamMembership,
variables: {
teamPublicId: this.teamPublicId,
publicId: this.inviter ?? '',
},
fetchPolicy: 'network-only'
});
Expand Down Expand Up @@ -176,6 +202,7 @@ export default {
this.handleJoinTeam();
} else {
// is member, redirect to doneUrl or team page
this.$showTipMsg('You are already a member of this team');
this.memberRedirect();
}
}
Expand Down
1 change: 1 addition & 0 deletions src/router/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,7 @@ module.exports = [
teamRecruitmentId: Number(route.query.teamRecruitmentId),
teamPublicId: route.query.teamPublicId,
promoId: Number(route.query.promoId),
inviter: route.query.inviter
})
},
{
Expand Down

0 comments on commit cad124a

Please sign in to comment.