Ask the user who they are when opening a group for the first time (#7)

This commit is contained in:
Sebastien Castiel
2024-01-09 08:53:51 -05:00
parent 6bd3299331
commit 1b9e624004
9 changed files with 600 additions and 42 deletions

View File

@@ -27,11 +27,15 @@ export function ExpenseList({
if (activeUser || newUser) {
localStorage.removeItem('newGroup-activeUser')
localStorage.removeItem(`${groupId}-newUser`)
const userId = participants.find(
(p) => p.name === (activeUser || newUser),
)?.id
if (userId) {
localStorage.setItem(`${groupId}-activeUser`, userId)
if (activeUser === 'None') {
localStorage.setItem(`${groupId}-activeUser`, 'None')
} else {
const userId = participants.find(
(p) => p.name === (activeUser || newUser),
)?.id
if (userId) {
localStorage.setItem(`${groupId}-activeUser`, userId)
}
}
}
}, [groupId, participants])