Skip to content

Commit

Permalink
feat: ability to attribute a loan to a team from cookie value
Browse files Browse the repository at this point in the history
  • Loading branch information
eddieferrer committed Dec 13, 2023
1 parent 4e60e76 commit 5b7cb36
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions src/components/Checkout/TeamAttribution.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ import numeral from 'numeral';
import updateLoanReservationTeam from '@/graphql/mutation/updateLoanReservationTeam.graphql';
import KvSelect from '~/@kiva/kv-components/vue/KvSelect';
const teamChallengeCookieName = 'kv-team-challenge';
export default {
name: 'TeamAttribution',
props: {
Expand All @@ -51,16 +53,18 @@ export default {
components: {
KvSelect
},
inject: ['apollo'],
inject: ['apollo', 'cookieStore'],
data() {
return {
selectedId: this.teamId || 0,
cachedId: null,
appendedTeams: []
};
},
computed: {
sortTeams() {
return _orderBy(this.teams, 'name');
const combinedTeams = [...this.teams, ...this.appendedTeams];
return _orderBy(combinedTeams, 'name');
}
},
watch: {
Expand All @@ -74,6 +78,26 @@ export default {
},
mounted() {
this.selectedId = this.teamId || 0;
// Team Challenge MVP Code
if (this.cookieStore.get(teamChallengeCookieName)) {
const teamChallengeLoanData = JSON.parse(this.cookieStore.get(teamChallengeCookieName));
teamChallengeLoanData.forEach(loan => {
if (loan.loanId === this.loanId) {
// Loan has a different team attribution, we should override the default
// Is team not in the users list, append it
if (!this.teams.some(team => team.id === loan.teamId)) {
this.appendedTeams.push({
id: loan.teamId,
name: loan.teamName
});
}
// Select the team from the cookie value
this.selectedId = loan.teamId;
this.updateLoanReservation();
}
});
}
},
methods: {
updateLoanReservation() {
Expand Down

0 comments on commit 5b7cb36

Please sign in to comment.