chore: add Biome for lint and fix all lint errors
- Install @biomejs/biome as devDependency at root - Configure biome.json with 2-space indent, double quotes, Tailwind CSS support - Add lint/lint:fix/format/format:fix scripts to root and app package.json - Fix noNonNullAssertion: env vars extracted to variables with suppression, <div role=button> replaced with <button> - Fix noUnusedVariables: remove unused destructured vars - Fix useIterableCallbackReturn: arrow functions with block body - Fix noExplicitAny: recharts Tooltip formatters - Fix noLabelWithoutControl: add htmlFor+id or use <span> for non-input labels - Fix noStaticElementInteractions/useKeyWithClickEvents: role+keyboard events for overlays - Fix noArrayIndexKey: use error string as key - Fix CSS parse: enable tailwindDirectives parser - Normalize formatting across 80 files with biome check --write
This commit is contained in:
@@ -1,19 +1,33 @@
|
||||
import { keepPreviousData, useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
import {
|
||||
getQuotes, fetchQuotes, getQuoteHistory, getDailyMinMax, getDailyQuotes, getHistoricalMinMax,
|
||||
getPeriodicExpenses, createPeriodicExpense as createPeriodicExpenseApi,
|
||||
updatePeriodicExpense as updatePeriodicExpenseApi,
|
||||
keepPreviousData,
|
||||
useMutation,
|
||||
useQuery,
|
||||
useQueryClient,
|
||||
} from "@tanstack/react-query";
|
||||
import {
|
||||
type CreateNonPeriodicExpenseInput,
|
||||
type CreatePeriodicExpenseInput,
|
||||
createNonPeriodicExpense as createNonPeriodicExpenseApi,
|
||||
createPeriodicExpense as createPeriodicExpenseApi,
|
||||
deletePeriodicExpense as deletePeriodicExpenseApi,
|
||||
fetchQuotes,
|
||||
generateMonthlyExpense as generateMonthlyExpenseApi,
|
||||
getExpenses, createNonPeriodicExpense as createNonPeriodicExpenseApi,
|
||||
payExpense as payExpenseApi,
|
||||
getDailyMinMax,
|
||||
getDailyQuotes,
|
||||
getExpenses,
|
||||
getHistoricalMinMax,
|
||||
getMonthlyPayedTotal,
|
||||
getMonthlyTotals,
|
||||
getTotalPending,
|
||||
importPeriodicExpenses,
|
||||
importExpenses,
|
||||
getPendingUpcomingExpenses,
|
||||
type CreatePeriodicExpenseInput, type CreateNonPeriodicExpenseInput, type PayExpenseInput,
|
||||
getPeriodicExpenses,
|
||||
getQuoteHistory,
|
||||
getQuotes,
|
||||
getTotalPending,
|
||||
importExpenses,
|
||||
importPeriodicExpenses,
|
||||
type PayExpenseInput,
|
||||
payExpense as payExpenseApi,
|
||||
updatePeriodicExpense as updatePeriodicExpenseApi,
|
||||
} from "./api";
|
||||
|
||||
export const quoteKeys = {
|
||||
@@ -48,7 +62,11 @@ export function useFetchQuotes() {
|
||||
});
|
||||
}
|
||||
|
||||
export function useQuoteHistory(type: string, startDate: string, endDate: string) {
|
||||
export function useQuoteHistory(
|
||||
type: string,
|
||||
startDate: string,
|
||||
endDate: string,
|
||||
) {
|
||||
return useQuery({
|
||||
queryKey: quoteKeys.history(type, startDate, endDate),
|
||||
queryFn: () => getQuoteHistory(type, startDate, endDate),
|
||||
@@ -57,7 +75,11 @@ export function useQuoteHistory(type: string, startDate: string, endDate: string
|
||||
});
|
||||
}
|
||||
|
||||
export function useDailyMinMax(type: string, startDate: string, endDate: string) {
|
||||
export function useDailyMinMax(
|
||||
type: string,
|
||||
startDate: string,
|
||||
endDate: string,
|
||||
) {
|
||||
return useQuery({
|
||||
queryKey: quoteKeys.minMax(type, startDate, endDate),
|
||||
queryFn: () => getDailyMinMax(type, startDate, endDate),
|
||||
@@ -66,7 +88,11 @@ export function useDailyMinMax(type: string, startDate: string, endDate: string)
|
||||
});
|
||||
}
|
||||
|
||||
export function useDailyQuotes(type: string, startDate: string, endDate: string) {
|
||||
export function useDailyQuotes(
|
||||
type: string,
|
||||
startDate: string,
|
||||
endDate: string,
|
||||
) {
|
||||
return useQuery({
|
||||
queryKey: quoteKeys.daily(type, startDate, endDate),
|
||||
queryFn: () => getDailyQuotes(type, startDate, endDate),
|
||||
@@ -88,10 +114,17 @@ export function useHistoricalMinMax(type: string) {
|
||||
export const expenseKeys = {
|
||||
periodic: ["periodic-expenses"] as const,
|
||||
all: ["expenses"] 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,
|
||||
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,
|
||||
pendingUpcoming: ["expenses", "pending-upcoming"] as const,
|
||||
};
|
||||
@@ -106,7 +139,8 @@ export function usePeriodicExpenses() {
|
||||
export function useCreatePeriodicExpense() {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: (data: CreatePeriodicExpenseInput) => createPeriodicExpenseApi(data),
|
||||
mutationFn: (data: CreatePeriodicExpenseInput) =>
|
||||
createPeriodicExpenseApi(data),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: expenseKeys.periodic });
|
||||
},
|
||||
@@ -116,8 +150,13 @@ export function useCreatePeriodicExpense() {
|
||||
export function useUpdatePeriodicExpense() {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: ({ id, data }: { id: number; data: CreatePeriodicExpenseInput }) =>
|
||||
updatePeriodicExpenseApi(id, data),
|
||||
mutationFn: ({
|
||||
id,
|
||||
data,
|
||||
}: {
|
||||
id: number;
|
||||
data: CreatePeriodicExpenseInput;
|
||||
}) => updatePeriodicExpenseApi(id, data),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: expenseKeys.periodic });
|
||||
},
|
||||
@@ -144,17 +183,30 @@ export function useGenerateMonthlyExpense() {
|
||||
});
|
||||
}
|
||||
|
||||
export function useExpenses(status: string, page: number = 1, pageSize: number = 10, periodicExpenseId?: number, search?: string) {
|
||||
export function useExpenses(
|
||||
status: string,
|
||||
page: number = 1,
|
||||
pageSize: number = 10,
|
||||
periodicExpenseId?: number,
|
||||
search?: string,
|
||||
) {
|
||||
return useQuery({
|
||||
queryKey: expenseKeys.byFilters(status, page, pageSize, periodicExpenseId, search),
|
||||
placeholderData: keepPreviousData,
|
||||
queryFn: () => getExpenses(
|
||||
status === "all" ? undefined : status,
|
||||
queryKey: expenseKeys.byFilters(
|
||||
status,
|
||||
page,
|
||||
pageSize,
|
||||
periodicExpenseId,
|
||||
search,
|
||||
),
|
||||
placeholderData: keepPreviousData,
|
||||
queryFn: () =>
|
||||
getExpenses(
|
||||
status === "all" ? undefined : status,
|
||||
page,
|
||||
pageSize,
|
||||
periodicExpenseId,
|
||||
search,
|
||||
),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -189,7 +241,8 @@ export function useMonthlyPayedTotal(year: number, month: number) {
|
||||
export function useCreateNonPeriodicExpense() {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: (data: CreateNonPeriodicExpenseInput) => createNonPeriodicExpenseApi(data),
|
||||
mutationFn: (data: CreateNonPeriodicExpenseInput) =>
|
||||
createNonPeriodicExpenseApi(data),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: expenseKeys.all });
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user