Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open Team Editor after creating team from character editor #1655

Merged
merged 2 commits into from
Mar 11, 2024
Merged
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
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
Loading