quivr/frontend/lib/helpers/redirectToPreviousPageOrSearchPage.ts
Stan Girard d0b8b797f6
feat(search): new way to interact with Quivr (#2026)
Co-authored-by: Zewed <dewez.antoine2@gmail.com>
Co-authored-by: Antoine Dewez <44063631+Zewed@users.noreply.github.com>
2024-01-19 20:34:30 -08:00

12 lines
323 B
TypeScript

import { redirect } from "next/navigation";
export const redirectToPreviousPageOrSearchPage = (): void => {
const previousPage = sessionStorage.getItem("previous-page");
if (previousPage === null) {
redirect("/search");
} else {
sessionStorage.removeItem("previous-page");
redirect(previousPage);
}
};