Modal on action
Action::make('refund')
->label(' Refund')
->requiresConfirmation()
->action(function ($record) {
if ($paymentGateway == 'Payment Terminals') {
$response = json_decode(ValorVirtualTerminal::issueRefundAPI($record->id),true);
// dd($response);
Notification::make()
->title('Refunded Successfully.')
->body($response['msg'])
->persistent()
->send();
}
I want to open a modal and show the response in the modal not in notification, I have no clue how to do this can someone help.
4 Replies
You can chain actions
Just make a new Action::make inside the action function
can give an example
Action::make('refund')
->label(' Refund')
->requiresConfirmation()
->action(function ($record) {
if ($paymentGateway == 'Payment Terminals') {
$response = json_decode(ValorVirtualTerminal::issueRefundAPI($record->id), true);
Action::make('refund') ->label(' Refund') ->modalContent(fn ($record) => view('livewire.refund-response-modal', ['record' => $record])) ->requiresConfirmation(); Notification::make() ->title('Refunded Successfully.') ->body($response['msg']) ->persistent() ->send(); } }) ->icon('heroicon-o-arrow-uturn-left') ->disabled(fn ($record) => $record->status === 'refund' ? true : false) ->extraAttributes(fn () => ['class' => 'mfm-box-shadow p-2 refund-action']), It's not opening any modal and I don't know if I am doing any thing wrong
Action::make('refund') ->label(' Refund') ->modalContent(fn ($record) => view('livewire.refund-response-modal', ['record' => $record])) ->requiresConfirmation(); Notification::make() ->title('Refunded Successfully.') ->body($response['msg']) ->persistent() ->send(); } }) ->icon('heroicon-o-arrow-uturn-left') ->disabled(fn ($record) => $record->status === 'refund' ? true : false) ->extraAttributes(fn () => ['class' => 'mfm-box-shadow p-2 refund-action']), It's not opening any modal and I don't know if I am doing any thing wrong
It's not really advised, actions are designed to be closed once the action is complete, why not just send a notification on complete?
Or you can use Wizard and on the final step (next) you handle the save etc, and then render a message/view after the afterStateValidated() has been done.