| 12 | |
| 13 | === |
| 14 | The `/search-routes` endpoint provides users with the ability to search for available transport routes from different organizers. |
| 15 | It supports both **viewing all routes** by default and **filtering routes** based on user input (departure and arrival locations). |
| 16 | The request is handled by `UserRouteController`, which interacts with `RouteService` to retrieve the relevant data. |
| 17 | |
| 18 | ==== Controller Details: |
| 19 | - **URL Mapping:** `/search-routes` |
| 20 | - **Method:** `GET` |
| 21 | - **Functionality:** |
| 22 | - Displays **all routes** when the page is accessed without search criteria. |
| 23 | - Filters results based on the user's input (`from` and `to`). |
| 24 | - **View:** Uses the `master` template and dynamically embeds `user/search-routes`. |
| 25 | |
| 26 | ==== Breakdown: |
| 27 | - When users first visit `/search-routes`, the controller calls `routeService.findAll()` to display all available routes. |
| 28 | - When users provide search criteria (`from` and/or `to`), it filters results using `routeService.findRouteByFromAndToDest(from, to)`. |
| 29 | - If no matching routes are found, a **"No routes found for your search."** message is displayed instead of an empty table. |
| 30 | - The retrieved data is added to the `Model`, ensuring the front-end can render the appropriate content. |
| 31 | |
| 32 | |