Skip to content

Commit

Permalink
DDCE-6205 - MODs - (Admin Only): Amend Routing for Back Button (#546)
Browse files Browse the repository at this point in the history
* MODs - (Admin Only): Amend Routing for Back Button
  • Loading branch information
suraj-suseelan authored Dec 18, 2024
1 parent 691c8bf commit 852482f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
package uk.gov.hmrc.merchandiseinbaggage.controllers

import cats.implicits._
import play.api.mvc.{Action, AnyContent, MessagesControllerComponents}
import play.api.mvc.{Action, AnyContent, Call, MessagesControllerComponents}
import uk.gov.hmrc.http.HeaderCarrier
import uk.gov.hmrc.merchandiseinbaggage.config.AppConfig
import uk.gov.hmrc.merchandiseinbaggage.connectors.MibConnector
import uk.gov.hmrc.merchandiseinbaggage.controllers.routes.{ImportExportChoiceController, NewOrExistingController}
import uk.gov.hmrc.merchandiseinbaggage.forms.RetrieveDeclarationForm.form
import uk.gov.hmrc.merchandiseinbaggage.model.core.RetrieveDeclaration
import uk.gov.hmrc.merchandiseinbaggage.navigation._
Expand All @@ -42,9 +43,12 @@ class RetrieveDeclarationController @Inject() (
)(implicit appConfig: AppConfig, val ec: ExecutionContext)
extends DeclarationJourneyUpdateController {

private def backLink(isAssistedDigital: Boolean): Call =
if (isAssistedDigital) ImportExportChoiceController.onPageLoad else NewOrExistingController.onPageLoad

override val onPageLoad: Action[AnyContent] = actionProvider.journeyAction { implicit request =>
val preFilledForm = request.declarationJourney.maybeRetrieveDeclaration.fold(form)(form.fill)
Ok(view(preFilledForm, routes.NewOrExistingController.onPageLoad, request.declarationJourney.declarationType))
Ok(view(preFilledForm, backLink(request.isAssistedDigital), request.declarationJourney.declarationType))
}

override val onSubmit: Action[AnyContent] = actionProvider.journeyAction.async { implicit request =>
Expand All @@ -53,7 +57,7 @@ class RetrieveDeclarationController @Inject() (
.fold(
formWithErrors =>
BadRequest(
view(formWithErrors, routes.NewOrExistingController.onPageLoad, request.declarationJourney.declarationType)
view(formWithErrors, backLink(request.isAssistedDigital), request.declarationJourney.declarationType)
).asFuture,
retrieveDeclaration => processRequest(retrieveDeclaration)
)
Expand Down
4 changes: 2 additions & 2 deletions project/AppDependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ object AppDependencies {

private val compile: Seq[ModuleID] = Seq(
"uk.gov.hmrc" %% "bootstrap-frontend-play-30" % bootstrapVersion,
"uk.gov.hmrc" %% "play-frontend-hmrc-play-30" % "11.5.0",
"uk.gov.hmrc" %% "play-frontend-hmrc-play-30" % "11.7.0",
"uk.gov.hmrc.mongo" %% "hmrc-mongo-play-30" % "2.3.0",
"com.beachape" %% "enumeratum-play" % "1.8.2",
"org.webjars.npm" % "accessible-autocomplete" % "3.0.0",
"com.softwaremill.quicklens" %% "quicklens" % "1.9.9",
"com.softwaremill.quicklens" %% "quicklens" % "1.9.10",
"org.typelevel" %% "cats-core" % "2.12.0",
"io.github.samueleresca" %% "pekko-quartz-scheduler" % "1.2.2-pekko-1.0.x"
)
Expand Down

0 comments on commit 852482f

Please sign in to comment.