PHP Classes

File: frontend/js/componentes/controllers/reservationController.js

Recommend this page to a friend!
  Classes of Rodrigo Faustino   Livraria   frontend/js/componentes/controllers/reservationController.js   Download  
File: frontend/js/componentes/controllers/reservationController.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: Livraria
Manage a bookstore using micro-services
Author: By
Last change:
Date: 3 months ago
Size: 1,320 bytes
 

Contents

Class file image Download
import { fetchReservations, updateReservation, deleteReservation } from '../models/reservationModel.js'; import { renderReservationsView, setupReservationButtons } from '../views/reservationsView.js'; export function renderReservations() { const adminContent = document.getElementById('admin-content'); adminContent.innerHTML = '<h2>Reservations</h2>'; fetchReservations() .then(reservations => { const reservationsContainer = renderReservationsView(adminContent, reservations); setupReservationButtons( reservationsContainer, handleUpdateReservationStatus, handleRemoveReservation ); }) .catch(error => console.error('Error loading reservations:', error)); } function handleUpdateReservationStatus(id) { updateReservation(id, 'sold') .then(() => { alert('Reservation status updated'); renderReservations(); }) .catch(error => console.error('Error updating reservation status:', error)); } function handleRemoveReservation(id) { deleteReservation(id) .then(() => { alert('Reservation removed'); renderReservations(); }) .catch(error => console.error('Error removing reservation:', error)); }