Cập nhật hồ sơ cá nhân trên web
Feature URL
Module
user
Status
in-development
Priority
P1
Platforms
fe · be
AC progress
9 / 12
Last reviewed
2026-05-29
Mục tiêu
Cho phép user chỉnh sửa các thông tin hồ sơ cơ bản trên web như tên hiển thị, bio, số điện thoại và khu vực hoạt động. Flow này giúp dữ liệu profile luôn đúng khi hiển thị trong menu, trang cá nhân, listing owner card và các màn liên quan.
Phạm vi
Trong phạm vi (In scope):
- Form chỉnh sửa profile trên
/customer/profile. - Cập nhật
fullName,bio,phone,province,ward. - Gọi
PUT /api/v1/users/mevới full-replace semantics. - Validate client-side cơ bản trước khi submit.
- Cập nhật lại Redux profile sau khi lưu thành công.
- Hiển thị lỗi validation/conflict từ backend.
Ngoài phạm vi (Out of scope):
- Cập nhật avatar, xem feature
user-avatar-update-web. - Đổi mật khẩu hoặc reset password.
- Xác minh OTP khi đổi phone.
- Admin chỉnh sửa hồ sơ user khác.
User Stories
- Là user, tôi muốn sửa tên hiển thị để hồ sơ và listing owner card dùng đúng tên.
- Là broker/user bán hàng, tôi muốn cập nhật bio và khu vực hoạt động để tăng độ tin cậy.
- Là user nhập sai phone, tôi muốn thấy lỗi rõ ràng trước hoặc sau khi submit.
- Là user lưu thành công, tôi muốn menu/header cập nhật ngay mà không cần reload trang.
Luồng chức năng
sequenceDiagram
actor User
participant Web
participant BE
User->>Web: Mở /customer/profile
Web->>BE: GET /api/v1/users/me
BE-->>Web: UserProfileResponse
User->>Web: Sửa fullName, bio, phone, province, ward
Web->>Web: Validate required/length/phone format
Web->>BE: PUT /api/v1/users/me
BE->>BE: Validate request body
BE->>BE: Kiểm tra phone chưa thuộc user khác
BE->>BE: Lưu profile mới
BE-->>Web: UserProfileResponse mới
Web->>Web: Update profile.current
Web->>User: Báo lưu thành côngAcceptance Criteria
- AC-1: Backend có
PUT /api/v1/users/meyêu cầu quyềnuser:update:self. - AC-2: API chỉ cập nhật user hiện tại từ JWT principal.
- AC-3: Request body gồm
fullName,bio,phone,province,ward. - AC-4:
fullNamebắt buộc và tối đa 255 ký tự. - AC-5:
biotối đa 500 ký tự. - AC-6:
phonenếu có phải khớp regex^0\d{9,10}$. - AC-7: Nếu phone mới đã thuộc user khác, backend trả conflict và không lưu thay đổi.
- AC-8: Backend trim string input, field optional blank được chuẩn hoá thành
null. - AC-9: Backend trả
UserProfileResponsesau khi cập nhật thành công. - AC-10: FE cần thêm thunk/service gọi
ROUTES_API_USER.UPDATE_PROFILE. - AC-11: FE cần form update profile trên
/customer/profile. - AC-12: Sau khi update thành công, FE phải refresh hoặc patch
profile.currentđểUserProfileMenuđổi tên ngay.
Quy tắc nghiệp vụ
PUT /users/melà full replace cho các field profile nằm trong request.- User không được cập nhật phone sang số đã được account khác sử dụng.
- Backend chưa xác minh OTP khi đổi phone; nếu cần bảo mật cao hơn phải tách thành flow riêng.
- Client không được gửi các field không thuộc profile như roles, status, emailVerified, authProvider.
- Lỗi validation phải hiển thị theo field để user biết cần sửa gì.
Dữ liệu & Trạng thái
Entity nghiệp vụ:
User: lưufullName,bio,phone,province,ward.UpdateProfileRequest: payload cập nhật profile.UserProfileResponse: profile sau khi cập nhật.profile.current: cache FE cần được đồng bộ sau save.
Trạng thái user-facing:
editing— form đang mở với dữ liệu hiện tại.dirty— có thay đổi chưa lưu.saving— đang gửiPUT /users/me.saved— lưu thành công và UI đã cập nhật.validation-error— dữ liệu sai format/required.phone-conflict— phone đã thuộc user khác.
Liên quan
- Phụ thuộc: user-profile-view-web
- Ảnh hưởng: user-profile-view-web, user-public-profile-listings-web