From 7d273db2ab72fa548be3bf784ffad6a57e0938e7 Mon Sep 17 00:00:00 2001 From: sundayenglish Date: Wed, 25 Jun 2025 14:49:59 +0700 Subject: [PATCH] Done Profile --- app/Components/Profile/Manager.php | 7 +-- .../components/profile/manager.blade.php | 43 +++++++++---------- .../views/components/skeleton-table.blade.php | 2 +- 3 files changed, 23 insertions(+), 29 deletions(-) diff --git a/app/Components/Profile/Manager.php b/app/Components/Profile/Manager.php index b0920a5..8fa168c 100644 --- a/app/Components/Profile/Manager.php +++ b/app/Components/Profile/Manager.php @@ -13,8 +13,6 @@ class Manager extends Component public object $user; public array $roles = []; public array $allRoles = []; - - // Đổi mật khẩu public string $mode = 'view'; // 'view' | 'password' public string $currentPassword = ''; public string $password = ''; @@ -51,17 +49,14 @@ class Manager extends Component // 1. Validate $this->validate(); - // 2. Kiểm tra mật khẩu hiện tại if (! Hash::check($this->currentPassword, $this->user->password)) { $this->addError('currentPassword', 'Mật khẩu hiện tại không đúng.'); return; } - // 3. Cập nhật mật khẩu mới $this->user->password = Hash::make($this->password); $this->user->save(); - // 4. Thông báo & quay về view session()->flash('message', 'Đổi mật khẩu thành công.'); $this->showView(); } @@ -72,7 +67,7 @@ class Manager extends Component 'user' => $this->user, 'roles' => $this->roles, 'allRoles' => collect($this->allRoles), - 'title' => 'Profile của tôi', + 'title' => 'My Profile', ]); } } diff --git a/resources/views/components/profile/manager.blade.php b/resources/views/components/profile/manager.blade.php index 7ff0d32..08407fb 100644 --- a/resources/views/components/profile/manager.blade.php +++ b/resources/views/components/profile/manager.blade.php @@ -7,13 +7,12 @@
{{ $title }}
@if ($mode === 'view') - @else @endif
@@ -26,77 +25,77 @@ @endif @if ($mode === 'view') - {{-- Skeleton khi loading dữ liệu profile --}} + {{-- Skeleton while loading profile data --}}
{{-- 2 columns (label + value), 4 rows --}} - +
- {{-- Actual profile --}} + {{-- Actual profile display --}}
-
Họ và tên
+
Full Name
{{ $user->fullname }}
Email
{{ $user->email }}
-
Vai trò
+
Roles
@if ($roles) {{ implode(', ', $roles) }} @else - Chưa có vai trò + No roles assigned @endif
-
Ngày tạo tài khoản
+
Account Created At
{{ $user->created_at?->format('d/m/Y H:i') ?? '—' }}
@else - {{-- Skeleton khi loading form đổi mật khẩu --}} + {{-- Skeleton while loading change-password form --}}
{{-- 3 fields + 2 buttons --}} - +
- {{-- Actual đổi mật khẩu --}} + {{-- Actual change-password form --}}
- + + placeholder="Enter current password"> @error('currentPassword')
{{ $message }}
@enderror
- + + placeholder="At least 8 characters"> @error('password')
{{ $message }}
@enderror
- + + placeholder="Re-enter new password">
diff --git a/resources/views/components/skeleton-table.blade.php b/resources/views/components/skeleton-table.blade.php index eb9865b..ea586f4 100644 --- a/resources/views/components/skeleton-table.blade.php +++ b/resources/views/components/skeleton-table.blade.php @@ -3,7 +3,7 @@ 'columns', 'rows', 'height', - 'pages' => 3, // Default to 3 pages if not specified + 'pages' => 0, // Default to 3 pages if not specified ])