Skip to content

Commit

Permalink
#EHA-33 "No result" case is added to desktop and controller GET funct…
Browse files Browse the repository at this point in the history
…ion for filtering veterinarian name.
  • Loading branch information
beyzaaydeniz committed Jan 3, 2024
1 parent b38d096 commit e9277c3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,19 @@ public String desktopFormSubmit(@RequestParam String clinicName, RedirectAttribu
@GetMapping("/desktop/{name}")
public String desktop(@PathVariable String name, Model model) {
List<VeterinarianDTO> filteredVeterinarians = veterinarianService.getVeterinariansByClinic(name);
if(filteredVeterinarians==null){
return null;

if (filteredVeterinarians == null || filteredVeterinarians.isEmpty()) {
// Handle the case where no veterinarians are found
model.addAttribute("viewType", "noResults");
return "desktop";
}

model.addAttribute("filteredVeterinarians", filteredVeterinarians);
model.addAttribute("viewType", "filtered");
return "desktop";
}


// Other controller methods for updating, deleting veterinarians, etc.
}

5 changes: 4 additions & 1 deletion src/main/resources/templates/desktop.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
<form th:action="@{/api/veterinarians/desktop}" method="post">
<label for="clinicName">Name:</label>
<input type="text" id="clinicName" name="clinicName" required>
<button type="submit" style="background-color: #2A3240; border: none; color: white;">Filter</button>
<button type="submit" style="background-color: #2A3240; border: none; color: white;">Filter Veterinarian</button>
</form>
<div class="Content" style="width: 80%; height: 849px; padding-top: 24px; padding-bottom: 85px; padding-left: 24px; padding-right: 24px; flex-direction: column; justify-content: flex-start; align-items: center; gap: 24px; display: flex">

Expand All @@ -86,6 +86,9 @@
</tr>
</tbody>
</table>
<div th:if="${viewType eq 'noResults'}">
<p>No veterinarians found for the provided name.</p>
</div>
<table th:if="${viewType == 'filtered'}" class="table table-hover table-sm" style="width: 100%; text-align: center;">
<thead>
<tr class="table-active">
Expand Down

0 comments on commit e9277c3

Please sign in to comment.