mirror of
https://github.com/escalante29/WealthySmart.git
synced 2026-05-19 09:28:47 +02:00
Fix date picker defaulting to UTC instead of browser local time
All checks were successful
Deploy to VPS / deploy (push) Successful in 17s
All checks were successful
Deploy to VPS / deploy (push) Successful in 17s
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import api, { type Category, type Transaction } from '../api';
|
import api, { type Category, type Transaction } from '../api';
|
||||||
|
import { formatLocalDatetime } from '@/lib/format';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import { Input } from '@/components/ui/input';
|
import { Input } from '@/components/ui/input';
|
||||||
import { Label } from '@/components/ui/label';
|
import { Label } from '@/components/ui/label';
|
||||||
@@ -33,7 +34,7 @@ export default function TransactionModal({ transaction, source, onClose, onSaved
|
|||||||
merchant: '',
|
merchant: '',
|
||||||
amount: '',
|
amount: '',
|
||||||
currency: 'CRC',
|
currency: 'CRC',
|
||||||
date: new Date().toISOString().slice(0, 16),
|
date: formatLocalDatetime(new Date()),
|
||||||
transaction_type: 'COMPRA',
|
transaction_type: 'COMPRA',
|
||||||
source,
|
source,
|
||||||
bank: 'BAC',
|
bank: 'BAC',
|
||||||
|
|||||||
@@ -8,6 +8,11 @@ export function formatAmount(amount: number, currency: string) {
|
|||||||
return `₡${abs.toLocaleString('es-CR', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
|
return `₡${abs.toLocaleString('es-CR', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function formatLocalDatetime(d: Date): string {
|
||||||
|
const pad = (n: number) => n.toString().padStart(2, '0');
|
||||||
|
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}T${pad(d.getHours())}:${pad(d.getMinutes())}`;
|
||||||
|
}
|
||||||
|
|
||||||
export function formatDate(dateStr: string) {
|
export function formatDate(dateStr: string) {
|
||||||
return new Date(dateStr).toLocaleDateString('en-US', { month: 'short', day: 'numeric' });
|
return new Date(dateStr).toLocaleDateString('en-US', { month: 'short', day: 'numeric' });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import {
|
|||||||
|
|
||||||
import api, { type Account, type Transaction } from '../api';
|
import api, { type Account, type Transaction } from '../api';
|
||||||
import { useSettings } from '@/hooks/useSettings';
|
import { useSettings } from '@/hooks/useSettings';
|
||||||
import { formatAmount, formatDate } from '@/lib/format';
|
import { formatAmount, formatDate, formatLocalDatetime } from '@/lib/format';
|
||||||
import DashboardSection from '@/components/DashboardSection';
|
import DashboardSection from '@/components/DashboardSection';
|
||||||
import SectionConfigDialog from '@/components/SectionConfigDialog';
|
import SectionConfigDialog from '@/components/SectionConfigDialog';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
@@ -340,7 +340,7 @@ export default function Dashboard() {
|
|||||||
merchant: merchants[i],
|
merchant: merchants[i],
|
||||||
amount: amounts[i],
|
amount: amounts[i],
|
||||||
currency: 'CRC',
|
currency: 'CRC',
|
||||||
date: new Date().toISOString(),
|
date: formatLocalDatetime(new Date()),
|
||||||
bank: 'BAC',
|
bank: 'BAC',
|
||||||
source: 'CREDIT_CARD',
|
source: 'CREDIT_CARD',
|
||||||
transaction_type: 'COMPRA',
|
transaction_type: 'COMPRA',
|
||||||
|
|||||||
Reference in New Issue
Block a user