Skip to content

Commit

Permalink
WIP: EY Practitioner invalid reference screen
Browse files Browse the repository at this point in the history
  • Loading branch information
vacabor committed Oct 4, 2024
1 parent 9254610 commit 64d4316
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ class FindReferenceForm < Form
attribute :email, :string

validates :reference_number, presence: {message: i18n_error_message(:presence)}
validate :validate_permissible_reference_number

def save
return false if invalid?

journey_session.answers.assign_attributes(
reference_number:,
start_email: email
start_email: email,
reference_number_found: claim_exists?
)
journey_session.save!
end
Expand All @@ -27,16 +27,6 @@ def claim_exists?
.where(practitioner_email_address: email)
.exists?
end

def validate_permissible_reference_number
unless claim_exists?
errors.add(
:reference_number,
:impermissible,
message: self.class.i18n_error_message(:impermissible)
)
end
end
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module EarlyYearsPayment
module Practitioner
class SessionAnswers < Journeys::SessionAnswers
attribute :reference_number, :string
attribute :reference_number_found, :boolean, default: nil
attribute :start_email, :string

def policy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Journeys
module EarlyYearsPayment
module Practitioner
class SlugSequence
SLUGS = %w[
CLAIM_SLUGS = %w[
find-reference
sign-in
how-we-use-your-information
Expand All @@ -14,6 +14,12 @@ class SlugSequence
check-your-answers
].freeze

RESULTS_SLUGS = %w[
ineligible
].freeze

SLUGS = (CLAIM_SLUGS + RESULTS_SLUGS).freeze

def self.start_page_url
Rails.application.routes.url_helpers.landing_page_path("early-years-payment-practitioner")
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def ineligible?
end

def ineligibility_reason
start_ineligibility_reason || authenticated_ineligibility_reason
start_ineligibility_reason || provider_ineligibility_reason || practitioner_ineligibility_reason
end

def start_ineligibility_reason
Expand All @@ -31,7 +31,7 @@ def start_ineligibility_reason
end
end

def authenticated_ineligibility_reason
def provider_ineligibility_reason
return nil unless answers.is_a?(Journeys::EarlyYearsPayment::Provider::Authenticated::SessionAnswers)

if answers.nursery_urn.to_s == "none_of_the_above"
Expand All @@ -43,6 +43,14 @@ def authenticated_ineligibility_reason
end
end

def practitioner_ineligibility_reason
return nil unless answers.is_a?(Journeys::EarlyYearsPayment::Practitioner::SessionAnswers)

if answers.reference_number_found == false
:reference_number_not_found
end
end

private

def ineligible_returner?
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<% content_for(:page_title, page_title("There is a problem", journey: current_journey_routing_name)) %>
<% @backlink_path = claim_path(current_journey_routing_name, "find-reference", request.query_parameters) %>

<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<h1 class="govuk-heading-l">
There is a problem
</h1>
<p class="govuk-body">
This claim reference isn’t correct. Check your invite email.
</p>

<p class="govuk-body">
Your employer will also have the claim reference in their claim confirmation email.
</p>

<p class="govuk-body">
Contact us at
<%= govuk_link_to t("early_years_payment_practitioner.feedback_email"), "mailto:#{t("early_years_payment_practitioner.feedback_email")}", no_visited_state: true %>.
if you need further assistance to sign into the early years financial incentive payments service.
</p>

<%= govuk_button_link_to "Try again", claim_path(current_journey_routing_name, "find-reference", request.query_parameters) %>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<% ineligibility_reason = Journeys::EarlyYearsPayment::Practitioner::EligibilityChecker.new(journey_session:).ineligibility_reason %>
<%= render "ineligibility_#{ineligibility_reason}" %>
4 changes: 2 additions & 2 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1392,8 +1392,8 @@ en:
claim_subject: "Early Years Payment"
early_years_payment_practitioner:
journey_name: Claim an early years financial incentive payment - practitioner
feedback_email: implementme@example.com
support_email: "help@opsteam.com"
feedback_email: "help@opsteam.education.gov.uk"
support_email: "help@opsteam.education.gov.uk"
claim_description: for early years financial incentive payment
forms:
find_reference:
Expand Down

0 comments on commit 64d4316

Please sign in to comment.