Send local_id with remix API call
This commit is contained in:
parent
cd4f808166
commit
b36fd03c11
3 changed files with 24 additions and 18 deletions
|
|
@ -10,6 +10,7 @@ import Link from 'next/link'
|
||||||
import api from '~utils/api'
|
import api from '~utils/api'
|
||||||
import { accountState, initialAccountState } from '~utils/accountState'
|
import { accountState, initialAccountState } from '~utils/accountState'
|
||||||
import { appState, initialAppState } from '~utils/appState'
|
import { appState, initialAppState } from '~utils/appState'
|
||||||
|
import { getLocalId } from '~utils/localId'
|
||||||
import { retrieveLocaleCookies } from '~utils/retrieveCookies'
|
import { retrieveLocaleCookies } from '~utils/retrieveCookies'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
|
@ -189,12 +190,16 @@ const Header = () => {
|
||||||
function remixTeam() {
|
function remixTeam() {
|
||||||
setOriginalName(partySnapshot.name ? partySnapshot.name : t('no_title'))
|
setOriginalName(partySnapshot.name ? partySnapshot.name : t('no_title'))
|
||||||
|
|
||||||
if (partySnapshot.shortcode)
|
if (partySnapshot.shortcode) {
|
||||||
api.remix(partySnapshot.shortcode).then((response) => {
|
const body = getLocalId()
|
||||||
const remix = response.data.party
|
api
|
||||||
router.push(`/p/${remix.shortcode}`)
|
.remix({ shortcode: partySnapshot.shortcode, body: body })
|
||||||
setRemixToastOpen(true)
|
.then((response) => {
|
||||||
})
|
const remix = response.data.party
|
||||||
|
router.push(`/p/${remix.shortcode}`)
|
||||||
|
setRemixToastOpen(true)
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleFavorite() {
|
function toggleFavorite() {
|
||||||
|
|
|
||||||
|
|
@ -12,15 +12,16 @@ import SummonGrid from '~components/SummonGrid'
|
||||||
import CharacterGrid from '~components/CharacterGrid'
|
import CharacterGrid from '~components/CharacterGrid'
|
||||||
|
|
||||||
import api from '~utils/api'
|
import api from '~utils/api'
|
||||||
|
import { accountState } from '~utils/accountState'
|
||||||
import { appState, initialAppState } from '~utils/appState'
|
import { appState, initialAppState } from '~utils/appState'
|
||||||
|
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 { accountCookie, setEditKey, unsetEditKey } from '~utils/userToken'
|
import { setEditKey, unsetEditKey } from '~utils/userToken'
|
||||||
|
|
||||||
import type { DetailsObject } from '~types'
|
import type { DetailsObject } from '~types'
|
||||||
|
|
||||||
import './index.scss'
|
import './index.scss'
|
||||||
import { accountState } from '~utils/accountState'
|
|
||||||
|
|
||||||
// Props
|
// Props
|
||||||
interface Props {
|
interface Props {
|
||||||
|
|
@ -109,7 +110,7 @@ const Party = (props: Props) => {
|
||||||
if (details) payload = formatDetailsObject(details)
|
if (details) payload = formatDetailsObject(details)
|
||||||
|
|
||||||
return await api.endpoints.parties
|
return await api.endpoints.parties
|
||||||
.create({ ...payload, ...localId() })
|
.create({ ...payload, ...getLocalId() })
|
||||||
.then((response) => storeParty(response.data.party))
|
.then((response) => storeParty(response.data.party))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -300,15 +301,6 @@ const Party = (props: Props) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Methods: Unauth validation
|
|
||||||
function localId() {
|
|
||||||
const cookie = accountCookie()
|
|
||||||
const parsed = JSON.parse(cookie as string)
|
|
||||||
if (parsed && !parsed.token) {
|
|
||||||
return { local_id: parsed.userId }
|
|
||||||
} else return {}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Render: JSX components
|
// Render: JSX components
|
||||||
const navigation = (
|
const navigation = (
|
||||||
<PartySegmentedControl
|
<PartySegmentedControl
|
||||||
|
|
|
||||||
9
utils/localId.tsx
Normal file
9
utils/localId.tsx
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
import { accountCookie } from './userToken'
|
||||||
|
|
||||||
|
export function getLocalId() {
|
||||||
|
const cookie = accountCookie()
|
||||||
|
const parsed = JSON.parse(cookie as string)
|
||||||
|
if (parsed && !parsed.token) {
|
||||||
|
return { local_id: parsed.userId }
|
||||||
|
} else return {}
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue