Skip to content

[Settings]: Company panel — manage Email Templates #235

Description

@nielsdrost7

SMART Plan — As an Admin, in the company Panel I want to be able to view, edit, delete Email Templates

Specific

Add an EmailTemplateResource to the Company panel (/{tenant}). The resource is scoped to the current tenant company and is accessible only to users with the customer_admin role (or elevated roles). It provides a full CRUD list page with view, edit, and delete actions, and a create action to add new templates scoped to the company.

Measurable

  • A customer_admin can navigate to the Email Templates resource in the company panel without a 403.
  • The list page shows only templates belonging to the current tenant company.
  • Edit and delete actions complete without errors and persist/remove the record correctly.
  • A customer (non-admin) role cannot access the resource (returns 403 or is hidden from navigation).

Achievable

  1. Create EmailTemplateResource for the company panel — Modules/Core/Filament/Company/Resources/EmailTemplates/EmailTemplateResource.php
  2. Create ListEmailTemplates page — Modules/Core/Filament/Company/Resources/EmailTemplates/Pages/ListEmailTemplates.php
  3. Create EditEmailTemplate page — Modules/Core/Filament/Company/Resources/EmailTemplates/Pages/EditEmailTemplate.php
  4. Create CreateEmailTemplate page — Modules/Core/Filament/Company/Resources/EmailTemplates/Pages/CreateEmailTemplate.php
  5. Scope all queries to Filament::getTenant() via BelongsToCompany trait or explicit ->where('company_id', ...) — EmailTemplate model
  6. Register the resource in CompanyPanelProvider — Modules/Core/Providers/CompanyPanelProvider.php
  7. Add navigation visibility guard (role check) — inside EmailTemplateResource::canAccess() or canViewAny()

Relevant

Company admins need to manage the email templates used for sending invoices, quotes, and payment reminders directly from their own panel without requiring platform admin intervention.

Time-bound

Sprint 6.


Arrange · Act · Assert

// Modules/Core/Tests/Feature/Company/EmailTemplateResourceTest.php

#[Test]
public function customer_admin_can_list_email_templates_in_company_panel(): void
{
    /* Arrange */
    $template = EmailTemplate::factory()->for($this->company)->create();

    /* Act */
    $response = $this->testLivewire(ListEmailTemplates::class);

    /* Assert */
    $response->assertSuccessful()
             ->assertCanSeeTableRecords([$template]);
}

#[Test]
public function customer_admin_can_edit_an_email_template(): void
{
    /* Arrange */
    $template = EmailTemplate::factory()->for($this->company)->create();

    /* Act */
    $response = $this->testLivewire(EditEmailTemplate::class, ['record' => $template->id])
        ->fillForm(['name' => 'Updated Name'])
        ->call('save');

    /* Assert */
    $response->assertHasNoErrors();
    $this->assertDatabaseHas('email_templates', ['id' => $template->id, 'name' => 'Updated Name']);
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    refinedRefined with SMART plan / test suggestions

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions