import { microloansRoutes } from '../routes';

export type MicroloansNavFlags = {
  hasOffer: boolean;
  hasActivePlan: boolean;
  hasFinishedPlans: boolean;
};

export function shouldShowMicroloansInSidebar(
  flags: MicroloansNavFlags,
): boolean {
  return flags.hasOffer || flags.hasActivePlan || flags.hasFinishedPlans;
}

export function getMicroloansEntryPath(flags: MicroloansNavFlags): string {
  if (flags.hasOffer) {
    return microloansRoutes.requestOffer();
  }
  if (flags.hasActivePlan) {
    return microloansRoutes.status();
  }
  if (flags.hasFinishedPlans) {
    return microloansRoutes.history();
  }
  return microloansRoutes.requestOffer();
}
