We have to pass around the slug as well
This commit is contained in:
parent
2bf1c75364
commit
be90172fad
5 changed files with 24 additions and 11 deletions
|
|
@ -38,6 +38,7 @@ const CharacterGrid = (props: Props) => {
|
||||||
const [found, setFound] = useState(false)
|
const [found, setFound] = useState(false)
|
||||||
const [loading, setLoading] = useState(true)
|
const [loading, setLoading] = useState(true)
|
||||||
const { id, setId } = useContext(PartyContext)
|
const { id, setId } = useContext(PartyContext)
|
||||||
|
const { slug, setSlug } = useContext(PartyContext)
|
||||||
const { editable, setEditable } = useContext(AppContext)
|
const { editable, setEditable } = useContext(AppContext)
|
||||||
|
|
||||||
// Set up states for Grid data
|
// Set up states for Grid data
|
||||||
|
|
@ -55,9 +56,10 @@ const CharacterGrid = (props: Props) => {
|
||||||
|
|
||||||
// Fetch data from the server
|
// Fetch data from the server
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (props.slug) fetchGrid(props.slug)
|
const shortcode = (props.slug) ? props.slug : slug
|
||||||
|
if (shortcode) fetchGrid(shortcode)
|
||||||
else setEditable(true)
|
else setEditable(true)
|
||||||
}, [])
|
}, [slug, props.slug])
|
||||||
|
|
||||||
// Initialize an array of current uncap values for each characters
|
// Initialize an array of current uncap values for each characters
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
@ -136,6 +138,9 @@ const CharacterGrid = (props: Props) => {
|
||||||
props.createParty()
|
props.createParty()
|
||||||
.then(response => {
|
.then(response => {
|
||||||
const party = response.data.party
|
const party = response.data.party
|
||||||
|
setId(party.id)
|
||||||
|
setSlug(party.shortcode)
|
||||||
|
|
||||||
if (props.pushHistory) props.pushHistory(`/p/${party.shortcode}`)
|
if (props.pushHistory) props.pushHistory(`/p/${party.shortcode}`)
|
||||||
saveCharacter(party.id, character, position)
|
saveCharacter(party.id, character, position)
|
||||||
.then(response => storeGridCharacter(response.data.grid_character))
|
.then(response => storeGridCharacter(response.data.grid_character))
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@ const Party = (props: Props) => {
|
||||||
// Set up states
|
// Set up states
|
||||||
const [currentTab, setCurrentTab] = useState<GridType>(GridType.Weapon)
|
const [currentTab, setCurrentTab] = useState<GridType>(GridType.Weapon)
|
||||||
const [id, setId] = useState('')
|
const [id, setId] = useState('')
|
||||||
|
const [slug, setSlug] = useState('')
|
||||||
const [element, setElement] = useState<TeamElement>(TeamElement.Any)
|
const [element, setElement] = useState<TeamElement>(TeamElement.Any)
|
||||||
const [editable, setEditable] = useState(false)
|
const [editable, setEditable] = useState(false)
|
||||||
const [hasExtra, setHasExtra] = useState(false)
|
const [hasExtra, setHasExtra] = useState(false)
|
||||||
|
|
@ -127,7 +128,7 @@ const Party = (props: Props) => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<PartyContext.Provider value={{ id, setId, element, setElement, editable, setEditable, hasExtra, setHasExtra }}>
|
<PartyContext.Provider value={{ id, setId, slug, setSlug, element, setElement, editable, setEditable, hasExtra, setHasExtra }}>
|
||||||
{ navigation }
|
{ navigation }
|
||||||
{ currentGrid() }
|
{ currentGrid() }
|
||||||
</PartyContext.Provider>
|
</PartyContext.Provider>
|
||||||
|
|
|
||||||
|
|
@ -35,13 +35,11 @@ const SummonGrid = (props: Props) => {
|
||||||
}
|
}
|
||||||
} : {}
|
} : {}
|
||||||
|
|
||||||
// Set up state for party
|
|
||||||
const { id, setId } = useContext(PartyContext)
|
|
||||||
|
|
||||||
|
|
||||||
// Set up state for view management
|
// Set up state for view management
|
||||||
const [found, setFound] = useState(false)
|
const [found, setFound] = useState(false)
|
||||||
const [loading, setLoading] = useState(true)
|
const [loading, setLoading] = useState(true)
|
||||||
|
const { id, setId } = useContext(PartyContext)
|
||||||
|
const { slug, setSlug } = useContext(PartyContext)
|
||||||
const { editable, setEditable } = useContext(AppContext)
|
const { editable, setEditable } = useContext(AppContext)
|
||||||
|
|
||||||
// Set up states for Grid data
|
// Set up states for Grid data
|
||||||
|
|
@ -61,9 +59,10 @@ const SummonGrid = (props: Props) => {
|
||||||
|
|
||||||
// Fetch data from the server
|
// Fetch data from the server
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (props.slug) fetchGrid(props.slug)
|
const shortcode = (props.slug) ? props.slug : slug
|
||||||
|
if (shortcode) fetchGrid(shortcode)
|
||||||
else setEditable(true)
|
else setEditable(true)
|
||||||
}, [])
|
}, [slug, props.slug])
|
||||||
|
|
||||||
// Initialize an array of current uncap values for each summon
|
// Initialize an array of current uncap values for each summon
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
@ -154,6 +153,9 @@ const SummonGrid = (props: Props) => {
|
||||||
props.createParty()
|
props.createParty()
|
||||||
.then(response => {
|
.then(response => {
|
||||||
const party = response.data.party
|
const party = response.data.party
|
||||||
|
setId(party.id)
|
||||||
|
setSlug(party.shortcode)
|
||||||
|
|
||||||
if (props.pushHistory) props.pushHistory(`/p/${party.shortcode}`)
|
if (props.pushHistory) props.pushHistory(`/p/${party.shortcode}`)
|
||||||
saveSummon(party.id, summon, position)
|
saveSummon(party.id, summon, position)
|
||||||
.then(response => storeGridSummon(response.data.grid_summon))
|
.then(response => storeGridSummon(response.data.grid_summon))
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@ const WeaponGrid = (props: Props) => {
|
||||||
// Set up the party context
|
// Set up the party context
|
||||||
const { setEditable: setAppEditable } = useContext(AppContext)
|
const { setEditable: setAppEditable } = useContext(AppContext)
|
||||||
const { id, setId } = useContext(PartyContext)
|
const { id, setId } = useContext(PartyContext)
|
||||||
|
const { slug, setSlug } = useContext(PartyContext)
|
||||||
const { editable, setEditable } = useContext(PartyContext)
|
const { editable, setEditable } = useContext(PartyContext)
|
||||||
const { hasExtra, setHasExtra } = useContext(PartyContext)
|
const { hasExtra, setHasExtra } = useContext(PartyContext)
|
||||||
const { setElement } = useContext(PartyContext)
|
const { setElement } = useContext(PartyContext)
|
||||||
|
|
@ -63,12 +64,13 @@ const WeaponGrid = (props: Props) => {
|
||||||
|
|
||||||
// Fetch data from the server
|
// Fetch data from the server
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (props.slug) fetchGrid(props.slug)
|
const shortcode = (props.slug) ? props.slug : slug
|
||||||
|
if (shortcode) fetchGrid(shortcode)
|
||||||
else {
|
else {
|
||||||
setEditable(true)
|
setEditable(true)
|
||||||
setAppEditable(true)
|
setAppEditable(true)
|
||||||
}
|
}
|
||||||
}, [props.slug])
|
}, [slug, props.slug])
|
||||||
|
|
||||||
// Initialize an array of current uncap values for each weapon
|
// Initialize an array of current uncap values for each weapon
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
@ -159,6 +161,7 @@ const WeaponGrid = (props: Props) => {
|
||||||
.then(response => {
|
.then(response => {
|
||||||
const party = response.data.party
|
const party = response.data.party
|
||||||
setId(party.id)
|
setId(party.id)
|
||||||
|
setSlug(party.shortcode)
|
||||||
|
|
||||||
if (props.pushHistory) props.pushHistory(`/p/${party.shortcode}`)
|
if (props.pushHistory) props.pushHistory(`/p/${party.shortcode}`)
|
||||||
saveWeapon(party.id, weapon, position)
|
saveWeapon(party.id, weapon, position)
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,8 @@ import { TeamElement } from '~utils/enums'
|
||||||
const PartyContext = createContext({
|
const PartyContext = createContext({
|
||||||
id: '',
|
id: '',
|
||||||
setId: (id: string) => {},
|
setId: (id: string) => {},
|
||||||
|
slug: '',
|
||||||
|
setSlug: (slug: string) => {},
|
||||||
element: TeamElement.Any,
|
element: TeamElement.Any,
|
||||||
setElement: (element: TeamElement) => {},
|
setElement: (element: TeamElement) => {},
|
||||||
editable: false,
|
editable: false,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue