<?php

namespace App\Livewire\Search;

use Livewire\Attributes\On;
use Livewire\Component;

class Tableresult extends Component
{

    public $humans='';

    protected $human=[];
    public $records_not_found=[];
    public $search_count=0;
    public $records_found= [];

    protected $listeners = ['viewResults'];
    public $doc_num='';
    public $serial_number='';
    public $doctype='';

    public function mount($humans = null, $serial_number=null,$doctype=null,$search_count=null)
    {
        $this->humans=$humans;
        $this->serial_number = $serial_number;
        $this->search_count = $search_count;
        $this->doctype =$doctype;
    }

    //triggered when search results are returned
    #[On('viewResults')]
    public function viewResults($humans=null,$serial_number=null,$doctype=null,$records_not_found=null,$search_count=null,$records_found=null)
    {
        $this->humans = $humans;
        $this->serial_number = $serial_number;
        $this->records_not_found = $records_not_found;
        $this->search_count = $search_count;
        $this->records_found = $records_found;
        $this->doctype = $doctype;
    }
    public function triggerResultsModal($doc_num,$serial,$doctype)
    {
       $this->dispatch('openModal', $doc_num,$serial,$doctype);
    }

    //passport logic
    public function passportresultsModal($id,$pass_no,$doctype)
    {
        $this->dispatch('openPassportModal', ['id'=>$id,'pass_no'=>$pass_no,'doctype'=>$doctype]);
    }

    public function render()
    {
        return view('livewire.search.tableresult');
    }
   /* public function placeholder()
    {
        return <<<'HTML'
        <div>
            loading jjj...
        </div>
        HTML;
    }*/
}
