diff --git a/app/Filament/Pages/SendSms.php b/app/Filament/Pages/SendSms.php index 8425a6e..77c15e7 100644 --- a/app/Filament/Pages/SendSms.php +++ b/app/Filament/Pages/SendSms.php @@ -43,10 +43,6 @@ class SendSms extends Page */ public ?array $data = []; - public ?int $activeCampaignId = null; - - public bool $campaignNotificationSent = false; - public static function getNavigationLabel(): string { return __('filament.send_sms.navigation'); @@ -131,8 +127,7 @@ class SendSms extends Page ->modalHeading(__('filament.send_sms.actions.send_confirm_heading')) ->modalDescription(fn (): string => $this->confirmationDescription()) ->modalSubmitActionLabel(__('filament.send_sms.actions.send_confirm_submit')) - ->action('sendCampaign') - ->disabled(fn (): bool => $this->activeCampaignId !== null && ! $this->isCampaignComplete()), + ->action('sendCampaign'), ]), ]), ]); @@ -140,15 +135,6 @@ class SendSms extends Page public function sendCampaign(): void { - if ($this->activeCampaignId !== null && ! $this->isCampaignComplete()) { - Notification::make() - ->title(__('filament.send_sms.notifications.campaign_still_sending')) - ->warning() - ->send(); - - return; - } - $data = $this->form->getState(); $validator = Validator::make($data, [ @@ -192,9 +178,6 @@ class SendSms extends Page excludedIds: $excludedIds, ); - $this->activeCampaignId = $campaign->id; - $this->campaignNotificationSent = false; - if ($campaign->isComplete()) { $this->notifyCampaignFinished($campaign); } else { @@ -206,32 +189,8 @@ class SendSms extends Page } } - public function refreshCampaignProgress(): void - { - if ($this->activeCampaignId === null) { - return; - } - - $campaign = SmsCampaign::query()->find($this->activeCampaignId); - - if ($campaign === null) { - $this->activeCampaignId = null; - - return; - } - - if ($campaign->isComplete()) { - $this->notifyCampaignFinished($campaign); - } - } - protected function notifyCampaignFinished(SmsCampaign $campaign): void { - if ($this->campaignNotificationSent) { - return; - } - - $this->campaignNotificationSent = true; $campaign->refresh(); if ($campaign->failed_count > 0 && $campaign->sent_count === 0) { @@ -259,18 +218,6 @@ class SendSms extends Page } } - protected function isCampaignComplete(): bool - { - if ($this->activeCampaignId === null) { - return true; - } - - return SmsCampaign::query() - ->whereKey($this->activeCampaignId) - ->whereNotNull('completed_at') - ->exists(); - } - protected function confirmationDescription(): string { $message = (string) ($this->data['message'] ?? ''); @@ -297,47 +244,6 @@ class SendSms extends Page ->count(); } - public function getCampaignProgressPercent(): int - { - if ($this->activeCampaignId === null) { - return 0; - } - - $campaign = SmsCampaign::query()->find($this->activeCampaignId); - - return $campaign?->progressPercent() ?? 0; - } - - public function getCampaignProgressLabel(): string - { - if ($this->activeCampaignId === null) { - return ''; - } - - $campaign = SmsCampaign::query()->find($this->activeCampaignId); - - if ($campaign === null) { - return ''; - } - - return __('filament.send_sms.progress.processed', [ - 'processed' => $campaign->processedCount(), - 'total' => $campaign->recipient_count, - 'sent' => $campaign->sent_count, - ]); - } - - /** - * @return array - */ - protected function getViewData(): array - { - return [ - 'campaignProgressPercent' => $this->getCampaignProgressPercent(), - 'campaignProgressLabel' => $this->getCampaignProgressLabel(), - ]; - } - /** * @return array */ diff --git a/lang/tk/filament.php b/lang/tk/filament.php index 3e45b7b..3ff284d 100644 --- a/lang/tk/filament.php +++ b/lang/tk/filament.php @@ -35,12 +35,7 @@ return [ 'send_confirm_heading' => 'SMS häzir ibermeli?', 'send_confirm_submit' => 'Iber', ], - 'progress' => [ - 'sending' => 'Habarlar iberilýär…', - 'processed' => ':processed / :total işlendi · :sent iberildi', - ], 'notifications' => [ - 'campaign_still_sending' => 'Kampaniýa entek iberilýär', 'no_valid_recipients' => 'Dogry alyjy ýok', 'no_valid_recipients_body' => 'Saýlawy ýa-da aýyrmalary üýtgediň — dogry telefon belgili kupon eýesi bu habary almaz.', 'queued' => 'SMS kampaniýasy nobata goýuldy', diff --git a/resources/views/filament/pages/send-sms.blade.php b/resources/views/filament/pages/send-sms.blade.php index d53d16b..a741733 100644 --- a/resources/views/filament/pages/send-sms.blade.php +++ b/resources/views/filament/pages/send-sms.blade.php @@ -1,25 +1,3 @@ - @if ($activeCampaignId) -
-
-

- {{ __('filament.send_sms.progress.sending') }} -

-

- {{ $campaignProgressLabel }} -

-
-
-
-
-
- @endif - {{ $this->content }}