- 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.
41 lines
1.2 KiB
TypeScript
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;
|
|
}
|