export const SideBarItemHasSubMenu = [
  "services",
  "customers",
  "representatives",
  "users",
  "taskmanager",
  "content",
  "financial",
  "support",
  "other",
  "products",
];

const pathSegmentToSubMenu: Record<string, string> = {
  services: "services",
  customers: "customers",
  representatives: "representatives",
  reseller: "representatives",
  users: "users",
  ads: "content",
  announcement: "content",
  blog: "content",
  learning: "content",
  sliders: "content",
  payments: "financial",
  receipts: "financial",
  transactions: "financial",
  discounts: "financial",
  "card-bank": "financial",
  support: "support",
  tickets: "support",
  feedback: "other",
  "access-logs": "other",
  criticisms: "other",
  messages: "other",
  dmenu: "products",
  dkala: "products",
  dpage: "products",
  dmail: "products",
};

export const getSubMenuNameFromPath = (pathname: string): string => {
  if (pathname.startsWith("/customers/subscriptions")) {
    return "customers";
  }

  if (pathname.startsWith("/workspace") || pathname.startsWith("/project") || pathname.startsWith("/taskmanager")) {
    return "taskmanager";
  }

  const segment = pathname.split("/")[1] ?? "";
  return pathSegmentToSubMenu[segment] ?? "";
};
