dstpabuaran.com/resources/js/components/notifications/pwa-update-toast.tsx
Yoga Pangestu 166419134f Refactor component imports for consistency and organization
- Updated import paths for various components to align with new directory structure.
- Changed imports from 'row-actions', 'confirm-dialog', 'image-preview-button', and 'file-upload' to their respective new locations in 'data-display', 'dialogs', and 'inputs'.
- Adjusted imports in multiple pages including purchase, restock, transaction, category, customer, product, raw-material, supplier, roles, and settings.
- Ensured all relevant components are imported from their new locations to maintain functionality.
2026-08-07 13:48:46 +07:00

41 lines
1.2 KiB
TypeScript

import { useEffect } from 'react';
import { toast } from 'sonner';
export function PWAUpdateToast() {
useEffect(() => {
const handleOfflineReady = () => {
toast.success('Aplikasi siap offline!', {
description: 'Aplikasi dapat digunakan tanpa koneksi internet.',
duration: 5000,
});
};
const handleUpdateAvailable = () => {
toast.info('Update tersedia!', {
description:
'Versi baru aplikasi telah tersedia. Klik untuk memperbarui.',
duration: Infinity,
action: {
label: 'Update',
onClick: () => {
window.location.reload();
},
},
});
};
window.addEventListener('sw-offline-ready', handleOfflineReady);
window.addEventListener('sw-update-available', handleUpdateAvailable);
return () => {
window.removeEventListener('sw-offline-ready', handleOfflineReady);
window.removeEventListener(
'sw-update-available',
handleUpdateAvailable,
);
};
}, []);
return null;
}