Skip to content

Commit

Permalink
Merge pull request #410 from UKGovernmentBEIS/PC-1463-improve-ux-for-…
Browse files Browse the repository at this point in the history
…no-address-found

PC-1463: Improve UX for when no address found
  • Loading branch information
samyou-softwire authored Dec 13, 2024
2 parents 3efd093 + 0c27ae9 commit fbb2380
Show file tree
Hide file tree
Showing 11 changed files with 454 additions and 377 deletions.
47 changes: 27 additions & 20 deletions help_to_heat/frontdoor/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,33 +143,40 @@
park_home_main_residence_field = "park_home_main_residence"
# yes/no options

address_choice_field = "address_choice"
address_choice_field_write_address = "write address"
address_choice_field_epc_api_fail = "epc api fail"
address_choice_field_enter_manually = "enter manually"
address_building_name_or_number_field = "building_name_or_number"
address_postcode_field = "postcode"
address_all_address_and_lmk_details_field = "address_and_lmk_details"

epc_select_choice_field = "epc_select_choice"
epc_select_choice_field_select_epc = "select epc"
epc_select_choice_field_epc_api_fail = "epc api fail"
epc_select_choice_field_enter_manually = "enter manually"

address_select_choice_field = "address_select_choice"
address_select_choice_field_select_address = "select address"
address_select_choice_field_enter_manually = "enter manually"

referral_already_submitted_field = "submit_another"
# this const was renamed to no longer include lmk.
# this is as this field stores info from both flows (lmk & uprn)
# the field value is left as is to preserve backwards compatibility
address_all_address_and_details_field = "address_and_lmk_details"

# journey fields are calculated based on user input & other factors, and decide where the user should go next
# they are stored in the users' session to record the result of these checks, to make journey calculation reproducible
address_choice_journey_field = "address_choice"
address_choice_journey_field_write_address = "write address"
address_choice_journey_field_epc_api_fail = "epc api fail"
address_choice_journey_field_enter_manually = "enter manually"
address_no_results_journey_field = "no_results" # yes/no options

epc_select_choice_journey_field = "epc_select_choice"
epc_select_choice_journey_field_select_epc = "select epc"
epc_select_choice_journey_field_epc_api_fail = "epc api fail"
epc_select_choice_journey_field_enter_manually = "enter manually"

address_select_choice_journey_field = "address_select_choice"
address_select_choice_journey_field_select_address = "select address"
address_select_choice_journey_field_enter_manually = "enter manually"

referral_already_submitted_journey_field = "submit_another"

address_manual_address_line_1_field = "address_line_1"
address_manual_address_line_2_field = "address_line_2"
address_manual_town_or_city_field = "town_or_city"
address_manual_county_field = "county"
address_manual_postcode_field = "postcode"

duplicate_uprn_field = "uprn_is_duplicate"
epc_found_field = "epc_found"
duplicate_uprn_journey_field = "uprn_is_duplicate" # yes/no options
epc_found_journey_field = "epc_found" # yes/no options
lmk_field = "lmk"
lmk_field_enter_manually = "enter-manually"
address_field = "address"
Expand Down Expand Up @@ -205,9 +212,9 @@
epc_accept_suggested_epc_field_not_found = "Not found"
epc_rating_field = "epc_rating"
epc_rating_field_not_found = "Not found"
epc_rating_is_eligible_field = "epc_rating_is_eligible"
epc_rating_is_eligible_field = "epc_rating_is_eligible" # yes/no options

no_epc_field = "confirm_no_epc"
no_epc_field = "confirm_no_epc" # yes/no options

benefits_field = "benefits"

Expand Down
72 changes: 38 additions & 34 deletions help_to_heat/frontdoor/routing/forwards_routing.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from help_to_heat.frontdoor.consts import (
address_choice_field,
address_choice_field_enter_manually,
address_choice_field_epc_api_fail,
address_choice_field_write_address,
address_choice_journey_field,
address_choice_journey_field_enter_manually,
address_choice_journey_field_epc_api_fail,
address_choice_journey_field_write_address,
address_manual_page,
address_no_results_journey_field,
address_page,
address_select_choice_field,
address_select_choice_field_select_address,
address_select_choice_journey_field,
address_select_choice_journey_field_select_address,
address_select_manual_page,
address_select_page,
benefits_field,
Expand All @@ -23,16 +24,16 @@
country_field_scotland,
country_field_wales,
country_page,
duplicate_uprn_field,
duplicate_uprn_journey_field,
epc_accept_suggested_epc_field,
epc_found_field,
epc_found_journey_field,
epc_ineligible_page,
epc_page,
epc_rating_is_eligible_field,
epc_select_choice_field,
epc_select_choice_field_enter_manually,
epc_select_choice_field_epc_api_fail,
epc_select_choice_field_select_epc,
epc_select_choice_journey_field,
epc_select_choice_journey_field_enter_manually,
epc_select_choice_journey_field_epc_api_fail,
epc_select_choice_journey_field_select_epc,
epc_select_manual_page,
epc_select_page,
field_no,
Expand Down Expand Up @@ -319,45 +320,48 @@ def _park_home_main_residence_next_page(answers):
return _unknown_response


@_requires_answer(address_choice_field)
@_requires_answer(address_choice_journey_field)
def _address_next_page(answers):
address_choice = answers.get(address_choice_field)
address_choice = answers.get(address_choice_journey_field)
address_no_results = answers.get(address_no_results_journey_field)
country = answers.get(country_field)

if address_choice == address_choice_field_write_address:
if address_no_results == field_yes:
return address_manual_page
if address_choice == address_choice_journey_field_write_address:
if country in [country_field_england, country_field_wales]:
return epc_select_page
if country == country_field_scotland:
return address_select_page
if address_choice == address_choice_field_epc_api_fail:
if address_choice == address_choice_journey_field_epc_api_fail:
return address_select_page
if address_choice == address_choice_field_enter_manually:
if address_choice == address_choice_journey_field_enter_manually:
return address_manual_page

return _unknown_response


@_requires_answer(epc_select_choice_field)
@_requires_answer(epc_select_choice_journey_field)
def _epc_select_next_page(answers):
choice = answers.get(epc_select_choice_field)
choice = answers.get(epc_select_choice_journey_field)

if choice == epc_select_choice_field_select_epc:
if choice == epc_select_choice_journey_field_select_epc:
return _post_address_input_next_page(answers)
if choice == epc_select_choice_field_epc_api_fail:
if choice == epc_select_choice_journey_field_epc_api_fail:
return address_select_page
if choice == epc_select_choice_field_enter_manually:
if choice == epc_select_choice_journey_field_enter_manually:
return epc_select_manual_page

return _unknown_response


@_requires_answer(address_select_choice_field)
@_requires_answer(address_select_choice_journey_field)
def _address_select_next_page(answers):
choice = answers.get(address_select_choice_field)
choice = answers.get(address_select_choice_journey_field)

if choice == address_select_choice_field_select_address:
if choice == address_select_choice_journey_field_select_address:
return _post_address_input_next_page(answers)
if choice == address_choice_field_enter_manually:
if choice == address_choice_journey_field_enter_manually:
return address_select_manual_page

return _unknown_response
Expand All @@ -377,7 +381,7 @@ def _address_select_manual_next_page(answers):

# after submitting an address, show already submitted page or continue
def _post_address_input_next_page(answers):
duplicate_uprn = answers.get(duplicate_uprn_field)
duplicate_uprn = answers.get(duplicate_uprn_journey_field)
if duplicate_uprn == field_yes:
return referral_already_submitted_page
if duplicate_uprn == field_no:
Expand Down Expand Up @@ -412,19 +416,19 @@ def _council_tax_band_next_page(answers):

# confirms epc if it was found, or send to no epc
def _post_council_tax_band_next_page(answers):
epc_found = answers.get(epc_found_field)
address_choice = answers.get(address_choice_field)
epc_select_choice = answers.get(epc_select_choice_field)
address_select_choice = answers.get(address_select_choice_field)
epc_found = answers.get(epc_found_journey_field)
address_choice = answers.get(address_choice_journey_field)
epc_select_choice = answers.get(epc_select_choice_journey_field)
address_select_choice = answers.get(address_select_choice_journey_field)
if epc_found == field_yes:
return epc_page
if epc_found == field_no:
# if they entered an address manually, don't show the no epc page as an epc wasn't searched for
# note that there are 3 address select pages so 3 places where the user can opt to enter manually
if (
address_choice == address_choice_field_enter_manually
or epc_select_choice == epc_select_choice_field_enter_manually
or address_select_choice == address_choice_field_enter_manually
address_choice == address_choice_journey_field_enter_manually
or epc_select_choice == epc_select_choice_journey_field_enter_manually
or address_select_choice == address_choice_journey_field_enter_manually
):
return _post_epc_next_page(answers)

Expand Down
1 change: 1 addition & 0 deletions help_to_heat/frontdoor/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,7 @@ class SessionSchema(Schema):
address_choice = fields.String()
epc_select_choice = fields.String()
address_select_choice = fields.String()
no_results = fields.String()
uprn_is_duplicate = fields.String()
epc_found = fields.String()
epc_rating_is_eligible = fields.String()
Expand Down
Loading

0 comments on commit fbb2380

Please sign in to comment.