Skip to content

Commit f1bcacc

Browse files
authored
Merge pull request #2977 from codecrafters-io/feat/replacement-currentPeriodEnd-cancelAt
feat(subscription): replace currentPeriodEnd with cancelAt
2 parents b40300b + b2da330 commit f1bcacc

File tree

5 files changed

+6
-21
lines changed

5 files changed

+6
-21
lines changed

app/components/settings/billing-page/membership-section.hbs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
Membership active
55
</Settings::BillingPage::StatusPill>
66
<div class="prose prose-sm prose-compact dark:prose-invert">
7-
{{#if (and @user.isVip (gt @user.vipStatusExpiresAt @user.activeSubscription.currentPeriodEnd))}}
7+
{{#if (and @user.isVip (gt @user.vipStatusExpiresAt @user.activeSubscription.cancelAt))}}
88
<p class="line-through">
99
You have access to all CodeCrafters content, valid until
10-
<strong>{{date-format @user.activeSubscription.currentPeriodEnd format="PPPp"}}</strong>.
10+
<strong>{{date-format @user.activeSubscription.cancelAt format="PPPp"}}</strong>.
1111
</p>
1212
<p>
1313
🎉 You have VIP access to all CodeCrafters content, valid until
@@ -16,7 +16,7 @@
1616
{{else}}
1717
<p>
1818
You have access to all CodeCrafters content, valid until
19-
<strong>{{date-format @user.activeSubscription.currentPeriodEnd format="PPPp"}}</strong>.
19+
<strong>{{date-format @user.activeSubscription.cancelAt format="PPPp"}}</strong>.
2020
</p>
2121
{{/if}}
2222
</div>

app/models/subscription.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import type UserModel from 'codecrafters-frontend/models/user';
33

44
export default class SubscriptionModel extends Model {
55
@attr('date') declare cancelAt: Date;
6-
@attr('date') declare currentPeriodEnd: Date;
76
@attr('date') declare endedAt: Date | null;
87
@attr('date') declare startDate: Date;
98

mirage/handlers/subscriptions.js

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,4 @@ export default function (server) {
88
server.post('/sessions/logout', function () {
99
return new Response(200, {}, {});
1010
});
11-
12-
server.post('/subscriptions/:id/cancel-trial', function (schema, request) {
13-
const subscription = schema.subscriptions.find(request.params.id);
14-
subscription.update({ endedAt: new Date() });
15-
16-
return subscription;
17-
});
18-
19-
server.post('/subscriptions/:id/cancel', function (schema, request) {
20-
const subscription = schema.subscriptions.find(request.params.id);
21-
subscription.update({ cancelAt: subscription.currentPeriodEnd });
22-
23-
return subscription;
24-
});
2511
}

tests/acceptance/settings-page/billing-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ module('Acceptance | settings-page | billing-test', function (hooks) {
1616
testScenario(this.server);
1717
signInAsSubscriber(this.owner, this.server);
1818
const subscription = this.server.schema.subscriptions.first();
19-
subscription.update('currentPeriodEnd', new Date('2035-07-31T01:00:00Z'));
19+
subscription.update('cancelAt', new Date('2035-07-31T01:00:00Z'));
2020

2121
await billingPage.visit();
2222

@@ -37,7 +37,7 @@ module('Acceptance | settings-page | billing-test', function (hooks) {
3737
user.update('isVip', true);
3838
user.update('vipStatusExpiresAt', new Date('2035-08-31T01:00:00Z'));
3939
const subscription = this.server.schema.subscriptions.first();
40-
subscription.update('currentPeriodEnd', new Date('2035-07-31T01:00:00Z'));
40+
subscription.update('cancelAt', new Date('2035-07-31T01:00:00Z'));
4141

4242
await billingPage.visit();
4343

tests/support/authentication-helpers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ export function signInAsSubscriber(owner, server, user) {
5252
user = user || server.schema.users.find('63c51e91-e448-4ea9-821b-a80415f266d3');
5353

5454
server.create('subscription', {
55+
cancelAt: new Date(new Date().getTime() + 24 * 60 * 60 * 1000),
5556
user: user,
56-
currentPeriodEnd: new Date(new Date().getTime() + 24 * 60 * 60 * 1000),
5757
});
5858

5959
return signIn(owner, server, user);

0 commit comments

Comments
 (0)