@extends('layouts.master')

@section('title')
    Dashboard
@endsection

@section('header')
<div class="page-title">
    <h3>Dashboard</h3>
</div>
@endsection

@section('contents')
    <!-- start page title -->
    <div class="page-title-box">
        <div class="row align-items-center">
            <div class="col-md-8">
                <h6 class="page-title">{!! $title !!}</h6>
                <ol class="breadcrumb m-0">
                    <li class="breadcrumb-item">Mahasiswa</li>
                    <li class="breadcrumb-item">{!! $title !!}</li>
                </ol>
            </div>
        </div>

    </div>
    <!-- end page title -->

    <div class="row">
        <div class="col-xl-4 col-md-6">
            <div class="card directory-card">
                <div class="card-body">
                    <div class="d-flex">
                        <div class="flex-shrink-0">
                            @if (is_null($biodata->noidentitas))
                                <img src="{{ asset('theme/images/users/user-null.jpg') }}" alt="" class="img-fluid img-thumbnail rounded-circle avatar-lg">
                            @else
                                @if (Auth::user()->roles->first()->name != 'mahasiswa')
                                <img src="https://siakadu.unesa.ac.id/photo/fotomhs/{{ $biodata->noidentitas }}.jpg" alt="" class="img-fluid img-thumbnail rounded-circle avatar-lg">
                                @else
                                <img src="https://siakadu.unesa.ac.id/photo/{{ $biodata->noidentitas }}.jpg" alt="" class="img-fluid img-thumbnail rounded-circle avatar-lg">
                                @endif
                                </div>
                            @endif

                        <div class="flex-grow-1 ms-3">
                            <h5 class="text-primary font-size-18 mb-1">{{ $biodata->name }}</h5>
                            <p class="font-size-12 mb-2">{{ $biodata->noidentitas }}</p>
                            <p class="mb-0">{{ $biodata->email }}</p>
                        </div>
                      </div>
                      <hr>
                    <p class="mb-0"><b>Fakultas : </b> {{ $biodata->fakultas }}</p>
                    <p class="mb-0"><b>Program Studi : </b> {{ $biodata->prodi }} </p>
                </div>
            </div>
        </div>
    </div>

@endsection

@section('js')
<script>
    function hapus(id, rowId){
        Swal.fire({
            title: 'Apakah anda yakin untuk menghapus Kelompok?',
            text: "Semua anggota kelompok juga akan terhapus",
            icon: 'warning',
            showCancelButton: true,
            confirmButtonText: 'OK',
        }).then((result) => {
            if (result.isConfirmed) {
                var token = '{{ csrf_token() }}';
                var request = $.ajax({
                    url: '{{ route('mahasiswa.kelompok.hapus') }}',
                    type: 'POST',
                    dataType: 'html',
                    data: {id:id, _token:token},
                    success: function(data){
                        Swal.fire({
                            title: 'Data Berhasil Di Hapus',
                            icon: 'success',
                            showConfirmButton: false,
                            timer: 1500
                        });

                        $('#'+rowId).remove();
                    },
                    error: function(xhr, status, error){
                        Swal.fire({
                            position: 'top-end',
                            icon: 'error',
                            title: xhr.responseText,
                            showConfirmButton: false,
                            timer: 3500
                        });
                    }
                });
            }
        })
    }
</script>
@endsection
