feat(admin): load pedidos asynchronously#190
Conversation
|
📝 Manual Update Required? It looks like you've modified core logic. Please check if the user manual needs a refresh! @marpisco |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: be69d0934c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Resolves the main merge conflict in the pedidos admin page while keeping the current admin shell layout and the async loading skeleton. Fixes the async pedidos review findings by moving rendered row actions off fragile inline handlers, preserving server-rendered action results, surfacing email warnings, refreshing stats, searching through the list API, keeping pagination deterministic, replacing stale filter loads, and preserving single-reservation email templates. Tested with git diff --check, git diff --cached --check, PHP lint on admin/pedidos.php and both pedidos API endpoints, and node --check on the extracted inline pedidos script. Co-authored-by: Codex <noreply@openai.com>
be69d09 to
05a122b
Compare
|
📝 Manual Update Required? It looks like you've modified core logic. Please check if the user manual needs a refresh! @marpisco |
|
@codex Search box is also reloaded, so if I'm typing, it'll remove my focus from the searchbox, Also, since it's being reloaded, if I type something that has no results, it'll make the searchbox disappear and force me to have to reload the entire page. |
Summary
Testing
|
|
📝 Manual Update Required? It looks like you've modified core logic. Please check if the user manual needs a refresh! @marpisco |
Moves the async pedidos empty-state container below the search and bulk controls so the controls stay first when a search has no results. This keeps the previous focus-preservation behavior while matching the expected layout. Tested with php -l admin/pedidos.php and git diff --check. Co-authored-by: Codex <noreply@openai.com>
|
📝 Manual Update Required? It looks like you've modified core logic. Please check if the user manual needs a refresh! @marpisco |
Moves the AJAX pedidos search field into a stable header, matching the simple form-control search used on the salas page. The async renderer now updates only the results area, so typing does not lose focus or trigger the blue focus flicker when new data arrives. Shows the existing loading spinner during focused search reloads instead of replacing the search input. The server-side fallback remains hidden from the async header when an action result is being shown. Tested with php -l admin/pedidos.php and git diff --check. Co-authored-by: Codex <noreply@openai.com>
|
📝 Manual Update Required? It looks like you've modified core logic. Please check if the user manual needs a refresh! @marpisco |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 10ae7e7faf
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| echo json_encode(['error' => 'Acesso negado.']); | ||
| exit; | ||
| } | ||
| if (!isset($_SESSION['validity']) || $_SESSION['validity'] < time()) { |
There was a problem hiding this comment.
Extend sessions for async pedidos requests
When admins keep this page open and interact only through the new async list/action endpoints, these requests bypass admin/index.php, where near-expiry sessions are extended by another 30 minutes. This guard only rejects once validity is in the past, so an actively filtering/scrolling admin can still be logged out as soon as the original timestamp expires; mirror the sliding-session refresh in the API auth path as well.
Useful? React with 👍 / 👎.
| const hasServerAction = new URLSearchParams(window.location.search).has('subaction'); | ||
| if (!hasServerAction) { | ||
| document.getElementById('pedidosAsyncHeader')?.classList.remove('d-none'); | ||
| loadPedidos(true); |
There was a problem hiding this comment.
Skip full server render before async fetch
On /admin/pedidos.php without subaction, this async fetch starts only after the PHP default branch above has already queried and emitted every pending reservation, including the per-row sala/cache/tempo lookups. Installations with many pending requests now pay the full old render plus an extra API request before the browser replaces it, so the new pagination does not protect the initial load; gate the server-side table to a fallback/no-JS path or leave the container empty for the async path.
Useful? React with 👍 / 👎.
Motivation
Description
admin/api/pedidos_list.phpwhich returns authenticated, paginated, filtered reservation records (sala/requisitor) with prepared statements and the same session/auth guards used by other admin APIs.admin/api/pedidos_action.phpwhich accepts CSRF-protected POSTs toaprovar/rejeitarsingle or bulk reservations, performs DB updates/deletes, logs actions vialogaction, and invokes the existing email helpers for notifications.admin/pedidos.phpto stop applying thefade-inclass on initial load, add skeleton styling, wrap the server-rendered pedidos area in#pedidosResultsand#pedidosAlerts, and inject client-side JS that intercepts filter submissions, shows skeleton rows while loading, fetches page 1 via AJAX frompedidos_list.php, appends more results on scroll via apageparameter, and submits approve/reject (single and bulk) viapedidos_action.phpwhile falling back to the original form/URL when network/JS handling fails.global-csrf-tokenhidden value and including it in programmatic requests, and reuse the existingsendReservationApprovedEmail,sendReservationRejectedEmail,sendBulkReservationApprovedEmail, andsendBulkReservationRejectedEmailhelpers for notifications.Testing
php -l admin/pedidos.php,php -l admin/api/pedidos_list.php, andphp -l admin/api/pedidos_action.php, all reporting no syntax errors.git diff --checkto verify whitespace/format issues and fixed trailing whitespace reported by the check.admin/api/dashboard_stats.phpandadmin/api/users_search.php.Codex Task