From 36ca63ad4df0a94f3de03da0e4777bddcb223c39 Mon Sep 17 00:00:00 2001 From: vedantborse-ai Date: Tue, 30 Jun 2026 13:10:01 +0530 Subject: [PATCH] Complete Task 3 - add goal icon persistence --- src/api/types.ts | 1 + src/ui/features/goalmanager/GoalManager.tsx | 41 ++++++++++++++++++++- src/ui/pages/Main/goals/GoalCard.tsx | 1 + 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/src/api/types.ts b/src/api/types.ts index f75edad..5beff48 100644 --- a/src/api/types.ts +++ b/src/api/types.ts @@ -20,6 +20,7 @@ export interface Application { export interface Goal { id: string name: string + icon?: string targetAmount: number balance: number targetDate: Date diff --git a/src/ui/features/goalmanager/GoalManager.tsx b/src/ui/features/goalmanager/GoalManager.tsx index 0779dda..6e8704e 100644 --- a/src/ui/features/goalmanager/GoalManager.tsx +++ b/src/ui/features/goalmanager/GoalManager.tsx @@ -11,6 +11,11 @@ import { selectGoalsMap, updateGoal as updateGoalRedux } from '../../../store/go import { useAppDispatch, useAppSelector } from '../../../store/hooks' import DatePicker from '../../components/DatePicker' import { Theme } from '../../components/Theme' +import AddIconButton from './AddIconButton' +import GoalIcon from './GoalIcon' +import EmojiPicker from '../../components/EmojiPicker' +import { BaseEmoji } from 'emoji-mart' + type Props = { goal: Goal } export function GoalManager(props: Props) { @@ -21,16 +26,20 @@ export function GoalManager(props: Props) { const [name, setName] = useState(null) const [targetDate, setTargetDate] = useState(null) const [targetAmount, setTargetAmount] = useState(null) + const [icon, setIcon] = useState(null) + const [isEmojiPickerOpen, setIsEmojiPickerOpen] = useState(false) useEffect(() => { setName(props.goal.name) setTargetDate(props.goal.targetDate) setTargetAmount(props.goal.targetAmount) + setIcon(props.goal.icon ?? null) }, [ props.goal.id, props.goal.name, props.goal.targetDate, props.goal.targetAmount, + props.goal.icon, ]) useEffect(() => { @@ -75,10 +84,40 @@ export function GoalManager(props: Props) { } } + const selectEmoji = (emoji: BaseEmoji) => { + setIcon(emoji.native) + setIsEmojiPickerOpen(false) + + const updatedGoal: Goal = { + ...props.goal, + name: name ?? props.goal.name, + targetDate: targetDate ?? props.goal.targetDate, + targetAmount: targetAmount ?? props.goal.targetAmount, + icon: emoji.native, + } + + dispatch(updateGoalRedux(updatedGoal)) + updateGoalApi(props.goal.id, updatedGoal) + } + return ( - + {icon ? ( + setIsEmojiPickerOpen(true)} + /> + ) : ( + setIsEmojiPickerOpen(true)} + /> + )} + + {isEmojiPickerOpen && ( + + )} diff --git a/src/ui/pages/Main/goals/GoalCard.tsx b/src/ui/pages/Main/goals/GoalCard.tsx index e8f6d0a..71991d9 100644 --- a/src/ui/pages/Main/goals/GoalCard.tsx +++ b/src/ui/pages/Main/goals/GoalCard.tsx @@ -27,6 +27,7 @@ export default function GoalCard(props: Props) { return ( + {goal.icon &&
{goal.icon}
} ${goal.targetAmount} {asLocaleDateString(goal.targetDate)}