feat(panel): özet kartları, anlık durum ve hızlı harcama ekleme
- Gelir, sabit gider, toplam birikim, devreden borç kartları - Anlık durum: kalan harcanabilir ve günlük harcama önerisi - Grup planlanan/gerçekleşen (Haftalık/Aylık) - "Harcama Ekle": masaüstünde başlıkta, mobilde yüzen düğme - Yükleniyor iskeleti, boş durumlar, açık dönem yokken son dönem özeti Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -71,6 +71,7 @@ export function EntryForm({
|
||||
categories,
|
||||
methods,
|
||||
entry,
|
||||
autoFocus = false,
|
||||
onSaved,
|
||||
onCancel,
|
||||
}: {
|
||||
@@ -82,6 +83,8 @@ export function EntryForm({
|
||||
methods: CatalogItem[]
|
||||
/** Düzenlenen kayıt */
|
||||
entry?: Entry
|
||||
/** Yeni kayıtta açılışta tutar alanına odaklan */
|
||||
autoFocus?: boolean
|
||||
/** Kaydedilen kaydın tarihi (o haftaya geçmek için) */
|
||||
onSaved: (date: string) => void
|
||||
onCancel?: () => void
|
||||
@@ -118,10 +121,10 @@ export function EntryForm({
|
||||
}
|
||||
}, [entry, week, today, getValues, setValue])
|
||||
|
||||
// Düzenlemeye geçince form görünür olsun ve tutara odaklansın
|
||||
// Düzenlemeye geçince (ya da Panel'den gelince) tutara odaklan
|
||||
useEffect(() => {
|
||||
if (entry) setFocus('amount')
|
||||
}, [entry, setFocus])
|
||||
if (entry || autoFocus) setFocus('amount')
|
||||
}, [entry, autoFocus, setFocus])
|
||||
|
||||
function pickGroup(code: GroupCode) {
|
||||
if (code === getValues('group')) return
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useRef, useState } from 'react'
|
||||
import { useSearchParams } from 'react-router'
|
||||
import { useLocation, useSearchParams } from 'react-router'
|
||||
import { Info } from 'lucide-react'
|
||||
import { PageError, PageHeader, PageLoading } from '@/components/page'
|
||||
import { PeriodPicker } from '@/features/periods/period-picker'
|
||||
@@ -40,6 +40,8 @@ function LedgerView({ period }: { period: Period }) {
|
||||
const [params, setParams] = useSearchParams()
|
||||
const [today] = useState(() => toIsoDate(new Date()))
|
||||
const [editing, setEditing] = useState<Entry | null>(null)
|
||||
// Panel'deki "Harcama Ekle" → tutar alanına odaklan
|
||||
const focusAmount = (useLocation().state as { focus?: boolean } | null)?.focus === true
|
||||
const formRef = useRef<HTMLDivElement>(null)
|
||||
const inPeriod = today >= period.start_date && today <= period.last_date
|
||||
const todayIndex = inPeriod ? weekIndexFor(period.weeks, today) : null
|
||||
@@ -108,6 +110,7 @@ function LedgerView({ period }: { period: Period }) {
|
||||
categories={catalog.c}
|
||||
methods={catalog.m}
|
||||
entry={editing ?? undefined}
|
||||
autoFocus={focusAmount}
|
||||
onSaved={(date) => goTo(weekIndexFor(period.weeks, date))}
|
||||
onCancel={() => setEditing(null)}
|
||||
/>
|
||||
|
||||
@@ -6,16 +6,19 @@ import type { GroupBudget } from '@/types/GroupBudget'
|
||||
|
||||
const s = t.ledger
|
||||
|
||||
/** Seçili haftada grup bazlı bütçe / harcanan / kalan (+ ilerleme çubuğu) */
|
||||
export function WeekSummary({ budget, index }: { budget: GroupBudget[]; index: number }) {
|
||||
/**
|
||||
* Grup bazlı bütçe / harcanan / kalan (+ ilerleme çubuğu): seçili hafta ya da `'month'` → tüm dönem.
|
||||
* Defter (haftalık) ve Panel (haftalık/aylık) kullanır.
|
||||
*/
|
||||
export function WeekSummary({ budget, index }: { budget: GroupBudget[]; index: number | 'month' }) {
|
||||
return (
|
||||
<div className="@container">
|
||||
<ul className="grid gap-3 @lg:grid-cols-2">
|
||||
{budget.map((b) => {
|
||||
const g = group(b.group)
|
||||
const w = b.weeks[index - 1]
|
||||
const planned = w?.amount ?? 0
|
||||
const spent = w?.spent ?? 0
|
||||
const w = index === 'month' ? null : b.weeks[index - 1]
|
||||
const planned = index === 'month' ? b.monthly : (w?.amount ?? 0)
|
||||
const spent = index === 'month' ? b.spent : (w?.spent ?? 0)
|
||||
const left = planned - spent
|
||||
const over = left < 0
|
||||
const ratio = planned > 0 ? Math.min(spent / planned, 1) : spent > 0 ? 1 : 0
|
||||
|
||||
Reference in New Issue
Block a user