Page refresh when header action is clicked
Hi, is it possible to refresh a page when a header action is being clicked?
I tried this so far:
protected $listeners = [
'refreshQuotationRequest' => '$refresh'
];
Actions\Action::make('create-concept-quotation')
->label('Maak concept offerte')
->icon('heroicon-o-document-arrow-up')
->color('info')
->form(
fn (Form $form) => $form->schema([
Select::make('product')
->required()
->label('Product')
->options(fn (WeFactService $weFactService) => $weFactService->allProducts()),
Checkbox::make('sent_mail_directly')
->label('Direct een mail versturen?'),
])
)
->action(function (array $data) {
$chain = [
new AddQuotationToWeFact(
quotationRequestId: $this->record->id,
payload: new ConceptQuotationPayload(strval($data['product']))
),
];
if ($data['sent_mail_directly']) {
$chain[] = new SendQuotationMailFromWeFact(
quotationRequestId: $this->record->id,
);
}
Bus::chain($chain)->dispatch();
Notification::make()
->title('Er wordt een concept offerte aangemaakt in WeFact, dit kan enkele minuten duren.')
->success()
->persistent()
->send();
$this->dispatch('refreshQuotationRequest');
})
->hidden(fn () => $this->record->status !== QuotationRequestStatus::PENDING),
protected $listeners = [
'refreshQuotationRequest' => '$refresh'
];
Actions\Action::make('create-concept-quotation')
->label('Maak concept offerte')
->icon('heroicon-o-document-arrow-up')
->color('info')
->form(
fn (Form $form) => $form->schema([
Select::make('product')
->required()
->label('Product')
->options(fn (WeFactService $weFactService) => $weFactService->allProducts()),
Checkbox::make('sent_mail_directly')
->label('Direct een mail versturen?'),
])
)
->action(function (array $data) {
$chain = [
new AddQuotationToWeFact(
quotationRequestId: $this->record->id,
payload: new ConceptQuotationPayload(strval($data['product']))
),
];
if ($data['sent_mail_directly']) {
$chain[] = new SendQuotationMailFromWeFact(
quotationRequestId: $this->record->id,
);
}
Bus::chain($chain)->dispatch();
Notification::make()
->title('Er wordt een concept offerte aangemaakt in WeFact, dit kan enkele minuten duren.')
->success()
->persistent()
->send();
$this->dispatch('refreshQuotationRequest');
})
->hidden(fn () => $this->record->status !== QuotationRequestStatus::PENDING),
4 Replies