Account for search queries when returning to page

This commit is contained in:
Kalle (Sendou)
2021-12-20 11:21:33 +02:00
parent be84598a9f
commit d82f0d7744
2 changed files with 4 additions and 2 deletions

View File

@@ -1,4 +1,4 @@
import { useLocation } from "react-router";
import { useLocation } from "remix";
import { getLogInUrl } from "~/utils";
import { useUser } from "~/utils/hooks";
import { DiscordIcon } from "../icons/Discord";

View File

@@ -26,7 +26,9 @@ export function getUser(ctx: any) {
/** Get link to log in with query param set as current page */
export function getLogInUrl(location: ReturnType<typeof useLocation>) {
return `/auth/discord?origin=${encodeURIComponent(location.pathname)}`;
return `/auth/discord?origin=${encodeURIComponent(
location.pathname + location.search
)}`;
}
/** Get fields from `request.formData()`. Throw an error if the formData doesn't contain a requested field. */