Add support for fetching only desired transactions related to specified profile
This commit is contained in:
@@ -7,5 +7,5 @@ buildNpmPackage {
|
||||
pname = "actual-importer-frontend";
|
||||
version = "0.0.1";
|
||||
src = ./.;
|
||||
npmDepsHash = "sha256-/G8OZBAkCuc0LTmpB1v8HTgaWdYd9AJfZTC0/eUQIx0=";
|
||||
npmDepsHash = "sha256-Xh+zpYX8u+wKuvBjGc4hxUI2Ed4tiXKC3zk8kFExBbc=";
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ export default function PrepareTransactionsPage() {
|
||||
|
||||
// If no "from" filter active, pull the latest 10 transactions
|
||||
if (!debouncedUserFilter.from) {
|
||||
const transactions = await getLatestTransactions(state.server, 10);
|
||||
const transactions = await getLatestTransactions(state.server, 10, state.profile);
|
||||
setExistingTransactions(transactions);
|
||||
return;
|
||||
}
|
||||
@@ -87,7 +87,7 @@ export default function PrepareTransactionsPage() {
|
||||
const start = debouncedUserFilter.from.format("YYYY-MM-DD");
|
||||
const end = (debouncedUserFilter.to ?? dayjs()).format("YYYY-MM-DD");
|
||||
|
||||
const transactions = await getDateRangedTransactions(state.server, start, end);
|
||||
const transactions = await getDateRangedTransactions(state.server, start, end, state.profile);
|
||||
setExistingTransactions(transactions);
|
||||
}, [enabledExistingTransactions, state.server, debouncedUserFilter]);
|
||||
|
||||
|
||||
@@ -40,21 +40,29 @@ export async function submitTransactions(transactions: Transaction[], server: st
|
||||
return data as SubmitResponse;
|
||||
}
|
||||
|
||||
export async function getLatestTransactions(server: string, limit: number = 5): Promise<Transaction[]> {
|
||||
export async function getLatestTransactions(server: string, limit: number = 5, profile?: string): Promise<Transaction[]> {
|
||||
const params = new URLSearchParams();
|
||||
params.append('limit', limit.toString());
|
||||
|
||||
if (profile !== undefined) {
|
||||
params.append('profile', profile);
|
||||
}
|
||||
|
||||
const response = await fetch(`/servers/${server}/transactions?${params.toString()}`);
|
||||
const data = await response.json();
|
||||
return data as Transaction[];
|
||||
}
|
||||
|
||||
export async function getDateRangedTransactions(server: string, start: string, end: string): Promise<Transaction[]> {
|
||||
export async function getDateRangedTransactions(server: string, start: string, end: string, profile?: string): Promise<Transaction[]> {
|
||||
const params = new URLSearchParams();
|
||||
|
||||
params.append('start', start);
|
||||
params.append('end', end);
|
||||
|
||||
if (profile !== undefined) {
|
||||
params.append('profile', profile);
|
||||
}
|
||||
|
||||
const response = await fetch(`/servers/${server}/transactions?${params.toString()}`);
|
||||
const data = await response.json();
|
||||
return data as Transaction[];
|
||||
|
||||
Reference in New Issue
Block a user