Skip to content

Commit 5a7c49c

Browse files
Refactor (#573)
* refactor: rename files and update namespaces for better organization * refactor: update path generator namespaces and implement new classes * refactor: add new tables and update model traits for better organization * refactor: add Dashboard and StatsWidget classes, and update AdminPanelProvider to include Dashboard * refactor: simplify namespace usage and improve property type declarations in AdminPanelProvider and BeneficiariesV2 * wip * refactor: streamline intervention population logic in ServiceForm * refactor: enhance case management features with new schemas and methods for better organization and data handling * refactor: implement initial evaluation pages and enhance intervention plan management * refactor: add intervention plan widgets for benefits, monthly plans, results, and services * refactor: add EditCaseAggressor page and enhance intervention plan widgets * refactor: add new pages and widgets for enhanced case management, including team, documents, antecedents, and monthly plans * refactor: add CloseFile and Monitoring resources, new migrations, export helpers, and activity label helpers * refactor: add InterventionPlanParticipationWidget, update monthly plan management, and enhance intervention plan UI and translation strings
1 parent d30b94a commit 5a7c49c

File tree

406 files changed

+15745
-3633
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

406 files changed

+15745
-3633
lines changed

.github/copilot-instructions.md

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -201,17 +201,16 @@ protected function isAccessible(User $user, ?string $path = null): bool
201201
# Laravel 12
202202

203203
- CRITICAL: ALWAYS use `search-docs` tool for version-specific Laravel documentation and updated code examples.
204-
- This project upgraded from Laravel 10 without migrating to the new streamlined Laravel file structure.
205-
- This is perfectly fine and recommended by Laravel. Follow the existing structure from Laravel 10. We do not need to migrate to the new Laravel structure unless the user explicitly requests it.
204+
- Since Laravel 11, Laravel has a new streamlined file structure which this project uses.
206205

207-
## Laravel 10 Structure
206+
## Laravel 12 Structure
208207

209-
- Middleware typically lives in `app/Http/Middleware/` and service providers in `app/Providers/`.
210-
- There is no `bootstrap/app.php` application configuration in a Laravel 10 structure:
211-
- Middleware registration happens in `app/Http/Kernel.php`
212-
- Exception handling is in `app/Exceptions/Handler.php`
213-
- Console commands and schedule register in `app/Console/Kernel.php`
214-
- Rate limits likely exist in `RouteServiceProvider` or `app/Http/Kernel.php`
208+
- In Laravel 12, middleware are no longer registered in `app/Http/Kernel.php`.
209+
- Middleware are configured declaratively in `bootstrap/app.php` using `Application::configure()->withMiddleware()`.
210+
- `bootstrap/app.php` is the file to register middleware, exceptions, and routing files.
211+
- `bootstrap/providers.php` contains application specific service providers.
212+
- The `app\Console\Kernel.php` file no longer exists; use `bootstrap/app.php` or `routes/console.php` for console configuration.
213+
- Console commands in `app/Console/Commands/` are automatically available and do not require manual registration.
215214

216215
## Database
217216

@@ -279,6 +278,7 @@ Select::make('type')
279278
TextInput::make('company_name')
280279
->required()
281280
->visible(fn (Get $get): bool => $get('type') === 'business'),
281+
282282
</code-snippet>
283283

284284
Use `state()` with a `Closure` to compute derived column values:
@@ -288,6 +288,7 @@ use Filament\Tables\Columns\TextColumn;
288288

289289
TextColumn::make('full_name')
290290
->state(fn (User $record): string => "{$record->first_name} {$record->last_name}"),
291+
291292
</code-snippet>
292293

293294
Actions encapsulate a button with optional modal form and logic:
@@ -301,6 +302,7 @@ Action::make('updateEmail')
301302
TextInput::make('email')->email()->required(),
302303
])
303304
->action(fn (array $data, User $record): void => $record->update($data)),
305+
304306
</code-snippet>
305307

306308
### Testing
@@ -313,6 +315,7 @@ Authenticate before testing panel functionality. Filament uses Livewire, so use
313315
->searchTable($users->first()->name)
314316
->assertCanSeeTableRecords($users->take(1))
315317
->assertCanNotSeeTableRecords($users->skip(1));
318+
316319
</code-snippet>
317320

318321
<code-snippet name="Filament Create Resource Test" lang="php">
@@ -329,6 +332,7 @@ Authenticate before testing panel functionality. Filament uses Livewire, so use
329332
'name' => 'Test',
330333
'email' => 'test@example.com',
331334
]);
335+
332336
</code-snippet>
333337

334338
<code-snippet name="Testing Validation" lang="php">
@@ -343,6 +347,7 @@ Authenticate before testing panel functionality. Filament uses Livewire, so use
343347
'email' => 'email',
344348
])
345349
->assertNotNotified();
350+
346351
</code-snippet>
347352

348353
<code-snippet name="Calling Actions" lang="php">
@@ -359,6 +364,7 @@ Authenticate before testing panel functionality. Filament uses Livewire, so use
359364
'role' => 'admin',
360365
])
361366
->assertNotified();
367+
362368
</code-snippet>
363369

364370
### Common Mistakes
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
---
2+
name: pest-testing
3+
description: >-
4+
Tests applications using the Pest 3 PHP framework. Activates when writing tests, creating unit or feature
5+
tests, adding assertions, testing Livewire components, architecture testing, debugging test failures,
6+
working with datasets or mocking; or when the user mentions test, spec, TDD, expects, assertion,
7+
coverage, or needs to verify functionality works.
8+
---
9+
10+
# Pest Testing 3
11+
12+
## When to Apply
13+
14+
Activate this skill when:
15+
- Creating new tests (unit or feature)
16+
- Modifying existing tests
17+
- Debugging test failures
18+
- Working with datasets, mocking, or test organization
19+
- Writing architecture tests
20+
21+
## Documentation
22+
23+
Use `search-docs` for detailed Pest 3 patterns and documentation.
24+
25+
## Basic Usage
26+
27+
### Creating Tests
28+
29+
All tests must be written using Pest. Use `php artisan make:test --pest {name}`.
30+
31+
### Test Organization
32+
33+
- Tests live in the `tests/Feature` and `tests/Unit` directories.
34+
- Do NOT remove tests without approval - these are core application code.
35+
- Test happy paths, failure paths, and edge cases.
36+
37+
### Basic Test Structure
38+
39+
<code-snippet name="Basic Pest Test Example" lang="php">
40+
41+
it('is true', function () {
42+
expect(true)->toBeTrue();
43+
});
44+
45+
</code-snippet>
46+
47+
### Running Tests
48+
49+
- Run minimal tests with filter before finalizing: `php artisan test --compact --filter=testName`.
50+
- Run all tests: `php artisan test --compact`.
51+
- Run file: `php artisan test --compact tests/Feature/ExampleTest.php`.
52+
53+
## Assertions
54+
55+
Use specific assertions (`assertSuccessful()`, `assertNotFound()`) instead of `assertStatus()`:
56+
57+
<code-snippet name="Pest Response Assertion" lang="php">
58+
59+
it('returns all', function () {
60+
$this->postJson('/api/docs', [])->assertSuccessful();
61+
});
62+
63+
</code-snippet>
64+
65+
| Use | Instead of |
66+
|-----|------------|
67+
| `assertSuccessful()` | `assertStatus(200)` |
68+
| `assertNotFound()` | `assertStatus(404)` |
69+
| `assertForbidden()` | `assertStatus(403)` |
70+
71+
## Mocking
72+
73+
Import mock function before use: `use function Pest\Laravel\mock;`
74+
75+
## Datasets
76+
77+
Use datasets for repetitive tests (validation rules, etc.):
78+
79+
<code-snippet name="Pest Dataset Example" lang="php">
80+
81+
it('has emails', function (string $email) {
82+
expect($email)->not->toBeEmpty();
83+
})->with([
84+
'james' => 'james@laravel.com',
85+
'taylor' => 'taylor@laravel.com',
86+
]);
87+
88+
</code-snippet>
89+
90+
## Pest 3 Features
91+
92+
### Architecture Testing
93+
94+
Pest 3 includes architecture testing to enforce code conventions:
95+
96+
<code-snippet name="Architecture Test Example" lang="php">
97+
98+
arch('controllers')
99+
->expect('App\Http\Controllers')
100+
->toExtendNothing()
101+
->toHaveSuffix('Controller');
102+
103+
arch('models')
104+
->expect('App\Models')
105+
->toExtend('Illuminate\Database\Eloquent\Model');
106+
107+
arch('no debugging')
108+
->expect(['dd', 'dump', 'ray'])
109+
->not->toBeUsed();
110+
111+
</code-snippet>
112+
113+
### Type Coverage
114+
115+
Pest 3 provides improved type coverage analysis. Run with `--type-coverage` flag.
116+
117+
## Common Pitfalls
118+
119+
- Not importing `use function Pest\Laravel\mock;` before using mock
120+
- Using `assertStatus(200)` instead of `assertSuccessful()`
121+
- Forgetting datasets for repetitive validation tests
122+
- Deleting tests without approval
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
---
2+
name: tailwindcss-development
3+
description: >-
4+
Styles applications using Tailwind CSS v4 utilities. Activates when adding styles, restyling components,
5+
working with gradients, spacing, layout, flex, grid, responsive design, dark mode, colors,
6+
typography, or borders; or when the user mentions CSS, styling, classes, Tailwind, restyle,
7+
hero section, cards, buttons, or any visual/UI changes.
8+
---
9+
10+
# Tailwind CSS Development
11+
12+
## When to Apply
13+
14+
Activate this skill when:
15+
16+
- Adding styles to components or pages
17+
- Working with responsive design
18+
- Implementing dark mode
19+
- Extracting repeated patterns into components
20+
- Debugging spacing or layout issues
21+
22+
## Documentation
23+
24+
Use `search-docs` for detailed Tailwind CSS v4 patterns and documentation.
25+
26+
## Basic Usage
27+
28+
- Use Tailwind CSS classes to style HTML. Check and follow existing Tailwind conventions in the project before introducing new patterns.
29+
- Offer to extract repeated patterns into components that match the project's conventions (e.g., Blade, JSX, Vue).
30+
- Consider class placement, order, priority, and defaults. Remove redundant classes, add classes to parent or child elements carefully to reduce repetition, and group elements logically.
31+
32+
## Tailwind CSS v4 Specifics
33+
34+
- Always use Tailwind CSS v4 and avoid deprecated utilities.
35+
- `corePlugins` is not supported in Tailwind v4.
36+
37+
### CSS-First Configuration
38+
39+
In Tailwind v4, configuration is CSS-first using the `@theme` directive — no separate `tailwind.config.js` file is needed:
40+
41+
<code-snippet name="CSS-First Config" lang="css">
42+
@theme {
43+
--color-brand: oklch(0.72 0.11 178);
44+
}
45+
</code-snippet>
46+
47+
### Import Syntax
48+
49+
In Tailwind v4, import Tailwind with a regular CSS `@import` statement instead of the `@tailwind` directives used in v3:
50+
51+
<code-snippet name="v4 Import Syntax" lang="diff">
52+
- @tailwind base;
53+
- @tailwind components;
54+
- @tailwind utilities;
55+
+ @import "tailwindcss";
56+
</code-snippet>
57+
58+
### Replaced Utilities
59+
60+
Tailwind v4 removed deprecated utilities. Use the replacements shown below. Opacity values remain numeric.
61+
62+
| Deprecated | Replacement |
63+
|------------|-------------|
64+
| bg-opacity-* | bg-black/* |
65+
| text-opacity-* | text-black/* |
66+
| border-opacity-* | border-black/* |
67+
| divide-opacity-* | divide-black/* |
68+
| ring-opacity-* | ring-black/* |
69+
| placeholder-opacity-* | placeholder-black/* |
70+
| flex-shrink-* | shrink-* |
71+
| flex-grow-* | grow-* |
72+
| overflow-ellipsis | text-ellipsis |
73+
| decoration-slice | box-decoration-slice |
74+
| decoration-clone | box-decoration-clone |
75+
76+
## Spacing
77+
78+
Use `gap` utilities instead of margins for spacing between siblings:
79+
80+
<code-snippet name="Gap Utilities" lang="html">
81+
<div class="flex gap-8">
82+
<div>Item 1</div>
83+
<div>Item 2</div>
84+
</div>
85+
</code-snippet>
86+
87+
## Dark Mode
88+
89+
If existing pages and components support dark mode, new pages and components must support it the same way, typically using the `dark:` variant:
90+
91+
<code-snippet name="Dark Mode" lang="html">
92+
<div class="bg-white dark:bg-gray-900 text-gray-900 dark:text-white">
93+
Content adapts to color scheme
94+
</div>
95+
</code-snippet>
96+
97+
## Common Patterns
98+
99+
### Flexbox Layout
100+
101+
<code-snippet name="Flexbox Layout" lang="html">
102+
<div class="flex items-center justify-between gap-4">
103+
<div>Left content</div>
104+
<div>Right content</div>
105+
</div>
106+
</code-snippet>
107+
108+
### Grid Layout
109+
110+
<code-snippet name="Grid Layout" lang="html">
111+
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
112+
<div>Card 1</div>
113+
<div>Card 2</div>
114+
<div>Card 3</div>
115+
</div>
116+
</code-snippet>
117+
118+
## Common Pitfalls
119+
120+
- Using deprecated v3 utilities (bg-opacity-*, flex-shrink-*, etc.)
121+
- Using `@tailwind` directives instead of `@import "tailwindcss"`
122+
- Trying to use `tailwind.config.js` instead of CSS `@theme` directive
123+
- Using margins for spacing between siblings instead of gap utilities
124+
- Forgetting to add dark mode variants when the project uses dark mode

app/Concerns/HasPermissions.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,25 @@ public function canChangeOrganizationProfile(): bool
9393
return (bool) $this->permissions?->admin_permissions->contains(AdminPermission::CAN_CHANGE_ORGANISATION_PROFILE);
9494
}
9595

96+
/**
97+
* Whether the user can access the organization panel (configuration section).
98+
* Requires at least one of: modify nomenclature, modify staff, modify organisation profile.
99+
*/
100+
public function hasAccessToOrganizationConfig(): bool
101+
{
102+
if ($this->isAdmin()) {
103+
return true;
104+
}
105+
106+
if ($this->isNgoAdmin()) {
107+
return true;
108+
}
109+
110+
return $this->hasAccessToNomenclature()
111+
|| $this->hasAccessToStaff()
112+
|| $this->canChangeOrganizationProfile();
113+
}
114+
96115
public function canSearchBeneficiary(): bool
97116
{
98117
if ($this->isNgoAdmin()) {

0 commit comments

Comments
 (0)