@extends ('layouts.patient')

@section('inner-content')
    <div class="">
        <div class="d-flex align-items-center pb-2">
            <h4 class="font-weight-bold m-0">Handouts</h4>
            <span class="mx-2 text-secondary">|</span>
            <div moe>
                <a start show class="">Add</a>
                <form url="/api/handoutClient/create">
                    <input type="hidden" name="clientUid" value="{{ $patient->uid }}">
                    <div class="mb-2">
                        <select name="handoutUid" class="form-control form-control-sm">
                            <option value=""> --select--</option>
                            @foreach($handouts as $handout)
                                <option value="{{$handout->uid}}">
                                    {{$handout->display_name}}
                                </option>
                            @endforeach
                        </select>
                    </div>
                    <div class="d-flex align-items-center">
                        <button class="btn btn-sm btn-primary mr-2" submit>Save</button>
                        <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
                    </div>
                </form>
            </div>
        </div>
        <table class="table table-striped table-sm table-bordered m-0">
            <thead>
            <tr>
                <th class="px-2 text-secondary">Internal Name</th>
                <th class="px-2 text-secondary">Display Name</th>
                <th class="px-2 text-secondary">View</th>
                <th class="px-2 text-secondary w-50">Shareable Link</th>
            </tr>
            </thead>
            <tbody>
            @foreach($patient->handouts() as $handout)
                <?php $downloadLink = env('APP_URL') . "/guest/handout/{$handout->handout_client_uid}"; ?>
                <tr>
                    <td class="px-2">{{$handout->internal_name}}</td>
                    <td class="px-2">{{$handout->display_name}}</td>
                    <td class="px-2">
                        <a native href="{{ $downloadLink }}" target="_blank" class="pdf-viewer-trigger">
                            <i class="fa fa-eye mr-2"></i>View
                        </a>
                    </td>
                    <td class="px-2"><b>{{ $downloadLink }}</b></td>
                </tr>
            @endforeach
            </tbody>
        </table>
    </div>
@endsection
