Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"@material-ui/core": "^4.12.4",
"@material-ui/pickers": "^3.3.10",
"@reduxjs/toolkit": "^1.5.1",
"@types/emoji-mart": "^3.0.5",
"@types/node": "^17.0.41",
"@types/react": "^16.9.0",
"@types/react-redux": "^7.1.7",
Expand Down Expand Up @@ -55,8 +54,8 @@
]
},
"devDependencies": {
"@types/emoji-mart": "^3.0.9",
"@types/emoji-mart": "^3.0.0",
"@types/react-dom": "^18.0.5",
"@types/styled-components": "^5.1.25"
}
}
}
1 change: 1 addition & 0 deletions src/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export interface Goal {
accountId: string
transactionIds: string[]
tagIds: string[]
icon?: string;
}

export interface Tag {
Expand Down
22 changes: 9 additions & 13 deletions src/ui/components/EmojiPicker.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
import { BaseEmoji, Picker } from 'emoji-mart'
import 'emoji-mart/css/emoji-mart.css'
import { useAppSelector } from '../../store/hooks'
import { selectMode } from '../../store/themeSlice'
import 'emoji-mart/css/emoji-mart.css';
import { Picker } from 'emoji-mart';
import React from 'react';

type Props = { onClick: (emoji: BaseEmoji, event: React.MouseEvent) => void }
// We removed the "event" requirement here so it matches the v3 Picker perfectly
type Props = { onClick: (emoji: any) => void }

export default function EmojiPicker(props: Props) {
const theme = useAppSelector(selectMode)

return (
<Picker
theme={theme}
<Picker
showPreview={false}
showSkinTones={false}
onClick={props.onClick}
color="primary"
onSelect={props.onClick}
/>
)
}
);
}
24 changes: 19 additions & 5 deletions src/ui/features/goalmanager/GoalManager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ 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 { Theme } from '../../components/Theme'
import { Theme } from '../../components/Theme';
import EmojiPicker from '../../components/EmojiPicker';

type Props = { goal: Goal }

export function GoalManager(props: Props) {
const dispatch = useAppDispatch()

Expand All @@ -21,6 +23,7 @@ export function GoalManager(props: Props) {
const [name, setName] = useState<string | null>(null)
const [targetDate, setTargetDate] = useState<Date | null>(null)
const [targetAmount, setTargetAmount] = useState<number | null>(null)
const [showPicker, setShowPicker] = useState(false);

useEffect(() => {
setName(props.goal.name)
Expand All @@ -33,9 +36,6 @@ export function GoalManager(props: Props) {
props.goal.targetAmount,
])

useEffect(() => {
setName(goal.name)
}, [goal.name])

const updateNameOnChange = (event: React.ChangeEvent<HTMLInputElement>) => {
const nextName = event.target.value
Expand Down Expand Up @@ -75,9 +75,23 @@ export function GoalManager(props: Props) {
}
}

const pickEmojiOnClick = (emoji: any) => {
const updatedGoal: Goal = {
...props.goal,
icon: emoji.native,
}

dispatch(updateGoalRedux(updatedGoal))
updateGoalApi(props.goal.id, updatedGoal)
setShowPicker(false)
}

return (
<GoalManagerContainer>
<NameInput value={name ?? ''} onChange={updateNameOnChange} />
<button type="button" onClick={() => setShowPicker(!showPicker)}>Pick Emoji</button>

{showPicker && <EmojiPicker onClick={pickEmojiOnClick} />}

<Group>
<Field name="Target Date" icon={faCalendarAlt} />
Expand Down Expand Up @@ -181,4 +195,4 @@ const StringInput = styled.input`

const Value = styled.div`
margin-left: 2rem;
`
`
1 change: 1 addition & 0 deletions src/ui/pages/Main/goals/GoalCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export default function GoalCard(props: Props) {

return (
<Container key={goal.id} onClick={onClick}>
<div style={{ fontSize: '3rem', marginBottom: '10px' }}>{goal.icon}</div>
<TargetAmount>${goal.targetAmount}</TargetAmount>
<TargetDate>{asLocaleDateString(goal.targetDate)}</TargetDate>
</Container>
Expand Down