Persist generated localId in localStorage
This commit is contained in:
parent
b36fd03c11
commit
3d429d18ac
1 changed files with 10 additions and 2 deletions
|
|
@ -1,6 +1,8 @@
|
|||
import React, { useEffect, useState } from 'react'
|
||||
import { useRouter } from 'next/router'
|
||||
import { getCookie, setCookie } from 'cookies-next'
|
||||
import { get, set } from 'local-storage'
|
||||
import { serverSideTranslations } from 'next-i18next/serverSideTranslations'
|
||||
import { useRouter } from 'next/router'
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
import clonedeep from 'lodash.clonedeep'
|
||||
|
||||
|
|
@ -19,7 +21,6 @@ import type { AxiosError } from 'axios'
|
|||
import type { NextApiRequest, NextApiResponse } from 'next'
|
||||
import type { PageContextObj, ResponseStatus } from '~types'
|
||||
import { GridType } from '~utils/enums'
|
||||
import { setCookie } from 'cookies-next'
|
||||
|
||||
interface Props {
|
||||
context?: PageContextObj
|
||||
|
|
@ -59,6 +60,13 @@ const NewRoute: React.FC<Props> = ({
|
|||
}
|
||||
}, [router.asPath])
|
||||
|
||||
// Persist generated userId in storage
|
||||
useEffect(() => {
|
||||
const cookie = getCookie('account')
|
||||
const data: AccountCookie = JSON.parse(cookie as string)
|
||||
if (!get('userId') && data && !data.token) set('userId', data.userId)
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
if (context && context.jobs && context.jobSkills) {
|
||||
appState.raids = context.raids
|
||||
|
|
|
|||
Loading…
Reference in a new issue