import { ROUTES } from "@/router/routes";

export const TIP_GIFT_CATEGORY_PARAM = "category";
export const TIP_GIFT_PLAN_ID_PARAM = "planId";

export interface TipGiftSelection {
  category: string | null;
  planId: string | null;
}

export function normalizeTipGiftParam(
  value: string | null | undefined,
): string | null {
  const normalized = value?.trim();
  return normalized ? normalized : null;
}

export function buildTipGiftPath(
  selection: TipGiftSelection,
  basePath: string = ROUTES.tip,
): string {
  const params = new URLSearchParams();
  if (selection.category) {
    params.set(TIP_GIFT_CATEGORY_PARAM, selection.category);
  }
  if (selection.planId) {
    params.set(TIP_GIFT_PLAN_ID_PARAM, selection.planId);
  }
  const query = params.toString();
  return query ? `${basePath}?${query}` : basePath;
}
