Fix updating raid in party details
This commit is contained in:
parent
cc3e14a8c4
commit
90a0447787
2 changed files with 9 additions and 19 deletions
|
|
@ -47,7 +47,6 @@ interface Props {
|
||||||
|
|
||||||
const PartyDetails = (props: Props) => {
|
const PartyDetails = (props: Props) => {
|
||||||
const { party, raids } = useSnapshot(appState)
|
const { party, raids } = useSnapshot(appState)
|
||||||
const { account } = useSnapshot(accountState)
|
|
||||||
|
|
||||||
const { t } = useTranslation('common')
|
const { t } = useTranslation('common')
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
@ -55,7 +54,8 @@ const PartyDetails = (props: Props) => {
|
||||||
|
|
||||||
const nameInput = React.createRef<HTMLInputElement>()
|
const nameInput = React.createRef<HTMLInputElement>()
|
||||||
const descriptionInput = React.createRef<HTMLTextAreaElement>()
|
const descriptionInput = React.createRef<HTMLTextAreaElement>()
|
||||||
const raidSelect = React.createRef<HTMLSelectElement>()
|
|
||||||
|
const [raidSlug, setRaidSlug] = useState('')
|
||||||
|
|
||||||
const readOnlyClasses = classNames({
|
const readOnlyClasses = classNames({
|
||||||
PartyDetails: true,
|
PartyDetails: true,
|
||||||
|
|
@ -115,10 +115,14 @@ const PartyDetails = (props: Props) => {
|
||||||
appState.party.detailsVisible = !appState.party.detailsVisible
|
appState.party.detailsVisible = !appState.party.detailsVisible
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function receiveRaid(slug?: string) {
|
||||||
|
if (slug) setRaidSlug(slug)
|
||||||
|
}
|
||||||
|
|
||||||
function updateDetails(event: React.MouseEvent) {
|
function updateDetails(event: React.MouseEvent) {
|
||||||
const nameValue = nameInput.current?.value
|
const nameValue = nameInput.current?.value
|
||||||
const descriptionValue = descriptionInput.current?.value
|
const descriptionValue = descriptionInput.current?.value
|
||||||
const raid = raids.find((raid) => raid.slug === raidSelect.current?.value)
|
const raid = raids.find((raid) => raid.slug === raidSlug)
|
||||||
|
|
||||||
props.updateCallback(nameValue, descriptionValue, raid)
|
props.updateCallback(nameValue, descriptionValue, raid)
|
||||||
toggleDetails()
|
toggleDetails()
|
||||||
|
|
@ -219,8 +223,8 @@ const PartyDetails = (props: Props) => {
|
||||||
/>
|
/>
|
||||||
<RaidDropdown
|
<RaidDropdown
|
||||||
showAllRaidsOption={false}
|
showAllRaidsOption={false}
|
||||||
currentRaid={party.raid?.slug || ''}
|
currentRaid={party.raid ? party.raid.slug : undefined}
|
||||||
ref={raidSelect}
|
onChange={receiveRaid}
|
||||||
/>
|
/>
|
||||||
<TextFieldset
|
<TextFieldset
|
||||||
fieldName="name"
|
fieldName="name"
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,4 @@
|
||||||
export default (raids: Raid[]) => {
|
export default (raids: Raid[]) => {
|
||||||
console.log('organizing raids...')
|
|
||||||
// Set up empty raid for "All raids"
|
|
||||||
const all = {
|
|
||||||
id: '0',
|
|
||||||
name: {
|
|
||||||
en: 'All raids',
|
|
||||||
ja: '全て',
|
|
||||||
},
|
|
||||||
slug: 'all',
|
|
||||||
level: 0,
|
|
||||||
group: 0,
|
|
||||||
element: 0,
|
|
||||||
}
|
|
||||||
|
|
||||||
const numGroups = Math.max.apply(
|
const numGroups = Math.max.apply(
|
||||||
Math,
|
Math,
|
||||||
raids.map((raid) => raid.group)
|
raids.map((raid) => raid.group)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue