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
gladjanus43
gladjanus435mo ago
You can chain actions Just make a new Action::make inside the action function
Arghyaashu
ArghyaashuOP5mo ago
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
toeknee
toeknee5mo ago
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.
LeandroFerreira
LeandroFerreira5mo ago
Action::make('refund')
->requiresConfirmation()
->action(function () {
...
$response = json_decode(ValorVirtualTerminal::issueRefundAPI($record->id), true);
$this->replaceMountedAction('refundResponse');
})
Action::make('refund')
->requiresConfirmation()
->action(function () {
...
$response = json_decode(ValorVirtualTerminal::issueRefundAPI($record->id), true);
$this->replaceMountedAction('refundResponse');
})
public function refundResponseAction(): Action
{
return Action::make('refundResponse')
->modalContent(...)
->modalSubmitAction(false)
->modalCancelActionLabel('Close');
}
public function refundResponseAction(): Action
{
return Action::make('refundResponse')
->modalContent(...)
->modalSubmitAction(false)
->modalCancelActionLabel('Close');
}
Want results from more Discord servers?
Add your server