const ROOT_ROUTE = "/";

const createRoute = (
  segments: Array<string | undefined>,
  queryParams?: Record<string, string>
): string => {
  const url = ROOT_ROUTE + segments.filter(Boolean).join("/");
  if (queryParams) {
    return url + "?" + new URLSearchParams(queryParams).toString();
  }
  return url;
};

export const ROUTES = {
  home: () => createRoute([]),

  // Payment
  payment: (queryParams?: Record<string, string>) =>
    createRoute(["payment"], queryParams),
  paymentSuccess: () => createRoute(["payment", "success"]),
  paymentFailed: () => createRoute(["payment", "failed"]),
};
