Allow unauth users to edit their remixed parties
This commit is contained in:
parent
e617cfb066
commit
dc44e9f999
3 changed files with 13 additions and 6 deletions
|
|
@ -12,6 +12,7 @@ import { accountState, initialAccountState } from '~utils/accountState'
|
||||||
import { appState, initialAppState } from '~utils/appState'
|
import { appState, initialAppState } from '~utils/appState'
|
||||||
import { getLocalId } from '~utils/localId'
|
import { getLocalId } from '~utils/localId'
|
||||||
import { retrieveLocaleCookies } from '~utils/retrieveCookies'
|
import { retrieveLocaleCookies } from '~utils/retrieveCookies'
|
||||||
|
import { setEditKey, storeEditKey } from '~utils/userToken'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
|
|
@ -196,6 +197,13 @@ const Header = () => {
|
||||||
.remix({ shortcode: partySnapshot.shortcode, body: body })
|
.remix({ shortcode: partySnapshot.shortcode, body: body })
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
const remix = response.data.party
|
const remix = response.data.party
|
||||||
|
|
||||||
|
// Store the edit key in local storage
|
||||||
|
if (remix.edit_key) {
|
||||||
|
storeEditKey(remix.id, remix.edit_key)
|
||||||
|
setEditKey(remix.id, remix.user)
|
||||||
|
}
|
||||||
|
|
||||||
router.push(`/p/${remix.shortcode}`)
|
router.push(`/p/${remix.shortcode}`)
|
||||||
setRemixToastOpen(true)
|
setRemixToastOpen(true)
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ import { getCookie } from 'cookies-next'
|
||||||
import { useRouter } from 'next/router'
|
import { useRouter } from 'next/router'
|
||||||
import { subscribe, useSnapshot } from 'valtio'
|
import { subscribe, useSnapshot } from 'valtio'
|
||||||
import clonedeep from 'lodash.clonedeep'
|
import clonedeep from 'lodash.clonedeep'
|
||||||
import ls from 'local-storage'
|
|
||||||
|
|
||||||
import PartySegmentedControl from '~components/PartySegmentedControl'
|
import PartySegmentedControl from '~components/PartySegmentedControl'
|
||||||
import PartyDetails from '~components/PartyDetails'
|
import PartyDetails from '~components/PartyDetails'
|
||||||
|
|
@ -17,7 +16,7 @@ import { appState, initialAppState } from '~utils/appState'
|
||||||
import { getLocalId } from '~utils/localId'
|
import { getLocalId } from '~utils/localId'
|
||||||
import { GridType } from '~utils/enums'
|
import { GridType } from '~utils/enums'
|
||||||
import { retrieveCookies } from '~utils/retrieveCookies'
|
import { retrieveCookies } from '~utils/retrieveCookies'
|
||||||
import { setEditKey, unsetEditKey } from '~utils/userToken'
|
import { setEditKey, storeEditKey, unsetEditKey } from '~utils/userToken'
|
||||||
|
|
||||||
import type { DetailsObject } from '~types'
|
import type { DetailsObject } from '~types'
|
||||||
|
|
||||||
|
|
@ -240,10 +239,6 @@ const Party = (props: Props) => {
|
||||||
return team
|
return team
|
||||||
}
|
}
|
||||||
|
|
||||||
const storeEditKey = (id: string, key: string) => {
|
|
||||||
ls(id, key)
|
|
||||||
}
|
|
||||||
|
|
||||||
const storeCharacters = (list: Array<GridCharacter>) => {
|
const storeCharacters = (list: Array<GridCharacter>) => {
|
||||||
list.forEach((object: GridCharacter) => {
|
list.forEach((object: GridCharacter) => {
|
||||||
if (object.position != null)
|
if (object.position != null)
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,10 @@ export const setHeaders = (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const storeEditKey = (id: string, key: string) => {
|
||||||
|
ls(id, key)
|
||||||
|
}
|
||||||
|
|
||||||
export const setEditKey = (id: string, user?: User) => {
|
export const setEditKey = (id: string, user?: User) => {
|
||||||
if (!user) {
|
if (!user) {
|
||||||
const edit_key = get<string>(id)
|
const edit_key = get<string>(id)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue