Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 34 additions & 27 deletions app-modules/basic-needs/src/Filament/Actions/SendEmailAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@
use Filament\Forms\Components\DateTimePicker;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\Toggle;
use Filament\Forms\Components\ToggleButtons;
use Filament\Pages\Page;
use Filament\Schemas\Components\Grid;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Components\Utilities\Get;
use Filament\Schemas\Components\Utilities\Set;
use Filament\Schemas\Components\Wizard\Step;
Expand All @@ -73,7 +75,7 @@ public static function make(string $view): Action
return Action::make('send_email')
->label('Send Email')
->icon('heroicon-m-chat-bubble-bottom-center-text')
->modalHeading('Send Engagement')
->modalHeading('Send Message')
->model(Engagement::class)
->authorize(fn () => Auth::user()->can('create', Engagement::class))
->steps(fn (): array => self::getSteps($view))
Expand Down Expand Up @@ -107,31 +109,36 @@ protected static function getSteps(string $view): array
*/
protected static function getContactInformationStep(string $view): Step
{
return Step::make('Contact Information')
return Step::make('Recipient Details')
->schema([
Select::make('recipient_type')
->label('Recipient Type')
->options([
'student' => 'Student',
'prospect' => 'Prospect',
])
->live()
->afterStateUpdated(fn (Set $set) => $set('recipient_id', null))
->required(),
Select::make('recipient_id')
->label('Recipient')
->searchable()
->hidden(fn (Get $get) => ! filled($get('recipient_type')))
->options(fn (Get $get) => self::getRecipientOptions($get))
->getSearchResultsUsing(fn (string $search, Get $get) => self::getRecipientSearchResults($search, $get))
->getOptionLabelUsing(fn (string $value, Get $get) => self::getRecipientOptionLabel($value, $get))
Comment thread
Orrison marked this conversation as resolved.
->afterStateUpdated(function (Get $get, Set $set, Component $livewire) use ($view) {
$record = method_exists($livewire, 'getRecord') ? $livewire->getRecord() : null;

self::updateBodyAndRouteId($get, $set, $record, $view);
})
->live()
->required(),
Section::make()
->label('Recipient Info')
->schema([
ToggleButtons::make('recipient_type')
->label('Recipient Type')
->options([
'student' => 'Student',
'prospect' => 'Prospect',
])
->inline()
->live()
->afterStateUpdated(fn (Set $set) => $set('recipient_id', null))
->required(),
Select::make('recipient_id')
->label('Recipient')
->searchable()
->hidden(fn (Get $get) => ! filled($get('recipient_type')))
->options(fn (Get $get) => self::getRecipientOptions($get))
->getSearchResultsUsing(fn (string $search, Get $get) => self::getRecipientSearchResults($search, $get))
->getOptionLabelUsing(fn (string $value, Get $get) => self::getRecipientOptionLabel($value, $get))
->afterStateUpdated(function (Get $get, Set $set, Component $livewire) use ($view) {
$record = method_exists($livewire, 'getRecord') ? $livewire->getRecord() : null;

self::updateBodyAndRouteId($get, $set, $record, $view);
})
->live()
->required(),
]),

Grid::make(1)
->schema(fn (Get $get) => self::getRecipientRouteIdSchema($get))
Expand All @@ -144,7 +151,7 @@ protected static function getContactInformationStep(string $view): Step
*/
protected static function getContentStep(string $view): Step
{
return Step::make('Content')
return Step::make('Message Details')
->schema(function (Get $get) use ($view): array {
$educatable = self::resolveRecipient($get('recipient_type'), $get('recipient_id'));

Expand Down Expand Up @@ -197,7 +204,7 @@ protected static function getSignatureStep(): Step

protected static function getSendLaterStep(): Step
{
return Step::make('Send Your Message')
return Step::make('Delivery Details')
->schema([
Toggle::make('send_later')
->reactive()
Expand Down
Loading