@extends('back-end.master.app')
@section('title', 'donners')
@section('body')
    <main class="app-content">
        <div class="card">
            <div class="card-header">
                <h4>donners</h4>
                @if ($errors->any())
                    @foreach ($errors->all() as $error)
                        <div>{{ $error }}</div>
                    @endforeach
                @endif
            </div>
            <div class="card-body">
                <form action="{{ route('dp.update',$data->id) }}" method="post" enctype="multipart/form-data">
                    @method('PUT')
                    @csrf
                    <div class="row">
                        <div class="col-md-9">
                            <div class="form-outline">
                                <input type="test" id="name" name="name" required value="{{ old('name') ?? $data->name }}"
                                    class="form-control" />
                                <label class="form-label" for="name">Name</label>
                            </div>
                        </div>
                        <div class="col-md-3">
                            <div class="form-outline">
                                <input type="test" id="amount" name="amount" required value="{{ old('amount') ?? $data->amount }}"
                                    class="form-control" />
                                <label class="form-label" for="amount">Amount</label>
                            </div>
                        </div>


                        <div class="col-md-9 mt-2">
                            <select id="type_id" type="text"
                                class="form-control select2 @error('type_id') is-invalid @enderror" required
                                name="type_id">
                                <option value="">Choose Type</option>
                                <option value="1" @if($data->type_id==1) {{ "selected" }} @endif>As Donner</option>
                                <option value="2" @if($data->type_id==2) {{ "selected" }} @endif>As Team Member</option>
                            </select>
                            @error('type_id')
                                <span class="invalid-feedback" role="alert">
                                    <strong>{{ $message }}</strong>
                                </span>
                            @enderror
                        </div>
                        <div class="col-md-3 mt-3">
                            <div class="form-outline">
                                <input type="file" id="image" name="image"  value="{{ old('image') }}"
                                    class="form-control" />
                            </div>
                        </div>

                        <div class="col-md-12 mt-3">
                            <div class="form-outline">
                                <input type="text" id="phone" name="phone" required value="{{ old('phone') ?? $data->phone }}"
                                    class="form-control" />
                                <label class="form-label" for="phone">Phone Number</label>
                            </div>
                        </div>
                        <div class="col-md-12 mt-3">
                            <div class="form-outline">
                                <input type="text" id="address" name="address" required value="{{ old('address') ?? $data->address }}"
                                    class="form-control" />
                                <label class="form-label" for="address">Address</label>
                            </div>
                        </div>
                        <div class="col-md-12 mt-3">
                            <div class="form-outline">
                                <input type="text" id="email" name="email" required value="{{ old('email') ?? $data->email }}"
                                    class="form-control" />
                                <label class="form-label" for="email">Email Address</label>
                            </div>
                        </div>
                        <div class="col-md-12 mt-3">
                            <div class="form-outline">
                                <input type="text" id="x_url" name="x_url" required value="{{ old('x_url') ?? $data->x_url}}"
                                    class="form-control" />
                                <label class="form-label" for="x_url">X URL</label>
                            </div>
                        </div>
                        <div class="col-md-12 mt-3">
                            <div class="form-outline">
                                <input type="text" id="facebook_url" name="facebook_url" required
                                    value="{{ old('facebook_url') ?? $data->facebook_url }}" class="form-control" />
                                <label class="form-label" for="facebook_url">Facebook URL</label>
                            </div>
                        </div>
                        <div class="col-md-12 mt-3">
                            <div class="form-outline">
                                <input type="text" id="instegram_url" name="instegram_url" required
                                    value="{{ old('instegram_url') ?? $data->instegram_url }}" class="form-control" />
                                <label class="form-label" for="instegram_url">Instegram URL</label>
                            </div>
                        </div>
                        <div class="col-md-12 mt-3">
                            <div class="form-outline">
                                <textarea cols="30" rows="10" id="bio" name="bio" required class="form-control">{{ old('bio') ?? $data->details }}</textarea>
                                <label class="form-label" for="bio">Biography</label>
                            </div>
                        </div>
                        <div class="col-md-4 mt-2">
                            <button type="submit" class="btn btn-primary btn-rounded mb-4">Save</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </main>
@endsection
@section('pageJs')
    <script type="text/javascript">
        $(".app-menu").removeClass("active");
        $("#nav_donnersi").addClass("active");
        $("#donnersi").addClass("is-expanded");
        $("#donners_history").addClass("active");
    </script>
@endsection
