feat: adição de novos ícones SVG e configuração do ambiente

- Adicionados ícones SVG para ChatGPT, Claude, Gemini e OpenRouter
- Implementados ícones para modos claro e escuro do ChatGPT
- Criado script de inicialização para PostgreSQL com extensão pgcrypto
- Adicionado script de configuração de ambiente que faz backup do .env
- Configurado tsconfig.json para TypeScript com opções de compilação
This commit is contained in:
Felipe Coutinho
2025-11-15 15:49:36 -03:00
commit ea0b8618e0
441 changed files with 53569 additions and 0 deletions

85
hooks/use-month-period.ts Normal file
View File

@@ -0,0 +1,85 @@
"use client";
import { usePathname, useRouter, useSearchParams } from "next/navigation";
import { useCallback, useMemo } from "react";
import { MONTH_NAMES } from "@/lib/utils/period";
const PERIOD_PARAM = "periodo";
const normalizeMonth = (value: string) => value.trim().toLowerCase();
export function useMonthPeriod() {
const searchParams = useSearchParams();
const pathname = usePathname();
const router = useRouter();
// Get current date info
const now = new Date();
const currentYear = now.getFullYear();
const currentMonthName = MONTH_NAMES[now.getMonth()];
const optionsMeses = [...MONTH_NAMES];
const defaultMonth = currentMonthName;
const defaultYear = currentYear.toString();
const periodFromParams = searchParams.get(PERIOD_PARAM);
const { month: currentMonth, year: currentYearValue } = useMemo(() => {
if (!periodFromParams) {
return { month: defaultMonth, year: defaultYear };
}
const [rawMonth, rawYear] = periodFromParams.split("-");
const normalizedMonth = normalizeMonth(rawMonth ?? "");
const normalizedYear = (rawYear ?? "").trim();
const monthExists = optionsMeses.includes(normalizedMonth);
const parsedYear = Number.parseInt(normalizedYear, 10);
if (!monthExists || Number.isNaN(parsedYear)) {
return { month: defaultMonth, year: defaultYear };
}
return {
month: normalizedMonth,
year: parsedYear.toString(),
};
}, [periodFromParams, defaultMonth, defaultYear, optionsMeses]);
const buildHref = useCallback(
(month: string, year: string | number) => {
const normalizedMonth = normalizeMonth(month);
const normalizedYear = String(year).trim();
const params = new URLSearchParams(searchParams.toString());
params.set(PERIOD_PARAM, `${normalizedMonth}-${normalizedYear}`);
return `${pathname}?${params.toString()}`;
},
[pathname, searchParams]
);
const replacePeriod = useCallback(
(target: string) => {
if (!target) {
return;
}
router.replace(target, { scroll: false });
},
[router]
);
return {
monthNames: optionsMeses,
pathname,
currentMonth,
currentYear: currentYearValue,
defaultMonth,
defaultYear,
buildHref,
replacePeriod,
};
}
export { PERIOD_PARAM as MONTH_PERIOD_PARAM };