chore(storagecleaner): import from file to avoid huge footprints on every page * chore(storagecleaner): import from file to avoid huge footprints on every page Approved-by: Anton Gunnarsson
27 lines
714 B
TypeScript
27 lines
714 B
TypeScript
"use client"
|
|
import { usePathname } from "next/navigation"
|
|
import { useEffect } from "react"
|
|
|
|
import { hotelreservation } from "@scandic-hotels/common/constants/routes/hotelReservation"
|
|
|
|
import useLang from "../../hooks/useLang"
|
|
import { detailsStorageName } from "../../stores/enter-details/consts"
|
|
|
|
/**
|
|
* Cleanup component to make sure no stale data is left
|
|
* from previous booking when user is not in the booking
|
|
* flow anymore
|
|
*/
|
|
export default function StorageCleaner() {
|
|
const lang = useLang()
|
|
const pathname = usePathname()
|
|
|
|
useEffect(() => {
|
|
if (!pathname.startsWith(hotelreservation(lang))) {
|
|
sessionStorage.removeItem(detailsStorageName)
|
|
}
|
|
}, [lang, pathname])
|
|
|
|
return null
|
|
}
|