<?php

use Livewire\Component;
use App\Models\Inquiry;

return new class extends Component
{
    public Inquiry $inquiry;
    public $reply = '';

    public function render()
    {
        return $this->view()->layout('layouts::auth');
    }

    public function mount(Inquiry $inquiry)
    {
        $this->inquiry = $inquiry;
    }

    public function archive()
    {
        $this->inquiry->update(['status' => 'archived']);
        session()->flash('message', 'Inquiry archived.');
        return $this->redirect(route('admin.inquiries'), navigate: true);
    }

    public function markAsReplied()
    {
        $this->inquiry->update(['status' => 'replied']);
        session()->flash('message', 'Inquiry marked as replied.');
    }

    public function sendResponse()
    {
        $this->validate([
            'reply' => 'required|min:10',
        ]);

        // In a real app, you'd send an email here
        $this->inquiry->update(['status' => 'replied']);

        session()->flash('message', 'Response sent successfully.');
        $this->reset('reply');
    }

    protected function view($data = [])
    {
        return app('view')->file('D:\02-my freelance\00-DR_Padhi\DR_PADHI\storage\framework/views/livewire/views/8a531536.blade.php', $data);
    }
};
