"use client"; import { AccountCardSelectContent, CategorySelectContent, PayerSelectContent, } from "@/features/transactions/components/select-items"; import type { SelectOption } from "@/features/transactions/components/types"; import { PeriodPicker } from "@/shared/components/period-picker"; import { Label } from "@/shared/components/ui/label"; import { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectSeparator, SelectTrigger, SelectValue, } from "@/shared/components/ui/select"; export type AccountCardValue = `card:${string}` | `account:${string}`; export function encodeAccountCard( type: "card" | "account", id: string, ): AccountCardValue { return `${type}:${id}` as AccountCardValue; } export function decodeAccountCard(value: string): { type: "card" | "account"; id: string; } | null { if (value.startsWith("card:")) return { type: "card", id: value.slice(5) }; if (value.startsWith("account:")) return { type: "account", id: value.slice(8) }; return null; } interface GlobalFieldsProps { accountOptions: SelectOption[]; cardOptions: SelectOption[]; payerOptions: SelectOption[]; categoryOptions: SelectOption[]; accountCardValue: string | null; payerId: string | null; invoicePeriod: string | null; onAccountCardChange: (value: string | null) => void; onPayerChange: (value: string | null) => void; onInvoicePeriodChange: (value: string | null) => void; onBulkCategoryChange: (categoryId: string) => void; } export function GlobalFields({ accountOptions, cardOptions, payerOptions, categoryOptions, accountCardValue, payerId, invoicePeriod, onAccountCardChange, onPayerChange, onInvoicePeriodChange, onBulkCategoryChange, }: GlobalFieldsProps) { const isCard = accountCardValue?.startsWith("card:") ?? false; const expenseCategories = categoryOptions.filter( (o) => o.group === "despesa", ); const incomeCategories = categoryOptions.filter((o) => o.group === "receita"); return (
Aplicado a todos os lançamentos importados.