update frontend

This commit is contained in:
Your Name 2025-12-21 19:09:10 -05:00
parent 1144e87358
commit e47daa2efb
2 changed files with 94 additions and 0 deletions

47
public/pwaInstall.js Normal file
View File

@ -0,0 +1,47 @@
// src/pwaInstall.js
let deferredPrompt = null;
window.addEventListener('beforeinstallprompt', (e) => {
// Empêche le prompt par défaut
e.preventDefault();
deferredPrompt = e;
console.log('PWA install prompt ready');
});
// Fonction pour déclencher linstall (tu peux lappeler sur un bouton)
export function promptInstall() {
if (deferredPrompt) {
deferredPrompt.prompt();
deferredPrompt.userChoice.then((choiceResult) => {
if (choiceResult.outcome === 'accepted') {
console.log('PWA installed');
} else {
console.log('PWA dismissed');
}
deferredPrompt = null;
});
}
}
// Ajoute un bouton "Installer lapp" dans ton UI (optionnel)
export function addInstallButton() {
const btn = document.createElement('button');
btn.textContent = 'Installer SocioWire';
btn.style.position = 'fixed';
btn.style.bottom = '20px';
btn.style.right = '20px';
btn.style.padding = '10px 20px';
btn.style.background = '#0ea5e9';
btn.style.color = 'white';
btn.style.border = 'none';
btn.style.borderRadius = '8px';
btn.style.cursor = 'pointer';
btn.style.zIndex = '9999';
btn.onclick = promptInstall;
document.body.appendChild(btn);
}
// Détection si déjà installé (cache)
if (window.matchMedia('(display-mode: standalone)').matches || navigator.standalone) {
console.log('App already installed');
}

47
src/pwaInstall.js Normal file
View File

@ -0,0 +1,47 @@
// src/pwaInstall.js
let deferredPrompt = null;
window.addEventListener('beforeinstallprompt', (e) => {
// Empêche le prompt par défaut
e.preventDefault();
deferredPrompt = e;
console.log('PWA install prompt ready');
});
// Fonction pour déclencher linstall (tu peux lappeler sur un bouton)
export function promptInstall() {
if (deferredPrompt) {
deferredPrompt.prompt();
deferredPrompt.userChoice.then((choiceResult) => {
if (choiceResult.outcome === 'accepted') {
console.log('PWA installed');
} else {
console.log('PWA dismissed');
}
deferredPrompt = null;
});
}
}
// Ajoute un bouton "Installer lapp" dans ton UI (optionnel)
export function addInstallButton() {
const btn = document.createElement('button');
btn.textContent = 'Installer SocioWire';
btn.style.position = 'fixed';
btn.style.bottom = '20px';
btn.style.right = '20px';
btn.style.padding = '10px 20px';
btn.style.background = '#0ea5e9';
btn.style.color = 'white';
btn.style.border = 'none';
btn.style.borderRadius = '8px';
btn.style.cursor = 'pointer';
btn.style.zIndex = '9999';
btn.onclick = promptInstall;
document.body.appendChild(btn);
}
// Détection si déjà installé (cache)
if (window.matchMedia('(display-mode: standalone)').matches || navigator.standalone) {
console.log('App already installed');
}