import { LoginContext } from "@/(pages)/login/login-context";
import { cookies } from "next/headers";

export default async function getLastSession() {
  const cookieStore = await cookies();
  const lastSession = cookieStore.get("last-session");

  let parsedLastSession = undefined;

  if (lastSession?.value) {
    parsedLastSession = JSON.parse(
      lastSession.value
    ) as LoginContext["lastSession"];
  }

  return parsedLastSession;
}
