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.14",
"@types/react-dom": "^18.0.5",
"@types/styled-components": "^5.1.25"
}
}
}
3 changes: 1 addition & 2 deletions src/api/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +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<User | null> {
try {
const response = await axios.get(`${API_ROOT}/api/User/${user.id}`)
Expand Down
1 change: 1 addition & 0 deletions src/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export interface Application {
export interface Goal {
id: string
name: string
icon?: string
targetAmount: number
balance: number
targetDate: Date
Expand Down
1 change: 1 addition & 0 deletions src/ui/components/EmojiPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'emoji-mart/css/emoji-mart.css'
import { useAppSelector } from '../../store/hooks'
import { selectMode } from '../../store/themeSlice'


type Props = { onClick: (emoji: BaseEmoji, event: React.MouseEvent) => void }

export default function EmojiPicker(props: Props) {
Expand Down
2 changes: 1 addition & 1 deletion src/ui/features/goalmanager/GoalIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ type Props = { icon: string | null; onClick: (e: React.MouseEvent) => void }
export default function GoalIcon(props: Props) {
return (
<TransparentButton onClick={props.onClick}>
<Icon>{props.icon}</Icon>
<Icon>{props.icon ?? "🎯"}</Icon>
</TransparentButton>
)
}
Expand Down
32 changes: 32 additions & 0 deletions src/ui/features/goalmanager/GoalManager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,30 @@ 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 EmojiPicker from '../../components/EmojiPicker'

type Props = { goal: Goal }
export function GoalManager(props: Props) {
const dispatch = useAppDispatch()

const [icon, setIcon] = useState<string | null>(props.goal.icon ?? null)
const [showPicker, setShowPicker] = useState(false)

const handleEmojiClick = (emoji: any, event: React.MouseEvent) => {
const selectedEmoji = emoji.native

setIcon(selectedEmoji)
setShowPicker(false)

const updatedGoal: Goal = {
...props.goal,
icon: selectedEmoji,
}

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

const goal = useAppSelector(selectGoalsMap)[props.goal.id]

const [name, setName] = useState<string | null>(null)
Expand Down Expand Up @@ -77,6 +96,19 @@ export function GoalManager(props: Props) {

return (
<GoalManagerContainer>

<button onClick={() => setShowPicker(!showPicker)}>
{icon ?? "🎯 Pick Icon"}
</button>

{showPicker && (
<EmojiPicker onClick={handleEmojiClick} />
)}
{icon && (
<div style={{ fontSize: "40px", marginBottom: "10px" }}>
{icon}
</div>
)}
<NameInput value={name ?? ''} onChange={updateNameOnChange} />

<Group>
Expand Down
Binary file added src/ui/features/goalmanager/GoalManager.zip
Binary file not shown.