<?php

namespace App\Livewire\Homepage;

use Livewire\Component;

class Kontakt extends Component
{
    public string $name = '';
    public string $email = '';
    public string $betreff = '';
    public string $nachricht = '';
    public bool $sent = false;

    protected array $rules = [
        'name'       => 'required|min:2|max:100',
        'email'      => 'required|email|max:255',
        'betreff'    => 'required|min:3|max:200',
        'nachricht'  => 'required|min:10|max:5000',
    ];

    public function send()
    {
        $this->validate();

        // TODO: Mail senden oder in DB speichern
        $this->sent = true;
        $this->reset(['name', 'email', 'betreff', 'nachricht']);
    }

    public function render()
    {
        return view('livewire.homepage.kontakt')
            ->layout('layouts.blank');
    }
}
