Skip to content

Commit 3f79742

Browse files
committed
update imports and calls
1 parent ef76766 commit 3f79742

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

resources/js/core-legacy/store-supporter-tag.tsx

+13-12
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@ import { route } from 'laroute';
66
import { debounce } from 'lodash';
77
import { fadeToggle } from 'utils/fade';
88
import { toggleCart } from 'utils/store-cart';
9+
import StoreSupporterTagPrice, { durationToPrice } from 'utils/store-supporter-tag-price';
910
import { present } from 'utils/string';
1011

1112
const maxValue = 52;
1213
const minValue = 4;
1314
const resolution = 8;
1415

1516
export default class StoreSupporterTag {
16-
private cost = 0;
17+
private cost;
1718
private readonly debouncedGetUser;
1819

1920

@@ -51,7 +52,7 @@ export default class StoreSupporterTag {
5152
}
5253
});
5354

54-
this.cost = this.calculate(this.initializeSlider().slider('value'));
55+
this.cost = this.calculate(+this.initializeSlider().slider('value'));
5556
this.initializeSliderPresets();
5657
this.initializeUsernameInput();
5758
this.updateCostDisplay();
@@ -73,8 +74,8 @@ export default class StoreSupporterTag {
7374
}
7475
}
7576

76-
private calculate(position: number): number {
77-
return new window.StoreSupporterTagPrice(Math.floor(position / resolution));
77+
private calculate(position: number) {
78+
return new StoreSupporterTagPrice(Math.floor(position / resolution));
7879
}
7980

8081
private readonly getUser = (username: string) => {
@@ -121,7 +122,7 @@ export default class StoreSupporterTag {
121122
private initializeSliderPresets() {
122123
$(this.sliderPresets).on('click', (event) => {
123124
const target = event.currentTarget;
124-
const price = StoreSupporterTagPrice.durationToPrice(target.dataset.months) as (number | undefined);
125+
const price = durationToPrice(+(target.dataset?.months ?? 0));
125126
if (price != null) {
126127
$(this.slider).slider('value', this.sliderValue(price));
127128
}
@@ -152,10 +153,10 @@ export default class StoreSupporterTag {
152153
}
153154

154155
private updateCostDisplay() {
155-
this.el.querySelector('input[name="item[cost]"]').value = this.cost.price();
156-
this.priceElement.textContent = `USD ${this.cost.price()}`;
157-
this.durationElement.textContent = this.cost.durationText();
158-
this.discountElement.textContent = this.cost.discountText();
156+
this.el.querySelector<HTMLElement>('input[name="item[cost]"]').value = this.cost.price;
157+
this.priceElement.textContent = `USD ${this.cost.price}`;
158+
this.durationElement.textContent = this.cost.durationText;
159+
this.discountElement.textContent = this.cost.discountText;
159160
for (const elem of this.sliderPresets) {
160161
this.updateSliderPreset(elem, this.cost);
161162
}
@@ -167,8 +168,8 @@ export default class StoreSupporterTag {
167168
this.updateUserInteraction();
168169
};
169170

170-
private updateSliderPreset(elem: HTMLElement, cost: number) {
171-
$(elem).toggleClass('js-slider-preset--active', cost.duration() >= +elem.dataset.months);
171+
private updateSliderPreset(elem: HTMLElement, cost: StoreSupporterTagPrice) {
172+
$(elem).toggleClass('js-slider-preset--active', cost.duration >= +elem.dataset.months);
172173
}
173174

174175
private updateTargetId() {
@@ -177,7 +178,7 @@ export default class StoreSupporterTag {
177178

178179
private updateUserInteraction() {
179180
const enabled = this.user?.id != null && Number.isFinite(this.user.id) && this.user.id > 0;
180-
const messageInputVisible = enabled && this.user?.id != window.currentUser.id;
181+
const messageInputVisible = enabled && this.user?.id !== window.currentUser.id;
181182
fadeToggle(this.messageInput, messageInputVisible);
182183

183184
toggleCart(enabled);

resources/js/entrypoints/app.ts

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import 'app-deps';
55

66
import 'jquery-pubsub.coffee';
77

8-
import '_classes/store-supporter-tag-price.coffee';
98
import '_classes/timeout.coffee';
109

1110
import 'spoilerbox.coffee';

0 commit comments

Comments
 (0)