Skip to content

Commit 89b62fa

Browse files
committed
refactor(billing-page): update invoice handling to use receipt URL
- Changed the invoice download link to use the receipt URL instead of the invoice ID. - Updated the link text from "Download Invoice" to "View Invoice" for clarity. - Removed the obsolete invoice download URL method from the Charge model.
1 parent 5ade0b2 commit 89b62fa

File tree

2 files changed

+4
-13
lines changed

2 files changed

+4
-13
lines changed

app/components/settings/billing-page/payment-history-section.hbs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@
4242
{{/if}}
4343
</div>
4444
<div class="flex items-center justify-end">
45-
{{#if (and charge.invoiceId charge.statusIsSucceeded)}}
45+
{{#if (and charge.receiptUrl charge.statusIsSucceeded)}}
4646
<a
47-
href={{charge.invoiceDownloadUrl}}
47+
href={{charge.receiptUrl}}
4848
target="_blank"
4949
class="text-teal-500 dark:text-teal-400 hover:text-teal-600 dark:hover:text-teal-300 font-semibold text-sm"
5050
data-test-download-invoice-link
5151
rel="noopener noreferrer"
5252
>
53-
Download Invoice
53+
View Invoice
5454
</a>
5555
{{else if charge.statusIsFailed}}
5656
<span class="text-gray-600 dark:text-gray-300 text-sm">Payment failed</span>

app/models/charge.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import Model, { attr, belongsTo } from '@ember-data/model';
2-
import config from 'codecrafters-frontend/config/environment';
32
import type UserModel from 'codecrafters-frontend/models/user';
43
import { equal } from '@ember/object/computed'; // eslint-disable-line ember/no-computed-properties-in-native-classes
54

@@ -10,7 +9,7 @@ export default class Charge extends Model {
109
@attr('number') declare amountRefunded: number;
1110
@attr('date') declare createdAt: Date;
1211
@attr('string') declare currency: string;
13-
@attr('string') declare invoiceId: string;
12+
@attr('string') declare receiptUrl: string;
1413
@attr('string') declare status: 'succeeded' | 'pending' | 'failed';
1514

1615
@belongsTo('user', { async: false, inverse: null }) declare user: UserModel;
@@ -23,14 +22,6 @@ export default class Charge extends Model {
2322
return Charge.buildDisplayString(this.amount, this.currency);
2423
}
2524

26-
get invoiceDownloadUrl() {
27-
if (!this.invoiceId) {
28-
return null;
29-
}
30-
31-
return `${config.x.backendUrl}/invoices/${this.invoiceId}/download`;
32-
}
33-
3425
get isFullyRefunded() {
3526
return this.amountRefunded === this.amount;
3627
}

0 commit comments

Comments
 (0)