Skip to content

Commit

Permalink
feat: complete status added to journey
Browse files Browse the repository at this point in the history
  • Loading branch information
roger-in-kiva committed Nov 22, 2024
1 parent 7c6277c commit ef81abc
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/components/MyKiva/BadgesSection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<button
class="tw-text-action hover:tw-underline tw-mt-auto"
>
{{ badge.hasStarted ? 'Continue' : 'Start this journey' }}
{{ ctaCaption(badge) }}
</button>
</div>
</div>
Expand Down Expand Up @@ -74,17 +74,27 @@ const visibleBadges = computed(() => {
.sort(indexIn(defaultBadges, 'id'));
});
const levelCaption = badge => {
return `Level ${getActiveTierData(badge).level}/${getBadgeWithVisibleTiers(badge).achievementData.tiers.length}`;
};
const getBadgeStatus = badge => {
const activeTier = getActiveTierData(badge);
if (activeTier?.level === badge?.achievementData?.tiers?.length) {
return BADGE_COMPLETED;
}
return BADGE_IN_PROGRESS;
};
const levelCaption = badge => {
if (getBadgeStatus(badge) === BADGE_COMPLETED) {
return 'Complete!';
}
return `Level ${getActiveTierData(badge).level}/${getBadgeWithVisibleTiers(badge).achievementData.tiers.length}`;
};
const ctaCaption = badge => {
if (getBadgeStatus(badge) === BADGE_COMPLETED) {
return 'See this journey';
}
return badge.hasStarted ? 'Continue' : 'Start this journey';
};
</script>
<style lang="postcss" scoped>
Expand Down

0 comments on commit ef81abc

Please sign in to comment.