refactor: migrate from ESLint to Biome and extract SQL queries to data.ts

- Replace ESLint with Biome for linting and formatting
- Configure Biome with tabs, double quotes, and organized imports
- Move all SQL/Drizzle queries from page.tsx files to data.ts files
- Create new data.ts files for: ajustes, dashboard, relatorios/categorias
- Update existing data.ts files: extrato, fatura (add lancamentos queries)
- Remove all drizzle-orm imports from page.tsx files
- Update README.md with new tooling info

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Felipe Coutinho
2026-01-27 13:15:37 +00:00
parent 8ffe61c59b
commit a7f63fb77a
442 changed files with 66141 additions and 69292 deletions

View File

@@ -6,100 +6,100 @@ import { cn } from "@/lib/utils/ui";
import { Input } from "./input";
const BRL_FORMATTER = new Intl.NumberFormat("pt-BR", {
style: "currency",
currency: "BRL",
minimumFractionDigits: 2,
maximumFractionDigits: 2,
style: "currency",
currency: "BRL",
minimumFractionDigits: 2,
maximumFractionDigits: 2,
});
const digitsToDecimalString = (digits: string) => {
const sanitized = digits.replace(/\D/g, "");
if (sanitized.length === 0) {
return "";
}
const sanitized = digits.replace(/\D/g, "");
if (sanitized.length === 0) {
return "";
}
const padded = sanitized.padStart(3, "0");
const integerPart = padded.slice(0, -2).replace(/^0+(?=\d)/, "") || "0";
const fractionPart = padded.slice(-2);
const padded = sanitized.padStart(3, "0");
const integerPart = padded.slice(0, -2).replace(/^0+(?=\d)/, "") || "0";
const fractionPart = padded.slice(-2);
return `${integerPart}.${fractionPart}`;
return `${integerPart}.${fractionPart}`;
};
const decimalToDigits = (value: string | undefined | null) => {
if (!value) {
return "";
}
if (!value) {
return "";
}
const normalized = value.toString().replace(/\s/g, "").replace(",", ".");
const numeric = Number(normalized);
const normalized = value.toString().replace(/\s/g, "").replace(",", ".");
const numeric = Number(normalized);
if (Number.isNaN(numeric)) {
return "";
}
if (Number.isNaN(numeric)) {
return "";
}
const cents = Math.round(Math.abs(numeric) * 100);
return cents === 0 ? "0" : cents.toString();
const cents = Math.round(Math.abs(numeric) * 100);
return cents === 0 ? "0" : cents.toString();
};
const formatDigits = (digits: string) => {
if (digits.length === 0) {
return "";
}
if (digits.length === 0) {
return "";
}
const decimal = digitsToDecimalString(digits);
const numeric = Number(decimal);
const decimal = digitsToDecimalString(digits);
const numeric = Number(decimal);
if (Number.isNaN(numeric)) {
return "";
}
if (Number.isNaN(numeric)) {
return "";
}
return BRL_FORMATTER.format(numeric);
return BRL_FORMATTER.format(numeric);
};
export interface CurrencyInputProps
extends Omit<
React.ComponentProps<typeof Input>,
"value" | "defaultValue" | "type" | "inputMode" | "onChange"
> {
value: string;
onValueChange: (value: string) => void;
extends Omit<
React.ComponentProps<typeof Input>,
"value" | "defaultValue" | "type" | "inputMode" | "onChange"
> {
value: string;
onValueChange: (value: string) => void;
}
export const CurrencyInput = React.forwardRef<
HTMLInputElement,
CurrencyInputProps
HTMLInputElement,
CurrencyInputProps
>(({ className, value, onValueChange, onBlur, onChange, ...props }, ref) => {
const digits = React.useMemo(() => decimalToDigits(value), [value]);
const displayValue = React.useMemo(() => formatDigits(digits), [digits]);
const digits = React.useMemo(() => decimalToDigits(value), [value]);
const displayValue = React.useMemo(() => formatDigits(digits), [digits]);
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
const rawValue = event.target.value;
const nextDigits = rawValue.replace(/\D/g, "");
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
const rawValue = event.target.value;
const nextDigits = rawValue.replace(/\D/g, "");
if (nextDigits.length === 0) {
onValueChange("");
} else {
onValueChange(digitsToDecimalString(nextDigits));
}
if (nextDigits.length === 0) {
onValueChange("");
} else {
onValueChange(digitsToDecimalString(nextDigits));
}
onChange?.(event);
};
onChange?.(event);
};
return (
<Input
{...props}
ref={ref}
type="text"
inputMode="decimal"
value={displayValue}
onChange={handleChange}
onBlur={onBlur}
className={cn(
"text-left font-medium tabular-nums tracking-tight",
className
)}
/>
);
return (
<Input
{...props}
ref={ref}
type="text"
inputMode="decimal"
value={displayValue}
onChange={handleChange}
onBlur={onBlur}
className={cn(
"text-left font-medium tabular-nums tracking-tight",
className,
)}
/>
);
});
CurrencyInput.displayName = "CurrencyInput";