@extends ('layouts/template')

@section('content')

    <div class="p-3 mcp-theme-1">
    <div class="card">

        <div class="card-header px-3 py-2 d-flex align-items-center">
            <strong class="">
                <i class="fas fa-user-injured"></i>
                Favorites
            </strong>
            <span class="ml-3 text-secondary">
                You can add Allergy, Rx and Dx items to favorites from the respective sections
            </span>
            <select class="ml-auto max-width-300px form-control form-control-sm"
                    onchange="fastLoad('/practice-management/my-favorites/' + this.value, true, false, false)">
                <option value="allergies" {{ $filter === 'allergies' ? 'selected' : '' }}>Allergies</option>
                <option value="rx" {{ $filter === 'rx' ? 'selected' : '' }}>Rx</option>
                <option value="dx" {{ $filter === 'dx' ? 'selected' : '' }}>Dx</option>
                <option value="all" {{ $filter === 'all' ? 'selected' : '' }}>All favorites</option>
            </select>
        </div>
        <div class="card-body p-0">
            <table class="table table-sm table-condensed p-0 m-0">
                <thead class="bg-light">
                <tr>
                    <th class="px-3 border-0 width-100px">Category</th>
                    <th class="border-0">Content</th>
                    <th class="border-0 w-25">&nbsp;</th>
                </tr>
                </thead>
                <tbody>
                @foreach($myFavorites as $favorite)
                    <tr>
                        <td class="px-3">{{ ucwords($favorite->category) }}</td>
                        <td>
                            <?php $parsed = json_decode($favorite->data); ?>
                            {{ $parsed->title }}
                        </td>
                        <td>
                            <div class="d-flex align-items-center">
                                <div moe relative wide class="mr-2">
                                    <a start show class="text-danger">
                                        <i class="fa fa-trash-alt"></i>
                                    </a>
                                    <form url="/api/proFavorite/remove" right>
                                        <input type="hidden" name="uid" value="{{$favorite->uid}}">
                                        <p>
                                            Are you sure you want to remove this from your favorites?
                                        </p>
                                        <div class="form-group m-0">
                                            <button submit class="btn btn-danger btn-sm mr-2">Yes</button>
                                            <button cancel class="btn btn-default border btn-sm mr-2">No</button>
                                        </div>
                                    </form>
                                </div>
                            </div>
                        </td>
                    </tr>
                @endforeach
                </tbody>
            </table>
        </div>
    </div>
    </div>

@endsection
