import Cookies from "js-cookie";

export const withHeaders = () => {
  const tenantKey = Cookies.get("tenant-key");
  const unitId = Cookies.get("unit-id");
  const positionId = Cookies.get("current-position-id");
  const projectId = Cookies.get("current-project-id");
  const delegatedPositionId = Cookies.get("delegatedPositionId");
  const headers: Record<string, string> = {};

  if (tenantKey) headers["tenant-key"] = tenantKey;
  if (unitId) headers["unit-id"] = unitId;
  if (projectId) headers["x-current-project-id"] = projectId;
  if (delegatedPositionId)
    headers["x-delegated-position-id"] = delegatedPositionId;
  if (positionId) headers["x-current-position-id"] = positionId;
  return headers;
};
