fix: corrigir tipos e eliminar non-null assertions
Substitui non-null assertions (!) por type assertions ou optional chaining com guards. Troca any por unknown/tipos explícitos. - drizzle.config: DATABASE_URL! → as string - use-form-state: Record<string, any> → Record<string, unknown> - actions: catch (e: any) → catch (e), model tipado explicitamente - pagadores/data: row: any → Record<string, unknown> - note-dialog: result tipado explicitamente - bulk-import: payload as any removido - Map.get()! → optional chaining + guards em relatórios e dashboard Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -127,9 +127,9 @@ export async function fetchInstallmentAnalysis(
|
||||
};
|
||||
|
||||
if (seriesMap.has(row.seriesId)) {
|
||||
const group = seriesMap.get(row.seriesId)!;
|
||||
group.pendingInstallments.push(installmentDetail);
|
||||
group.totalPendingAmount += amount;
|
||||
const group = seriesMap.get(row.seriesId);
|
||||
group?.pendingInstallments.push(installmentDetail);
|
||||
if (group) group.totalPendingAmount += amount;
|
||||
} else {
|
||||
seriesMap.set(row.seriesId, {
|
||||
seriesId: row.seriesId,
|
||||
|
||||
@@ -64,6 +64,8 @@ type ContaSluggedOption = BaseSluggedOption & {
|
||||
type CartaoSluggedOption = BaseSluggedOption & {
|
||||
kind: "cartao";
|
||||
logo: string | null;
|
||||
closingDay: string | null;
|
||||
dueDay: string | null;
|
||||
};
|
||||
|
||||
export type SluggedFilters = {
|
||||
@@ -160,6 +162,8 @@ export const toOption = (
|
||||
logo?: string | null,
|
||||
icon?: string | null,
|
||||
accountType?: string | null,
|
||||
closingDay?: string | null,
|
||||
dueDay?: string | null,
|
||||
): SelectOption => ({
|
||||
value,
|
||||
label: normalizeLabel(label),
|
||||
@@ -170,6 +174,8 @@ export const toOption = (
|
||||
logo: logo ?? null,
|
||||
icon: icon ?? null,
|
||||
accountType: accountType ?? null,
|
||||
closingDay: closingDay ?? null,
|
||||
dueDay: dueDay ?? null,
|
||||
});
|
||||
|
||||
export const fetchLancamentoFilterSources = async (userId: string) => {
|
||||
@@ -252,6 +258,8 @@ export const buildSluggedFilters = ({
|
||||
slug: contaCartaoSlugger(label),
|
||||
kind: "cartao" as const,
|
||||
logo: cartao.logo ?? null,
|
||||
closingDay: cartao.closingDay ?? null,
|
||||
dueDay: cartao.dueDay ?? null,
|
||||
};
|
||||
});
|
||||
|
||||
@@ -378,7 +386,7 @@ export const buildLancamentoWhere = ({
|
||||
ilike(lancamentos.condition, searchPattern),
|
||||
and(isNotNull(contas.name), ilike(contas.name, searchPattern)),
|
||||
and(isNotNull(cartoes.name), ilike(cartoes.name, searchPattern)),
|
||||
)!,
|
||||
) as SQL,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -501,8 +509,20 @@ export const buildOptionSets = ({
|
||||
: cartaoFiltersRaw;
|
||||
|
||||
const cartaoOptions = sortByLabel(
|
||||
cartaoOptionsSource.map(({ id, label, slug, logo }) =>
|
||||
toOption(id, label, undefined, undefined, slug, undefined, logo),
|
||||
cartaoOptionsSource.map(({ id, label, slug, logo, closingDay, dueDay }) =>
|
||||
toOption(
|
||||
id,
|
||||
label,
|
||||
undefined,
|
||||
undefined,
|
||||
slug,
|
||||
undefined,
|
||||
logo,
|
||||
undefined,
|
||||
undefined,
|
||||
closingDay,
|
||||
dueDay,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
@@ -123,12 +123,16 @@ export async function fetchCategoryChartData(
|
||||
});
|
||||
}
|
||||
|
||||
categoryMap.get(categoryId)!.dataByPeriod.set(period, amount);
|
||||
categoryMap.get(categoryId)?.dataByPeriod.set(period, amount);
|
||||
}
|
||||
|
||||
const chartData = periods.map((period) => {
|
||||
const [year, month] = period.split("-");
|
||||
const date = new Date(Number.parseInt(year, 10), Number.parseInt(month, 10) - 1, 1);
|
||||
const date = new Date(
|
||||
Number.parseInt(year, 10),
|
||||
Number.parseInt(month, 10) - 1,
|
||||
1,
|
||||
);
|
||||
const monthLabel = format(date, "MMM", { locale: ptBR }).toUpperCase();
|
||||
|
||||
const dataPoint: { month: string; [key: string]: number | string } = {
|
||||
@@ -144,7 +148,11 @@ export async function fetchCategoryChartData(
|
||||
|
||||
const months = periods.map((period) => {
|
||||
const [year, month] = period.split("-");
|
||||
const date = new Date(Number.parseInt(year, 10), Number.parseInt(month, 10) - 1, 1);
|
||||
const date = new Date(
|
||||
Number.parseInt(year, 10),
|
||||
Number.parseInt(month, 10) - 1,
|
||||
1,
|
||||
);
|
||||
return format(date, "MMM", { locale: ptBR }).toUpperCase();
|
||||
});
|
||||
|
||||
|
||||
@@ -98,7 +98,8 @@ export async function fetchCategoryReport(
|
||||
});
|
||||
}
|
||||
|
||||
const categoryItem = categoryMap.get(categoryId)!;
|
||||
const categoryItem = categoryMap.get(categoryId);
|
||||
if (!categoryItem) continue;
|
||||
|
||||
// Add monthly data (will calculate percentage later)
|
||||
categoryItem.monthlyData.set(period, {
|
||||
@@ -122,7 +123,8 @@ export async function fetchCategoryReport(
|
||||
|
||||
for (let i = 0; i < sortedPeriods.length; i++) {
|
||||
const period = sortedPeriods[i];
|
||||
const monthlyData = categoryItem.monthlyData.get(period)!;
|
||||
const monthlyData = categoryItem.monthlyData.get(period);
|
||||
if (!monthlyData) continue;
|
||||
|
||||
if (i > 0) {
|
||||
// Get previous period data
|
||||
|
||||
@@ -164,7 +164,8 @@ export async function fetchTopEstabelecimentosData(
|
||||
c.establishmentName === est.name && c.categoriaId,
|
||||
)
|
||||
.map((c: CategoryByEstRow) => ({
|
||||
name: categoryMap.get(c.categoriaId!)?.name || "Sem categoria",
|
||||
name:
|
||||
categoryMap.get(c.categoriaId as string)?.name || "Sem categoria",
|
||||
count: Number(c.count) || 0,
|
||||
}))
|
||||
.sort(
|
||||
@@ -222,9 +223,9 @@ export async function fetchTopEstabelecimentosData(
|
||||
const topCategories: TopCategoryData[] = topCategoriesData
|
||||
.filter((c: TopCategoryRow) => c.categoriaId)
|
||||
.map((cat: TopCategoryRow) => {
|
||||
const catInfo = categoryMap.get(cat.categoriaId!);
|
||||
const catInfo = categoryMap.get(cat.categoriaId as string);
|
||||
return {
|
||||
id: cat.categoriaId!,
|
||||
id: cat.categoriaId as string,
|
||||
name: catInfo?.name || "Sem categoria",
|
||||
icon: catInfo?.icon || null,
|
||||
totalAmount: Math.abs(safeToNumber(cat.totalAmount)),
|
||||
|
||||
Reference in New Issue
Block a user