Skip to content

Commit

Permalink
Merge pull request #920 from hmrc/BDOG-3170-derives
Browse files Browse the repository at this point in the history
BDOG-3170 Fix servicename on url search results
  • Loading branch information
colin-lamed authored Jul 4, 2024
2 parents 5922480 + 3053b71 commit 1e36389
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
8 changes: 3 additions & 5 deletions app/uk/gov/hmrc/cataloguefrontend/SearchByUrlController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,21 @@ class SearchByUrlController @Inject() (
) extends FrontendController(mcc)
with CatalogueAuthBuilders:

private val serviceNameToUrl = routes.CatalogueController.service

def searchLanding: Action[AnyContent] =
BasicAuthAction.async { implicit request =>
Future.successful(Ok(searchByUrlPage(UrlSearchFilter.form, Nil, serviceNameToUrl)))
Future.successful(Ok(searchByUrlPage(UrlSearchFilter.form, Nil)))
}

def searchUrl =
BasicAuthAction.async { implicit request =>
UrlSearchFilter.form
.bindFromRequest()
.fold(
formWithErrors => Future.successful(Ok(searchByUrlPage(formWithErrors, Nil, serviceNameToUrl))),
formWithErrors => Future.successful(Ok(searchByUrlPage(formWithErrors, Nil))),
query => searchByUrlService
.search(query.name)
.map: results =>
Ok(searchByUrlPage(UrlSearchFilter.form.bindFromRequest(), results, serviceNameToUrl))
Ok(searchByUrlPage(UrlSearchFilter.form.bindFromRequest(), results))
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
*@

@import play.api.mvc.Call
@import uk.gov.hmrc.cataloguefrontend.{routes => appRoutes}
@import uk.gov.hmrc.cataloguefrontend.service.SearchByUrlService.FrontendRoutes

@this()

@(form : Form[?],
searchResults : Seq[FrontendRoutes],
serviceNameToUrl: ServiceName => Call
searchResults : Seq[FrontendRoutes]
)(implicit
request : RequestHeader
)
Expand Down Expand Up @@ -64,7 +64,7 @@ <h1 id="search-service-header" class="page-heading mt-4">Search for a service by

<div class="card">
<div class="card-body">
<form action="@uk.gov.hmrc.cataloguefrontend.routes.SearchByUrlController.searchUrl" method="post">
<form action="@appRoutes.SearchByUrlController.searchUrl" method="post">
@csrfFormField
<div class="row mb-3">
<label for="search-box" class="col-md-3 col-form-label fw-bold">https://www.tax.service.gov.uk/</label>
Expand All @@ -86,7 +86,7 @@ <h1 id="search-service-header" class="page-heading mt-4">Search for a service by
@for(route <- result.routes) {
<tr>
<td>
<a id="link-to-@{result.service}" href="@serviceNameToUrl(result.service)">@result.service</a>
<a id="link-to-@{result.service.asString}" href="@appRoutes.CatalogueController.service(result.service)">@result.service.asString</a>
</td>
<td>
@if(route.isRegex) {
Expand Down

0 comments on commit 1e36389

Please sign in to comment.