feat(expenses): enhance expenses management with filtering and search capabilities
This commit is contained in:
@@ -77,8 +77,8 @@ export function useDailyQuotes(type: string, startDate: string, endDate: string)
|
||||
export const expenseKeys = {
|
||||
periodic: ["periodic-expenses"] as const,
|
||||
all: ["expenses"] as const,
|
||||
byStatus: (status: string, page: number, pageSize: number) =>
|
||||
["expenses", status, page, pageSize] as const,
|
||||
byFilters: (status: string, page: number, pageSize: number, periodicExpenseId?: number, search?: string) =>
|
||||
["expenses", status, page, pageSize, periodicExpenseId, search] as const,
|
||||
monthlyTotal: (year: number, month: number) => ["expenses", "monthly-total", year, month] as const,
|
||||
monthlyTotals: (year: number, month: number) => ["expenses", "totals", year, month] as const,
|
||||
totalPending: ["expenses", "pending-total"] as const,
|
||||
@@ -132,10 +132,16 @@ export function useGenerateMonthlyExpense() {
|
||||
});
|
||||
}
|
||||
|
||||
export function useExpenses(status: string, page: number = 1, pageSize: number = 10) {
|
||||
export function useExpenses(status: string, page: number = 1, pageSize: number = 10, periodicExpenseId?: number, search?: string) {
|
||||
return useQuery({
|
||||
queryKey: expenseKeys.byStatus(status, page, pageSize),
|
||||
queryFn: () => getExpenses(status === "all" ? undefined : status, page, pageSize),
|
||||
queryKey: expenseKeys.byFilters(status, page, pageSize, periodicExpenseId, search),
|
||||
queryFn: () => getExpenses(
|
||||
status === "all" ? undefined : status,
|
||||
page,
|
||||
pageSize,
|
||||
periodicExpenseId,
|
||||
search,
|
||||
),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user