diff --git a/app/Http/Requests/AdvertisementRequest.php b/app/Http/Requests/AdvertisementRequest.php index c2f29a8..80ca222 100644 --- a/app/Http/Requests/AdvertisementRequest.php +++ b/app/Http/Requests/AdvertisementRequest.php @@ -40,4 +40,40 @@ class AdvertisementRequest extends FormRequest 'contact' => 'required|string', ]; } + + /** + * pesan error validasi + */ + public function messages(): array + { + return [ + 'no.required' => 'Nomor harus diisi.', + 'business_name.required' => 'Nama usaha harus diisi.', + 'business_name.string' => 'Nama usaha harus berupa teks.', + 'npwpd.required' => 'NPWPD harus diisi.', + 'npwpd.string' => 'NPWPD harus berupa teks.', + 'advertisement_type.required' => 'Jenis reklame harus diisi.', + 'advertisement_type.string' => 'Jenis reklame harus berupa teks.', + 'advertisement_content.required' => 'Isi reklame harus diisi.', + 'advertisement_content.string' => 'Isi reklame harus berupa teks.', + 'business_address.required' => 'Alamat usaha harus diisi.', + 'business_address.string' => 'Alamat usaha harus berupa teks.', + 'advertisement_location.required' => 'Lokasi reklame harus diisi.', + 'advertisement_location.string' => 'Lokasi reklame harus berupa teks.', + 'village_name.required' => 'Nama desa harus diisi.', + 'district_name.required' => 'Nama kecamatan harus diisi.', + 'length.required' => 'Panjang harus diisi.', + 'width.required' => 'Lebar harus diisi.', + 'viewing_angle.required' => 'Sudut pandang harus diisi.', + 'viewing_angle.string' => 'Sudut pandang harus berupa teks.', + 'face.required' => 'Jumlah sisi harus diisi.', + 'face.string' => 'Jumlah sisi harus berupa teks.', + 'area.required' => 'Luas harus diisi.', + 'area.string' => 'Luas harus berupa teks.', + 'angle.required' => 'Sudut harus diisi.', + 'angle.string' => 'Sudut harus berupa teks.', + 'contact.required' => 'Kontak harus diisi.', + 'contact.string' => 'Kontak harus berupa teks.', + ]; + } } diff --git a/app/Http/Requests/TourismRequest.php b/app/Http/Requests/TourismRequest.php index fc618cc..a7a503a 100644 --- a/app/Http/Requests/TourismRequest.php +++ b/app/Http/Requests/TourismRequest.php @@ -49,4 +49,85 @@ class TourismRequest extends FormRequest 'tki' => 'required|string', ]; } + + /** + * Get the validation messages for the defined validation rules. + * + * @return array + */ + public function messages(): array + { + return [ + 'project_id.required' => 'ID proyek harus diisi.', + 'project_id.string' => 'ID proyek harus berupa teks.', + + 'project_type_id.required' => 'ID tipe proyek harus diisi.', + 'project_type_id.string' => 'ID tipe proyek harus berupa teks.', + + 'nib.required' => 'NIB harus diisi.', + 'nib.string' => 'NIB harus berupa teks.', + + 'business_name.required' => 'Nama usaha harus diisi.', + 'business_name.string' => 'Nama usaha harus berupa teks.', + + 'oss_publication_date.required' => 'Tanggal publikasi OSS harus diisi.', + + 'investment_status_description.required' => 'Deskripsi status investasi harus diisi.', + 'investment_status_description.string' => 'Deskripsi status investasi harus berupa teks.', + + 'business_form.required' => 'Bentuk usaha harus diisi.', + 'business_form.string' => 'Bentuk usaha harus berupa teks.', + + 'project_risk.required' => 'Risiko proyek harus diisi.', + 'project_risk.string' => 'Risiko proyek harus berupa teks.', + + 'project_name.required' => 'Nama proyek harus diisi.', + 'project_name.string' => 'Nama proyek harus berupa teks.', + + 'business_scale.required' => 'Skala usaha harus diisi.', + 'business_scale.string' => 'Skala usaha harus berupa teks.', + + 'business_address.required' => 'Alamat usaha harus diisi.', + 'business_address.string' => 'Alamat usaha harus berupa teks.', + + 'district_name.required' => 'Nama kecamatan harus diisi.', + + 'village_name.required' => 'Nama desa harus diisi.', + + 'longitude.required' => 'Garis bujur harus diisi.', + 'longitude.string' => 'Garis bujur harus berupa teks.', + + 'latitude.required' => 'Garis lintang harus diisi.', + 'latitude.string' => 'Garis lintang harus berupa teks.', + + 'project_submission_date.required' => 'Tanggal pengajuan proyek harus diisi.', + + 'kbli.required' => 'Kode KBLI harus diisi.', + 'kbli.string' => 'Kode KBLI harus berupa teks.', + + 'kbli_title.required' => 'Judul KBLI harus diisi.', + 'kbli_title.string' => 'Judul KBLI harus berupa teks.', + + 'supervisory_sector.required' => 'Sektor pengawasan harus diisi.', + 'supervisory_sector.string' => 'Sektor pengawasan harus berupa teks.', + + 'user_name.required' => 'Nama pengguna harus diisi.', + 'user_name.string' => 'Nama pengguna harus berupa teks.', + + 'email.required' => 'Email harus diisi.', + 'email.string' => 'Email harus berupa teks.', + + 'contact.required' => 'Kontak harus diisi.', + 'contact.string' => 'Kontak harus berupa teks.', + + 'land_area_in_m2.required' => 'Luas lahan dalam m² harus diisi.', + 'land_area_in_m2.string' => 'Luas lahan dalam m² harus berupa teks.', + + 'investment_amount.required' => 'Jumlah investasi harus diisi.', + 'investment_amount.string' => 'Jumlah investasi harus berupa teks.', + + 'tki.required' => 'Jumlah tenaga kerja Indonesia harus diisi.', + 'tki.string' => 'Jumlah tenaga kerja Indonesia harus berupa teks.', + ]; + } } diff --git a/resources/js/data/advertisements/form-create-update.js b/resources/js/data/advertisements/form-create-update.js index b22bb16..95a2edc 100644 --- a/resources/js/data/advertisements/form-create-update.js +++ b/resources/js/data/advertisements/form-create-update.js @@ -28,12 +28,7 @@ document.addEventListener("DOMContentLoaded", function () { data[key] = value; }); - // Log semua data dalam FormData - for (let pair of formData.entries()) { - console.log(pair[0] + ": " + pair[1]); - } const url = form.getAttribute("action"); - console.log("Ini adalah url dari form action", url); const method = isEdit ? "PUT" : "POST"; @@ -49,7 +44,6 @@ document.addEventListener("DOMContentLoaded", function () { }) .then(response => response.json()) .then(data => { - console.log("Response data:", data); if (!data.errors) { // Remove existing icon (if any) before adding the new one if (authLogo) { @@ -74,11 +68,11 @@ document.addEventListener("DOMContentLoaded", function () { toast.classList.add('show'); // Show the toast setTimeout(() => { toast.classList.remove('show'); // Hide the toast after 3 seconds - }, 3000); + }, 2000); setTimeout(() => { window.location.href = '/data/advertisements'; - }, 3000); + }, 1000); } else { if (authLogo) { // Hapus ikon yang sudah ada jika ada @@ -96,21 +90,21 @@ document.addEventListener("DOMContentLoaded", function () { // Tambahkan ikon ke dalam auth-logo authLogo.appendChild(icon); } - // Set error message for the toast - toastBody.textContent = "Error: " + (responseData.message || "Something went wrong"); - toast.classList.add('show'); // Show the toast // Enable button and reset its text on error modalButton.disabled = false; modalButton.innerHTML = isEdit ? "Update" : "Create"; + // Set error message for the toast + toastBody.textContent = "Failed: " + (data.message || "Something went wrong"); + toast.classList.add('show'); // Show the toast + setTimeout(() => { toast.classList.remove('show'); // Hide the toast after 3 seconds }, 3000); } }) - .catch(error => { - console.error("Error:", error); + .catch(errors => { if (authLogo) { // Hapus ikon yang sudah ada jika ada const existingIcon = authLogo.querySelector('.bx'); @@ -127,14 +121,14 @@ document.addEventListener("DOMContentLoaded", function () { // Tambahkan ikon ke dalam auth-logo authLogo.appendChild(icon); } + // Enable button and reset its text on error + modalButton.disabled = false; + modalButton.innerHTML = isEdit ? "Update" : "Create"; + // Set error message for the toast toastBody.textContent = "An error occurred while processing your request."; toast.classList.add('show'); // Show the toast - // Enable button and reset its text on error - modalButton.disabled = false; - modalButton.innerHTML = isEdit ? "Update" : "Create"; - setTimeout(() => { toast.classList.remove('show'); // Hide the toast after 3 seconds }, 3000); @@ -144,7 +138,6 @@ document.addEventListener("DOMContentLoaded", function () { // Fungsi fetchOptions untuk autocomplete server-side window.fetchOptions = function (field) { let inputValue = document.getElementById(field).value; - console.log("Query Value:", inputValue); // Debugging log if (inputValue.length < 2) return; let districtValue = document.getElementById("district_name").value; // Ambil kecamatan terpilih diff --git a/resources/js/data/tourisms/form-create-update.js b/resources/js/data/tourisms/form-create-update.js index eb25d90..c3d6971 100644 --- a/resources/js/data/tourisms/form-create-update.js +++ b/resources/js/data/tourisms/form-create-update.js @@ -28,12 +28,7 @@ document.addEventListener("DOMContentLoaded", function () { data[key] = value; }); - // Log semua data dalam FormData - for (let pair of formData.entries()) { - console.log(pair[0] + ": " + pair[1]); - } const url = form.getAttribute("action"); - console.log("Ini adalah url dari form action", url); const method = isEdit ? "PUT" : "POST"; @@ -49,7 +44,6 @@ document.addEventListener("DOMContentLoaded", function () { }) .then((response) => response.json()) .then((data) => { - console.log("Response data:", data); if (!data.errors) { // Remove existing icon (if any) before adding the new one if (authLogo) { @@ -113,7 +107,6 @@ document.addEventListener("DOMContentLoaded", function () { } }) .catch((error) => { - console.error("Error:", error); if (authLogo) { // Hapus ikon yang sudah ada jika ada const existingIcon = authLogo.querySelector(".bx"); @@ -148,7 +141,6 @@ document.addEventListener("DOMContentLoaded", function () { // Fungsi fetchOptions untuk autocomplete server-side window.fetchOptions = function (field) { let inputValue = document.getElementById(field).value; - console.log("Query Value:", inputValue); // Debugging log if (inputValue.length < 2) return; let districtValue = document.getElementById("district_name").value; // Ambil kecamatan terpilih diff --git a/resources/js/data/umkm/form-create-update.js b/resources/js/data/umkm/form-create-update.js index 1e93639..d0ebd52 100644 --- a/resources/js/data/umkm/form-create-update.js +++ b/resources/js/data/umkm/form-create-update.js @@ -28,12 +28,7 @@ document.addEventListener("DOMContentLoaded", function () { data[key] = value; }); - // Log semua data dalam FormData - for (let pair of formData.entries()) { - console.log(pair[0] + ": " + pair[1]); - } const url = form.getAttribute("action"); - console.log("Ini adalah url dari form action", url); const method = isEdit ? "PUT" : "POST"; @@ -74,11 +69,11 @@ document.addEventListener("DOMContentLoaded", function () { toast.classList.add('show'); // Show the toast setTimeout(() => { toast.classList.remove('show'); // Hide the toast after 3 seconds - }, 3000); + }, 2000); setTimeout(() => { window.location.href = '/data/umkm'; - }, 3000); + }, 1000); } else { if (authLogo) { // Hapus ikon yang sudah ada jika ada @@ -96,14 +91,16 @@ document.addEventListener("DOMContentLoaded", function () { // Tambahkan ikon ke dalam auth-logo authLogo.appendChild(icon); } - // Set error message for the toast - toastBody.textContent = "Error: " + (data.message || "Something went wrong"); - toast.classList.add('show'); // Show the toast // Enable button and reset its text on error modalButton.disabled = false; modalButton.innerHTML = isEdit ? "Update" : "Create"; + + // Set error message for the toast + toastBody.textContent = "Error: " + (data.message || "Something went wrong"); + toast.classList.add('show'); // Show the toast + setTimeout(() => { toast.classList.remove('show'); // Hide the toast after 3 seconds }, 3000); @@ -127,14 +124,15 @@ document.addEventListener("DOMContentLoaded", function () { // Tambahkan ikon ke dalam auth-logo authLogo.appendChild(icon); } - // Set error message for the toast - toastBody.textContent = "An error occurred while processing your request."; - toast.classList.add('show'); // Show the toast // Enable button and reset its text on error modalButton.disabled = false; modalButton.innerHTML = isEdit ? "Update" : "Create"; + // Set error message for the toast + toastBody.textContent = "An error occurred while processing your request."; + toast.classList.add('show'); // Show the toast + setTimeout(() => { toast.classList.remove('show'); // Hide the toast after 3 seconds }, 3000); @@ -144,7 +142,6 @@ document.addEventListener("DOMContentLoaded", function () { // Fungsi fetchOptions untuk autocomplete server-side window.fetchOptions = function (field) { let inputValue = document.getElementById(field).value; - console.log("Query Value:", inputValue); // Debugging log if (inputValue.length < 2) return; let districtValue = document.getElementById("district_name").value; // Ambil kecamatan terpilih