diff --git a/src/resources/views/pages/airline/index.edge b/src/resources/views/pages/airline/index.edge
index d1b081e..6d66de2 100644
--- a/src/resources/views/pages/airline/index.edge
+++ b/src/resources/views/pages/airline/index.edge
@@ -56,10 +56,47 @@
{{ airline.name }} |
{{ airline._count.Airplanes }} |
- {{-- Edit --}}
-
+
+ @component('components/ui/modal', {
+ title: 'Edit Airline',
+ buttonClass: 'shadow-md py-2 px-4 inline-flex items-center gap-x-2 text-sm font-medium rounded-lg border border-transparent bg-yellow-300 text-yellow-800 hover:bg-yellow-400 focus:outline-none focus:bg-yellow-200 disabled:opacity-50 disabled:pointer-events-none',
+ })
+ @slot('header')
+ Edit
+ @end
+ @slot('content')
+
+ Edit Airline
+ {{ airline.iataCode }}
+
+
+ {{-- --}}
+
+
+
+
+ @end
+ @end
+ @component('components/ui/modal', {
+ title: 'Delete Airline',
+ buttonClass: 'shadow-md py-2 px-4 inline-flex items-center gap-x-2 text-sm font-medium rounded-lg border border-transparent bg-red-300 text-red-800 hover:bg-red-400 focus:outline-none focus:bg-red-200 disabled:opacity-50 disabled:pointer-events-none',
+ })
+ @slot('header')
+ Delete
+ @end
+ @slot('content')
+
+ Are you sure you want to delete this Airline?
+
+
+
+
+
+
+
+ @end
+ @end
+
|
@end
@@ -116,8 +153,38 @@
}
});
});
+
+
});
+ function deleteAirline(iataCode) {
+ $.ajax({
+ url: '{{ api }}/api/v1/airlines/' + iataCode,
+ method: 'DELETE',
+ headers: {
+ 'Authorization': `Bearer ${token}`
+ },
+ success: function (response) {
+ showToast("success", "Success", "Airline deleted successfully!");
+ setTimeout(() => {
+ window.location.reload();
+ }, 1000);
+ },
+ error: function (xhr) {
+ if (xhr.responseJSON && xhr.responseJSON.errors) {
+ const errors = xhr.responseJSON.errors;
+ let errorMessages = '';
+ errors.forEach(error => {
+ errorMessages += `${error.field}: ${error.message}\n`;
+ });
+ showToast("error", "Error", errorMessages);
+ } else {
+ showToast("error", "Error", "An error occurred. Please try again.");
+ }
+ },
+ });
+ }
+
@endslot