Skip to content
This repository was archived by the owner on Jul 14, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions assets/javascripts/discourse/connectors/user-main-nav/billing.gjs
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
import Component from "@ember/component";
import { LinkTo } from "@ember/routing";
import { service } from "@ember/service";
import { classNames, tagName } from "@ember-decorators/component";
import icon from "discourse/helpers/d-icon";
import { i18n } from "discourse-i18n";
import userViewingSelf from "../../helpers/user-viewing-self";

@tagName("li")
@classNames("user-main-nav-outlet", "billing")
export default class Billing extends Component {
@service currentUser;

get viewingSelf() {
return (
this.currentUser &&
this.currentUser.username.toLowerCase() ===
this.model.username.toLowerCase()
);
}

<template>
{{#if (userViewingSelf this.model)}}
{{#if this.viewingSelf}}
<LinkTo @route="user.billing">
{{icon "far-credit-card"}}
{{i18n "discourse_subscriptions.navigation.billing"}}
Expand Down
8 changes: 2 additions & 6 deletions assets/javascripts/discourse/helpers/format-currency.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { helper } from "@ember/component/helper";

export function formatCurrency([currency, amount]) {
export default function formatCurrency(currency, amount) {
let currencySign;

switch (currency.toUpperCase()) {
Expand Down Expand Up @@ -38,8 +36,6 @@ export function formatCurrency([currency, amount]) {
currencySign = "$";
}

let formattedAmount = parseFloat(amount).toFixed(2);
const formattedAmount = parseFloat(amount).toFixed(2);
return currencySign + formattedAmount;
}

export default helper(formatCurrency);
7 changes: 0 additions & 7 deletions assets/javascripts/discourse/helpers/stripe-payment-link.js

This file was deleted.

11 changes: 0 additions & 11 deletions assets/javascripts/discourse/helpers/user-viewing-self.js

This file was deleted.

10 changes: 5 additions & 5 deletions test/javascripts/unit/helpers/format-currency-test.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { setupTest } from "ember-qunit";
import { module, test } from "qunit";
import { formatCurrency } from "discourse/plugins/discourse-subscriptions/discourse/helpers/format-currency";
import formatCurrency from "discourse/plugins/discourse-subscriptions/discourse/helpers/format-currency";

module("Subscriptions | Unit | Helper | format-currency", function (hooks) {
setupTest(hooks);

test("it formats USD correctly", function (assert) {
let result = formatCurrency(["USD", 338.2]);
test("formats USD correctly", function (assert) {
const result = formatCurrency("USD", 338.2);
assert.equal(result, "$338.20", "Formats USD correctly");
});

test("it rounds correctly", function (assert) {
let result = formatCurrency(["USD", 338.289]);
test("rounds correctly", function (assert) {
const result = formatCurrency("USD", 338.289);
assert.equal(result, "$338.29", "Rounds correctly");
});
});