Logged out users couldnt make teams from two tabs

This commit is contained in:
Justin Edmund 2024-01-08 04:05:32 -08:00
parent 8319cb861a
commit 318f1527b7

View file

@ -80,6 +80,7 @@ const Party = (props: Props) => {
? JSON.parse(cookie as string) ? JSON.parse(cookie as string)
: null : null
// Unset edit key and make the party not editable on first load
let editable = false let editable = false
unsetEditKey() unsetEditKey()
@ -98,7 +99,7 @@ const Party = (props: Props) => {
editable = true editable = true
// Also set edit key header // Also set edit key header
setEditKey(props.team.id, props.team.user) setEditKey(props.team.id)
} }
} }
} }
@ -109,8 +110,7 @@ const Party = (props: Props) => {
// Methods: Creating a new party // Methods: Creating a new party
async function createParty(details?: DetailsObject) { async function createParty(details?: DetailsObject) {
let payload = {} let payload = formatDetailsObject(details ?? {})
if (details) payload = formatDetailsObject(details)
return await api.endpoints.parties.create(payload).then((response) => { return await api.endpoints.parties.create(payload).then((response) => {
storeParty(response.data.party) storeParty(response.data.party)
@ -213,7 +213,7 @@ const Party = (props: Props) => {
// Store the edit key in local storage // Store the edit key in local storage
if (remix.edit_key) { if (remix.edit_key) {
storeEditKey(remix.id, remix.edit_key) storeEditKey(remix.id, remix.edit_key)
setEditKey(remix.id, remix.user) setEditKey(remix.id)
} }
router.push(`/p/${remix.shortcode}`) router.push(`/p/${remix.shortcode}`)
@ -288,10 +288,15 @@ const Party = (props: Props) => {
appState.party.detailsVisible = false appState.party.detailsVisible = false
// Store the edit key in local storage // Handle the state of the edit key
if (!team.user) {
if (team.edit_key) { if (team.edit_key) {
storeEditKey(team.id, team.edit_key) storeEditKey(team.id, team.edit_key)
setEditKey(team.id, team.user) } else if (team.local_id) {
setEditKey(team.local_id)
}
} else {
unsetEditKey()
} }
// Populate state // Populate state