Skip to content

Feature/t152 integrate reject modal - #43

Merged
ThienlocTran merged 12 commits into
devfrom
feature/T152-Integrate-Reject-Modal
Jul 16, 2026
Merged

ThienlocTran merged 12 commits into
devfrom
feature/T152-Integrate-Reject-Modal

Conversation

@25ThienNgoc

@25ThienNgoc 25ThienNgoc commented Jul 11, 2026 •

Copy link
Copy Markdown
Collaborator

check và merge code giúp tui

Summary by CodeRabbit

  • Tính năng mới
    • Thêm màn hình “Phiếu xuất chờ duyệt” có phân trang và xem nhanh chi tiết.
    • Thêm trang chi tiết duyệt/xem/từ chối phiếu xuất, hiển thị cảnh báo vượt tồn và nhập lý do từ chối.
  • Cải tiến
    • Nâng cấp phân quyền điều hướng cho các tuyến liên quan phê duyệt phiếu xuất.
    • Cải thiện sidebar (cập nhật menu, tối ưu hiển thị khi thu nhỏ).
    • Mở rộng DataTable với tùy chọn “dòng có thể bấm” và phát sự kiện khi chọn hàng.

@coderabbitai

coderabbitai Bot commented Jul 11, 2026 •

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

PR thêm luồng phiếu xuất chờ duyệt gồm API chuẩn hóa dữ liệu, danh sách phân trang, xem chi tiết, duyệt/từ chối, hỗ trợ hàng có thể nhấp và cập nhật quyền cùng điều hướng.

Changes

Luồng duyệt phiếu xuất

Layer / File(s) Summary
API và chuẩn hóa dữ liệu
src/services/stockOutApprovalService.js
Thêm API lấy danh sách, chi tiết, duyệt, từ chối; chuẩn hóa phiếu, phân trang và lỗi.
Màn hình chi tiết và thao tác
src/components/StockOutApprovalDetail.vue
Hiển thị chi tiết phiếu, cảnh báo vượt tồn và luồng duyệt/từ chối theo quyền.
Danh sách chờ duyệt và DataTable
src/views/PendingExportApprovalsView.vue, src/components/DataTable.vue
Thêm danh sách phân trang, chi tiết nhanh và sự kiện row-click để mở chi tiết phiếu.
Điều hướng và phân quyền
src/services/permissionService.js, src/router/index.js, src/components/AppSidebar.vue, src/views/StockDocumentDetailView.vue
Thêm quyền dùng chung, route/sidebar, cập nhật route guard và thay placeholder bằng màn hình chi tiết.

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

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed Tiêu đề đúng với một phần thay đổi chính là tích hợp modal từ chối, dù chưa phản ánh toàn bộ phạm vi của PR.
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/T152-Integrate-Reject-Modal

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.

@25ThienNgoc

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 11, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@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: 5

🤖 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`:
- Around line 8-38: Update the Import Excel entry in the items array of
AppSidebar.vue to include the "admin" role tag so visibleItems hides it from
non-ADMIN roles. Leave the existing ADMIN access rule for /import-excel in
src/router/index.js lines 67-73 unchanged; no direct change is required there.

In `@src/components/StockOutApprovalDetail.vue`:
- Around line 186-190: Update the props.receiptId watcher to reset rejectState
whenever the receipt changes, alongside actionMessage and actionError, before
calling loadDetail. Ensure any open reject modal and its previous reason are
cleared so confirmReject cannot submit stale data for the new receipt.
- Around line 139-154: Update the rejection flow around rejectExportReceipt to
use its response directly, matching handleApprove, and remove the subsequent
loadDetail call. Ensure a successful rejection closes and resets rejectState and
shows the success message even when refreshing detail data would fail; retain
the existing error handling for an actual rejectExportReceipt failure.

In `@src/views/PendingExportApprovalsView.vue`:
- Around line 134-139: Thêm thuộc tính :clickable="true" vào component DataTable
trong PendingExportApprovalsView, giữ nguyên cấu hình `@row-click`="goToDetail" để
sự kiện nhấp vào hàng được phát ra và điều hướng đến trang chi tiết hoạt động.
- Around line 73-85: Update openDetail to guard against concurrent requests
using detailLoading, preventing a second receipt selection while a detail
request is already in progress. Keep the existing loading, error,
selectedReceipt, and finally-state behavior unchanged for the accepted request.
🪄 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: 31683ba3-0dc0-42cb-b63b-ff14365f8fdd

📥 Commits

Reviewing files that changed from the base of the PR and between fadc594 and 959c634.

📒 Files selected for processing (7)
  • src/components/AppSidebar.vue
  • src/components/DataTable.vue
  • src/components/StockOutApprovalDetail.vue
  • src/router/index.js
  • src/services/stockOutApprovalService.js
  • src/views/PendingExportApprovalsView.vue
  • src/views/StockDocumentDetailView.vue

Comment thread src/components/AppSidebar.vue
Comment thread src/components/StockOutApprovalDetail.vue
Comment thread src/components/StockOutApprovalDetail.vue Outdated
Comment thread src/views/PendingExportApprovalsView.vue
Comment thread src/views/PendingExportApprovalsView.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/components/AppSidebar.vue (1)

11-11: 🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win

Thêm check /partners trong src/router/index.js. Sidebar đã ẩn mục này với EMPLOYEE, nhưng canAccessRoute() vẫn cho phép /partners, nên mở thẳng URL vẫn vào được màn Nhà cung cấp.

🤖 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/components/AppSidebar.vue` at line 11, Update canAccessRoute in the
router configuration to explicitly restrict the /partners route for EMPLOYEE
users, matching the existing visibility rule in AppSidebar. Preserve access for
roles that are allowed to manage suppliers while preventing direct navigation to
/partners by EMPLOYEE.

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/components/AppSidebar.vue`:
- Line 11: Update canAccessRoute in the router configuration to explicitly
restrict the /partners route for EMPLOYEE users, matching the existing
visibility rule in AppSidebar. Preserve access for roles that are allowed to
manage suppliers while preventing direct navigation to /partners by EMPLOYEE.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 247a716b-8270-47d2-9c5b-2fd4ad396efc

📥 Commits

Reviewing files that changed from the base of the PR and between 959c634 and b530842.

📒 Files selected for processing (3)
  • src/components/AppSidebar.vue
  • src/components/StockOutApprovalDetail.vue
  • src/views/PendingExportApprovalsView.vue

@25ThienNgoc
25ThienNgoc force-pushed the feature/T152-Integrate-Reject-Modal branch from b530842 to 718b8df Compare July 11, 2026 23:46
@25ThienNgoc

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 11, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@25ThienNgoc

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 12, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@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: 2

🤖 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`:
- Around line 30-38: Remove the hardcoded role checks from the visibleItems
computed property and centralize route-access rules in a shared authorization
helper or service. Update both visibleItems and the router’s canAccessRoute to
reuse that common authorization logic, preserving the existing ADMIN, MANAGER,
and approval/manage access behavior.

In `@src/components/StockOutApprovalDetail.vue`:
- Around line 58-76: Thêm bộ đếm request dùng chung, chẳng hạn loadDetailId cạnh
các ref, và tăng giá trị mỗi khi loadDetail bắt đầu. Lưu ID của lần gọi hiện tại
rồi chỉ cập nhật receipt, error và trạng thái loading nếu ID đó vẫn là request
mới nhất; bỏ qua response hoặc lỗi stale khi props.receiptId thay đổi nhanh, đảm
bảo không hiển thị dữ liệu phiếu cũ.
🪄 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: d50c2c7b-9978-4d79-9be2-e884c0c9213c

📥 Commits

Reviewing files that changed from the base of the PR and between b530842 and aa4e3cf.

📒 Files selected for processing (7)
  • src/components/AppSidebar.vue
  • src/components/DataTable.vue
  • src/components/StockOutApprovalDetail.vue
  • src/router/index.js
  • src/services/stockOutApprovalService.js
  • src/views/PendingExportApprovalsView.vue
  • src/views/StockDocumentDetailView.vue

Comment thread src/components/AppSidebar.vue
Comment thread src/components/StockOutApprovalDetail.vue
@25ThienNgoc

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 12, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@25ThienNgoc

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 12, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@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: 1

Caution

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

⚠️ Outside diff range comments (2)
src/components/StockOutApprovalDetail.vue (1)

158-160: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Khi reject lỗi, thông báo lỗi hiển thị sau modal nên user không thấy.

Nhánh catch chỉ set rejectState.submitting = false (modal vẫn mở) rồi gán lỗi vào actionError — chỗ này nằm ở khu "Hành động" phía sau modal. Người dùng vẫn thấy modal mở nhưng không thấy báo lỗi bên trong, dễ tưởng không có gì xảy ra. Nên gán vào rejectState.error để lỗi hiện ngay trong modal.

🔧 Đề xuất sửa
   } catch (err) {
-    rejectState.value.submitting = false;
-    actionError.value = err.message || "Không thể từ chối phiếu xuất.";
+    rejectState.value.submitting = false;
+    rejectState.value.error = err.message || "Không thể từ chối phiếu xuất.";
   } finally {
🤖 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/components/StockOutApprovalDetail.vue` around lines 158 - 160, Update the
rejection error handling in the catch branch of the reject action to assign the
failure message to rejectState.error instead of actionError.value, so the
still-open rejection modal displays the error immediately; keep resetting
rejectState.submitting and the existing fallback message unchanged.
src/router/index.js (1)

64-65: 🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win

Guard này chỉ hỗ trợ UX, không thay thế phân quyền ở backend.

canAccessRoute trả true cho path không khớp rule, nên các route chi tiết (vd /pending-export-approvals/:id, /stock-out/:id) vẫn vào được với mọi role. Không có redirect loop vì /dashboard luôn được phép — phần này ổn. Nhưng cần đảm bảo backend cũng enforce quyền cho các endpoint chi tiết/duyệt/từ chối, không dựa vào guard FE.

As per path instructions: "Nhắc rõ frontend guard chỉ hỗ trợ UX, không thay thế authorization ở backend."

🤖 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/router/index.js` around lines 64 - 65, Keep the frontend guard around
canAccessRoute and getCurrentRoleCode as UX-only navigation protection, and add
or verify backend authorization for detailed, approval, and rejection endpoints
such as pending-export-approvals/:id and stock-out/:id. Ensure unauthorized
roles are rejected server-side rather than relying on the guard, while
preserving the existing /dashboard redirect behavior.

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.

Inline comments:
In `@src/services/permissionService.js`:
- Around line 41-60: Update canAccessRoute to add explicit rules for the
stock-in and stock-out detail routes matching /stock-in/:id and /stock-out/:id,
instead of allowing them through the default return true path. Apply the
intended authorized-role restriction consistently with the existing stock route
rules while preserving current behavior for create/edit and unrelated routes.

---

Outside diff comments:
In `@src/components/StockOutApprovalDetail.vue`:
- Around line 158-160: Update the rejection error handling in the catch branch
of the reject action to assign the failure message to rejectState.error instead
of actionError.value, so the still-open rejection modal displays the error
immediately; keep resetting rejectState.submitting and the existing fallback
message unchanged.

In `@src/router/index.js`:
- Around line 64-65: Keep the frontend guard around canAccessRoute and
getCurrentRoleCode as UX-only navigation protection, and add or verify backend
authorization for detailed, approval, and rejection endpoints such as
pending-export-approvals/:id and stock-out/:id. Ensure unauthorized roles are
rejected server-side rather than relying on the guard, while preserving the
existing /dashboard redirect behavior.
🪄 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: 6892d30d-5343-4c71-b77e-3bcc01102429

📥 Commits

Reviewing files that changed from the base of the PR and between aa4e3cf and 5c8542a.

📒 Files selected for processing (4)
  • src/components/AppSidebar.vue
  • src/components/StockOutApprovalDetail.vue
  • src/router/index.js
  • src/services/permissionService.js

Comment thread src/services/permissionService.js
@25ThienNgoc

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 12, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@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: 1

🤖 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/services/permissionService.js`:
- Around line 56-58: Update the route authorization logic in canAccessRoute so
MANAGER is allowed to access the stock-out detail route (/stock-out/:id) used
for approval, while preserving the existing ADMIN/EMPLOYEE restrictions for
stock-out creation and editing routes.
🪄 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: 58198ab0-a76b-4abf-8404-c3c57c6ba06e

📥 Commits

Reviewing files that changed from the base of the PR and between 5c8542a and 391ceea.

📒 Files selected for processing (2)
  • src/components/StockOutApprovalDetail.vue
  • src/services/permissionService.js

Comment thread src/services/permissionService.js Outdated
@ThienlocTran
ThienlocTran merged commit 64a3093 into dev Jul 16, 2026
1 check passed
@ThienlocTran
ThienlocTran deleted the feature/T152-Integrate-Reject-Modal branch July 31, 2026 11:37
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.

2 participants