Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User Story 7 #7

Open
SVinnik99 opened this issue Jan 5, 2024 · 1 comment
Open

User Story 7 #7

SVinnik99 opened this issue Jan 5, 2024 · 1 comment

Comments

@SVinnik99
Copy link
Owner

No description provided.

@SVinnik99 SVinnik99 converted this from a draft issue Jan 5, 2024
@SVinnik99
Copy link
Owner Author

US-07 Search for a reservation by phone number

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

  1. The /search page will
    • Display a search box <input name="mobile_number" /> that displays the placeholder text: "Enter a customer's phone number"
    • Display a "Find" button next to the search box.
    • Clicking on the "Find" button will submit a request to the server (e.g. GET /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.
      • the search page will display all reservations matching the phone number, regardless of status.
    • display No reservations found if there are no records found after clicking the Find button.

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");
}

@SVinnik99 SVinnik99 moved this from Todo to Done in @SVinnik99's Thinkful Capstone Feb 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

No branches or pull requests

1 participant