@extends('pemerintah.main')

@section('content')
    <div class="container py-5 mt-5">
        <h2 class="mb-4">Edit Profile</h2>

        <div class="card">
            <div class="card-body">
                <form action="{{ route('profile.update', $data->id) }}" method="POST" enctype="multipart/form-data">
                    @csrf

                    <div class="row mb-3">
                        <div class="col-lg-6">
                            <div class="form-group">
                                <label for="role" class="form-label">Pilih Role<span
                                    style="color: red;">*</span></label>
                                <select id="role" name="role" class="form-control" required>
                                    <option value="">Pilih Role</option>
                                    <option value="pemerintah" {{ $data->role === 'pemerintah' ? 'selected' : '' }}>
                                        Pemerintah</option>
                                    <option value="umkm" {{ $data->role === 'umkm' ? 'selected' : '' }}>UMKM</option>
                                    <option value="investor" {{ $data->role === 'investor' ? 'selected' : '' }}>Investor
                                    </option>
                                    <option value="akademisi" {{ $data->role === 'akademisi' ? 'selected' : '' }}>Akademisi
                                    </option>
                                    <option value="komunitas" {{ $data->role === 'komunitas' ? 'selected' : '' }}>Komunitas
                                    </option>
                                </select>
                                @error('role')
                                    <span class="text-danger">{{ $message }}</span>
                                @enderror
                            </div>
                        </div>

                        {{-- <div class="col-lg-6">
                            <div class="form-group">
                                <label for="sub_sektor" class="form-label">Preferensi Sub Sektor</label>
                                <div id="sub_sektor">
                                    @php
                                        $subSectors = [
                                            'Aplikasi dan permainan',
                                            'Arsitektur',
                                            'Desain',
                                            'Film video dan animasi',
                                            'Fotografi',
                                            'Kriya',
                                            'Kuliner',
                                            'Mode',
                                            'Musik',
                                            'Penerbitan',
                                            'Periklanan',
                                            'Permainan rakyat',
                                            'Radio dan televisi',
                                            'Riset dan pengembangan',
                                            'Seni pertunjukan',
                                            'Seni rupa',
                                            'Software',
                                        ];

                                        // Assuming $data->sub_sektor contains the saved sub sectors as a comma-separated string
                                        $selectedSubSectors = explode(',', $data->sub_sektor ?? '');

                                    @endphp

                                    @foreach ($subSectors as $subSector)
                                        <div class="form-check">
                                            <input class="form-check-input" type="checkbox" name="sub_sektor[]"
                                                value="{{ $subSector }}" id="{{ str_replace(' ', '_', $subSector) }}"
                                                {{ in_array($subSector, $selectedSubSectors) ? 'checked' : '' }}>
                                            <label class="form-check-label" for="{{ str_replace(' ', '_', $subSector) }}">
                                                {{ $subSector }}
                                            </label>
                                        </div>
                                    @endforeach
                                </div>
                                @error('sub_sektor')
                                    <span class="text-danger">{{ $message }}</span>
                                @enderror
                            </div>
                        </div> --}}


                    </div>

                    <div class="form-group mb-3">
                        <label for="full_name">Nama Lengkap<span
                            style="color: red;">*</span></label>
                        <input type="text" name="full_name" class="form-control"
                            value="{{ old('full_name', $data->full_name) }}" required placeholder="Masukkan nama lengkap">
                    </div>

                    <div class="form-group mb-3">
                        <label for="nik">NIK</label>
                        <input type="text" name="nik" class="form-control" value="{{ old('nik', $data->nik) }}"
                            required placeholder="Masukkan NIK">
                    </div>

                    <div class="form-group mb-3">
                        <label for="birthdate">Tanggal Lahir<span
                            style="color: red;">*</span></label>
                        <input type="date" name="birthdate" class="form-control"
                            value="{{ old('birthdate', $data->birthdate) }}" required>
                    </div>

                    <div class="form-group mb-3">
                        <label for="address">Alamat<span
                            style="color: red;">*</span></label>
                        <textarea name="address" class="form-control" required placeholder="Masukkan alamat">{{ old('address', $data->address) }}</textarea>
                    </div>

                    <div class="form-group mb-3">
                        <label for="phone_number">Nomor Telepon<span
                            style="color: red;">*</span></label>
                        <input type="text" name="phone_number" class="form-control"
                            value="{{ old('phone_number', $data->phone_number) }}" required
                            placeholder="Masukkan nomor telepon">
                    </div>

                    <div class="form-group mb-3">
                        <label for="email">Email<span
                            style="color: red;">*</span></label>
                        <input type="email" name="email" class="form-control" value="{{ old('email', $data->email) }}"
                            required placeholder="Masukkan email">
                    </div>


                    <div class="form-group mb-3">
                        <label for="password" class="form-label">Kata Sandi<span
                            style="color: red;">*</span></label>
                        <input type="password" id="password" name="password" class="form-control"
                            placeholder="Masukkan kata sandi baru" value="{{ old('password') }}">
                        <small class="form-text text-muted">Jika tidak ingin mengubah kata sandi, biarkan kosong.</small>
                        @error('password')
                            <span class="text-danger">{{ $message }}</span>
                        @enderror
                    </div>

                    <div class="form-group mb-3">
                        <label for="password_confirmation" class="form-label">Konfirmasi Kata Sandi<span
                            style="color: red;">*</span></label>
                        <input type="password" id="password_confirmation" name="password_confirmation" class="form-control"
                            placeholder="Konfirmasi kata sandi baru" value="{{ old('password_confirmation') }}">
                        @error('password_confirmation')
                            <span class="text-danger">{{ $message }}</span>
                        @enderror
                    </div>



                    {{-- <div class="col-lg-6">
                        <div class="form-group mb-3">
                            <label for="foto" class="form-label">Foto</label>

                            <!-- Input for file upload -->
                            <input type="file" id="foto" name="foto" class="form-control">

                            <!-- Display the existing photo if available -->
                            @if ($relatedData && $relatedData->foto)
                                <div class="mb-2">
                                    <img src="{{ asset('storage/' . $relatedData->foto) }}" alt="Existing Foto"
                                        class="mt-2 max-w-xs rounded-md shadow-md">
                                </div>
                            @else
                                <p>Tidak ada foto yang tersedia untuk item ini.</p>
                            @endif

                            <!-- Error message for the file input -->
                            @error('foto')
                                <span class="text-danger">{{ $message }}</span>
                            @enderror
                        </div>
                    </div>

 --}}

                    <div class="col-lg-6">
                        <div class="form-group mb-3">
                            <label for="foto" class="form-label">Foto<span
                                style="color: red;">*</span></label>

                            <!-- Input untuk mengunggah file -->
                            <input type="file" id="foto" name="foto" class="form-control" accept=".jpeg, .jpg, .png">

                            <!-- Preview gambar setelah file dipilih -->
                            <div id="fotoPreviewContainer" class="mt-3" style="display: none;">
                                <h5>Preview Foto:</h5>
                                <img id="fotoPreview" style="width: 100%; height: auto;" alt="Preview Foto">
                            </div>

                            <!-- Tampilkan foto yang sudah ada (jika tersedia) -->
                            @if ($relatedData && $relatedData->foto)
                                <div class="mb-2">
                                    <h5>Foto Saat Ini:</h5>
                                    <img src="{{ asset('storage/' . $relatedData->foto) }}" alt="Existing Foto"
                                        class="mt-2 max-w-xs rounded-md shadow-md">
                                </div>
                            @else
                                <p>Tidak ada foto yang tersedia untuk item ini.</p>
                            @endif

                            <!-- Pesan error jika ada masalah pada input file -->
                            @error('foto')
                                <span class="text-danger">{{ $message }}</span>
                            @enderror
                        </div>
                    </div>

                    <script>
                        document.getElementById('foto').addEventListener('change', function(event) {
                            const file = event.target.files[0]; // Ambil file yang dipilih
                            const previewContainer = document.getElementById('fotoPreviewContainer');
                            const previewImage = document.getElementById('fotoPreview');

                            // Pastikan file adalah gambar (jpeg, png, atau jpg)
                            if (file && file.type.startsWith('image/')) {
                                const reader = new FileReader(); // Gunakan FileReader untuk membaca file

                                // Setelah file dibaca, tampilkan preview
                                reader.onload = function(e) {
                                    previewImage.src = e.target.result; // Set src ke hasil FileReader
                                    previewContainer.style.display = 'block'; // Tampilkan container preview
                                };

                                reader.readAsDataURL(file); // Membaca file gambar
                            } else {
                                previewContainer.style.display = 'none'; // Sembunyikan preview jika bukan gambar
                            }
                        });
                    </script>



                    @if ($data->role === 'pemerintah')
                        <h3>Detail Pemerintah</h3>
                        <div class="form-group mb-3">
                            <label for="institution_name">Nama Instansi<span
                                style="color: red;">*</span></label>
                            <input type="text" name="institution_name" class="form-control"
                                value="{{ old('institution_name', $relatedData->institution_name ?? '') }}" required>
                        </div>
                        <div class="form-group mb-3">
                            <label for="description_pemerintah">Deskripsi Pemerintah<span
                                style="color: red;">*</span></label>
                            <textarea name="description_pemerintah" class="form-control" required>{{ old('description_pemerintah', $relatedData->description_pemerintah ?? '') }}</textarea>
                        </div>
                    @elseif($data->role === 'umkm')
                        <h3>Detail UMKM</h3>
                        <div class="form-group mb-3">
                            <label for="umkm_name">Nama UMKM<span
                                style="color: red;">*</span></label>
                            <input type="text" name="umkm_name" class="form-control"
                                value="{{ old('umkm_name', $relatedData->umkm_name ?? '') }}" required>
                        </div>
                        <div class="form-group mb-3">
                            <label for="establishment_date_umkm">Tanggal Pendirian<span
                                style="color: red;">*</span></label>
                            <input type="date" name="establishment_date_umkm" class="form-control"
                                value="{{ old('establishment_date_umkm', $relatedData->establishment_date_umkm ?? '') }}"
                                required>
                        </div>
                        <div class="form-group mb-3">
                            <label for="description_umkm">Deskripsi<span
                                style="color: red;">*</span></label>
                            <textarea name="description_umkm" class="form-control" required>{{ old('description_umkm', $relatedData->description_umkm ?? '') }}</textarea>
                        </div>
                        <div class="form-group mb-3">
                            <label for="product">Produk<span
                                style="color: red;">*</span></label>
                            <input type="text" name="product" class="form-control"
                                value="{{ old('product', $relatedData->product ?? '') }}" required>
                        </div>
                        {{-- <div class="col-lg-6">
                            <div class="form-group mb-3">
                                <label for="laporan_keuangan" class="form-label">Laporan Keuangan</label>

                                <!-- Input untuk unggah file -->
                                <input type="file" id="laporan_keuangan" name="laporan_keuangan"
                                    class="form-control">

                                <!-- Menampilkan laporan keuangan yang sudah ada jika tersedia -->
                                @if ($relatedData && $relatedData->laporan_keuangan)
                                    <div class="mt-2">
                                        <a href="{{ asset('storage/' . $relatedData->laporan_keuangan) }}"
                                            download="{{ basename($relatedData->laporan_keuangan) }}"
                                            class="text-indigo-600 hover:underline">
                                            Unduh Laporan Keuangan
                                        </a>
                                    </div>
                                @else
                                    <p>Laporan keuangan belum tersedia.</p>
                                @endif

                                <!-- Pesan error untuk input file -->
                                @error('laporan_keuangan')
                                    <span class="text-danger">{{ $message }}</span>
                                @enderror
                            </div>
                        </div> --}}

                        <div class="col-lg-6">
                            <div class="form-group mb-3">
                                <label for="laporan_keuangan" class="form-label">Laporan Keuangan<span
                                    style="color: red;">*</span></label>

                                <!-- Input untuk unggah file -->
                                <input type="file" id="laporan_keuangan" name="laporan_keuangan"
                                    class="form-control" accept=".pdf">

                                <!-- Preview file PDF yang diunggah -->
                                <div id="pdfPreviewContainer" class="mt-3" style="display: none;">
                                    <h5>Preview Laporan Keuangan:</h5>
                                    <iframe id="pdfPreview" style="width: 100%; height: 500px;" frameborder="0"></iframe>
                                </div>

                                <!-- Menampilkan laporan keuangan yang sudah ada jika tersedia -->
                                @if ($relatedData && $relatedData->laporan_keuangan)
                                    <div class="mt-2">
                                        <a href="{{ asset('storage/' . $relatedData->laporan_keuangan) }}"
                                            download="{{ basename($relatedData->laporan_keuangan) }}"
                                            class="text-indigo-600 hover:underline">
                                            Unduh Laporan Keuangan
                                        </a>
                                    </div>
                                @else
                                    <p>Laporan keuangan belum tersedia.</p>
                                @endif

                                <!-- Pesan error untuk input file -->
                                @error('laporan_keuangan')
                                    <span class="text-danger">{{ $message }}</span>
                                @enderror
                            </div>
                        </div>
                        <script>
                            document.getElementById('laporan_keuangan').addEventListener('change', function(event) {
                                const file = event.target.files[0]; // Ambil file yang dipilih
                                const previewContainer = document.getElementById('pdfPreviewContainer');
                                const previewIframe = document.getElementById('pdfPreview');

                                // Menampilkan preview hanya jika file adalah PDF
                                if (file && file.type === 'application/pdf') {
                                    const reader = new FileReader();

                                    // Setelah file dibaca, tampilkan di iframe
                                    reader.onload = function(e) {
                                        previewIframe.src = e.target.result; // Tampilkan isi file dalam iframe
                                        previewContainer.style.display = 'block'; // Tampilkan container preview
                                    };

                                    reader.readAsDataURL(file); // Membaca file sebagai URL data
                                } else {
                                    previewContainer.style.display = 'none'; // Sembunyikan jika bukan PDF
                                }
                            });
                        </script>


                        <div class="form-group mb-3">
                            <label for="siup_number_umkm">Nomor NIB<span
                                style="color: red;">*</span></label>
                            <input type="text" name="siup_number_umkm" class="form-control"
                                value="{{ old('siup_number_umkm', $relatedData->siup_number_umkm ?? '') }}" required>
                        </div>
                        <div class="form-group mb-3">
                            <label for="profit_umkm" class="form-label">Kategori Pendapatan UMKM<span
                                style="color: red;">*</span></label>
                            <select id="profit_umkm" name="profit_umkm" class="form-control">
                                <option value="">Pilih Kategori Pendapatan<span
                                    style="color: red;">*</span></option>
                                <option value="< Rp 5 juta"
                                    {{ old('profit_umkm', $relatedData->profit_umkm) == '< Rp 5 juta' ? 'selected' : '' }}>
                                    < Rp 5 juta </option>
                                <option value="Rp 5 juta - Rp 10 juta"
                                    {{ old('profit_umkm', $relatedData->profit_umkm) == 'Rp 5 juta - Rp 10 juta' ? 'selected' : '' }}>
                                    Rp 5 juta - Rp 10 juta
                                </option>
                                <option value="Rp 10 juta - Rp 20 juta"
                                    {{ old('profit_umkm', $relatedData->profit_umkm) == 'Rp 10 juta - Rp 20 juta' ? 'selected' : '' }}>
                                    Rp 10 juta - Rp 20 juta
                                </option>
                                <option value="Rp 20 juta - Rp 50 juta"
                                    {{ old('profit_umkm', $relatedData->profit_umkm) == 'Rp 20 juta - Rp 50 juta' ? 'selected' : '' }}>
                                    Rp 20 juta - Rp 50 juta
                                </option>
                                <option value="> Rp 50 juta"
                                    {{ old('profit_umkm', $relatedData->profit_umkm) == '> Rp 50 juta' ? 'selected' : '' }}>
                                    > Rp 50 juta
                                </option>
                            </select>
                            @error('profit_umkm')
                                <span class="error text-danger">{{ $message }}</span>
                            @enderror
                        </div>
                        <br><br>

                        <div class="form-group mb-3">
                            <label for="pirt">Nomor PIRT</label>
                            <input type="text" name="pirt" class="form-control"
                                value="{{ old('pirt', $relatedData->pirt ?? '') }}" required>
                        </div>
                        <!-- Input untuk Sertifikat Halal MUI -->
                        <div class="col-lg-6">
                            <div class="form-group mb-3">
                                <label for="sertifikat_halal_mui" class="form-label">Sertifikat Halal MUI</label>

                                <!-- Input untuk unggah file -->
                                <input type="file" id="sertifikat_halal_mui" name="sertifikat_halal_mui"
                                    class="form-control" accept=".pdf">

                                <!-- Preview file PDF yang diunggah -->
                                <div id="pdfPreviewContainerHalalMUI" class="mt-3" style="display: none;">
                                    <h5>Preview Sertifikat Halal MUI:</h5>
                                    <iframe id="pdfPreviewHalalMUI" style="width: 100%; height: 500px;"
                                        frameborder="0"></iframe>
                                </div>

                                <!-- Menampilkan sertifikat halal MUI yang sudah ada jika tersedia -->
                                @if ($relatedData && $relatedData->sertifikat_halal_mui)
                                    <div class="mt-2">
                                        <a href="{{ asset('storage/' . $relatedData->sertifikat_halal_mui) }}"
                                            download="{{ basename($relatedData->sertifikat_halal_mui) }}"
                                            class="text-indigo-600 hover:underline">
                                            Unduh Sertifikat Halal MUI
                                        </a>
                                    </div>
                                @else
                                    <p>Sertifikat Halal MUI belum tersedia.</p>
                                @endif

                                <!-- Pesan error untuk input file -->
                                @error('sertifikat_halal_mui')
                                    <span class="text-danger">{{ $message }}</span>
                                @enderror
                            </div>
                        </div>

                        <!-- Script untuk menampilkan preview PDF -->
                        <script>
                            document.getElementById('sertifikat_halal_mui').addEventListener('change', function(event) {
                                const file = event.target.files[0]; // Ambil file yang dipilih
                                const previewContainer = document.getElementById('pdfPreviewContainerHalalMUI');
                                const previewIframe = document.getElementById('pdfPreviewHalalMUI');

                                // Menampilkan preview hanya jika file adalah PDF
                                if (file && file.type === 'application/pdf') {
                                    const reader = new FileReader();

                                    // Setelah file dibaca, tampilkan di iframe
                                    reader.onload = function(e) {
                                        previewIframe.src = e.target.result; // Tampilkan isi file dalam iframe
                                        previewContainer.style.display = 'block'; // Tampilkan container preview
                                    };

                                    reader.readAsDataURL(file); // Membaca file sebagai URL data
                                } else {
                                    previewContainer.style.display = 'none'; // Sembunyikan jika bukan PDF
                                }
                            });
                        </script>

                        <div class="form-group mb-3">
                            <label for="bpom">Nomor BPOM</label>
                            <input type="text" name="bpom" class="form-control"
                                value="{{ old('bpom', $relatedData->bpom ?? '') }}" required>
                        </div>
                    @elseif($data->role === 'investor')
                        <h3>Detail Investor</h3>
                        <div class="row mb-3">
                            <div class="form-group mb-3">
                                <label for="category" class="form-label">Kategori<span
                                    style="color: red;">*</span></label>
                                <select name="category" class="form-control" required>
                                    <option value="personal"
                                        {{ old('category', $relatedData->category ?? '') === 'personal' ? 'selected' : '' }}>
                                        Personal</option>
                                    <option value="perusahaan"
                                        {{ old('category', $relatedData->category ?? '') === 'perusahaan' ? 'selected' : '' }}>
                                        Perusahaan</option>
                                </select>
                            </div>
                        </div>
                        @if ($relatedData->category === 'personal')
                            <div class="form-group mb-3">
                                <label for="npwp_number_inves_personal">Nomor NPWP<span
                                    style="color: red;">*</span></label>
                                <input type="text" name="npwp_number_inves_personal" class="form-control"
                                    value="{{ old('npwp_number_inves_personal', $relatedData->personalDetails->npwp_number_inves_personal ?? '') }}"
                                    required>
                            </div>
                            <div class="form-group mb-3">
                                <label for="job">Pekerjaan<span
                                    style="color: red;">*</span></label>
                                <input type="text" name="job" class="form-control"
                                    value="{{ old('job', $relatedData->personalDetails->job ?? '') }}">
                            </div>
                            <div class="form-group mb-3">
                                <label for="total_assets">Total Aset(Rp)<span
                                    style="color: red;">*</span></label>
                                <input type="number" name="total_assets" class="form-control" step="0.01"
                                    value="{{ old('total_assets', $relatedData->personalDetails->total_assets ?? '') }}">
                            </div>
                            <div class="form-group mb-3">
                                <label for="profit_inves_personal">Profit(Rp Per Bulan)<span
                                    style="color: red;">*</span></label>
                                <input type="number" name="profit_inves_personal" class="form-control" step="0.01"
                                    value="{{ old('profit_inves_personal', $relatedData->personalDetails->profit_inves_personal ?? '') }}">
                            </div>
                        @elseif ($relatedData->category === 'perusahaan')
                            <div class="form-group mb-3">
                                <label for="company_name">Nama Perusahaan<span
                                    style="color: red;">*</span></label>
                                <input type="text" name="company_name" class="form-control"
                                    value="{{ old('company_name', $relatedData->perusahaanDetails->company_name ?? '') }}"
                                    required>
                            </div>
                            <div class="form-group mb-3">
                                <label for="npwp_number_inves_perusahaan">Nomor NPWP<span
                                    style="color: red;">*</span></label>
                                <input type="text" name="npwp_number_inves_perusahaan" class="form-control"
                                    value="{{ old('npwp_number_inves_perusahaan', $relatedData->perusahaanDetails->npwp_number_inves_perusahaan ?? '') }}"
                                    required>
                            </div>
                            <div class="form-group mb-3">
                                <label for="siup_number_inves_perusahaan">Nomor SIUP<span
                                    style="color: red;">*</span></label>
                                <input type="text" name="siup_number_inves_perusahaan" class="form-control"
                                    value="{{ old('siup_number_inves_perusahaan', $relatedData->perusahaanDetails->siup_number_inves_perusahaan ?? '') }}"
                                    required>
                            </div>
                            <div class="form-group mb-3">
                                <label for="nib_number">Nomor NIB<span
                                    style="color: red;">*</span></label>
                                <input type="text" name="nib_number" class="form-control"
                                    value="{{ old('nib_number', $relatedData->perusahaanDetails->nib_number ?? '') }}"
                                    required>
                            </div>
                            <div class="form-group mb-3">
                                <label for="establishment_date_inves_perusahaan">Tanggal Pendirian<span
                                    style="color: red;">*</span></label>
                                <input type="date" name="establishment_date_inves_perusahaan" class="form-control"
                                    value="{{ old('establishment_date_inves_perusahaan', $relatedData->perusahaanDetails->establishment_date_inves_perusahaan ?? '') }}">
                            </div>
                            <div class="form-group mb-3">
                                <label for="description_inves_perusahaan">Deskripsi<span
                                    style="color: red;">*</span></label>
                                <textarea name="description_inves_perusahaan" class="form-control">{{ old('description_inves_perusahaan', $relatedData->perusahaanDetails->description_inves_perusahaan ?? '') }}</textarea>
                            </div>
                            <div class="form-group mb-3">
                                <label for="profit_inves_perusahaan">Profit<span
                                    style="color: red;">*</span></label>
                                <input type="number" name="profit_inves_perusahaan" class="form-control" step="0.01"
                                    value="{{ old('profit_inves_perusahaan', $relatedData->perusahaanDetails->profit_inves_perusahaan ?? '') }}">
                            </div>
                        @endif
                    @elseif($data->role === 'akademisi')
                        <h3>Detail Akademisi</h3>
                        <div class="form-group mb-3">
                            <label for="university_name">Nama Instansi<span
                                style="color: red;">*</span></label>
                            <input type="text" name="university_name" class="form-control"
                                value="{{ old('university_name', $relatedData->university_name ?? '') }}" required>
                        </div>
                        <div class="form-group mb-3">
                            <label for="description_akademisi">Deskripsi<span
                                style="color: red;">*</span></label>
                            <textarea name="description_akademisi" class="form-control" required>{{ old('description_akademisi', $relatedData->description_akademisi ?? '') }}</textarea>
                        </div>
                        <div class="form-group mb-3">
                            <label for="faculty">Fakultas<span
                                style="color: red;">*</span></label>
                            <input type="text" name="faculty" class="form-control"
                                value="{{ old('faculty', $relatedData->faculty ?? '') }}" required>
                        </div>
                        <div class="form-group mb-3">
                            <label for="study_program">Program Studi<span
                                style="color: red;">*</span></label>
                            <input type="text" name="study_program" class="form-control"
                                value="{{ old('study_program', $relatedData->study_program ?? '') }}" required>
                        </div>
                        <div class="form-group mb-3">
                            <label for="expertise_field">Bidang Keahlian<span
                                style="color: red;">*</span></label>
                            <input type="text" name="expertise_field" class="form-control"
                                value="{{ old('expertise_field', $relatedData->expertise_field ?? '') }}" required>
                        </div>
                    @elseif($data->role === 'komunitas')
                        <h3>Detail Komunitas</h3>
                        <div class="form-group mb-3">
                            <label for="community_name">Nama Komunitas<span
                                style="color: red;">*</span></label>
                            <input type="text" name="community_name" class="form-control"
                                value="{{ old('community_name', $relatedData->community_name ?? '') }}" required>
                        </div>
                        <div class="form-group mb-3">
                            <label for="establishment_date_komunitas">Tanggal Pendirian<span
                                style="color: red;">*</span></label>
                            <input type="date" name="establishment_date_komunitas" class="form-control"
                                value="{{ old('establishment_date_komunitas', $relatedData->establishment_date_komunitas) }}"
                                required>
                        </div>
                        <div class="form-group mb-3">
                            <label for="description_komunitas">Deskripsi<span
                                style="color: red;">*</span></label>
                            <textarea name="description_komunitas" class="form-control" required>{{ old('description_komunitas', $relatedData->description_komunitas ?? '') }}</textarea>
                        </div>
                        <div class="form-group mb-3">
                            <label for="community_license">Lisensi Komunitas<span
                                style="color: red;">*</span></label>
                            <input type="text" name="community_license" class="form-control"
                                value="{{ old('community_license', $relatedData->community_license ?? '') }}">
                        </div>
                    @endif
                    {{-- 
                    <div class="form-group text-center">
                        <button type="submit" class="btn btn-primary">Update Profile</button>
                        <a href="{{ route('profile.show') }}" class="btn btn-secondary">Back</a>
                    </div> --}}

                    <div class="form-group text-center">
                        <button type="submit" class="btn btn-primary mt-2 w-100 w-md-auto">Update Profile</button>
                        <a href="{{ route('profile.show') }}" class="btn btn-secondary mt-2 w-100 w-md-auto">Back</a>
                    </div>



                </form>
            </div>
        </div>
    </div>
@endsection
