Skip to content

Commit

Permalink
feat(frontend): make redirect cookies long lived
Browse files Browse the repository at this point in the history
  • Loading branch information
IgnisDa committed Aug 16, 2024
1 parent 2ec1686 commit ea0236d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion apps/frontend/app/lib/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { $path } from "remix-routes";
import { useInterval } from "usehooks-ts";
import {
CurrentWorkoutKey,
dayjsLib,
getMetadataDetailsQuery,
getStringAsciiValue,
getUserMetadataDetailsQuery,
Expand Down Expand Up @@ -41,13 +42,16 @@ export const useFallbackImageUrl = (text = "No Image") => {

export const useAppSearchParam = (cookieKey: string) => {
const [searchParams, setSearchParams] = useSearchParams();
const coreDetails = useCoreDetails();

const updateCookieP = (key: string, value?: string | null) => {
const cookieValue = Cookies.get(cookieKey);
const cookieSearchParams = new URLSearchParams(cookieValue);
if (!value) cookieSearchParams.delete(key);
else cookieSearchParams.set(key, value);
Cookies.set(cookieKey, cookieSearchParams.toString());
Cookies.set(cookieKey, cookieSearchParams.toString(), {
expires: dayjsLib().add(coreDetails.tokenValidForDays, "day").toDate(),
});
};

const delP = (key: string) => {
Expand Down

0 comments on commit ea0236d

Please sign in to comment.