mirror of
https://github.com/felipegcoutinho/openmonetis.git
synced 2026-07-09 19:36:02 +00:00
feat(preferencias): permite ocultar resumo do lancamento
This commit is contained in:
@@ -68,6 +68,7 @@ const updatePreferencesSchema = z.object({
|
||||
statementNoteAsColumn: z.boolean(),
|
||||
transactionsColumnOrder: z.array(z.string()).nullable(),
|
||||
attachmentMaxSizeMb: z.number().int().min(1).max(100),
|
||||
showTransactionSummary: z.boolean(),
|
||||
});
|
||||
|
||||
type ResettableUser = {
|
||||
@@ -582,6 +583,7 @@ export async function updatePreferencesAction(
|
||||
statementNoteAsColumn: validated.statementNoteAsColumn,
|
||||
transactionsColumnOrder: validated.transactionsColumnOrder,
|
||||
attachmentMaxSizeMb: validated.attachmentMaxSizeMb,
|
||||
showTransactionSummary: validated.showTransactionSummary,
|
||||
updatedAt: new Date(),
|
||||
})
|
||||
.where(eq(schema.userPreferences.userId, session.user.id));
|
||||
@@ -592,6 +594,7 @@ export async function updatePreferencesAction(
|
||||
statementNoteAsColumn: validated.statementNoteAsColumn,
|
||||
transactionsColumnOrder: validated.transactionsColumnOrder,
|
||||
attachmentMaxSizeMb: validated.attachmentMaxSizeMb,
|
||||
showTransactionSummary: validated.showTransactionSummary,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ interface PreferencesFormProps {
|
||||
statementNoteAsColumn: boolean;
|
||||
transactionsColumnOrder: string[] | null;
|
||||
attachmentMaxSizeMb: number;
|
||||
showTransactionSummary: boolean;
|
||||
}
|
||||
|
||||
function SortableColumnItem({ id }: { id: string }) {
|
||||
@@ -85,6 +86,7 @@ export function PreferencesForm({
|
||||
statementNoteAsColumn: initialExtratoNoteAsColumn,
|
||||
transactionsColumnOrder: initialColumnOrder,
|
||||
attachmentMaxSizeMb: initialAttachmentMaxSizeMb,
|
||||
showTransactionSummary: initialShowTransactionSummary,
|
||||
}: PreferencesFormProps) {
|
||||
const router = useRouter();
|
||||
const [isPending, startTransition] = useTransition();
|
||||
@@ -104,6 +106,9 @@ export function PreferencesForm({
|
||||
? initialAttachmentMaxSizeMb
|
||||
: 50) as AttachmentSizeOption,
|
||||
);
|
||||
const [showTransactionSummary, setShowTransactionSummary] = useState(
|
||||
initialShowTransactionSummary,
|
||||
);
|
||||
|
||||
const sensors = useSensors(
|
||||
useSensor(PointerSensor, { activationConstraint: { distance: 8 } }),
|
||||
@@ -129,6 +134,7 @@ export function PreferencesForm({
|
||||
statementNoteAsColumn,
|
||||
transactionsColumnOrder: columnOrder,
|
||||
attachmentMaxSizeMb,
|
||||
showTransactionSummary,
|
||||
});
|
||||
|
||||
if (result.success) {
|
||||
@@ -172,6 +178,26 @@ export function PreferencesForm({
|
||||
|
||||
<Separator />
|
||||
|
||||
<section className="flex items-center justify-between max-w-md">
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="show-transaction-summary" className="text-sm">
|
||||
Resumo da operação
|
||||
</Label>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Exibe um resumo dos dados preenchidos no final do modal de
|
||||
lançamento.
|
||||
</p>
|
||||
</div>
|
||||
<Switch
|
||||
id="show-transaction-summary"
|
||||
checked={showTransactionSummary}
|
||||
onCheckedChange={setShowTransactionSummary}
|
||||
disabled={isPending}
|
||||
/>
|
||||
</section>
|
||||
|
||||
<Separator />
|
||||
|
||||
<section className="space-y-2 max-w-md">
|
||||
<Label className="text-sm">Ordem das colunas</Label>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
|
||||
@@ -6,6 +6,7 @@ interface UserPreferences {
|
||||
statementNoteAsColumn: boolean;
|
||||
transactionsColumnOrder: string[] | null;
|
||||
attachmentMaxSizeMb: number;
|
||||
showTransactionSummary: boolean;
|
||||
}
|
||||
|
||||
interface ApiToken {
|
||||
@@ -34,6 +35,7 @@ export async function fetchUserPreferences(
|
||||
statementNoteAsColumn: schema.userPreferences.statementNoteAsColumn,
|
||||
transactionsColumnOrder: schema.userPreferences.transactionsColumnOrder,
|
||||
attachmentMaxSizeMb: schema.userPreferences.attachmentMaxSizeMb,
|
||||
showTransactionSummary: schema.userPreferences.showTransactionSummary,
|
||||
})
|
||||
.from(schema.userPreferences)
|
||||
.where(eq(schema.userPreferences.userId, userId))
|
||||
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
buildTransactionInitialState,
|
||||
deriveCreditCardPeriod,
|
||||
} from "@/features/transactions/lib/form-helpers";
|
||||
import { useAppPreferences } from "@/shared/components/providers/app-preferences-provider";
|
||||
import { Button } from "@/shared/components/ui/button";
|
||||
import {
|
||||
Collapsible,
|
||||
@@ -104,6 +105,7 @@ export function TransactionDialog({
|
||||
const [pendingUploadFiles, setPendingUploadFiles] = useState<File[]>([]);
|
||||
const [extrasOpen, setExtrasOpen] = useState(false);
|
||||
const scrollContainerRef = useRef<HTMLDivElement>(null);
|
||||
const { showTransactionSummary } = useAppPreferences();
|
||||
|
||||
useEffect(() => {
|
||||
if (dialogOpen) {
|
||||
@@ -730,15 +732,17 @@ export function TransactionDialog({
|
||||
</Collapsible>
|
||||
)}
|
||||
|
||||
<div className="mt-3">
|
||||
<TransactionSummaryCard
|
||||
formState={formState}
|
||||
payerOptions={payerOptions}
|
||||
accountOptions={accountOptions}
|
||||
cardOptions={cardOptions}
|
||||
categoryOptions={categoryOptions}
|
||||
/>
|
||||
</div>
|
||||
{showTransactionSummary ? (
|
||||
<div className="mt-3">
|
||||
<TransactionSummaryCard
|
||||
formState={formState}
|
||||
payerOptions={payerOptions}
|
||||
accountOptions={accountOptions}
|
||||
cardOptions={cardOptions}
|
||||
categoryOptions={categoryOptions}
|
||||
/>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
{errorMessage ? (
|
||||
|
||||
Reference in New Issue
Block a user