Skip to content

Commit 12cb8c0

Browse files
committed
fix: rename affiliate username and avatar fields across UI and model
Update all references from usernameForDisplay and overriddenAffiliateAvatarUrl to affiliateUsername and affiliateAvatarUrl respectively. Remove deprecated overridden fields from the AffiliateLink model. These changes unify how affiliate usernames and avatars are handled and ensure consistent display across referral notices, join pages, and membership plan components.
1 parent e3e959d commit 12cb8c0

File tree

8 files changed

+17
-40
lines changed

8 files changed

+17
-40
lines changed

app/components/affiliate-link-page/accept-referral-button.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
{{else if this.currentUserIsReferrer}}
1818
<EmberTooltip @text="You can't accept your own referral offer." />
1919
{{else if this.currentUserHasActiveDiscountFromAffiliateReferral}}
20-
<EmberTooltip @text="You've already accepted {{this.currentUser.currentAffiliateReferral.affiliateLink.usernameForDisplay}}'s referral offer." />
20+
<EmberTooltip @text="You've already accepted {{this.currentUser.currentAffiliateReferral.affiliateLink.affiliateUsername}}'s referral offer." />
2121
{{else if this.currentUserCanAccessMembershipBenefits}}
2222
<EmberTooltip @text="As a CodeCrafters member, you already have full access." />
2323
{{/if}}

app/components/affiliate-link-page/accept-referral-container.hbs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,15 @@
55
...attributes
66
>
77
<div class="flex items-center justify-center">
8-
{{#if @affiliateLink.overriddenAffiliateAvatarUrl}}
9-
{{! No border for overridden avatars, we'll expect them to include a border in the image itself if needed }}
10-
<img alt="avatar" src={{@affiliateLink.overriddenAffiliateAvatarUrl}} class="w-16 h-16 mr-2" />
11-
{{else}}
12-
<AvatarImage
13-
@user={{@affiliateLink.user}}
14-
class="w-16 h-16 border border-gray-300 shadow-xs group-hover:shadow-sm mr-2 transition-shadow rounded-md"
15-
/>
16-
{{/if}}
8+
<img alt="avatar" src={{@affiliateLink.affiliateAvatarUrl}} class="w-16 h-16 mr-2" />
179

1810
{{svg-jar "plus" class="w-10 h-10 text-gray-600 dark:text-gray-400 mr-2 opacity-90 group-hover:opacity-100 transition-all"}}
1911

2012
<img class="h-14" src={{this.logoImage}} alt="CodeCrafters" />
2113
</div>
2214

2315
<div class="prose dark:prose-invert text-center max-w-sm">
24-
<b class="dark:text-gray-50">@{{@affiliateLink.usernameForDisplay}}</b>
16+
<b class="dark:text-gray-50">@{{@affiliateLink.affiliateUsername}}</b>
2517
wants you to try CodeCrafters. Signing up is free.
2618
<b class="dark:text-gray-50">40% off</b>
2719
if you upgrade.

app/components/pay-page/choose-membership-plan-modal/plan-card.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
5959
{{#if @promotionalDiscount.isFromAffiliateReferral}}<span
6060
class="text-nowrap"
61-
>{{@promotionalDiscount.affiliateReferral.affiliateLink.usernameForDisplay}}'s</span>
61+
>{{@promotionalDiscount.affiliateReferral.affiliateLink.affiliateUsername}}'s</span>
6262
referral offer{{else if @promotionalDiscount.isFromStage2Completion}}Stage 2 completion discount{{else if
6363
@promotionalDiscount.isFromSignup
6464
}}Signup discount{{/if}}, expires in

app/components/pay-page/referral-discount-notice.hbs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,13 @@
88
</div>
99

1010
<div class="bg-repeating-gradient-to-b from-yellow-100 to-amber-500 text-transparent bg-clip-text leading-7 inline-block mt-0.5">
11-
{{#if @discount.affiliateReferral.affiliateLink.overriddenAffiliateAvatarUrl}}
12-
<img
13-
alt="avatar"
14-
src={{@discount.affiliateReferral.affiliateLink.overriddenAffiliateAvatarUrl}}
15-
class="inline-block mb-0 w-6 h-6 transform -translate-y-px"
16-
/>
17-
{{else}}
18-
<AvatarImage
19-
@user={{@discount.affiliateReferral.referrer}}
20-
class="inline-block mb-0 w-6 h-6 border border-gray-100 rounded-full transform -translate-y-px"
21-
/>
22-
{{/if}}
11+
<img
12+
alt="avatar"
13+
src={{@discount.affiliateReferral.affiliateLink.affiliateAvatarUrl}}
14+
class="inline-block mb-0 w-6 h-6 transform -translate-y-px"
15+
/>
2316

24-
<b>{{@discount.affiliateReferral.affiliateLink.usernameForDisplay}}</b>'s referral offer: Subscribe in
17+
<b>{{@discount.affiliateReferral.affiliateLink.affiliateUsername}}</b>'s referral offer: Subscribe in
2518
<span class="font-bold percy-timestamp font-mono text-lg border-b border-yellow-500 border-dashed">{{this.timeLeftText}}</span>
2619
to get
2720
<span class="font-bold">40% off</span>

app/models/affiliate-link.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,15 @@ export default class AffiliateLinkModel extends Model {
99

1010
@hasMany('affiliate-referral', { async: false, inverse: 'affiliateLink' }) declare referrals: AffiliateReferralModel[];
1111

12+
@attr('string') declare affiliateUsername: string;
13+
@attr('string') declare affiliateAvatarUrl: string;
1214
@attr('string') declare slug: string;
1315
@attr('string') declare url: string;
14-
@attr('string') declare overriddenAffiliateUsername: string | null;
15-
@attr('string') declare overriddenAffiliateAvatarUrl: string | null;
16-
17-
get avatarUrlForDisplay() {
18-
return this.overriddenAffiliateAvatarUrl || this.user.avatarUrl;
19-
}
2016

2117
get totalEarningsAmountInCents() {
2218
return this.referrals.reduce((sum, referral) => sum + referral.totalEarningsAmountInCents, 0);
2319
}
2420

25-
get usernameForDisplay() {
26-
return this.overriddenAffiliateUsername || this.user.username;
27-
}
28-
2921
get visibleReferrals(): AffiliateReferralModel[] {
3022
const referralsGroupedByCustomer = this.referrals.reduce(
3123
groupByFieldReducer((referral) => referral.customer.id),

app/templates/join-course.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{page-title (concat "Join " this.model.affiliateLink.usernameForDisplay " on CodeCrafters") replace=true}}
1+
{{page-title (concat "Join " this.model.affiliateLink.affiliateUsername " on CodeCrafters") replace=true}}
22

33
{{! Note: This is very similar to the course overview page atm so it re-uses a lot of the same components. }}
44
<div class="container mx-auto lg:max-w-(--breakpoint-lg) pt-6 md:pt-10 pb-10 px-3 md:px-6">

app/templates/join-track.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{page-title (concat "Join " this.model.affiliateLink.usernameForDisplay " on CodeCrafters") replace=true}}
1+
{{page-title (concat "Join " this.model.affiliateLink.affiliateUsername " on CodeCrafters") replace=true}}
22

33
{{! Note: This is very similar to the track page atm so it re-uses a lot of the same components. }}
44
<div class="container mx-auto lg:max-w-(--breakpoint-lg) px-3 md:px-6 py-6 md:py-10">

app/templates/join.hbs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{page-title (concat "Join " this.model.affiliateLink.usernameForDisplay " on CodeCrafters") replace=true}}
1+
{{page-title (concat "Join " this.model.affiliateLink.affiliateUsername " on CodeCrafters") replace=true}}
22

33
<div class="bg-white bg-github-green-dot-wall">
44
<div class="container mx-auto lg:max-w-(--breakpoint-xl) pt-8 sm:pt-16 pb-48 px-3 md:px-6">
@@ -41,7 +41,7 @@
4141

4242
<div class="flex flex-col gap-4 justify-center items-center mt-16">
4343
<AffiliateLinkPage::AcceptReferralButton @affiliateLink={{this.model.affiliateLink}} />
44-
<div class="text-xs text-slate-700 text-center">Get access to 40% off via @{{@model.affiliateLink.usernameForDisplay}}</div>
44+
<div class="text-xs text-slate-700 text-center">Get access to 40% off via @{{@model.affiliateLink.affiliateUsername}}</div>
4545
</div>
4646

4747
<h2 class="text-2xl font-bold text-gray-900 md:text-3xl text-center mt-16">
@@ -56,7 +56,7 @@
5656

5757
<div class="flex flex-col gap-4 justify-center items-center mt-16">
5858
<AffiliateLinkPage::AcceptReferralButton @affiliateLink={{this.model.affiliateLink}} />
59-
<div class="text-xs text-slate-700 text-center">Get access to 40% off via @{{@model.affiliateLink.usernameForDisplay}}</div>
59+
<div class="text-xs text-slate-700 text-center">Get access to 40% off via @{{@model.affiliateLink.affiliateUsername}}</div>
6060
</div>
6161
</div>
6262
</div>

0 commit comments

Comments
 (0)