fix: remove livewire legacy from help view

This commit is contained in:
Andras Bacsai
2024-11-03 21:27:26 +01:00
parent c211227141
commit 8c9989136b
4 changed files with 17 additions and 30 deletions

View File

@@ -5,55 +5,39 @@ namespace App\Livewire;
use DanHarrin\LivewireRateLimiting\WithRateLimiting;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Route;
use Livewire\Attributes\Rule;
use Livewire\Component;
class Help extends Component
{
use WithRateLimiting;
#[Rule(['required', 'min:10', 'max:1000'])]
public string $description;
#[Rule(['required', 'min:3'])]
public string $subject;
public ?string $path = null;
protected $rules = [
'description' => 'required|min:10',
'subject' => 'required|min:3',
];
public function mount()
{
$this->path = Route::current()?->uri() ?? null;
if (isDev()) {
$this->description = "I'm having trouble with {$this->path}";
$this->subject = "Help with {$this->path}";
}
}
public function submit()
{
try {
$this->rateLimit(3, 30);
$this->validate();
$debug = "Route: {$this->path}";
$this->rateLimit(3, 30);
$settings = instanceSettings();
$mail = new MailMessage;
$mail->view(
'emails.help',
[
'description' => $this->description,
'debug' => $debug,
]
);
$mail->subject("[HELP]: {$this->subject}");
$settings = instanceSettings();
$type = set_transanctional_email_settings($settings);
if (! $type) {
// Sending feedback through Cloud API
if ($type === false) {
$url = 'https://app.coolify.io/api/feedback';
if (isDev()) {
$url = 'http://localhost:80/api/feedback';
}
Http::post($url, [
'content' => 'User: `'.auth()->user()?->email.'` with subject: `'.$this->subject.'` has the following problem: `'.$this->description.'`',
]);