<?php
$nama = $nama ?? '';
$email = $email ?? '';
$jabatan = $jabatan ?? '';
$no_hp = $no_hp ?? '';
$perusahaan = $perusahaan ?? '';
$foto = $foto ?? null;
?>

<?php require __DIR__ . '/../layout/header.php'; ?>
<?php require __DIR__ . '/../layout/sidebar.php'; ?>

<div class="main">

    <div class="header">Profil Member</div>

    <div class="card">

        <form action="/membership/profile-update" method="POST">

            <!-- FOTO -->
            <div class="form-group text-center">

                <img id="imagePreview"
                 src="<?= !empty($foto) 
                    ? '/membership/public/assets/uploads/'.$foto.'?v='.time()
                    : 'https://ui-avatars.com/api/?name='.urlencode($nama) ?>"
                 class="profile-img">

                <br><br>

                <input type="file" id="inputImage" accept="image/*">

                <!-- hasil crop -->
                <input type="hidden" name="cropped_image" id="croppedImage">

            </div>

            <!-- FORM -->
            <div class="grid">

                <div class="form-group">
                    <label>Nama</label>
                    <input type="text" name="nama" value="<?= $nama ?>" required>
                </div>

                <div class="form-group">
                    <label>Email</label>
                    <input type="text" value="<?= $email ?>" disabled>
                </div>

                <div class="form-group">
                    <label>Jabatan</label>
                    <input type="text" name="jabatan" value="<?= $jabatan ?>">
                </div>

                <div class="form-group">
                    <label>No HP</label>
                    <input type="text" name="no_hp" value="<?= $no_hp ?>">
                </div>

                <div class="form-group" style="grid-column: span 2;">
                    <label>Perusahaan</label>
                    <input type="text" name="perusahaan" value="<?= $perusahaan ?>">
                </div>

            </div>

            <br>

            <button class="btn btn-primary">Simpan Perubahan</button>

        </form>

    </div>

</div>

<?php require __DIR__ . '/../layout/footer.php'; ?>