<?php $__env->startSection('title', $post->exists ? 'Edit Artikel' : 'Tambah Artikel'); ?>
<?php $__env->startSection('page-title', $post->exists ? 'Edit Artikel' : 'Tambah Berita / Pengumuman'); ?>

<?php $__env->startSection('content'); ?>
<div class="max-w-3xl">
    <form method="POST" action="<?php echo e($post->exists ? route('admin.posts.update', $post->id) : route('admin.posts.store')); ?>" enctype="multipart/form-data" class="space-y-5">
        <?php echo csrf_field(); ?>
        <?php if($post->exists): ?> <?php echo method_field('PUT'); ?> <?php endif; ?>

        <div class="card-admin grid grid-cols-1 md:grid-cols-2 gap-4">
            <div>
                <label class="form-label">Tipe *</label>
                <select name="tipe" class="form-select" required>
                    <option value="berita" <?php echo e(old('tipe', $post->tipe ?? 'berita') === 'berita' ? 'selected' : ''); ?>>Berita</option>
                    <option value="pengumuman" <?php echo e(old('tipe', $post->tipe) === 'pengumuman' ? 'selected' : ''); ?>>Pengumuman</option>
                </select>
            </div>
            <div>
                <label class="form-label">Tanggal *</label>
                <input type="date" name="tanggal" value="<?php echo e(old('tanggal', $post->exists ? $post->tanggal->format('Y-m-d') : date('Y-m-d'))); ?>" class="form-input" required>
            </div>
            <div class="md:col-span-2">
                <label class="form-label">Judul *</label>
                <input name="judul" value="<?php echo e(old('judul', $post->judul)); ?>" class="form-input" required placeholder="Judul berita atau pengumuman">
            </div>
            <div>
                <label class="form-label">Penulis</label>
                <input name="penulis" value="<?php echo e(old('penulis', $post->penulis)); ?>" class="form-input" placeholder="Admin Desa Suka Baru">
            </div>
            <div>
                <label class="form-label">Foto Sampul</label>
                <?php if($post->exists && $post->foto_url): ?>
                    <img src="<?php echo e($post->foto_url); ?>" class="w-full h-24 object-cover rounded-lg mb-2">
                <?php endif; ?>
                <input type="file" name="foto" accept="image/*" class="form-input">
            </div>
        </div>

        <div class="card-admin">
            <label class="form-label">Isi Artikel *</label>
            <textarea name="isi" rows="14" class="form-textarea" required><?php echo e(old('isi', $post->isi)); ?></textarea>
        </div>

        <?php if($errors->any()): ?>
            <div class="bg-red-50 border border-red-200 rounded-lg p-3">
                <?php $__currentLoopData = $errors->all(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $e): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><p class="text-red-600 text-sm"><?php echo e($e); ?></p><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </div>
        <?php endif; ?>

        <div class="flex gap-3">
            <button type="submit" class="btn-primary">💾 <?php echo e($post->exists ? 'Perbarui' : 'Publikasikan'); ?></button>
            <a href="<?php echo e(route('admin.posts.index')); ?>" class="btn-secondary">Batal</a>
        </div>
    </form>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.admin', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH F:\web Desa Suka Baru\website-desa-suka-baru\resources\views/admin/posts/form.blade.php ENDPATH**/ ?>