 
<?php $__env->startSection('title', 'Edit Produk'); ?> 
<?php $__env->startSection('content'); ?>

<div class="container">
    <form method="POST" action="<?php echo e(route('products.update', $product->id)); ?>" enctype="multipart/form-data">
        <?php echo csrf_field(); ?>
        <?php echo method_field('PUT'); ?>

        <input type="hidden" name="remove_image" id="remove_image" value="0">

        <div class="d-flex justify-content-between align-items-start flex-lg-row flex-column">

            <div class="text-center p-4 pt-0 d-flex flex-column">
                <label for="image" class="upload-box d-flex flex-column align-items-center justify-content-center" style="min-height:220px;">
                    <div id="image-preview" class="d-flex align-items-center justify-content-center w-100 h-100">
                        <?php if($product->image): ?>
                            <img id="preview-img" src="<?php echo e(asset($product->image)); ?>" style="display:block; max-width:200px;">
                            <div id="image-instruction" class="text-muted" style="display:none;">Upload Foto</div>
                        <?php else: ?>
                            <div id="image-instruction" class="text-muted">Upload Foto</div>
                        <?php endif; ?>
                    </div>

                    <img id="preview-img-new" src="#" style="display:none; max-width:200px;">
                    <div id="file-name-new"></div>
                </label>

                <input 
                    type="file" 
                    name="image" 
                    id="image" 
                    class="d-none" 
                    accept="image/*"
                    onchange="previewImage(event)"
                >

                <button type="button" id="remove-image-btn"
                    class="btn btn-outline-danger remove-btn mt-2"
                    style="<?php echo e($product->image ? 'display:inline-block;' : 'display:none;'); ?>"
                    onclick="removeImage()"
                >
                    Remove File
                </button>
            </div>

            <div class="w-100">

                <?php if (isset($component)) { $__componentOriginal262894a2c291df91ae9f7b925bf8a923 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal262894a2c291df91ae9f7b925bf8a923 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.input-text','data' => ['inRowLabel' => 'Nama Produk','name' => 'name','required' => true,'placeholder' => 'Masukkan nama produk','value' => old('name', $product->name),'errorMessage' => $errors->first('name')]] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('input-text'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['inRowLabel' => 'Nama Produk','name' => 'name','required' => true,'placeholder' => 'Masukkan nama produk','value' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute(old('name', $product->name)),'errorMessage' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute($errors->first('name'))]); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal262894a2c291df91ae9f7b925bf8a923)): ?>
<?php $attributes = $__attributesOriginal262894a2c291df91ae9f7b925bf8a923; ?>
<?php unset($__attributesOriginal262894a2c291df91ae9f7b925bf8a923); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal262894a2c291df91ae9f7b925bf8a923)): ?>
<?php $component = $__componentOriginal262894a2c291df91ae9f7b925bf8a923; ?>
<?php unset($__componentOriginal262894a2c291df91ae9f7b925bf8a923); ?>
<?php endif; ?>

                <?php if (isset($component)) { $__componentOriginal262894a2c291df91ae9f7b925bf8a923 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal262894a2c291df91ae9f7b925bf8a923 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.input-text','data' => ['inRowLabel' => 'Harga','name' => 'price','required' => true,'placeholder' => 'Masukkan harga produk','value' => old('price', $product->price),'errorMessage' => $errors->first('price')]] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('input-text'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['inRowLabel' => 'Harga','name' => 'price','required' => true,'placeholder' => 'Masukkan harga produk','value' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute(old('price', $product->price)),'errorMessage' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute($errors->first('price'))]); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal262894a2c291df91ae9f7b925bf8a923)): ?>
<?php $attributes = $__attributesOriginal262894a2c291df91ae9f7b925bf8a923; ?>
<?php unset($__attributesOriginal262894a2c291df91ae9f7b925bf8a923); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal262894a2c291df91ae9f7b925bf8a923)): ?>
<?php $component = $__componentOriginal262894a2c291df91ae9f7b925bf8a923; ?>
<?php unset($__componentOriginal262894a2c291df91ae9f7b925bf8a923); ?>
<?php endif; ?>

                <?php if (isset($component)) { $__componentOriginal0005bf01aa83ec4ca92674161039a6ca = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal0005bf01aa83ec4ca92674161039a6ca = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.input-select','data' => ['inRowLabel' => 'Tersedia untuk Reseller','name' => 'available_for_reseller','id' => 'available_for_reseller','options' => ['0' => 'Tidak', '1' => 'Ya'],'value' => old('available_for_reseller', $product->available_for_reseller)]] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('input-select'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['inRowLabel' => 'Tersedia untuk Reseller','name' => 'available_for_reseller','id' => 'available_for_reseller','options' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute(['0' => 'Tidak', '1' => 'Ya']),'value' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute(old('available_for_reseller', $product->available_for_reseller))]); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal0005bf01aa83ec4ca92674161039a6ca)): ?>
<?php $attributes = $__attributesOriginal0005bf01aa83ec4ca92674161039a6ca; ?>
<?php unset($__attributesOriginal0005bf01aa83ec4ca92674161039a6ca); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal0005bf01aa83ec4ca92674161039a6ca)): ?>
<?php $component = $__componentOriginal0005bf01aa83ec4ca92674161039a6ca; ?>
<?php unset($__componentOriginal0005bf01aa83ec4ca92674161039a6ca); ?>
<?php endif; ?>

                <?php if (isset($component)) { $__componentOriginal262894a2c291df91ae9f7b925bf8a923 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal262894a2c291df91ae9f7b925bf8a923 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.input-text','data' => ['inRowLabel' => 'Harga Reseller','name' => 'reseller_price','id' => 'reseller_price','placeholder' => 'Masukkan harga reseller','value' => old('reseller_price', $product->reseller_price),'errorMessage' => $errors->first('reseller_price')]] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('input-text'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['inRowLabel' => 'Harga Reseller','name' => 'reseller_price','id' => 'reseller_price','placeholder' => 'Masukkan harga reseller','value' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute(old('reseller_price', $product->reseller_price)),'errorMessage' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute($errors->first('reseller_price'))]); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal262894a2c291df91ae9f7b925bf8a923)): ?>
<?php $attributes = $__attributesOriginal262894a2c291df91ae9f7b925bf8a923; ?>
<?php unset($__attributesOriginal262894a2c291df91ae9f7b925bf8a923); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal262894a2c291df91ae9f7b925bf8a923)): ?>
<?php $component = $__componentOriginal262894a2c291df91ae9f7b925bf8a923; ?>
<?php unset($__componentOriginal262894a2c291df91ae9f7b925bf8a923); ?>
<?php endif; ?>

                <?php if (isset($component)) { $__componentOriginal112ecadca39af188988f468fd61b41b6 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal112ecadca39af188988f468fd61b41b6 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.input-text-area','data' => ['label' => 'Deskripsi','name' => 'description','rows' => '3','required' => true,'placeholder' => 'Masukkan deskripsi produk','value' => old('description', $product->description),'errorMessage' => $errors->first('description')]] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('input-text-area'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['label' => 'Deskripsi','name' => 'description','rows' => '3','required' => true,'placeholder' => 'Masukkan deskripsi produk','value' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute(old('description', $product->description)),'errorMessage' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute($errors->first('description'))]); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal112ecadca39af188988f468fd61b41b6)): ?>
<?php $attributes = $__attributesOriginal112ecadca39af188988f468fd61b41b6; ?>
<?php unset($__attributesOriginal112ecadca39af188988f468fd61b41b6); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal112ecadca39af188988f468fd61b41b6)): ?>
<?php $component = $__componentOriginal112ecadca39af188988f468fd61b41b6; ?>
<?php unset($__componentOriginal112ecadca39af188988f468fd61b41b6); ?>
<?php endif; ?>

                <div class="d-flex justify-content-between pe-2 mt-4">
                    <?php if (isset($component)) { $__componentOriginalb04da7a8feb93a7268b6e0eef6b32739 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginalb04da7a8feb93a7268b6e0eef6b32739 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.gold-button','data' => ['type' => 'button','onclick' => 'window.location.href=\''.e(route('products.index')).'\'']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('gold-button'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['type' => 'button','onclick' => 'window.location.href=\''.e(route('products.index')).'\'']); ?>
                        <i class="bi bi-arrow-left"></i> Back
                     <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginalb04da7a8feb93a7268b6e0eef6b32739)): ?>
<?php $attributes = $__attributesOriginalb04da7a8feb93a7268b6e0eef6b32739; ?>
<?php unset($__attributesOriginalb04da7a8feb93a7268b6e0eef6b32739); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalb04da7a8feb93a7268b6e0eef6b32739)): ?>
<?php $component = $__componentOriginalb04da7a8feb93a7268b6e0eef6b32739; ?>
<?php unset($__componentOriginalb04da7a8feb93a7268b6e0eef6b32739); ?>
<?php endif; ?>

                    <?php if (isset($component)) { $__componentOriginald0f1fd2689e4bb7060122a5b91fe8561 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginald0f1fd2689e4bb7060122a5b91fe8561 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.button','data' => ['type' => 'submit']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('button'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['type' => 'submit']); ?>
                        Update Product
                     <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginald0f1fd2689e4bb7060122a5b91fe8561)): ?>
<?php $attributes = $__attributesOriginald0f1fd2689e4bb7060122a5b91fe8561; ?>
<?php unset($__attributesOriginald0f1fd2689e4bb7060122a5b91fe8561); ?>
<?php endif; ?>
<?php if (isset($__componentOriginald0f1fd2689e4bb7060122a5b91fe8561)): ?>
<?php $component = $__componentOriginald0f1fd2689e4bb7060122a5b91fe8561; ?>
<?php unset($__componentOriginald0f1fd2689e4bb7060122a5b91fe8561); ?>
<?php endif; ?>
                </div>

            </div>
        </div>
    </form>
</div>

<script>
function previewImage(event) {
    const input = event.target;
    const previewNew = document.getElementById('preview-img-new');
    const previewOld = document.getElementById('preview-img');
    const instruction = document.getElementById('image-instruction');
    const removeBtn = document.getElementById('remove-image-btn');
    const removeFlag = document.getElementById('remove_image');

    if (input.files && input.files[0]) {
        const reader = new FileReader();
        reader.onload = e => {
            previewNew.src = e.target.result;
            previewNew.style.display = 'block';
        };
        reader.readAsDataURL(input.files[0]);

        if (previewOld) previewOld.style.display = 'none';
        instruction.style.display = 'none';
        removeBtn.style.display = 'inline-block';
        removeFlag.value = 0;
    }
}

function removeImage() {
    const input = document.getElementById('image');
    const previewOld = document.getElementById('preview-img');
    const previewNew = document.getElementById('preview-img-new');
    const instruction = document.getElementById('image-instruction');
    const removeBtn = document.getElementById('remove-image-btn');
    const removeFlag = document.getElementById('remove_image');

    input.value = "";
    if (previewOld) previewOld.style.display = 'none';
    previewNew.style.display = 'none';
    instruction.style.display = 'block';
    removeBtn.style.display = 'none';
    removeFlag.value = 1;
}
</script>

<?php $__env->stopSection(); ?>

<?php echo $__env->make('layout.main', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\PAW\PiaZhang\resources\views/products/edit.blade.php ENDPATH**/ ?>