diff --git a/frontend/src/lib/components/reporting/ReportingDateRangeSelector.svelte b/frontend/src/lib/components/reporting/ReportingDateRangeSelector.svelte
index 631cb7ee50c..07cd9ae3b00 100644
--- a/frontend/src/lib/components/reporting/ReportingDateRangeSelector.svelte
+++ b/frontend/src/lib/components/reporting/ReportingDateRangeSelector.svelte
@@ -1,11 +1,11 @@
@@ -28,8 +28,8 @@
type="radio"
name="dateRange"
value={option.value}
- checked={selectedRange === option.value}
- aria-checked={selectedRange === option.value}
+ checked={period === option.value}
+ aria-checked={period === option.value}
on:change={() => handleChange(option.value)}
/>
{option.label}
diff --git a/frontend/src/lib/components/reporting/ReportingTransactions.svelte b/frontend/src/lib/components/reporting/ReportingTransactions.svelte
index 8e4d2d77810..ebfe39313b4 100644
--- a/frontend/src/lib/components/reporting/ReportingTransactions.svelte
+++ b/frontend/src/lib/components/reporting/ReportingTransactions.svelte
@@ -1,11 +1,11 @@
diff --git a/frontend/src/lib/services/reporting.services.ts b/frontend/src/lib/services/reporting.services.ts
index 3991bb3ec9e..e2a26facd7a 100644
--- a/frontend/src/lib/services/reporting.services.ts
+++ b/frontend/src/lib/services/reporting.services.ts
@@ -1,26 +1,16 @@
import { getTransactions } from "$lib/api/icp-index.api";
import type { Account } from "$lib/types/account";
-import type { TransactionsDateRange } from "$lib/types/reporting";
+import type {
+ TransactionEntity,
+ TransactionResults,
+ TransactionsDateRange,
+} from "$lib/types/reporting";
import { neuronStake } from "$lib/utils/neuron.utils";
import { SignIdentity } from "@dfinity/agent";
import type { TransactionWithId } from "@dfinity/ledger-icp";
import type { NeuronInfo } from "@dfinity/nns";
import { isNullish, nonNullish } from "@dfinity/utils";
-type TransactionEntity =
- | {
- identifier: string;
- balance: bigint;
- type: "account";
- originalData: Account;
- }
- | {
- identifier: string;
- balance: bigint;
- type: "neuron";
- originalData: NeuronInfo;
- };
-
const accountToTransactionEntity = (account: Account): TransactionEntity => {
return {
identifier: account.identifier,
@@ -46,12 +36,6 @@ export const mapAccountOrNeuronToTransactionEntity = (
return accountToTransactionEntity(entity);
};
-export type TransactionResults = {
- entity: TransactionEntity;
- transactions: TransactionWithId[];
- error?: string;
-}[];
-
export const getAccountTransactionsConcurrently = async ({
entities,
identity,
@@ -171,7 +155,13 @@ export const getAllTransactionsFromAccountAndIdentity = async ({
}
};
-// Helper function to filter transactions by date range
+/**
+ * Filters an array of transactions based on a timestamp range.
+ *
+ * @param transactions - Array of transactions to filter
+ * @param range - Optional time range with inclusive 'from' and exclusive 'to' timestamps in nanoseconds
+ * @returns Filtered array of transactions that fall within the specified range
+ */
const filterTransactionsByRange = (
transactions: TransactionWithId[],
range?: TransactionsDateRange
diff --git a/frontend/src/lib/types/reporting.ts b/frontend/src/lib/types/reporting.ts
index 39d384c4e4a..31e95f60db6 100644
--- a/frontend/src/lib/types/reporting.ts
+++ b/frontend/src/lib/types/reporting.ts
@@ -1,4 +1,8 @@
-export type ReportingDateRange = "all" | "last-year" | "year-to-date";
+import type { Account } from "$lib/types/account";
+import type { TransactionWithId } from "@dfinity/ledger-icp";
+import type { NeuronInfo } from "@dfinity/nns";
+
+export type ReportingPeriod = "all" | "last-year" | "year-to-date";
export type TransactionsDateRange = {
/** Start of the date range (inclusive) - timestamp in nanoseconds */
@@ -6,3 +10,23 @@ export type TransactionsDateRange = {
/** End of the date range (exclusive) - timestamp in nanoseconds */
to?: bigint;
};
+
+export type TransactionEntity =
+ | {
+ identifier: string;
+ balance: bigint;
+ type: "account";
+ originalData: Account;
+ }
+ | {
+ identifier: string;
+ balance: bigint;
+ type: "neuron";
+ originalData: NeuronInfo;
+ };
+
+export type TransactionResults = {
+ entity: TransactionEntity;
+ transactions: TransactionWithId[];
+ error?: string;
+}[];
diff --git a/frontend/src/lib/utils/reporting.utils.ts b/frontend/src/lib/utils/reporting.utils.ts
index 1cf2c37f090..d5381e7a97f 100644
--- a/frontend/src/lib/utils/reporting.utils.ts
+++ b/frontend/src/lib/utils/reporting.utils.ts
@@ -1,6 +1,6 @@
-import type { TransactionResults } from "$lib/services/reporting.services";
import type {
- ReportingDateRange,
+ ReportingPeriod,
+ TransactionResults,
TransactionsDateRange,
} from "$lib/types/reporting";
import {
@@ -465,7 +465,7 @@ export const buildNeuronsDatasets = ({
};
export const convertPeriodToNanosecondRange = (
- period: ReportingDateRange
+ period: ReportingPeriod
): TransactionsDateRange => {
const now = new Date();
const currentYear = now.getFullYear();