diff --git a/app/resources/views/ventas/reservations.blade.php b/app/resources/views/ventas/reservations.blade.php index 3d61aa0..92d46c9 100644 --- a/app/resources/views/ventas/reservations.blade.php +++ b/app/resources/views/ventas/reservations.blade.php @@ -102,6 +102,7 @@ @include('ventas.reservations.modal.add') + @include('ventas.reservations.modal.comment') @endsection @push('page_styles') @@ -376,6 +377,9 @@ hide() { this.component.style.display = 'none' } + find(id) { + return this.reservations.find(reservation => reservation.id === parseInt(id)) + } send = { get(url) { return APIClient.fetch(url).then(response => response.json()).then(json => { @@ -392,14 +396,6 @@ } }) }, - delete(url) { - const method = 'delete' - return APIClient.fetch(url, {method}).then(response => response.json()).then(json => { - if (json.success) { - window.location.reload() - } - }) - } } actions = {} } @@ -436,9 +432,12 @@ }, remove: event => { event.preventDefault() - const id = event.currentTarget.dataset.id - const url = `{{ $urls->api }}/ventas/reservation/${id}/remove` - this.send.delete(url) + const reservation_id = event.currentTarget.dataset.id + const url = `{{ $urls->api }}/ventas/reservation/${reservation_id}/remove` + const method = 'delete' + const action = 'Cancelar' + const reservation_data = this.find(reservation_id) + reservations.components.modals.comment.show({reservation_id, action, url, method, reservation_data}) return false } } @@ -459,9 +458,12 @@ }, reject: event => { event.preventDefault() - const id = event.currentTarget.dataset.id - const url = `{{ $urls->api }}/ventas/reservation/${id}/reject` - this.send.get(url) + const reservation_id = event.currentTarget.dataset.id + const url = `{{ $urls->api }}/ventas/reservation/${reservation_id}/reject` + const method = 'delete' + const action = 'Rechazar' + const reservation_data = this.find(reservation_id) + reservations.components.modals.comment.show({reservation_id, action, url, method, reservation_data}) return false } } @@ -505,7 +507,8 @@ rejected: null }, modals: { - add: null + add: null, + comment: null, } }, display: { @@ -645,6 +648,7 @@ this.show.projects() this.components.modals.add = new AddReservationModal(configuration.ids.projects) + this.components.modals.comment = new CommentModal() const project_id = {{ $project_id ?? 'null' }}; if (project_id !== null) { diff --git a/app/resources/views/ventas/reservations/modal/comment.blade.php b/app/resources/views/ventas/reservations/modal/comment.blade.php new file mode 100644 index 0000000..55eb4fb --- /dev/null +++ b/app/resources/views/ventas/reservations/modal/comment.blade.php @@ -0,0 +1,157 @@ +