Skip to content

Commit

Permalink
Open Team Editor after creating team from character editor (#1655)
Browse files Browse the repository at this point in the history
* Open Team Editor after creating team from character editor

* remove console.log
  • Loading branch information
frzyc authored Mar 11, 2024
1 parent fdd2346 commit 0465507
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -238,15 +238,15 @@ function InTeam() {
database.teams.set(teamId, (team) => {
team.teamCharIds[0] = teamCharId
})
navigate(`/teams/${teamId}`)
navigate(`/teams/${teamId}`, { state: { openSetting: true } })
}
const onAddNewTeam = () => {
const teamId = database.teams.new()
const teamCharId = database.teamChars.new(characterKey)
database.teams.set(teamId, (team) => {
team.teamCharIds[0] = teamCharId
})
navigate(`/teams/${teamId}`)
navigate(`/teams/${teamId}`, { state: { openSetting: true } })
}
const onDelete = (teamCharId: string) => {
if (
Expand Down
13 changes: 10 additions & 3 deletions apps/frontend/src/app/PageTeam/TeamSetting/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import {
import ContentCopyIcon from '@mui/icons-material/ContentCopy'
import ContentPasteIcon from '@mui/icons-material/ContentPaste'
import DeleteForeverIcon from '@mui/icons-material/DeleteForever'
import { useNavigate } from 'react-router-dom'
import { useLocation, useNavigate } from 'react-router-dom'
// TODO: Translation

export default function TeamSetting({
Expand All @@ -51,8 +51,15 @@ export default function TeamSetting({
const database = useDatabase()
const team = database.teams.get(teamId)!
const noChars = team.teamCharIds.every((id) => !id)
// open the settings modal by default
const [open, setOpen] = useState(noChars ? true : false)

const location = useLocation()

const { openSetting = false } = (location.state ?? {
openSetting: false,
}) as {
openSetting?: boolean
}
const [open, setOpen] = useState(openSetting || noChars)

const [name, setName] = useState(team.name)
const nameDeferred = useDeferredValue(name)
Expand Down

0 comments on commit 0465507

Please sign in to comment.