Skip to content

Commit 4f095a9

Browse files
authored
Merge pull request #2811 from codecrafters-io/arpan/cc-1703-revamp-membership-page
Add a billing tab to the settings
2 parents f6fe8ec + 4419bb2 commit 4f095a9

40 files changed

+559
-407
lines changed

app/components/billing-status-badge/member-badge.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<PrimaryLinkButton @size={{this.linkButtonSize}} @route="membership" data-test-member-badge ...attributes>
1+
<PrimaryLinkButton @size={{this.linkButtonSize}} @route="settings.billing" data-test-member-badge ...attributes>
22

33
<span class="flex items-center">
44
Member

app/components/header/account-dropdown.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export default class AccountDropdownComponent extends Component {
5252
@action
5353
async handleManageSubscriptionClick(dropdownActions: { close: () => void }) {
5454
dropdownActions.close();
55-
this.router.transitionTo('membership');
55+
this.router.transitionTo('settings.billing');
5656
}
5757

5858
@action

app/components/membership-page/actions-section.hbs

Lines changed: 0 additions & 26 deletions
This file was deleted.

app/components/membership-page/actions-section.js

Lines changed: 0 additions & 23 deletions
This file was deleted.

app/components/membership-page/membership-plan-section.hbs

Lines changed: 0 additions & 29 deletions
This file was deleted.

app/components/membership-page/membership-plan-section.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

app/components/membership-page/payment-method-section.hbs

Lines changed: 0 additions & 9 deletions
This file was deleted.

app/components/membership-page/payment-method-section.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

app/components/membership-page/recent-payments-section.hbs

Lines changed: 0 additions & 51 deletions
This file was deleted.

app/components/membership-page/recent-payments-section.js

Lines changed: 0 additions & 20 deletions
This file was deleted.

app/components/membership-page/section.hbs

Lines changed: 0 additions & 10 deletions
This file was deleted.

app/components/membership-page/section.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

app/components/membership-page/upcoming-payment-section.hbs

Lines changed: 0 additions & 17 deletions
This file was deleted.

app/components/membership-page/upcoming-payment-section.js

Lines changed: 0 additions & 19 deletions
This file was deleted.
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<Settings::FormSection @title="Membership" @description="Your CodeCrafters membership details" data-test-membership-section>
2+
{{#if @user.hasActiveSubscription}}
3+
<Settings::BillingPage::StatusPill @color="green" class="mb-3">
4+
Membership active
5+
</Settings::BillingPage::StatusPill>
6+
<div class="prose prose-sm prose-compact dark:prose-invert">
7+
{{#if (and @user.isVip (gt @user.vipStatusExpiresAt @user.activeSubscription.currentPeriodEnd))}}
8+
<p class="line-through">
9+
You have access to all CodeCrafters content, valid until
10+
<strong>{{date-format @user.activeSubscription.currentPeriodEnd format="PPPp"}}</strong>.
11+
</p>
12+
<p>
13+
🎉 You have VIP access to all CodeCrafters content, valid until
14+
<strong>{{date-format @user.vipStatusExpiresAt format="PPPp"}}</strong>.
15+
</p>
16+
{{else}}
17+
<p>
18+
You have access to all CodeCrafters content, valid until
19+
<strong>{{date-format @user.activeSubscription.currentPeriodEnd format="PPPp"}}</strong>.
20+
</p>
21+
{{/if}}
22+
</div>
23+
{{else if @user.isVip}}
24+
<Settings::BillingPage::StatusPill @color="green" class="mb-3">
25+
VIP Access
26+
</Settings::BillingPage::StatusPill>
27+
<div class="prose prose-sm prose-compact dark:prose-invert">
28+
<p>
29+
{{#if @user.vipStatusExpiresAt}}
30+
🎉 You have VIP access to all CodeCrafters content, valid until
31+
<strong>{{date-format @user.vipStatusExpiresAt format="PPPp"}}</strong>.
32+
{{else}}
33+
🎉 You have VIP access to all CodeCrafters content.
34+
{{/if}}
35+
</p>
36+
</div>
37+
{{else if @user.expiredSubscription}}
38+
<Settings::BillingPage::StatusPill @color="red" class="mb-3">
39+
Membership inactive
40+
</Settings::BillingPage::StatusPill>
41+
<div class="prose prose-sm prose-compact dark:prose-invert">
42+
<p>
43+
Your CodeCrafters membership is
44+
<strong class="text-red-600">currently inactive</strong>.
45+
</p>
46+
<p>
47+
Start a new membership to get access to
48+
<a href="https://docs.codecrafters.io/membership" target="_blank" rel="noopener noreferrer">membership benefits</a>.
49+
</p>
50+
</div>
51+
<PrimaryLinkButton @size="small" @route="pay" class="mt-3">
52+
Start membership →
53+
</PrimaryLinkButton>
54+
{{else}}
55+
<Settings::BillingPage::StatusPill @color="yellow" class="mb-3">
56+
No membership found
57+
</Settings::BillingPage::StatusPill>
58+
<div class="prose prose-sm prose-compact dark:prose-invert">
59+
<p>
60+
You don't have a CodeCrafters membership. Start one to get access to
61+
<a href="https://docs.codecrafters.io/membership" target="_blank" rel="noopener noreferrer">membership benefits</a>.
62+
</p>
63+
</div>
64+
<PrimaryLinkButton @size="small" @route="pay" class="mt-3">
65+
Start membership →
66+
</PrimaryLinkButton>
67+
{{/if}}
68+
</Settings::FormSection>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import Component from '@glimmer/component';
2+
import type UserModel from 'codecrafters-frontend/models/user';
3+
4+
interface Signature {
5+
Element: HTMLDivElement;
6+
7+
Args: {
8+
user: UserModel;
9+
};
10+
}
11+
12+
export default class MembershipSectionComponent extends Component<Signature> {}
13+
14+
declare module '@glint/environment-ember-loose/registry' {
15+
export default interface Registry {
16+
'Settings::BillingPage::MembershipSection': typeof MembershipSectionComponent;
17+
}
18+
}

0 commit comments

Comments
 (0)