Skip to content

feat: implement pagination for job listings and enhance UI components#58

Merged
Benevanio merged 3 commits into
masterfrom
feature/add-pagination
Apr 5, 2026
Merged

feat: implement pagination for job listings and enhance UI components#58
Benevanio merged 3 commits into
masterfrom
feature/add-pagination

Conversation

@Benevanio

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings April 5, 2026 13:25
@Benevanio Benevanio linked an issue Apr 5, 2026 that may be closed by this pull request
5 tasks
@vercel

vercel Bot commented Apr 5, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
painel-vagas Ready Ready Preview, Comment Apr 5, 2026 1:37pm

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Implements a revised pagination experience for job listings in the frontend (page size + numeric navigation) and adjusts backend Swagger docs initialization to be more fault-tolerant at startup.

Changes:

  • Add page-size clamping and a dedicated setPageSize API in useJobsPagination.
  • Update JobsTableCard UI with results summary, numeric pagination buttons, and page-size number input; update related unit tests.
  • Add Swagger dependencies and switch backend server Swagger setup to async/dynamic registration.

Reviewed changes

Copilot reviewed 6 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
package.json Adds Swagger dependencies; minor build config formatting change.
package-lock.json Locks Swagger dependency additions.
frontend/src/hooks/useJobsPagination.ts Adds page-size clamping and updates default page size.
frontend/src/components/JobsTableCard.tsx Reworks pagination controls and adds results summary UI.
frontend/tests/unit/utils/useJobsPagination.test.ts Updates hook tests for act() and page-size clamping behavior.
frontend/tests/unit/components/JobsTableCard.test.tsx Updates component tests for the new pagination UI and summary text.
backend/src/server.js Makes Swagger docs registration async/dynamic and moves startup into an async bootstrap.
Vagas Full Setup 1.0.0.exe Windows installer artifact included in the PR.
Comments suppressed due to low confidence (1)

frontend/src/components/JobsTableCard.tsx:55

  • getJobId falls back to using the passed index when job.link is missing. In this component, the index comes from paginatedJobs.map, so it resets on each page; that makes the computed ID unstable across pagination and can collide between pages, leading to incorrect React row reuse and incorrect spam/lido mark state when navigating pages. Prefer a stable ID derived from job fields only, or ensure the index used is global (e.g., slice-start + index) rather than page-local.
function getJobId(job: Job, index: number) {
  return job.link?.trim() || [job.titulo, job.empresa, job.local, String(index)].filter(Boolean).join("|");
}

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread backend/src/server.js
Comment on lines +51 to +55
app.listen(PORT, () => {
// eslint-disable-next-line no-console
console.log(`API de vagas rodando em http://localhost:${PORT}`);
console.log(`Documentação da API em http://localhost:${PORT}/docs`);
});

Copilot AI Apr 5, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The startup log prints the docs URL unconditionally, even when registerSwaggerDocs() fails and Swagger is disabled (catch path). This makes logs misleading. Consider returning a boolean from registerSwaggerDocs() (or setting a flag) and only logging the docs URL when the route is actually registered.

Copilot uses AI. Check for mistakes.
Comment on lines 31 to 36
currentPage: 1,
totalPages: 2,
pageSize: 25,
totalPages: 5,
pageSize: 4,
onPageChange: vi.fn(),
onPageSizeChange: vi.fn(),
};

Copilot AI Apr 5, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

baseProps.onPageChange / onPageSizeChange are shared vi.fn() mocks across all tests in this file, but they aren’t reset between tests. This can produce false positives because calls from earlier tests satisfy later toHaveBeenCalledWith assertions. Create fresh props per test or reset mocks in a beforeEach (e.g., vi.clearAllMocks() or reassign new vi.fn()).

Copilot uses AI. Check for mistakes.
Copilot AI review requested due to automatic review settings April 5, 2026 13:36
@Benevanio Benevanio moved this from Backlog to In Progress in JobAtlas – Kanban Apr 5, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 10 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +233 to +238
<button
type="button"
aria-label="Pagina anterior"
onClick={() => onPageChange(Math.max(1, currentPage - 1))}
disabled={currentPage === 1}
className="flex h-9 min-w-9 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-40"

Copilot AI Apr 5, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Os botões de navegação usam aria-label="Pagina anterior" (sem acento). Para manter consistência com o restante do UI em pt-BR e evitar erro de ortografia em leitores de tela, ajuste para "Página anterior" (e alinhe os testes que buscam esse label).

Copilot uses AI. Check for mistakes.

<button
type="button"
aria-label="Pagina seguinte"

Copilot AI Apr 5, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mesmo ponto do botão anterior: aria-label="Pagina seguinte" está sem acento. Troque para "Página seguinte" e atualize os testes correspondentes.

Suggested change
aria-label="Pagina seguinte"
aria-label="Página seguinte"

Copilot uses AI. Check for mistakes.
Comment on lines +51 to +55
it("aciona paginacao numerica", () => {
render(<JobsTableCard {...baseProps} />);
fireEvent.click(screen.getByRole("button", { name: "Proxima" }));
expect(baseProps.onPageChange).toHaveBeenCalled();
fireEvent.click(screen.getByRole("button", { name: "2" }));
expect(baseProps.onPageChange).toHaveBeenCalledWith(2);
});

Copilot AI Apr 5, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

O componente JobsTableCard removeu a prop jobs, mas o teste ainda passa/propaga jobs (via baseProps e também explicitamente em outro teste). Isso pode falhar na checagem de tipos/TSX. Remova jobs do baseProps e das chamadas a <JobsTableCard ...> para manter o contrato de props atualizado.

Copilot uses AI. Check for mistakes.
@Benevanio
Benevanio merged commit 0eddcf1 into master Apr 5, 2026
10 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in JobAtlas – Kanban Apr 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implementar paginação na listagem de vagas

2 participants