Skip to content

Commit

Permalink
typescript changes to make ci run pass
Browse files Browse the repository at this point in the history
  • Loading branch information
Moggach committed Sep 4, 2024
1 parent 2aad3d5 commit 6a885df
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
10 changes: 5 additions & 5 deletions frontend/controllers/donation-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,21 @@ import { Controller } from "@hotwired/stimulus";

class DonationController extends Controller {
static targets = ["input"];
inputTargets: any;

setInputs(value: number) {
// If the new value is one of the radios, select them
// Else unselect all radios
if (value) {
this.inputTargets.forEach((input) => {
this.inputTargets.forEach((input: { type: string; checked: boolean; value: string | number; }) => {
if (input.type === "radio") {
input.checked = parseFloat(input.value) === value;
input.checked = parseFloat(input.value as string) === value;
} else {
input.value = value;
input.value = String(value);
}
});
} else {
this.inputTargets.forEach((input) => {
this.inputTargets.forEach((input: { type: string; checked: boolean; value: string; }) => {
if (input.type === "radio") {
input.checked = false;
} else {
Expand All @@ -24,7 +25,6 @@ class DonationController extends Controller {
});
}
}

update(e: InputEvent) {
let value = parseFloat((e.target as HTMLInputElement)?.value || "0") || 0;
this.setInputs(value);
Expand Down
9 changes: 4 additions & 5 deletions frontend/controllers/product-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,9 @@ export default class ShopifyBuyControllerBase extends Controller {
}
private LOCALSTORAGE_CHECKOUT_ID = "checkoutId";

get checkoutId() {
return window.localStorage
.getItem(this.LOCALSTORAGE_CHECKOUT_ID)
?.toString();
get checkoutId(): string | number {
const id = window.localStorage.getItem(this.LOCALSTORAGE_CHECKOUT_ID);
return id ? id.toString() : "";
}

set checkoutId(id: string | number) {
Expand All @@ -81,7 +80,7 @@ export default class ShopifyBuyControllerBase extends Controller {
});

if (this.checkoutId) {
this.checkoutValue = await this.client.checkout.fetch(this.checkoutId);
this.checkoutValue = await this.client.checkout.fetch(this.checkoutId.toString());
}

let checkoutIsExpired = false;
Expand Down
10 changes: 8 additions & 2 deletions frontend/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ import "bootstrap";
import initialiseSentry from "./sentry";
import initialisePosthog from "./posthog";
import { startApp } from "groundwork-django";
const controllers = import.meta.glob("./controllers/*-controller.ts");
import { ControllerConstructor } from "@hotwired/stimulus";

const controllers = import.meta.glob("./controllers/*-controller.ts") as Record<
string,
() => Promise<{ default: ControllerConstructor }>
>;

Turbo.session.drive = false;

initialisePosthog();
Expand All @@ -17,4 +23,4 @@ import { Application } from "@hotwired/stimulus";
import ReadMore from "stimulus-read-more";
const application = Application.start();
application.register("read-more", ReadMore);
application.debug = true;
application.debug = true;

0 comments on commit 6a885df

Please sign in to comment.