1
0

feat: redirect the user to the last page they were on before logging in after login

This commit is contained in:
kolaente
2021-10-13 21:53:39 +02:00
parent 97dd55d946
commit 9a2f95ecc6
5 changed files with 44 additions and 5 deletions

View 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)
}