<h5 class="title pb-3">@lang('profile.financial_information.edit.title')</h5>

@php 
    $financeData = $finance ?? ($dealer->finances[0] ?? null); 
@endphp

<form action="{{ route('dealers.profile.financial.update', $financeData ? $financeData->id : 0) }}" method="post" async-form on-async-modal data-event="profile.updated">
    @csrf
    @method('put')

    <div class="row gy-4">
        <div class="col-md-4">
            <div class="form-group">
                <label class="form-label">Bank Name <span class="text-danger">*</span><</label>
                <div class="form-control-wrap">
                    <input type="text" name="bank_name" class="form-control form-control-lg" value="{{ old('bank_name', optional($financeData)->name) }}">
                    <span class="invalid-feedback" role="alert" style="display: none;"></span>
                </div>
            </div>
        </div>

        <div class="col-md-4">
            <div class="form-group">
                <label class="form-label">Account Holder <span class="text-danger">*</span></label>
                <div class="form-control-wrap">
                    <input type="text" name="account_holder_name" class="form-control form-control-lg"
                        value="{{ old('account_holder_name', optional($financeData)->account_holder_name) }}">
                    <span class="invalid-feedback" role="alert" style="display: none;"></span>
                </div>
            </div>
        </div>

        <div class="col-md-4">
            <div class="form-group">
                <label class="form-label">Account Number <span class="text-danger">*</span><</label>
                <div class="form-control-wrap">
                    <input type="text" name="account_number" class="form-control form-control-lg" value="{{ old('account_number', optional($financeData)->account_number) }}">
                    <span class="invalid-feedback" role="alert" style="display: none;"></span>
                </div>
            </div>
        </div>

        <div class="col-12">
            <ul class="align-center flex-wrap flex-sm-nowrap gx-4 gy-2">
                <li><button type="submit" class="btn btn-lg btn-primary">@lang('global.form.button.save')</button></li>
                <li><button type="button" class="btn btn-lg btn-outline-danger" async-modal-close>@lang('global.form.button.cancel')</button></li>
            </ul>
        </div>
    </div>
</form>
