Skip to content

Commit

Permalink
Fix more types
Browse files Browse the repository at this point in the history
  • Loading branch information
monachilada committed Sep 5, 2024
1 parent c1031e6 commit 92fd4ad
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/dito/app/utils/cookies.server.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createCookie } from "@remix-run/node";
import type { Answers } from "routes/vorpruefung.$questionId/route";
import type { PreCheckAnswers } from "routes/vorpruefung.$questionId/route";

export const userAnswers = createCookie("user-answers", {
maxAge: 604_800, // one week
Expand All @@ -8,12 +8,14 @@ export const userAnswers = createCookie("user-answers", {
export const getAnswersFromCookie = async (request: Request) => {
const cookieHeader = request.headers.get("Cookie");
const cookie = (await userAnswers.parse(cookieHeader)) as {
answers: Answers;
answers: PreCheckAnswers;
hasViewedResult: boolean;
} | null;
return cookie ?? { answers: {}, hasViewedResult: false };
};

export const getHeaderFromCookie = async (cookie: { answers: Answers }) => {
export const getHeaderFromCookie = async (cookie: {
answers: PreCheckAnswers;
}) => {
return { headers: { "Set-Cookie": await userAnswers.serialize(cookie) } };
};

0 comments on commit 92fd4ad

Please sign in to comment.