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
- Create
EmailTemplateResource for the company panel — Modules/Core/Filament/Company/Resources/EmailTemplates/EmailTemplateResource.php
- Create
ListEmailTemplates page — Modules/Core/Filament/Company/Resources/EmailTemplates/Pages/ListEmailTemplates.php
- Create
EditEmailTemplate page — Modules/Core/Filament/Company/Resources/EmailTemplates/Pages/EditEmailTemplate.php
- Create
CreateEmailTemplate page — Modules/Core/Filament/Company/Resources/EmailTemplates/Pages/CreateEmailTemplate.php
- Scope all queries to
Filament::getTenant() via BelongsToCompany trait or explicit ->where('company_id', ...) — EmailTemplate model
- Register the resource in
CompanyPanelProvider — Modules/Core/Providers/CompanyPanelProvider.php
- 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']);
}
SMART Plan — As an Admin, in the company Panel I want to be able to view, edit, delete Email Templates
Specific
Add an
EmailTemplateResourceto the Company panel (/{tenant}). The resource is scoped to the current tenant company and is accessible only to users with thecustomer_adminrole (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
customer_admincan navigate to the Email Templates resource in the company panel without a 403.customer(non-admin) role cannot access the resource (returns 403 or is hidden from navigation).Achievable
EmailTemplateResourcefor the company panel —Modules/Core/Filament/Company/Resources/EmailTemplates/EmailTemplateResource.phpListEmailTemplatespage —Modules/Core/Filament/Company/Resources/EmailTemplates/Pages/ListEmailTemplates.phpEditEmailTemplatepage —Modules/Core/Filament/Company/Resources/EmailTemplates/Pages/EditEmailTemplate.phpCreateEmailTemplatepage —Modules/Core/Filament/Company/Resources/EmailTemplates/Pages/CreateEmailTemplate.phpFilament::getTenant()viaBelongsToCompanytrait or explicit->where('company_id', ...)—EmailTemplatemodelCompanyPanelProvider—Modules/Core/Providers/CompanyPanelProvider.phpEmailTemplateResource::canAccess()orcanViewAny()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