Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ const App: React.FC = () => {
</div>
</section>

<section id="planos" className="py-24 pb-20 bg-fiber-dark py-5">
<section id="planos" className="py-24 pb-20 bg-fiber-dark">
<div className="max-w-7xl 2xl:max-w-[1600px] mx-auto px-4 sm:px-6 lg:px-8">
<div className="text-center max-w-3xl mx-auto mb-16">
<h2 className="text-3xl font-bold text-white sm:text-4xl mb-4">
Expand Down
Binary file added public/img/fiberlig.mp4
Binary file not shown.
31 changes: 13 additions & 18 deletions src/components/ClientArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1126,30 +1126,25 @@ const ClientArea: React.FC<ClientAreaProps> = ({ onNavigate }) => {
}

// --- LÓGICA DE CÁLCULO DE DÉBITOS PARA O BANNER GERAL ---
// O banner só aparece se a fatura está com status "A" E a data de vencimento
// já passou (fatura efetivamente vencida). Faturas em aberto com vencimento
// futuro (cliente em dia) NÃO devem acionar o alerta.
const now = new Date();
const currentMonth = now.getMonth() + 1;
const currentYear = now.getFullYear();
now.setHours(0, 0, 0, 0);

const totalGeralDivida = (dashboardData?.faturas || [])
.filter((f) => {
if (f.status !== "A") return false;
const dateStr = String(f.data_vencimento);
let month = 0, year = 0;
if (dateStr.includes("/")) {
const parts = dateStr.split("/");
month = parseInt(parts[1], 10);
year = parseInt(parts[2], 10);
} else if (dateStr.includes("-")) {
const parts = dateStr.split("-");
if (parts[0].length === 4) {
year = parseInt(parts[0], 10);
month = parseInt(parts[1], 10);
} else {
year = parseInt(parts[2], 10);
month = parseInt(parts[1], 10);
}
}
return month === currentMonth && year === currentYear;
// Normaliza para ISO (YYYY-MM-DD) ao adicionar horário fixo para evitar
// problemas de fuso horário ao comparar apenas a data.
const dataSegura = dateStr.includes("T")
? dateStr
: dateStr.replace(/(\d{2})\/(\d{2})\/(\d{4})/, "$3-$2-$1") + "T12:00:00";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Handle DD-MM-YYYY due dates before comparison

This normalization only rewrites DD/MM/YYYY; if data_vencimento arrives as hyphenated day-first (for example 10-04-2026, a format the previous logic explicitly parsed), dataSegura becomes 10-04-2026T12:00:00, which produces Invalid Date, and the filter silently drops that invoice because venc < now is false. In those payloads, overdue invoices are omitted from totalGeralDivida, so the debt alert banner can disappear even when there is pending debt.

Useful? React with 👍 / 👎.

const venc = new Date(dataSegura);
venc.setHours(0, 0, 0, 0);
// Só conta como dívida se o vencimento já passou (venceu ontem ou antes)
return venc < now;
})
.reduce((acc, curr) => acc + parseFloat(String(curr.valor).replace(",", ".")), 0);

Expand Down
Loading