feat: consolidate frontend API layer, add query-client, and harden backend Fase 1

Frontend:
- Consolidate duplicate API layers into single src/lib/axios.ts per app
- Remove src/lib/api-client.ts and src/utils/api.ts (admin)
- Add src/lib/query-client.ts with TanStack Query config per app
- Update all imports and auto-import config

Backend:
- Fix organisations.billing_status default to 'trial'
- Fix user_invitations.invited_by_user_id to nullOnDelete
- Add MeResource with separated app_roles and pivot-based org roles
- Add cross-org check to EventPolicy view() and update()
- Restrict EventPolicy create/update to org_admin/event_manager (not org_member)
- Attach creator as org_admin on organisation store
- Add query scopes to Event and UserInvitation models
- Improve factories with Dutch test data
- Expand test suite from 29 to 41 tests (90 assertions)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-07 17:35:34 +02:00
parent 611c311854
commit 0d24506c89
36 changed files with 454 additions and 118 deletions

View File

@@ -14,12 +14,14 @@ final class EventFactory extends Factory
/** @return array<string, mixed> */
public function definition(): array
{
$name = fake()->unique()->words(3, true);
$startDate = fake()->dateTimeBetween('+1 week', '+3 months');
$city = fake('nl_NL')->city();
$year = fake()->year('+2 years');
$name = "Festival {$city} {$year}";
$startDate = fake()->dateTimeBetween('+1 month', '+6 months');
return [
'organisation_id' => Organisation::factory(),
'name' => ucfirst($name),
'name' => $name,
'slug' => str($name)->slug()->toString(),
'start_date' => $startDate,
'end_date' => fake()->dateTimeBetween($startDate, (clone $startDate)->modify('+3 days')),

View File

@@ -13,12 +13,12 @@ final class OrganisationFactory extends Factory
/** @return array<string, mixed> */
public function definition(): array
{
$name = fake()->unique()->company();
$name = fake('nl_NL')->unique()->company();
return [
'name' => $name,
'slug' => str($name)->slug()->toString(),
'billing_status' => 'active',
'slug' => str($name)->slug()->append('-' . fake()->numerify('##'))->toString(),
'billing_status' => fake()->randomElement(['trial', 'active', 'suspended', 'cancelled']),
'settings' => [],
];
}