Skip to content

Feature/t227 account profile UI - #66

Merged
ThienlocTran merged 9 commits into
devfrom
feature/T227-account-profile-ui
Aug 4, 2026
Merged

ThienlocTran merged 9 commits into
devfrom
feature/T227-account-profile-ui

Conversation

@25ThienNgoc

@25ThienNgoc 25ThienNgoc commented Aug 1, 2026 •

Copy link
Copy Markdown
Collaborator

check giúp tui

Summary by CodeRabbit

  • Tính năng mới

    • Thêm mục và trang “Hồ sơ”, hiển thị thông tin tài khoản, vai trò và trạng thái.
    • Dashboard bổ sung biểu đồ tổng quan, chỉ số tồn kho, phê duyệt và cảnh báo.
    • Bổ sung trạng thái tải, lỗi, rỗng và khả năng thử lại.
    • Cải thiện bố cục hiển thị trên nhiều kích thước màn hình.
  • Sửa lỗi

    • Hiển thị chính xác loại phiếu, nhãn và đối tác trong màn hình phê duyệt.
    • Ngăn tải dữ liệu sản phẩm và kho khi không đủ quyền.

@coderabbitai

coderabbitai Bot commented Aug 1, 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 trang hồ sơ người dùng, API tổng quan dashboard, biểu đồ ApexCharts và kiểm tra quyền trước khi gọi API. PR cũng cập nhật trạng thái dashboard và cách hiển thị loại phiếu trong màn hình phê duyệt.

Changes

Tính năng ứng dụng

Layer / File(s) Summary
Tải và chuẩn hóa hồ sơ
src/services/profileService.js
Tải hồ sơ từ nhiều endpoint, chuẩn hóa dữ liệu và xử lý lỗi xác thực, lỗi 404.
Route và giao diện hồ sơ
src/router/index.js, src/components/AppSidebar.vue, src/views/ProfileView.vue
Đăng ký /profile, thêm mục điều hướng và hiển thị hồ sơ cùng các trạng thái tải.
API, quyền truy cập và giao diện dashboard
src/services/dashboardService.js, src/services/productService.js, src/services/warehouseService.js, src/views/DashboardView.vue
Thêm API tổng quan, biểu đồ, lọc theo quyền và các trạng thái loading, lỗi, rỗng.
Hiển thị phiếu phê duyệt theo loại
src/views/ApprovalsView.vue
Hiển thị loại phiếu và nhãn đối tác theo phiếu đang xem trong danh sách và modal chi tiết.

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

Possibly related PRs

Suggested reviewers: thienloctran

🚥 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 đề mô tả rõ phần chính của thay đổi: bổ sung giao diện hồ sơ tài khoản và các luồng hỗ trợ liên quan.
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/T227-account-profile-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/services/profileService.js`:
- Around line 51-56: Update the outer catch in the profile-loading flow to
rethrow normalized 401 errors before checking hasProfileData(fallbackProfile),
so an expired session cannot return stale localStorage data. Preserve the
existing fallback behavior for non-401 errors and avoid logging tokens or
profile data.
- Line 50: Thay đổi nhánh fallback trong hàm xử lý hồ sơ để trả về null khi
normalizeProfile(getCurrentUser()) và tất cả endpoint đều không có dữ liệu, thay
vì trả fallbackProfile rỗng. Giữ nguyên kết quả object cho hồ sơ hợp lệ và đảm
bảo ProfileView.vue nhận null để kích hoạt empty state, không ảnh hưởng loading
hoặc error state.
- Around line 6-11: Thêm cấu hình timeout cho axios instance trong phần khởi tạo
profileClient, sử dụng hằng số API_TIMEOUT_MS như dashboardClient. Giữ nguyên
baseURL và headers hiện có.

In `@src/views/DashboardView.vue`:
- Around line 85-89: Update pendingApprovalsTotal in DashboardView.vue to
conditionally sum importReceipts only when canSeeImportApprovals.value is true
and exportReceipts only when canSeeExportApprovals.value is true, defaulting
unauthorized or missing values to zero while preserving backend authorization
for /api/dashboard/overview.
🪄 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: 9081f4f1-0519-4196-a969-8b0036bb5f40

📥 Commits

Reviewing files that changed from the base of the PR and between 7b51677 and 7dcf58b.

📒 Files selected for processing (7)
  • src/components/AppSidebar.vue
  • src/router/index.js
  • src/services/dashboardService.js
  • src/services/profileService.js
  • src/views/ApprovalsView.vue
  • src/views/DashboardView.vue
  • src/views/ProfileView.vue

Comment thread src/services/profileService.js
Comment thread src/services/profileService.js Outdated
Comment thread src/services/profileService.js Outdated
Comment thread src/views/DashboardView.vue Outdated

@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 (1)
src/views/DashboardView.vue (1)

252-257: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Hiển thị đúng lỗi khi dashboardOverview thất bại.

Khi overviewResult bị reject với lỗi khác 401, đoạn này chỉ đặt dashboardOverviewFailed. errorMessage vẫn rỗng. Nếu các API còn lại trả về 0, hasDashboardData là false, nên Line 603 không vào nhánh lỗi. Người dùng sẽ thấy “Chưa có dữ liệu tổng quan” thay vì lỗi tải dữ liệu.

Gán thông báo lỗi chung sau nhánh 401.

As per path instructions, src/views/** phải xử lý đúng loading, empty state và error state.

Đề xuất sửa
       if (overviewResult.reason?.status === 401) {
         isLoading.value = false;
         isRetrying.value = false;
         router.replace("/login");
         return;
       }
+      errorMessage.value = "Không thể tải dữ liệu tổng quan.";
🤖 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/DashboardView.vue` around lines 252 - 257, Update the rejected
branch handling overviewResult in DashboardView so non-401 failures also assign
the shared errorMessage after the existing 401 handling. Preserve
dashboardOverview being cleared and dashboardOverviewFailed being set, ensuring
the error state is displayed even when hasDashboardData is false.

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/profileService.js`:
- Around line 52-56: Cập nhật luồng tải hồ sơ trong hàm bao quanh
fallbackProfile để inner catch lưu lỗi cuối cùng từ các endpoint, bao gồm
timeout, lỗi mạng và HTTP ngoài 401/404, thay vì nuốt lỗi. Khi không có
fallbackProfile, hãy ném lỗi cuối; chỉ trả null khi mọi endpoint hoàn tất thành
công nhưng không có dữ liệu, đồng thời giữ nguyên hành vi trả fallback khi
fallbackProfile hợp lệ.

---

Outside diff comments:
In `@src/views/DashboardView.vue`:
- Around line 252-257: Update the rejected branch handling overviewResult in
DashboardView so non-401 failures also assign the shared errorMessage after the
existing 401 handling. Preserve dashboardOverview being cleared and
dashboardOverviewFailed being set, ensuring the error state is displayed even
when hasDashboardData is false.
🪄 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: d2d29068-7dd5-450e-a32a-e90f5a4eba57

📥 Commits

Reviewing files that changed from the base of the PR and between 7dcf58b and c42bf18.

📒 Files selected for processing (3)
  • src/services/profileService.js
  • src/views/DashboardView.vue
  • src/views/ProfileView.vue

Comment thread src/services/profileService.js

@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 (1)
src/views/DashboardView.vue (1)

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

Kiểm tra quyền trước khi tải và hiển thị KPI sản phẩm/kho.

loadProductCount() và loadWarehouseCount() luôn chạy, dù EMPLOYEE bị router chặn /products và /warehouses. Điều này có thể gây lỗi 403 trên banner chung và hiển thị số lượng tài nguyên ngoài quyền trên dashboard. Đổi lại, chỉ gọi API và hiển thị KPI khi canAccessRoute("/products") hoặc canAccessRoute("/warehouses") cho phép; backend cũng cần kiểm tra quyền khi trả về tổng số.

🤖 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/DashboardView.vue` around lines 240 - 245, Update the
Promise.allSettled flow in DashboardView so loadProductCount and
loadWarehouseCount are invoked only when canAccessRoute("/products") and
canAccessRoute("/warehouses") respectively allow access, and hide or omit their
KPI values otherwise while preserving the overview request. Also enforce the
same route permissions in the backend endpoints that return product and
warehouse totals.

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/profileService.js`:
- Around line 46-49: Trong luồng thử các endpoint của hàm profile service, xử lý
trạng thái 404 trước khi gán giá trị cho lastError. Khi error.response?.status
là 404, tiếp tục endpoint kế tiếp mà không lưu lỗi; chỉ cập nhật lastError cho
các lỗi khác để khi mọi endpoint đều không có hồ sơ, hàm trả về null theo luồng
hiện có.

---

Outside diff comments:
In `@src/views/DashboardView.vue`:
- Around line 240-245: Update the Promise.allSettled flow in DashboardView so
loadProductCount and loadWarehouseCount are invoked only when
canAccessRoute("/products") and canAccessRoute("/warehouses") respectively allow
access, and hide or omit their KPI values otherwise while preserving the
overview request. Also enforce the same route permissions in the backend
endpoints that return product and warehouse totals.
🪄 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: 39afd763-f3ed-45dd-b82f-d6b9fba8e49b

📥 Commits

Reviewing files that changed from the base of the PR and between c42bf18 and f98b0a9.

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

Comment on lines +46 to +49
lastError = normalizedError

if (error.response?.status === 404) {
continue

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Không lưu lỗi 404 vào lastError.

Line 46 lưu 404 trước khi Line 48 chuyển sang endpoint tiếp theo. Nếu tất cả endpoint đều trả 404 và không có fallbackProfile, hàm sẽ ném lỗi 404 tại Line 62 thay vì trả null. UI hồ sơ sẽ hiển thị error state thay vì empty state.

Chỉ gán lastError sau nhánh 404.

Đề xuất sửa
-        lastError = normalizedError
-
         if (error.response?.status === 404) {
           continue
         }
 
+        lastError = normalizedError
+
         if (error.response?.status && error.response.status < 500) {
🤖 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/services/profileService.js` around lines 46 - 49, Trong luồng thử các
endpoint của hàm profile service, xử lý trạng thái 404 trước khi gán giá trị cho
lastError. Khi error.response?.status là 404, tiếp tục endpoint kế tiếp mà không
lưu lỗi; chỉ cập nhật lastError cho các lỗi khác để khi mọi endpoint đều không
có hồ sơ, hàm trả về null theo luồng hiện có.

Source: Path instructions

@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/views/DashboardView.vue`:
- Around line 242-243: Thay thế giá trị giả `overviewResult` trong luồng khởi
tạo `requests` bằng lời gọi API thực tế `getDashboardOverview()`, để kết quả
thành công cập nhật `dashboardOverview.value` và lỗi được xử lý theo flow hiện
có. Kiểm tra lại loading, empty state và error state trong luồng dashboard, đồng
thời giữ nguyên cách xử lý các request khá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: a2efeeb1-496d-4dd1-b897-ad9e267db8ac

📥 Commits

Reviewing files that changed from the base of the PR and between f98b0a9 and 5a2c634.

📒 Files selected for processing (3)
  • src/services/productService.js
  • src/services/warehouseService.js
  • src/views/DashboardView.vue

Comment thread src/views/DashboardView.vue Outdated

@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 (1)
src/views/DashboardView.vue (1)

246-255: 🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Ẩn KPI khi role không có quyền truy cập.

Khi canSeeProducts hoặc canSeeWarehouses là false, code thay request bằng Promise.resolve(0). Tuy nhiên template vẫn hiển thị KPI “Tổng sản phẩm” và “Tổng kho” với giá trị 0. UI đang hiển thị dữ liệu giả cho tài nguyên bị hạn chế.

Chỉ render từng card khi quyền tương ứng được cấp. Đồng thời tính visibleKpiCardCount từ cả quyền sản phẩm, kho và tồn kho.

As per path instructions, UI phải phản ánh đúng quyền ADMIN/MANAGER/EMPLOYEE.

Đề xuất sửa
-const visibleKpiCardCount = computed(() => (canSeeWarnings.value ? 4 : 2));
+const visibleKpiCardCount = computed(
+  () =>
+    (canSeeProducts.value ? 1 : 0) +
+    (canSeeWarehouses.value ? 1 : 0) +
+    (canSeeWarnings.value ? 2 : 0),
+);

-<article class="kpi-card">
+<article v-if="canSeeProducts" class="kpi-card">

-<article class="kpi-card">
+<article v-if="canSeeWarehouses" class="kpi-card">
🤖 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/DashboardView.vue` around lines 246 - 255, Update DashboardView’s
KPI template to conditionally render the product and warehouse cards only when
canSeeProducts and canSeeWarehouses are true, instead of displaying their
fallback zero values. Adjust visibleKpiCardCount to derive from product,
warehouse, and inventory permissions so the layout reflects ADMIN, MANAGER, and
EMPLOYEE access correctly.

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/views/DashboardView.vue`:
- Around line 242-245: Update the request initialization in the dashboard
loading flow to call loadDashboardOverview() only when the current role can
access at least one of inventory, alerts, approvals, or
pending-export-approvals. Keep product-only roles from requesting or storing
dashboardOverview, while preserving the backend’s per-field permission checks
for roles that do request the overview.

---

Outside diff comments:
In `@src/views/DashboardView.vue`:
- Around line 246-255: Update DashboardView’s KPI template to conditionally
render the product and warehouse cards only when canSeeProducts and
canSeeWarehouses are true, instead of displaying their fallback zero values.
Adjust visibleKpiCardCount to derive from product, warehouse, and inventory
permissions so the layout reflects ADMIN, MANAGER, and EMPLOYEE access
correctly.
🪄 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: 4ec3538a-d854-4e7c-ac8d-9ed9d2f84afc

📥 Commits

Reviewing files that changed from the base of the PR and between 5a2c634 and 43e7662.

📒 Files selected for processing (1)
  • src/views/DashboardView.vue

Comment thread src/views/DashboardView.vue Outdated

@ThienlocTran ThienlocTran left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Chưa có backend mà làm đc frontend lun :)) . quá ghê gớm

@ThienlocTran
ThienlocTran merged commit 2ed6393 into dev Aug 4, 2026
1 check passed
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