Open shirenekboyd opened 2 years ago
Hint To search for a partial or complete phone number, you should ignore all formatting and search only for the digits. You will need to remove any non-numeric characters from the submitted mobile number and also use the PostgreSQL translate function.
The following function will perform the correct search.
function search(mobile_number) {
return knex("reservations")
.whereRaw(
"translate(mobile_number, '() -', '') like ?",
`%${mobile_number.replace(/\D/g, "")}%`
)
.orderBy("reservation_date");
}
As a restaurant manager I want to search for a reservation by phone number (partial or complete) so that I can quickly access a customer's reservation when they call about their reservation.
Acceptance Criteria
/search
page will<input name="mobile_number" />
that displays the placeholder text: "Enter a customer's phone number"/reservations?mobile_number=800-555-1212
). then the system will look for the reservation(s) in the database and display all matched records on the /search page using the same reservations list component as the/dashboard
page.No reservations found
if there are no records found after clicking the Find button.