11import { useState , useEffect } from "react" ;
2- import { Vault , Pencil , Check , X , HelpCircle } from "lucide-react" ;
2+ import { Vault , Pencil , Check , X , HelpCircle , Info } from "lucide-react" ;
33import { api } from "../api/client" ;
44import { Card } from "./ui/Card" ;
55import { Input } from "./ui/Input" ;
66import { ProgressBar } from "./ui/ProgressBar" ;
7+ import { Modal } from "./ui/Modal" ;
8+ import { Button } from "./ui/Button" ;
79
810interface SavingsCardProps {
911 remaining : number ;
@@ -14,6 +16,7 @@ export function SavingsCard({ remaining, onAnalyzeClick }: SavingsCardProps) {
1416 const [ savings , setSavings ] = useState < number > ( 0 ) ;
1517 const [ isEditing , setIsEditing ] = useState ( false ) ;
1618 const [ editValue , setEditValue ] = useState ( "" ) ;
19+ const [ showInfoModal , setShowInfoModal ] = useState ( false ) ;
1720
1821 useEffect ( ( ) => {
1922 api . savings . get ( ) . then ( ( res ) => {
@@ -45,11 +48,21 @@ export function SavingsCard({ remaining, onAnalyzeClick }: SavingsCardProps) {
4548 const isAhead = difference >= 0 ;
4649
4750 return (
51+ < >
4852 < Card className = "!p-4" >
4953 < div className = "flex items-center justify-between mb-2" >
50- < span className = "text-xs text-charcoal-500 dark:text-charcoal-400" >
51- Savings
52- </ span >
54+ < div className = "flex items-center gap-1.5" >
55+ < span className = "text-xs text-charcoal-500 dark:text-charcoal-400" >
56+ Savings
57+ </ span >
58+ < button
59+ onClick = { ( ) => setShowInfoModal ( true ) }
60+ className = "p-0.5 hover:bg-sand-200 dark:hover:bg-charcoal-700 rounded transition-colors touch-manipulation"
61+ title = "How this works"
62+ >
63+ < Info size = { 12 } className = "text-charcoal-400 hover:text-charcoal-600 dark:hover:text-charcoal-300" />
64+ </ button >
65+ </ div >
5366 < Vault size = { 16 } className = "text-sage-600" />
5467 </ div >
5568
@@ -121,5 +134,62 @@ export function SavingsCard({ remaining, onAnalyzeClick }: SavingsCardProps) {
121134 </ p >
122135 </ div >
123136 </ Card >
137+
138+ < Modal isOpen = { showInfoModal } onClose = { ( ) => setShowInfoModal ( false ) } title = "How Savings Tracking Works" >
139+ < div className = "space-y-4" >
140+ < div >
141+ < h3 className = "text-sm font-semibold text-charcoal-700 dark:text-sand-200 mb-2" >
142+ Current Savings
143+ </ h3 >
144+ < p className = "text-sm text-charcoal-600 dark:text-charcoal-300" >
145+ This is your actual savings balance right now. Update it anytime throughout the month as you add or withdraw money.
146+ </ p >
147+ </ div >
148+
149+ < div >
150+ < h3 className = "text-sm font-semibold text-charcoal-700 dark:text-sand-200 mb-2" >
151+ Monthly Target
152+ </ h3 >
153+ < p className = "text-sm text-charcoal-600 dark:text-charcoal-300 mb-2" >
154+ Your target is calculated as:
155+ </ p >
156+ < div className = "bg-sand-100 dark:bg-charcoal-800 p-3 rounded text-xs font-mono space-y-1" >
157+ < div > Current Savings: ${ savings . toFixed ( 2 ) } </ div >
158+ < div > + Remaining Budget: ${ remaining . toFixed ( 2 ) } </ div >
159+ < div className = "border-t border-sand-300 dark:border-charcoal-600 pt-1 mt-1" >
160+ = Target: ${ ( savings + remaining ) . toFixed ( 2 ) }
161+ </ div >
162+ </ div >
163+ < p className = "text-sm text-charcoal-600 dark:text-charcoal-300 mt-2" >
164+ This shows what you < strong > should</ strong > have saved by month-end if you stick to your budget.
165+ </ p >
166+ </ div >
167+
168+ < div >
169+ < h3 className = "text-sm font-semibold text-charcoal-700 dark:text-sand-200 mb-2" >
170+ Progress Tracking
171+ </ h3 >
172+ < p className = "text-sm text-charcoal-600 dark:text-charcoal-300" >
173+ The progress bar and percentage show how close you are to your target. If you're ahead, you've saved more than planned. If you're behind, you may have overspent or not saved enough yet this month.
174+ </ p >
175+ </ div >
176+
177+ < div >
178+ < h3 className = "text-sm font-semibold text-charcoal-700 dark:text-sand-200 mb-2" >
179+ Why This Works
180+ </ h3 >
181+ < p className = "text-sm text-charcoal-600 dark:text-charcoal-300" >
182+ You don't need to remember your starting balance! The target adjusts based on your current budget. As long as you update your savings balance regularly, you'll always know if you're on track.
183+ </ p >
184+ </ div >
185+
186+ < div className = "pt-4 border-t border-sand-300 dark:border-charcoal-700" >
187+ < Button onClick = { ( ) => setShowInfoModal ( false ) } className = "w-full sm:w-auto" >
188+ Got it
189+ </ Button >
190+ </ div >
191+ </ div >
192+ </ Modal >
193+ </ >
124194 ) ;
125195}
0 commit comments