Skip to content

T164 ExcelImport admin UI - #36

Merged
ThienlocTran merged 4 commits into
devfrom
feature/T164-excel-import-ui
Jul 8, 2026
Merged

ThienlocTran merged 4 commits into
devfrom
feature/T164-excel-import-ui

Conversation

@ThienlocTran

@ThienlocTran ThienlocTran commented Jul 7, 2026 •

Copy link
Copy Markdown
Owner

Scope

Implement the frontend UI and API client wrapper for user story T164 ExcelImport.

Included

  • Added excelImportService.js in src/services containing the HTTP API client wrapper.
  • Integrated the route guard in src/router/index.js to restrict /import-excel access to the ADMIN role only.
  • Restricted the 'Import Excel' navigation item visibility to ADMIN only in src/components/AppSidebar.vue.
  • Replaced the placeholder ImportExcelView.vue with a complete step-by-step sequential workflow layout (Steps 1 to 6).
  • Implemented file integrity check: changes to the file, import type, or warehouse selection reset the workflow state, prompting the user with a warning.
  • Handled loading states, button disabling, duplicate request prevention, error rendering, and confirmation modal.
  • Rendered validation error reports in a tabular structure with pagination.

Not included

  • Any modifications to the backend codebase.
  • Any new dependencies or changes to configuration files/environment variables.

Route/menu added

  • Path: /import-excel (restricted to role ADMIN only).
  • Sidebar item: "Import Excel" (only visible to role ADMIN).

API endpoints used

  • GET /api/excel-imports/template
  • POST /api/excel-imports
  • POST /api/excel-imports/{id}/validate-errors
  • GET /api/excel-imports/{id}/errors
  • POST /api/excel-imports/{id}/confirm
  • POST /api/excel-imports/{id}/apply

File integrity behavior

  • The frontend keeps the selected File object in memory.
  • If the file, type, or warehouse is changed at any point in the workflow, the session resets and requires re-initialization and validation.

Validation/error display behavior

  • Step 4 displays the validation result summary (Total, Valid, and Error rows).
  • If errors exist, it displays a pagination table with detailed descriptions (row, column, value, message, suggestion).

Role/access behavior

  • The route and sidebar are fully restricted to users with the ADMIN role. Managers and warehouse employees are redirected to the dashboard.

Build/lint/typecheck results

  • Checked with npm run build which successfully completed compilation with zero errors.
  • Checked with git diff --check showing clean diff with zero whitespace issues.

Confirmation

  • I confirm that no backend codebase, env files, config files, or secrets were changed or committed.

Summary by CodeRabbit

  • New Features

    • Thêm luồng nhập Excel đầy đủ với 6 bước: tải mẫu, chọn tệp, tạo & kiểm tra phiên, xem lỗi (có phân trang), xác nhận và áp dụng nhập.
    • Cải thiện trải nghiệm thao tác bằng stepper hiển thị trạng thái tiến trình và hộp thoại xác nhận trước khi thực hiện.
  • Bug Fixes

    • Áp dụng kiểm soát quyền cho mục “Import Excel” và tuyến đường liên quan, chỉ hiển thị/cho phép với vai trò phù hợp.
    • Chuẩn hóa xử lý lỗi cho quy trình nhập Excel, bao gồm xử lý đăng nhập hết hạn.

@coderabbitai

coderabbitai Bot commented Jul 7, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@ThienlocTran, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 50 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 772c65ce-ee7e-4f30-ab40-ae852d0e5d8b

📥 Commits

Reviewing files that changed from the base of the PR and between c18f532 and 94bf699.

📒 Files selected for processing (4)
  • src/components/AppSidebar.vue
  • src/services/excelImportService.js
  • src/services/permissionService.js
  • src/views/ImportExcelView.vue
📝 Walkthrough

Walkthrough

PR thêm phân quyền admin cho menu và route Import Excel, tạo service excelImportService.js cho các API import Excel, và viết lại ImportExcelView.vue thành luồng import 6 bước end-to-end.

Changes

Import Excel end-to-end

Layer / File(s) Summary
Phân quyền menu và route
src/components/AppSidebar.vue, src/router/index.js
Item sidebar "Import Excel" thêm token role admin để lọc theo canManageEmployees; route /import-excel được thêm vào điều kiện chỉ cho role === 'ADMIN' truy cập.
Service gọi API Import Excel
src/services/excelImportService.js
File mới tạo axios instance và các hàm export gọi endpoint template, tạo phiên, validate, lấy lỗi, confirm, apply; lỗi 401 được normalize qua clearAuth().
Logic state và xử lý stepper
src/views/ImportExcelView.vue
Script setup quản lý state/computed/watcher cho 6 bước, tải kho, kiểm tra file .xlsx, và các hàm gọi service cho từng bước cùng reset luồng.
Template và style stepper UI
src/views/ImportExcelView.vue
Template thay thế UI cũ bằng stepper 6 bước với bảng lỗi phân trang, ConfirmDialog, và CSS scoped cho trạng thái các bước.

Estimated code review effort: 4 (Complex) | ~60 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed Tiêu đề liên quan trực tiếp đến thay đổi chính: UI ExcelImport cho admin.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/T164-excel-import-ui

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/components/AppSidebar.vue`:
- Line 19: The Import Excel sidebar item is incorrectly relying on the
employee-management permission helper, so its access control is coupled to the
wrong meaning. Create a dedicated import permission check such as canImportExcel
in permissionService.js, and update AppSidebar.vue to use that new helper for
the Import Excel item instead of canManageEmployees(role). Keep the existing
behavior the same for now, but separate the permission semantics so future role
changes do not leak access unintentionally.

In `@src/services/excelImportService.js`:
- Around line 39-44: The multipart upload request in excelImportService is
setting Content-Type manually, which can break FormData boundaries. Update
createImportSession, validateImportSession, and applyImportSession to stop
overriding the multipart/form-data header in the axios post call, and let
axios/browser generate the Content-Type automatically while keeping the
authorization header intact.

In `@src/views/ImportExcelView.vue`:
- Around line 116-132: The onFileChange handler rejects non-.xlsx files but
leaves the file input value intact, so reselecting the same file path will not
trigger change again. Update onFileChange to clear event.target.value whenever a
file is rejected (and ensure the input is reset before returning), while keeping
the existing selectedFile, fileError, globalError, and globalSuccess behavior
intact.
- Around line 261-273: The fetchErrors handler in ImportExcelView.vue is
swallowing errors and does not treat 401 consistently with the other handlers.
Update fetchErrors to detect unauthorized responses from getSessionErrors and
call router.replace('/login') just like the other flows, while also surfacing a
user-visible error state/message instead of only logging to console. Keep the
loading flag reset in finally and ensure the error handling path is consistent
with the existing session/error pagination logic.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 38baf3a1-d0d8-4526-9871-89ddab8f1ea3

📥 Commits

Reviewing files that changed from the base of the PR and between c99a015 and 2a76792.

📒 Files selected for processing (4)
  • src/components/AppSidebar.vue
  • src/router/index.js
  • src/services/excelImportService.js
  • src/views/ImportExcelView.vue

Comment thread src/components/AppSidebar.vue Outdated
Comment thread src/services/excelImportService.js
Comment thread src/views/ImportExcelView.vue
Comment thread src/views/ImportExcelView.vue

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/views/ImportExcelView.vue (1)

84-94: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Hiển thị lỗi khi không tải được danh sách kho src/views/ImportExcelView.vue:84-94

getWarehouses() đã trả về mảng trực tiếp, nên phần shape dữ liệu này ổn. Vấn đề còn lại là khi gọi API lỗi thì chỉ console.error, dropdown kho trống mà người dùng không biết để thử lại hoặc xử lý tiếp. Thêm một state lỗi/thông báo ngay dưới ô chọn kho.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/views/ImportExcelView.vue` around lines 84 - 94, The fetchWarehouseList
flow in ImportExcelView currently only logs API failures, leaving the warehouse
dropdown empty without any user-facing feedback. Add an error state/message
alongside isLoadingWarehouses and warehouses, set it in the catch block of
fetchWarehouseList, clear it on success, and render the message directly under
the warehouse selector so users know the load failed and can retry.

Source: Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@src/views/ImportExcelView.vue`:
- Around line 84-94: The fetchWarehouseList flow in ImportExcelView currently
only logs API failures, leaving the warehouse dropdown empty without any
user-facing feedback. Add an error state/message alongside isLoadingWarehouses
and warehouses, set it in the catch block of fetchWarehouseList, clear it on
success, and render the message directly under the warehouse selector so users
know the load failed and can retry.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: b699aa8d-dbb3-4dc1-853f-9a38fa6ac562

📥 Commits

Reviewing files that changed from the base of the PR and between 2a76792 and c18f532.

📒 Files selected for processing (2)
  • src/services/excelImportService.js
  • src/views/ImportExcelView.vue

@ThienlocTran ThienlocTran left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

đã sửa các lỗi rabbit ai bắt

@ThienlocTran
ThienlocTran merged commit fadc594 into dev Jul 8, 2026
1 check passed
@ThienlocTran
ThienlocTran deleted the feature/T164-excel-import-ui branch July 31, 2026 11:37
This was referenced Aug 10, 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.

1 participant