From 8fe883fb36a66dcab1d81bdc11f3ae228680afb1 Mon Sep 17 00:00:00 2001 From: vrk24 Date: Fri, 5 Jun 2026 01:55:15 +0530 Subject: [PATCH 1/2] Add emoji icon picker to Goal manager --- src/api/types.ts | 1 + src/ui/features/goalmanager/GoalManager.tsx | 57 ++++++++++++++++++--- 2 files changed, 50 insertions(+), 8 deletions(-) diff --git a/src/api/types.ts b/src/api/types.ts index f75edad..6193f2a 100644 --- a/src/api/types.ts +++ b/src/api/types.ts @@ -27,6 +27,7 @@ export interface Goal { accountId: string transactionIds: string[] tagIds: string[] + icon?: string } export interface Tag { diff --git a/src/ui/features/goalmanager/GoalManager.tsx b/src/ui/features/goalmanager/GoalManager.tsx index 0779dda..d9ed5cf 100644 --- a/src/ui/features/goalmanager/GoalManager.tsx +++ b/src/ui/features/goalmanager/GoalManager.tsx @@ -1,6 +1,7 @@ import { faCalendarAlt } from '@fortawesome/free-regular-svg-icons' import { faDollarSign, IconDefinition } from '@fortawesome/free-solid-svg-icons' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' +import { BaseEmoji } from 'emoji-mart' import { MaterialUiPickersDate } from '@material-ui/pickers/typings/date' import 'date-fns' import React, { useEffect, useState } from 'react' @@ -10,7 +11,10 @@ import { Goal } from '../../../api/types' import { selectGoalsMap, updateGoal as updateGoalRedux } from '../../../store/goalsSlice' import { useAppDispatch, useAppSelector } from '../../../store/hooks' import DatePicker from '../../components/DatePicker' +import EmojiPicker from '../../components/EmojiPicker' import { Theme } from '../../components/Theme' +import AddIconButton from './AddIconButton' +import GoalIcon from './GoalIcon' type Props = { goal: Goal } export function GoalManager(props: Props) { @@ -21,16 +25,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 [showEmojiPicker, setShowEmojiPicker] = 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(() => { @@ -40,10 +48,7 @@ export function GoalManager(props: Props) { const updateNameOnChange = (event: React.ChangeEvent) => { const nextName = event.target.value setName(nextName) - const updatedGoal: Goal = { - ...props.goal, - name: nextName, - } + const updatedGoal: Goal = { ...props.goal, name: nextName } dispatch(updateGoalRedux(updatedGoal)) updateGoalApi(props.goal.id, updatedGoal) } @@ -75,8 +80,35 @@ export function GoalManager(props: Props) { } } + const pickEmojiOnClick = (emoji: BaseEmoji, event: React.MouseEvent) => { + const nextIcon = emoji.native + setIcon(nextIcon) + setShowEmojiPicker(false) + const updatedGoal: Goal = { ...props.goal, icon: nextIcon } + dispatch(updateGoalRedux(updatedGoal)) + updateGoalApi(props.goal.id, updatedGoal) + } + + const toggleEmojiPicker = (e: React.MouseEvent) => { + setShowEmojiPicker(!showEmojiPicker) + } + return ( + + + + + + + + + {showEmojiPicker && ( + + + + )} + @@ -131,7 +163,18 @@ const GoalManagerContainer = styled.div` width: 100%; position: relative; ` - +const GoalIconContainer = styled.div` + display: ${({ shouldShow }) => (shouldShow ? 'flex' : 'none')}; +` +const AddIconButtonContainer = styled.div` + display: ${({ shouldShow }) => (shouldShow ? 'flex' : 'none')}; +` +const EmojiPickerContainer = styled.div` + position: absolute; + top: ${({ hasIcon }) => (hasIcon ? '8rem' : '3rem')}; + left: 0; + z-index: 100; +` const Group = styled.div` display: flex; flex-direction: row; @@ -148,7 +191,6 @@ const NameInput = styled.input` font-weight: bold; color: ${({ theme }: { theme: Theme }) => theme.text}; ` - const FieldName = styled.h1` font-size: 1.8rem; margin-left: 1rem; @@ -178,7 +220,6 @@ const StringInput = styled.input` font-weight: bold; color: ${({ theme }: { theme: Theme }) => theme.text}; ` - const Value = styled.div` margin-left: 2rem; -` +` \ No newline at end of file From 62b0c658ac584121644cc06952ab315c603c1675 Mon Sep 17 00:00:00 2001 From: vrk24 Date: Fri, 5 Jun 2026 02:16:44 +0530 Subject: [PATCH 2/2] Connect frontend to local server and implement emoji persistence --- src/api/lib.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/lib.ts b/src/api/lib.ts index 3c593ca..9af5604 100644 --- a/src/api/lib.ts +++ b/src/api/lib.ts @@ -2,7 +2,7 @@ import axios from 'axios' import { user } from '../data/user' import { Goal, Transaction, User } from './types' -export const API_ROOT = 'https://fencer-commbank.azurewebsites.net' +export const API_ROOT = 'http://localhost:5203' export async function getUser(): Promise { try {