feat: add helper, clean up code, remove test route

This commit is contained in:
llama committed 2023-10-26 20:14:05 +11:00
1 parent c963982bfb
commit f4f7373272
6 files changed
+56 -35

No files matched your search

@@ -1,5 +1,6 @@
<?php
use App\Helpers\Slack;
use App\Models\Log;
use Illuminate\Support\Facades\Http;
use Livewire\Attributes\Layout;
@@ -15,12 +16,9 @@ new #[Layout('layouts.app')] class extends Component
{
$validated = $this->validate();
// TODO: move this to a helper class so we can reuse code between API and FE
$response = Http::post(config('bot.webhook'), ['text' => $validated['quote']]);
$slack = new Slack();
activity()
->event('send')
->log("Manually sent quote: {$validated['quote']}");
$slack->sendText($validated['quote']);
$this->quote = '';
}
@@ -20,7 +20,6 @@ new #[Layout('layouts.guest')] class extends Component
$this->authorize('request', $quote);
$quote->request();
// TODO: add code to send a notification
}
public function delete(Quote $quote): void
@@ -64,9 +63,12 @@ new #[Layout('layouts.guest')] class extends Component
@if(auth()->user())
<td class="relative w-8 pl-4 pr-3 text-sm sm:pl-6 border-t">
<div class="flex flex-row space-x-2">
@if(auth()->user()->is_admin)
{{-- For now this is admin only, when we add credits we can make it avaliable to users --}}
<form wire:submit="request({{ $quote }})">
<x-button wire:loading.attr="disabled" wire:loading.class="opacity-50" class="bg-nexi-purple w-24">{{ __('Request') }}</x-button>
</form>
@endif
@if(auth()->user()->is_admin)
<x-button
x-data=""