From 2812e72ad39089fb90cbc2c1a68afb0dd85d84c5 Mon Sep 17 00:00:00 2001 From: Eddie Ferrer Date: Wed, 13 Dec 2023 14:33:59 -0700 Subject: [PATCH 1/2] feat: ability to attribute a loan to a team from cookie value --- src/components/Checkout/BasketItem.vue | 40 ++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/src/components/Checkout/BasketItem.vue b/src/components/Checkout/BasketItem.vue index 3b07ab4cf1..0d08d0ac53 100644 --- a/src/components/Checkout/BasketItem.vue +++ b/src/components/Checkout/BasketItem.vue @@ -38,10 +38,10 @@ /> { + if (loan.loanId === this.loan.id) { + // Loan has a different team attribution, we should override the default + // Is team not in the users list, append it + if (!this.combinedTeams.some(team => team.id === loan.teamId)) { + this.appendedTeams.push({ + id: loan.teamId, + name: loan.teamName + }); + } + this.forceTeamId = loan.teamId; + } + }); + } + } }; From a2548e2afe5c8ac89e66e97a70f4f87c60429f56 Mon Sep 17 00:00:00 2001 From: Eddie Ferrer Date: Mon, 18 Dec 2023 09:26:15 -0700 Subject: [PATCH 2/2] feat: clean up cookie for team challenge in basket item after using --- src/components/Checkout/BasketItem.vue | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/components/Checkout/BasketItem.vue b/src/components/Checkout/BasketItem.vue index 0d08d0ac53..2cc9d443d7 100644 --- a/src/components/Checkout/BasketItem.vue +++ b/src/components/Checkout/BasketItem.vue @@ -225,6 +225,13 @@ export default { this.forceTeamId = loan.teamId; } }); + // Remove this loan from the cookie object after we've used it + teamChallengeLoanData.splice( + teamChallengeLoanData.findIndex(loan => loan.loanId === this.loan.id), + 1 + ); + // overwrite the cookie with the new data + this.cookieStore.set(teamChallengeCookieName, JSON.stringify(teamChallengeLoanData)); } } };