feat: redirect the user to the last page they were on before logging in after login
This commit is contained in:
parent
97dd55d946
commit
9a2f95ecc6
5 changed files with 44 additions and 5 deletions
18
src/helpers/saveLastVisited.ts
Normal file
18
src/helpers/saveLastVisited.ts
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
const LAST_VISITED_KEY = 'lastVisited'
|
||||
|
||||
export const saveLastVisited = (name: string, params: object) => {
|
||||
localStorage.setItem(LAST_VISITED_KEY, JSON.stringify({name, params}))
|
||||
}
|
||||
|
||||
export const getLastVisited = () => {
|
||||
const lastVisited = localStorage.getItem(LAST_VISITED_KEY)
|
||||
if (lastVisited === null) {
|
||||
return null
|
||||
}
|
||||
|
||||
return JSON.parse(lastVisited)
|
||||
}
|
||||
|
||||
export const clearLastVisited = () => {
|
||||
return localStorage.removeItem(LAST_VISITED_KEY)
|
||||
}
|
||||
Reference in a new issue