reviewd and fixed epic 1 & 2
This commit is contained in:
@@ -15,6 +15,12 @@ So that **I can manage client information and provide them platform access**.
|
||||
- **Technology:** Livewire Volt, Flux UI forms
|
||||
- **Follows pattern:** Admin CRUD patterns, class-based Volt components
|
||||
- **Touch points:** User model, admin dashboard
|
||||
- **PRD Reference:** Section 5.3 (User Management System), Section 16.1 (Database Schema)
|
||||
|
||||
### Prerequisites from Epic 1
|
||||
- Users table with fields: `name`, `email`, `password`, `user_type`, `national_id`, `phone`, `preferred_language`, `status`
|
||||
- AdminLog model and `admin_logs` table for audit logging
|
||||
- Bilingual infrastructure (lang files, `__()` helper)
|
||||
|
||||
## Acceptance Criteria
|
||||
|
||||
@@ -63,6 +69,15 @@ So that **I can manage client information and provide them platform access**.
|
||||
|
||||
## Technical Notes
|
||||
|
||||
### Files to Create
|
||||
```
|
||||
resources/views/livewire/admin/clients/individual/
|
||||
├── index.blade.php # List view with search/filter/pagination
|
||||
├── create.blade.php # Create form
|
||||
├── edit.blade.php # Edit form
|
||||
└── show.blade.php # View profile page
|
||||
```
|
||||
|
||||
### User Model Scope
|
||||
```php
|
||||
// In User model
|
||||
@@ -136,6 +151,80 @@ AdminLog::create([
|
||||
]);
|
||||
```
|
||||
|
||||
### Edge Cases & Error Handling
|
||||
- **Validation failure:** Display inline field errors using Flux UI error states
|
||||
- **Duplicate email:** Show "Email already exists" error on email field
|
||||
- **Duplicate National ID:** Show "National ID already registered" error
|
||||
- **Empty search results:** Display "No clients found" message with clear filters option
|
||||
|
||||
## Testing Requirements
|
||||
|
||||
### Test File Location
|
||||
`tests/Feature/Admin/IndividualClientTest.php`
|
||||
|
||||
### Test Scenarios
|
||||
|
||||
#### Create Client Tests
|
||||
- [ ] Can create individual client with all valid data
|
||||
- [ ] Cannot create client without required name field
|
||||
- [ ] Cannot create client without required email field
|
||||
- [ ] Cannot create client without required national_id field
|
||||
- [ ] Cannot create client without required phone field
|
||||
- [ ] Cannot create client with invalid email format
|
||||
- [ ] Cannot create client with duplicate email (existing user)
|
||||
- [ ] Cannot create client with duplicate national_id
|
||||
- [ ] Cannot create client with password less than 8 characters
|
||||
- [ ] Created client has user_type set to 'individual'
|
||||
- [ ] AdminLog entry created on successful creation
|
||||
|
||||
#### List View Tests
|
||||
- [ ] Index page displays only individual clients (not company/admin)
|
||||
- [ ] Pagination works with 10/25/50 per page options
|
||||
- [ ] Clients sorted by created_at desc by default
|
||||
|
||||
#### Search & Filter Tests
|
||||
- [ ] Can search clients by name (partial match)
|
||||
- [ ] Can search clients by email (partial match)
|
||||
- [ ] Can search clients by national_id (partial match)
|
||||
- [ ] Can filter clients by active status
|
||||
- [ ] Can filter clients by deactivated status
|
||||
- [ ] Clear filters resets search and filter
|
||||
|
||||
#### Edit Client Tests
|
||||
- [ ] Can edit existing client information
|
||||
- [ ] Edit form pre-populates with current values
|
||||
- [ ] Validation rules apply on edit (except unique for own record)
|
||||
- [ ] AdminLog entry created on successful update
|
||||
- [ ] Cannot change user_type via edit form
|
||||
|
||||
#### View Profile Tests
|
||||
- [ ] Profile page displays all client information
|
||||
- [ ] Profile shows consultation count/summary
|
||||
- [ ] Profile shows timeline count/summary
|
||||
|
||||
### Testing Approach
|
||||
```php
|
||||
use Livewire\Volt\Volt;
|
||||
|
||||
test('admin can create individual client', function () {
|
||||
$admin = User::factory()->admin()->create();
|
||||
|
||||
Volt::actingAs($admin)
|
||||
->test('admin.clients.individual.create')
|
||||
->set('name', 'Test Client')
|
||||
->set('email', 'client@example.com')
|
||||
->set('national_id', '123456789')
|
||||
->set('phone', '+970599123456')
|
||||
->set('password', 'password123')
|
||||
->set('preferred_language', 'ar')
|
||||
->call('create')
|
||||
->assertHasNoErrors();
|
||||
|
||||
expect(User::where('email', 'client@example.com')->exists())->toBeTrue();
|
||||
expect(AdminLog::where('action_type', 'create')->exists())->toBeTrue();
|
||||
});
|
||||
```
|
||||
|
||||
## Definition of Done
|
||||
|
||||
- [ ] Create individual client form works
|
||||
@@ -151,7 +240,10 @@ AdminLog::create([
|
||||
|
||||
## Dependencies
|
||||
|
||||
- **Epic 1:** Authentication system, database schema, bilingual support
|
||||
- **Story 1.1:** Database schema with `users` table (user_type, national_id, status fields) and `admin_logs` table
|
||||
- **Story 1.2:** Authentication system with admin role, AdminLog model
|
||||
- **Story 1.3:** Bilingual infrastructure (translation files, `__()` helper)
|
||||
- **Story 1.4:** Base admin layout and navigation
|
||||
|
||||
## Risk Assessment
|
||||
|
||||
|
||||
Reference in New Issue
Block a user