diff --git a/components/calendario/monthly-calendar.tsx b/components/calendario/monthly-calendar.tsx
index 2704050..92b019f 100644
--- a/components/calendario/monthly-calendar.tsx
+++ b/components/calendario/monthly-calendar.tsx
@@ -118,7 +118,6 @@ export function MonthlyCalendar({
cartaoOptions={formOptions.cartaoOptions}
categoriaOptions={formOptions.categoriaOptions}
estabelecimentos={formOptions.estabelecimentos}
- periodPreferences={formOptions.periodPreferences}
defaultPeriod={period.period}
defaultPurchaseDate={createDate ?? undefined}
/>
diff --git a/components/calendario/types.ts b/components/calendario/types.ts
index fad5292..c164071 100644
--- a/components/calendario/types.ts
+++ b/components/calendario/types.ts
@@ -1,5 +1,4 @@
import type { LancamentoItem, SelectOption } from "@/components/lancamentos/types";
-import type { PeriodPreferences } from "@/lib/user-preferences/period";
export type CalendarEventType = "lancamento" | "boleto" | "cartao";
@@ -54,7 +53,6 @@ export type CalendarFormOptions = {
cartaoOptions: SelectOption[];
categoriaOptions: SelectOption[];
estabelecimentos: string[];
- periodPreferences: PeriodPreferences;
};
export type CalendarData = {
diff --git a/components/lancamentos/dialogs/anticipate-installments-dialog/anticipate-installments-dialog.tsx b/components/lancamentos/dialogs/anticipate-installments-dialog/anticipate-installments-dialog.tsx
index 41ce4d8..a5c4bc7 100644
--- a/components/lancamentos/dialogs/anticipate-installments-dialog/anticipate-installments-dialog.tsx
+++ b/components/lancamentos/dialogs/anticipate-installments-dialog/anticipate-installments-dialog.tsx
@@ -32,11 +32,10 @@ import {
SelectValue,
} from "@/components/ui/select";
import { Textarea } from "@/components/ui/textarea";
+import { PeriodPicker } from "@/components/period-picker";
import { useControlledState } from "@/hooks/use-controlled-state";
import { useFormState } from "@/hooks/use-form-state";
import type { EligibleInstallment } from "@/lib/installments/anticipation-types";
-import type { PeriodPreferences } from "@/lib/user-preferences/period";
-import { createMonthOptions } from "@/lib/utils/period";
import { RiLoader4Line } from "@remixicon/react";
import {
useCallback,
@@ -55,7 +54,6 @@ interface AnticipateInstallmentsDialogProps {
categorias: Array<{ id: string; name: string; icon: string | null }>;
pagadores: Array<{ id: string; name: string }>;
defaultPeriod: string;
- periodPreferences: PeriodPreferences;
open?: boolean;
onOpenChange?: (open: boolean) => void;
}
@@ -75,7 +73,6 @@ export function AnticipateInstallmentsDialog({
categorias,
pagadores,
defaultPeriod,
- periodPreferences,
open,
onOpenChange,
}: AnticipateInstallmentsDialogProps) {
@@ -104,16 +101,6 @@ export function AnticipateInstallmentsDialog({
note: "",
});
- const periodOptions = useMemo(
- () =>
- createMonthOptions(
- formState.anticipationPeriod,
- periodPreferences.monthsBefore,
- periodPreferences.monthsAfter
- ),
- [formState.anticipationPeriod, periodPreferences.monthsBefore, periodPreferences.monthsAfter]
- );
-
// Buscar parcelas elegíveis ao abrir o dialog
useEffect(() => {
if (dialogOpen) {
@@ -262,24 +249,14 @@ export function AnticipateInstallmentsDialog({
Período
-
+ className="w-full"
+ />
diff --git a/components/lancamentos/dialogs/lancamento-dialog/basic-fields-section.tsx b/components/lancamentos/dialogs/lancamento-dialog/basic-fields-section.tsx
index b0da06d..26e2db9 100644
--- a/components/lancamentos/dialogs/lancamento-dialog/basic-fields-section.tsx
+++ b/components/lancamentos/dialogs/lancamento-dialog/basic-fields-section.tsx
@@ -2,13 +2,7 @@
import { Label } from "@/components/ui/label";
import { DatePicker } from "@/components/ui/date-picker";
-import {
- Select,
- SelectContent,
- SelectItem,
- SelectTrigger,
- SelectValue,
-} from "@/components/ui/select";
+import { PeriodPicker } from "@/components/period-picker";
import { CurrencyInput } from "@/components/ui/currency-input";
import { CalculatorDialogButton } from "@/components/calculadora/calculator-dialog";
import { RiCalculatorLine } from "@remixicon/react";
@@ -19,8 +13,7 @@ export function BasicFieldsSection({
formState,
onFieldChange,
estabelecimentos,
- monthOptions,
-}: BasicFieldsSectionProps) {
+}: Omit
) {
return (
<>
@@ -37,21 +30,11 @@ export function BasicFieldsSection({
-
+ onChange={(value) => onFieldChange("period", value)}
+ className="w-full"
+ />
diff --git a/components/lancamentos/dialogs/lancamento-dialog/lancamento-dialog-types.ts b/components/lancamentos/dialogs/lancamento-dialog/lancamento-dialog-types.ts
index bba7035..f3399fb 100644
--- a/components/lancamentos/dialogs/lancamento-dialog/lancamento-dialog-types.ts
+++ b/components/lancamentos/dialogs/lancamento-dialog/lancamento-dialog-types.ts
@@ -1,5 +1,4 @@
import type { LancamentoFormState } from "@/lib/lancamentos/form-helpers";
-import type { PeriodPreferences } from "@/lib/user-preferences/period";
import type { LancamentoItem, SelectOption } from "../../types";
export type FormState = LancamentoFormState;
@@ -18,7 +17,6 @@ export interface LancamentoDialogProps {
estabelecimentos: string[];
lancamento?: LancamentoItem;
defaultPeriod?: string;
- periodPreferences: PeriodPreferences;
defaultCartaoId?: string | null;
defaultPaymentMethod?: string | null;
defaultPurchaseDate?: string | null;
@@ -48,7 +46,6 @@ export interface BaseFieldSectionProps {
export interface BasicFieldsSectionProps extends BaseFieldSectionProps {
estabelecimentos: string[];
- monthOptions: Array<{ value: string; label: string }>;
}
export interface CategorySectionProps extends BaseFieldSectionProps {
diff --git a/components/lancamentos/dialogs/lancamento-dialog/lancamento-dialog.tsx b/components/lancamentos/dialogs/lancamento-dialog/lancamento-dialog.tsx
index a7b4eaa..fe5f78d 100644
--- a/components/lancamentos/dialogs/lancamento-dialog/lancamento-dialog.tsx
+++ b/components/lancamentos/dialogs/lancamento-dialog/lancamento-dialog.tsx
@@ -22,7 +22,6 @@ import {
applyFieldDependencies,
buildLancamentoInitialState,
} from "@/lib/lancamentos/form-helpers";
-import { createMonthOptions } from "@/lib/utils/period";
import {
useCallback,
useEffect,
@@ -58,7 +57,6 @@ export function LancamentoDialog({
estabelecimentos,
lancamento,
defaultPeriod,
- periodPreferences,
defaultCartaoId,
defaultPaymentMethod,
defaultPurchaseDate,
@@ -125,15 +123,6 @@ export function LancamentoDialog({
return groupAndSortCategorias(filtered);
}, [categoriaOptions, formState.transactionType]);
- const monthOptions = useMemo(
- () =>
- createMonthOptions(
- formState.period,
- periodPreferences.monthsBefore,
- periodPreferences.monthsAfter
- ),
- [formState.period, periodPreferences.monthsBefore, periodPreferences.monthsAfter]
- );
const handleFieldChange = useCallback(
(key: Key, value: FormState[Key]) => {
@@ -352,7 +341,6 @@ export function LancamentoDialog({
formState={formState}
onFieldChange={handleFieldChange}
estabelecimentos={estabelecimentos}
- monthOptions={monthOptions}
/>
- createMonthOptions(
- selectedPeriod,
- periodPreferences.monthsBefore,
- periodPreferences.monthsAfter
- ),
- [selectedPeriod, periodPreferences.monthsBefore, periodPreferences.monthsAfter]
- );
-
// Categorias agrupadas e filtradas por tipo de transação
const groupedCategorias = useMemo(() => {
const filtered = categoriaOptions.filter(
@@ -336,18 +322,11 @@ export function MassAddDialog({
{/* Period */}
-
+
{/* Conta/Cartao */}
diff --git a/components/lancamentos/page/lancamentos-page.tsx b/components/lancamentos/page/lancamentos-page.tsx
index 8a5e4d8..d894803 100644
--- a/components/lancamentos/page/lancamentos-page.tsx
+++ b/components/lancamentos/page/lancamentos-page.tsx
@@ -25,7 +25,6 @@ import type {
LancamentoItem,
SelectOption,
} from "../types";
-import type { PeriodPreferences } from "@/lib/user-preferences/period";
interface LancamentosPageProps {
lancamentos: LancamentoItem[];
@@ -40,7 +39,6 @@ interface LancamentosPageProps {
contaCartaoFilterOptions: ContaCartaoFilterOption[];
selectedPeriod: string;
estabelecimentos: string[];
- periodPreferences: PeriodPreferences;
allowCreate?: boolean;
defaultCartaoId?: string | null;
defaultPaymentMethod?: string | null;
@@ -61,7 +59,6 @@ export function LancamentosPage({
contaCartaoFilterOptions,
selectedPeriod,
estabelecimentos,
- periodPreferences,
allowCreate = true,
defaultCartaoId,
defaultPaymentMethod,
@@ -357,7 +354,6 @@ export function LancamentosPage({
categoriaOptions={categoriaOptions}
estabelecimentos={estabelecimentos}
defaultPeriod={selectedPeriod}
- periodPreferences={periodPreferences}
defaultCartaoId={defaultCartaoId}
defaultPaymentMethod={defaultPaymentMethod}
lockCartaoSelection={lockCartaoSelection}
@@ -383,7 +379,6 @@ export function LancamentosPage({
estabelecimentos={estabelecimentos}
lancamento={lancamentoToCopy ?? undefined}
defaultPeriod={selectedPeriod}
- periodPreferences={periodPreferences}
/>
@@ -479,7 +473,6 @@ export function LancamentosPage({
categoriaOptions={categoriaOptions}
estabelecimentos={estabelecimentos}
selectedPeriod={selectedPeriod}
- periodPreferences={periodPreferences}
defaultPagadorId={defaultPagadorId}
/>
) : null}
@@ -515,7 +508,6 @@ export function LancamentosPage({
name: p.label,
}))}
defaultPeriod={selectedPeriod}
- periodPreferences={periodPreferences}
/>
)}
diff --git a/components/month-picker/month-picker.tsx b/components/month-picker/month-navigation.tsx
similarity index 98%
rename from components/month-picker/month-picker.tsx
rename to components/month-picker/month-navigation.tsx
index 3006713..e79cb7e 100644
--- a/components/month-picker/month-picker.tsx
+++ b/components/month-picker/month-navigation.tsx
@@ -8,7 +8,7 @@ import LoadingSpinner from "./loading-spinner";
import NavigationButton from "./nav-button";
import ReturnButton from "./return-button";
-export default function MonthPicker() {
+export default function MonthNavigation() {
const {
monthNames,
currentMonth,
diff --git a/components/orcamentos/budget-dialog.tsx b/components/orcamentos/budget-dialog.tsx
index c799da7..8de4842 100644
--- a/components/orcamentos/budget-dialog.tsx
+++ b/components/orcamentos/budget-dialog.tsx
@@ -24,10 +24,9 @@ import {
SelectValue,
} from "@/components/ui/select";
import { Label } from "@/components/ui/label";
+import { PeriodPicker } from "@/components/period-picker";
import { useControlledState } from "@/hooks/use-controlled-state";
import { useFormState } from "@/hooks/use-form-state";
-import type { PeriodPreferences } from "@/lib/user-preferences/period";
-import { createMonthOptions } from "@/lib/utils/period";
import {
useCallback,
useEffect,
@@ -45,7 +44,6 @@ interface BudgetDialogProps {
budget?: Budget;
categories: BudgetCategory[];
defaultPeriod: string;
- periodPreferences: PeriodPreferences;
open?: boolean;
onOpenChange?: (open: boolean) => void;
}
@@ -68,7 +66,6 @@ export function BudgetDialog({
budget,
categories,
defaultPeriod,
- periodPreferences,
open,
onOpenChange,
}: BudgetDialogProps) {
@@ -110,16 +107,6 @@ export function BudgetDialog({
}
}, [dialogOpen]);
- const periodOptions = useMemo(
- () =>
- createMonthOptions(
- formState.period,
- periodPreferences.monthsBefore,
- periodPreferences.monthsAfter
- ),
- [formState.period, periodPreferences.monthsBefore, periodPreferences.monthsAfter]
- );
-
const handleSubmit = useCallback(
(event: React.FormEvent) => {
event.preventDefault();
@@ -244,21 +231,11 @@ export function BudgetDialog({
-
+ onChange={(value) => updateField("period", value)}
+ className="w-full"
+ />
diff --git a/components/orcamentos/budgets-page.tsx b/components/orcamentos/budgets-page.tsx
index 2fd00a0..06b7e69 100644
--- a/components/orcamentos/budgets-page.tsx
+++ b/components/orcamentos/budgets-page.tsx
@@ -4,7 +4,6 @@ import { deleteBudgetAction } from "@/app/(dashboard)/orcamentos/actions";
import { ConfirmActionDialog } from "@/components/confirm-action-dialog";
import { EmptyState } from "@/components/empty-state";
import { Button } from "@/components/ui/button";
-import type { PeriodPreferences } from "@/lib/user-preferences/period";
import { RiAddCircleLine, RiFundsLine } from "@remixicon/react";
import { useCallback, useState } from "react";
import { toast } from "sonner";
@@ -18,7 +17,6 @@ interface BudgetsPageProps {
categories: BudgetCategory[];
selectedPeriod: string;
periodLabel: string;
- periodPreferences: PeriodPreferences;
}
export function BudgetsPage({
@@ -26,7 +24,6 @@ export function BudgetsPage({
categories,
selectedPeriod,
periodLabel,
- periodPreferences,
}: BudgetsPageProps) {
const [editOpen, setEditOpen] = useState(false);
const [selectedBudget, setSelectedBudget] = useState
(null);
@@ -94,7 +91,6 @@ export function BudgetsPage({
mode="create"
categories={categories}
defaultPeriod={selectedPeriod}
- periodPreferences={periodPreferences}
trigger={