Skip to content

shouldShowPlayOption

Description
Determines whether the user should be prompted to play the lottery. This is based on geo-eligibility, age verification status, and game availability in their current state.


Function Signature

shouldShowPlayOption(userId: string): Promise<{
  show: boolean;
  state?: string;
  availableGames?: string[];
  ageVerified?: boolean;
  reason?: "geo" | "age" | "other";
}>

Behavior - Uses checkGeoEligibility() to verify user is in a participating state. - Uses checkAgeVerificationStatus() to confirm age eligibility. - Returns a flag indicating whether the lottery play prompt should be shown, and why not if it's suppressed.


Sample Output (Eligible)

{
  "show": true,
  "state": "MI",
  "availableGames": ["Powerball", "Mega Millions"],
  "ageVerified": true
}

Sample Output (Not Eligible - Geo)

{
  "show": false,
  "reason": "geo"
}

Sample Output (Not Eligible - Age)

{
  "show": false,
  "reason": "age"
}

Compliance Note
This function performs pre-play validation of both location and age as required by state laws. It suppresses any lottery prompt until both checks pass.