Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

1.2 KB
Raw Blame
// SPDX-License-Identifier: AGPL-3.0-only
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.

import { SESSION_SECRET } from "@carbon/auth";
import { createCookieSessionStorage } from "react-router";

const MES_PEOPLE_OVERRIDE_KEY = "mes-people-override";

const sessionStorage = createCookieSessionStorage({
  cookie: {
    name: MES_PEOPLE_OVERRIDE_KEY,
    path: "/",
    secrets: [SESSION_SECRET!],
    secure: false
  }
});

/**
 * The date (YYYY-MM-DD) for which the operator dismissed the people-assignment
 * station default this session; undefined when never dismissed.
 */
export async function getPeopleOverride(
  request: Request
): Promise<string | undefined> {
  const session = await sessionStorage.getSession(
    request.headers.get("Cookie")
  );
  return session.get(MES_PEOPLE_OVERRIDE_KEY) as string | undefined;
}

export async function setPeopleOverride(request: Request, date: string) {
  const session = await sessionStorage.getSession(
    request.headers.get("Cookie")
  );
  session.set(MES_PEOPLE_OVERRIDE_KEY, date);
  return sessionStorage.commitSession(session);
}