quivr/frontend/lib/helpers/redirectToPreviousPageOrSearchPage.ts

12 lines
323 B
TypeScript
Raw Normal View History

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