reviewd and fixed epic 1 & 2
This commit is contained in:
@@ -11,10 +11,15 @@ So that **I can serve corporate clients with their unique data requirements**.
|
||||
## Story Context
|
||||
|
||||
### Existing System Integration
|
||||
- **Integrates with:** Users table, potential contact_persons table
|
||||
- **Technology:** Livewire Volt, Flux UI forms
|
||||
- **Follows pattern:** Same CRUD pattern as individual clients
|
||||
- **Touch points:** User model, admin dashboard
|
||||
- **Integrates with:** `users` table (company-specific fields), `admin_logs` table
|
||||
- **Technology:** Livewire Volt (class-based), Flux UI forms, Pest tests
|
||||
- **Follows pattern:** Same CRUD pattern as Story 2.1 Individual Clients
|
||||
- **Key Files to Create/Modify:**
|
||||
- `resources/views/livewire/admin/users/company/` - Volt components (index, create, edit, show)
|
||||
- `app/Models/User.php` - Add `scopeCompany()` method
|
||||
- `resources/lang/ar/messages.php` - Arabic translations
|
||||
- `resources/lang/en/messages.php` - English translations
|
||||
- `tests/Feature/Admin/CompanyClientTest.php` - Feature tests
|
||||
|
||||
## Acceptance Criteria
|
||||
|
||||
@@ -32,11 +37,8 @@ So that **I can serve corporate clients with their unique data requirements**.
|
||||
- [ ] Duplicate email/registration number prevention
|
||||
- [ ] Success message on creation
|
||||
|
||||
### Multiple Contact Persons (Optional Enhancement)
|
||||
- [ ] Support unlimited contact persons per company
|
||||
- [ ] Each contact: Name, ID, Phone, Email
|
||||
- [ ] Primary contact indicator
|
||||
- [ ] Add/remove contacts dynamically
|
||||
### Multiple Contact Persons (OUT OF SCOPE)
|
||||
> **Note:** Multiple contact persons support is deferred to a future enhancement story. This story implements single contact person stored directly on the `users` table. The `contact_persons` table migration in Technical Notes is for reference only if this feature is later prioritized.
|
||||
|
||||
### List View
|
||||
- [ ] Display all company clients (user_type = 'company')
|
||||
@@ -56,8 +58,7 @@ So that **I can serve corporate clients with their unique data requirements**.
|
||||
- [ ] Success message on update
|
||||
|
||||
### View Company Profile
|
||||
- [ ] Display all company information
|
||||
- [ ] List all contact persons
|
||||
- [ ] Display all company information (including contact person details)
|
||||
- [ ] Show consultation history summary
|
||||
- [ ] Show timeline history summary
|
||||
|
||||
@@ -86,9 +87,11 @@ users table:
|
||||
- contact_person_id (nullable, required for company)
|
||||
```
|
||||
|
||||
### Alternative: Separate Contact Persons Table
|
||||
### Future Reference: Separate Contact Persons Table
|
||||
> **Note:** This migration is NOT part of this story. It is preserved here for future reference if multiple contact persons feature is prioritized.
|
||||
|
||||
```php
|
||||
// contact_persons migration
|
||||
// contact_persons migration (FUTURE - NOT IN SCOPE)
|
||||
Schema::create('contact_persons', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
|
||||
@@ -119,10 +122,13 @@ public function rules(): array
|
||||
```
|
||||
|
||||
### Volt Component for Create
|
||||
Follow the same component structure as Story 2.1 (`docs/stories/story-2.1-individual-client-account-management.md`).
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\AdminLog; // Assumes AdminLog model exists from Story 1.1
|
||||
use Livewire\Volt\Component;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
@@ -148,8 +154,17 @@ new class extends Component {
|
||||
'status' => 'active',
|
||||
]);
|
||||
|
||||
// Log action
|
||||
// Send welcome email
|
||||
// Log action (same pattern as Story 2.1)
|
||||
AdminLog::create([
|
||||
'admin_id' => auth()->id(),
|
||||
'action_type' => 'create',
|
||||
'target_type' => 'user',
|
||||
'target_id' => $user->id,
|
||||
'new_values' => $user->only(['company_name', 'email', 'company_registration']),
|
||||
'ip_address' => request()->ip(),
|
||||
]);
|
||||
|
||||
// Send welcome email (depends on Story 2.5)
|
||||
|
||||
session()->flash('success', __('messages.company_created'));
|
||||
$this->redirect(route('admin.users.index'));
|
||||
@@ -157,6 +172,51 @@ new class extends Component {
|
||||
};
|
||||
```
|
||||
|
||||
## Testing Requirements
|
||||
|
||||
### Test Approach
|
||||
- Feature tests using Pest with `Volt::test()` for Livewire components
|
||||
- Factory-based test data generation
|
||||
|
||||
### Key Test Scenarios
|
||||
|
||||
#### Create Company Client
|
||||
- [ ] Successfully create company with all valid required fields
|
||||
- [ ] Validation fails when required fields are missing
|
||||
- [ ] Validation fails for duplicate email address
|
||||
- [ ] Validation fails for duplicate company registration number
|
||||
- [ ] Preferred language defaults to Arabic when not specified
|
||||
- [ ] Audit log entry created on successful creation
|
||||
|
||||
#### List View
|
||||
- [ ] List displays only company type users (excludes individual/admin)
|
||||
- [ ] Pagination works correctly (10/25/50 per page)
|
||||
- [ ] Default sort is by created date descending
|
||||
|
||||
#### Search & Filter
|
||||
- [ ] Search by company name returns correct results
|
||||
- [ ] Search by email returns correct results
|
||||
- [ ] Search by registration number returns correct results
|
||||
- [ ] Filter by active status works
|
||||
- [ ] Filter by deactivated status works
|
||||
- [ ] Combined search and filter works correctly
|
||||
|
||||
#### Edit Company
|
||||
- [ ] Successfully update company information
|
||||
- [ ] Validation fails for duplicate email (excluding current record)
|
||||
- [ ] Validation fails for duplicate registration number (excluding current record)
|
||||
- [ ] Audit log entry created on successful update
|
||||
|
||||
#### View Profile
|
||||
- [ ] Profile displays all company information correctly
|
||||
- [ ] Consultation history summary displays (empty state if none)
|
||||
- [ ] Timeline history summary displays (empty state if none)
|
||||
|
||||
#### Bilingual Support
|
||||
- [ ] Form labels display correctly in Arabic
|
||||
- [ ] Form labels display correctly in English
|
||||
- [ ] Validation messages display in user's preferred language
|
||||
|
||||
## Definition of Done
|
||||
|
||||
- [ ] Create company client form works
|
||||
@@ -173,7 +233,17 @@ new class extends Component {
|
||||
## Dependencies
|
||||
|
||||
- **Epic 1:** Authentication system, database schema
|
||||
- **Story 2.1:** Same CRUD patterns
|
||||
- **Story 1.1:** Database schema must include the following columns in `users` table:
|
||||
- `user_type` (enum: 'individual', 'company', 'admin')
|
||||
- `status` (enum: 'active', 'deactivated')
|
||||
- `phone` (string)
|
||||
- `preferred_language` (enum: 'ar', 'en')
|
||||
- `company_name` (nullable string)
|
||||
- `company_registration` (nullable string, unique when not null)
|
||||
- `contact_person_name` (nullable string)
|
||||
- `contact_person_id` (nullable string)
|
||||
- `national_id` (nullable string, unique when not null)
|
||||
- **Story 2.1:** CRUD patterns established in `docs/stories/story-2.1-individual-client-account-management.md`
|
||||
|
||||
## Risk Assessment
|
||||
|
||||
|
||||
Reference in New Issue
Block a user