218 lines
12 KiB
PHP
218 lines
12 KiB
PHP
@extends('layouts.app')
|
|
|
|
@section('title', 'Tambah User Baru - Admin Dashboard')
|
|
|
|
@section('content')
|
|
<div class="min-h-screen bg-gray-50">
|
|
<!-- Top Navigation -->
|
|
<nav class="bg-white shadow-lg sticky top-0 z-50">
|
|
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
|
<div class="flex justify-between h-16">
|
|
<div class="flex items-center">
|
|
<button id="sidebar-toggle" class="lg:hidden text-gray-700 hover:text-primary mr-4">
|
|
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
d="M4 6h16M4 12h16M4 18h16"></path>
|
|
</svg>
|
|
</button>
|
|
<div class="flex-shrink-0">
|
|
<h1 class="text-xl md:text-2xl font-bold text-primary">🏥 Admin Puskesmas</h1>
|
|
</div>
|
|
</div>
|
|
<div class="hidden md:flex items-center space-x-4">
|
|
<span class="text-gray-700">Selamat datang, Admin</span>
|
|
<button onclick="confirmLogout()"
|
|
class="bg-red-500 hover:bg-red-600 text-white px-4 py-2 rounded-md text-sm font-medium transition duration-200">
|
|
Logout
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
|
|
<div class="flex">
|
|
@include('admin.partials.sidebar')
|
|
|
|
<!-- Main Content -->
|
|
<div class="flex-1 lg:ml-64">
|
|
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
|
|
<!-- Header -->
|
|
<div class="mb-8">
|
|
<div class="flex items-center justify-between">
|
|
<div>
|
|
<h1 class="text-2xl font-bold text-gray-900">Tambah User Baru</h1>
|
|
<p class="mt-2 text-gray-600">Tambahkan user baru ke sistem Puskesmas</p>
|
|
</div>
|
|
<a href="{{ route('admin.users.index') }}"
|
|
class="inline-flex items-center px-4 py-2 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">
|
|
<svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
d="M10 19l-7-7m0 0l7-7m-7 7h18"></path>
|
|
</svg>
|
|
Kembali
|
|
</a>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Form -->
|
|
<div class="bg-white shadow rounded-lg">
|
|
<div class="px-6 py-4 border-b border-gray-200">
|
|
<h3 class="text-lg font-medium text-gray-900">Informasi User</h3>
|
|
</div>
|
|
|
|
<form action="{{ route('admin.users.store') }}" method="POST" class="p-6 space-y-6">
|
|
@csrf
|
|
|
|
@if ($errors->any())
|
|
<div class="bg-red-50 border border-red-200 text-red-700 px-4 py-3 rounded-md">
|
|
<ul class="list-disc list-inside space-y-1">
|
|
@foreach ($errors->all() as $error)
|
|
<li>{{ $error }}</li>
|
|
@endforeach
|
|
</ul>
|
|
</div>
|
|
@endif
|
|
|
|
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
|
<!-- Nama -->
|
|
<div>
|
|
<label for="nama" class="block text-sm font-medium text-gray-700 mb-2">Nama
|
|
Lengkap <span class="text-red-500">*</span></label>
|
|
<input type="text" name="nama" id="nama" value="{{ old('nama') }}" required
|
|
class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
|
|
</div>
|
|
|
|
<!-- No KTP -->
|
|
<div>
|
|
<label for="no_ktp" class="block text-sm font-medium text-gray-700 mb-2">Nomor KTP
|
|
<span class="text-red-500">*</span></label>
|
|
<input type="text" name="no_ktp" id="no_ktp" value="{{ old('no_ktp') }}"
|
|
maxlength="16" required pattern="[0-9]*" inputmode="numeric"
|
|
oninput="this.value = this.value.replace(/[^0-9]/g, '')"
|
|
class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
|
|
placeholder="16 digit angka">
|
|
</div>
|
|
|
|
<!-- Jenis Kelamin -->
|
|
<div>
|
|
<label for="jenis_kelamin" class="block text-sm font-medium text-gray-700 mb-2">Jenis
|
|
Kelamin <span class="text-red-500">*</span></label>
|
|
<select name="jenis_kelamin" id="jenis_kelamin" required
|
|
class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
|
|
<option value="">Pilih Jenis Kelamin</option>
|
|
<option value="laki-laki"
|
|
{{ old('jenis_kelamin') == 'laki-laki' ? 'selected' : '' }}>Laki-laki</option>
|
|
<option value="perempuan"
|
|
{{ old('jenis_kelamin') == 'perempuan' ? 'selected' : '' }}>Perempuan</option>
|
|
</select>
|
|
</div>
|
|
|
|
<!-- No HP -->
|
|
<div>
|
|
<label for="no_hp" class="block text-sm font-medium text-gray-700 mb-2">Nomor HP
|
|
<span class="text-red-500">*</span></label>
|
|
<input type="text" name="no_hp" id="no_hp" value="{{ old('no_hp') }}" required
|
|
pattern="[0-9]*" inputmode="numeric"
|
|
oninput="this.value = this.value.replace(/[^0-9]/g, '')"
|
|
class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
|
|
</div>
|
|
|
|
<!-- Pekerjaan -->
|
|
<div>
|
|
<label for="pekerjaan" class="block text-sm font-medium text-gray-700 mb-2">Pekerjaan
|
|
<span class="text-red-500">*</span></label>
|
|
<input type="text" name="pekerjaan" id="pekerjaan" value="{{ old('pekerjaan') }}"
|
|
required
|
|
class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
|
|
</div>
|
|
|
|
<!-- Password -->
|
|
<div>
|
|
<label for="password" class="block text-sm font-medium text-gray-700 mb-2">Password
|
|
<span class="text-red-500">*</span></label>
|
|
<input type="password" name="password" id="password" required
|
|
class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
|
|
placeholder="Minimal 8 karakter">
|
|
</div>
|
|
|
|
<!-- Konfirmasi Password -->
|
|
<div>
|
|
<label for="password_confirmation"
|
|
class="block text-sm font-medium text-gray-700 mb-2">Konfirmasi Password <span
|
|
class="text-red-500">*</span></label>
|
|
<input type="password" name="password_confirmation" id="password_confirmation"
|
|
required
|
|
class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Alamat -->
|
|
<div>
|
|
<label for="alamat" class="block text-sm font-medium text-gray-700 mb-2">Alamat Lengkap
|
|
<span class="text-red-500">*</span></label>
|
|
<textarea name="alamat" id="alamat" rows="3" required
|
|
class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500">{{ old('alamat') }}</textarea>
|
|
</div>
|
|
|
|
<!-- Action Buttons -->
|
|
<div class="flex justify-end space-x-3 pt-6 border-t border-gray-200">
|
|
<a href="{{ route('admin.users.index') }}"
|
|
class="px-4 py-2 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">
|
|
Batal
|
|
</a>
|
|
<button type="submit"
|
|
class="px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">
|
|
Tambah User
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
// Sidebar toggle functionality
|
|
document.getElementById('sidebar-toggle').addEventListener('click', function() {
|
|
document.getElementById('sidebar').classList.toggle('-translate-x-full');
|
|
});
|
|
|
|
document.getElementById('sidebar-close').addEventListener('click', function() {
|
|
document.getElementById('sidebar').classList.add('-translate-x-full');
|
|
});
|
|
|
|
// Logout confirmation
|
|
function confirmLogout() {
|
|
if (confirm('Apakah Anda yakin ingin logout?')) {
|
|
document.createElement('form').submit();
|
|
}
|
|
}
|
|
|
|
// Auto-format KTP input
|
|
document.getElementById('no_ktp').addEventListener('input', function(e) {
|
|
this.value = this.value.replace(/[^0-9]/g, '');
|
|
});
|
|
|
|
// Show SweetAlert2 for session errors
|
|
@if (session('error'))
|
|
Swal.fire({
|
|
icon: 'error',
|
|
title: 'Error!',
|
|
text: '{{ session('error') }}',
|
|
confirmButtonColor: '#d33',
|
|
});
|
|
@endif
|
|
|
|
// Show SweetAlert2 for session success
|
|
@if (session('success'))
|
|
Swal.fire({
|
|
icon: 'success',
|
|
title: 'Berhasil!',
|
|
text: '{{ session('success') }}',
|
|
confirmButtonColor: '#28a745',
|
|
});
|
|
@endif
|
|
</script>
|
|
@endsection
|