---
phase: 81-global-search-bar
plan: 01
subsystem: ui
tags: [javascript, ajax, search, orders, topbar]

requires:
  - phase: 44-inline-status-change
    provides: orders list infrastructure
provides:
  - global search bar in topbar
  - GET /api/orders/search endpoint
  - keyboard-navigable search dropdown
affects: []

tech-stack:
  added: []
  patterns: [debounced AJAX search with dropdown results]

key-files:
  created: [public/assets/js/modules/global-search.js, resources/scss/modules/_global-search.scss]
  modified: [src/Modules/Orders/OrdersRepository.php, src/Modules/Orders/OrdersController.php, routes/web.php, resources/views/layouts/app.php, resources/scss/app.scss, public/assets/css/app.css]

key-decisions: []

patterns-established:
  - "Global search: debounced AJAX fetch to /api/orders/search with dropdown rendering"

duration: 5min
started: 2026-04-07T00:00:00Z
completed: 2026-04-07T00:00:00Z
---

# Phase 81 Plan 01: Global Search Bar Summary

**Globalna wyszukiwarka zamowien w topbarze — AJAX search z debounce, dropdown wynikow, nawigacja klawiaturowa, przeszukiwanie po numerze/nazwisku/email/telefonie/produkcie.**

## Performance

| Metric | Value |
|--------|-------|
| Duration | 5min |
| Tasks | 2 completed |
| Files modified | 8 |

## Acceptance Criteria Results

| Criterion | Status | Notes |
|-----------|--------|-------|
| AC-1: Pole wyszukiwania w topbarze | Pass | Input miedzy hamburgerem a user info |
| AC-2: Wyszukiwanie AJAX z debounce | Pass | 300ms debounce, min 2 znaki |
| AC-3: Wyniki wyszukiwania | Pass | Numer, nazwisko, email, telefon; max 10; "Brak wynikow" |
| AC-4: Nawigacja do zamowienia | Pass | Klik na wynik → /orders/{id} |
| AC-5: Nawigacja klawiaturowa | Pass | ArrowUp/Down, Enter, Escape |
| AC-6: Zamykanie dropdowna | Pass | Klik poza zamyka |

## Accomplishments

- Nowy endpoint `GET /api/orders/search?q=...&limit=10` z prepared statements
- Metoda `quickSearch()` w OrdersRepository szuka po 6 polach (source_order_id, external_order_id, name, email, phone, product name)
- Modul JS global-search.js z debounce, dropdown, nawigacja klawiaturowa
- Responsywne style SCSS

## Files Created/Modified

| File | Change | Purpose |
|------|--------|---------|
| `src/Modules/Orders/OrdersRepository.php` | Modified | Nowa metoda `quickSearch()` |
| `src/Modules/Orders/OrdersController.php` | Modified | Nowa metoda `quickSearch()` |
| `routes/web.php` | Modified | Route GET /api/orders/search |
| `resources/views/layouts/app.php` | Modified | Pole wyszukiwania w topbarze + script include |
| `public/assets/js/modules/global-search.js` | Created | Modul JS (debounce, dropdown, klawiatura) |
| `resources/scss/modules/_global-search.scss` | Created | Style komponentu wyszukiwarki |
| `resources/scss/app.scss` | Modified | Import nowego modulu SCSS |
| `public/assets/css/app.css` | Modified | Zbudowany CSS |

## Deviations from Plan

None — plan executed exactly as written.

## Issues Encountered

None.

## Next Phase Readiness

**Ready:**
- Wyszukiwarka globalna dziala na kazdej stronie

**Concerns:**
- None

**Blockers:**
- None

---
*Phase: 81-global-search-bar, Plan: 01*
*Completed: 2026-04-07*
