77 lines
2.3 KiB
JavaScript
77 lines
2.3 KiB
JavaScript
|
document.querySelector('.btn-gestion-promotion').addEventListener('click', function(event) {
|
||
|
event.preventDefault();
|
||
|
|
||
|
document.getElementById('container_modal');
|
||
|
|
||
|
fetch('/reductions')
|
||
|
.then(response => {
|
||
|
if (!response.ok) {
|
||
|
throw new Error('Erreur de chargement de la section Promotions');
|
||
|
}
|
||
|
return response.text();
|
||
|
})
|
||
|
.then(html => {
|
||
|
// Insérer le HTML dans le conteneur et l'afficher
|
||
|
container_modal.innerHTML = html;
|
||
|
container_modal.style.display = 'block';
|
||
|
})
|
||
|
.catch(error => {
|
||
|
console.error('Erreur:', error);
|
||
|
});
|
||
|
});
|
||
|
|
||
|
function addPromotion (event) {
|
||
|
document.getElementById('container_modal');
|
||
|
|
||
|
fetch(`/reductions/new`)
|
||
|
.then(response => {
|
||
|
return response.text();
|
||
|
})
|
||
|
.then(html => {
|
||
|
// Insérer le HTML dans le conteneur et l'afficher
|
||
|
container_modal.innerHTML = html;
|
||
|
container_modal.style.display = 'block';
|
||
|
})
|
||
|
.catch(error => {
|
||
|
console.error('Erreur:', error);
|
||
|
});
|
||
|
}
|
||
|
|
||
|
|
||
|
function updatePromotion (event) {
|
||
|
document.getElementById('container_modal');
|
||
|
const reductionsIdString = event.getAttribute('data-id');
|
||
|
let reductionsId = parseInt(reductionsIdString);
|
||
|
|
||
|
fetch(`/reductions/${reductionsId}/edit`)
|
||
|
.then(response => {
|
||
|
return response.text();
|
||
|
})
|
||
|
.then(html => {
|
||
|
// Insérer le HTML dans le conteneur et l'afficher
|
||
|
container_modal.innerHTML = html;
|
||
|
container_modal.style.display = 'block';
|
||
|
})
|
||
|
.catch(error => {
|
||
|
console.error('Erreur:', error);
|
||
|
});
|
||
|
}
|
||
|
|
||
|
function deletePromotion (event) {
|
||
|
document.getElementById('container_modal');
|
||
|
const reductionsIdString = event.getAttribute('data-id');
|
||
|
let reductionsId = parseInt(reductionsIdString);
|
||
|
|
||
|
fetch(`/reductions/${reductionsId}`)
|
||
|
.then(response => {
|
||
|
return response.text();
|
||
|
})
|
||
|
.then(html => {
|
||
|
// Insérer le HTML dans le conteneur et l'afficher
|
||
|
container_modal.innerHTML = html;
|
||
|
container_modal.style.display = 'block';
|
||
|
})
|
||
|
.catch(error => {
|
||
|
console.error('Erreur:', error);
|
||
|
});
|
||
|
}
|