libra/docs/stories/story-6.8-system-settings.md

100 lines
2.5 KiB
Markdown

# Story 6.8: System Settings
## Epic Reference
**Epic 6:** Admin Dashboard
## User Story
As an **admin**,
I want **to configure system-wide settings**,
So that **I can customize the platform to my needs**.
## Acceptance Criteria
### Profile Settings
- [ ] Admin name
- [ ] Email
- [ ] Password change
- [ ] Preferred language
### Email Settings
- [ ] View current sender email
- [ ] Test email functionality
### Notification Preferences (Optional)
- [ ] Toggle admin notifications
- [ ] Summary email frequency
### Behavior
- [ ] Settings saved and applied immediately
- [ ] Validation for all inputs
## Technical Notes
```php
new class extends Component {
public string $name = '';
public string $email = '';
public string $current_password = '';
public string $password = '';
public string $password_confirmation = '';
public string $preferred_language = 'ar';
public function mount(): void
{
$user = auth()->user();
$this->name = $user->name;
$this->email = $user->email;
$this->preferred_language = $user->preferred_language;
}
public function updateProfile(): void
{
$this->validate([
'name' => ['required', 'string', 'max:255'],
'email' => ['required', 'email', Rule::unique('users')->ignore(auth()->id())],
'preferred_language' => ['required', 'in:ar,en'],
]);
auth()->user()->update([
'name' => $this->name,
'email' => $this->email,
'preferred_language' => $this->preferred_language,
]);
session()->flash('success', __('messages.profile_updated'));
}
public function updatePassword(): void
{
$this->validate([
'current_password' => ['required', 'current_password'],
'password' => ['required', 'string', 'min:8', 'confirmed'],
]);
auth()->user()->update([
'password' => Hash::make($this->password),
]);
$this->reset(['current_password', 'password', 'password_confirmation']);
session()->flash('success', __('messages.password_updated'));
}
public function sendTestEmail(): void
{
Mail::to(auth()->user())->send(new TestEmail());
session()->flash('success', __('messages.test_email_sent'));
}
};
```
## Definition of Done
- [ ] Profile updates work
- [ ] Password change works
- [ ] Language preference persists
- [ ] Test email sends
- [ ] Validation complete
- [ ] Tests pass
## Estimation
**Complexity:** Medium | **Effort:** 3-4 hours