feat(pwa): implement service worker and PWA enhancements
- Added service worker (sw.js) for offline functionality, caching strategies, and performance improvements. - Registered service worker in App component to manage updates and offline readiness. - Introduced ServiceWorkerStatus component to display connection status and provide cache management controls. - Created manifest.json for PWA configuration, including app name, icons, and display settings. - Updated index.html with PWA meta tags and links to support mobile web app capabilities. - Refactored authentication guards to utilize useAuthStatus hook for improved user state management. - Removed deprecated unregister-sw.js file to streamline service worker management.
This commit is contained in:
@@ -1,36 +1,25 @@
|
||||
import { Col, ConfigProvider, Layout } from 'antd';
|
||||
import { Outlet, useNavigate } from 'react-router-dom';
|
||||
import { useEffect, memo, useMemo, useCallback } from 'react';
|
||||
import { memo, useMemo } from 'react';
|
||||
import { useMediaQuery } from 'react-responsive';
|
||||
|
||||
import Navbar from '../features/navbar/navbar';
|
||||
import { useAppSelector } from '../hooks/useAppSelector';
|
||||
import { useAppDispatch } from '../hooks/useAppDispatch';
|
||||
import { colors } from '../styles/colors';
|
||||
import { verifyAuthentication } from '@/features/auth/authSlice';
|
||||
|
||||
import { useRenderPerformance } from '@/utils/performance';
|
||||
import HubSpot from '@/components/HubSpot';
|
||||
|
||||
const MainLayout = memo(() => {
|
||||
const themeMode = useAppSelector(state => state.themeReducer.mode);
|
||||
const isDesktop = useMediaQuery({ query: '(min-width: 1024px)' });
|
||||
const dispatch = useAppDispatch();
|
||||
const navigate = useNavigate();
|
||||
|
||||
|
||||
// Performance monitoring in development
|
||||
useRenderPerformance('MainLayout');
|
||||
|
||||
// Memoize auth verification function
|
||||
const verifyAuthStatus = useCallback(async () => {
|
||||
const session = await dispatch(verifyAuthentication()).unwrap();
|
||||
if (!session.user.setup_completed) {
|
||||
navigate('/worklenz/setup');
|
||||
}
|
||||
}, [dispatch, navigate]);
|
||||
|
||||
useEffect(() => {
|
||||
void verifyAuthStatus();
|
||||
}, [verifyAuthStatus]);
|
||||
|
||||
|
||||
// Memoize styles to prevent object recreation on every render
|
||||
const headerStyles = useMemo(
|
||||
|
||||
@@ -22,11 +22,7 @@ const ReportingLayout = () => {
|
||||
const currentSession = getCurrentSession();
|
||||
const navigate = useNavigate();
|
||||
|
||||
useEffect(() => {
|
||||
if (currentSession?.is_expired) {
|
||||
navigate('/worklenz/license-expired');
|
||||
}
|
||||
}, [currentSession, navigate]);
|
||||
|
||||
|
||||
// function to handle collapse
|
||||
const handleCollapsedToggler = () => {
|
||||
|
||||
@@ -11,11 +11,7 @@ const SettingsLayout = () => {
|
||||
const currentSession = getCurrentSession();
|
||||
const navigate = useNavigate();
|
||||
|
||||
useEffect(() => {
|
||||
if (currentSession?.is_expired) {
|
||||
navigate('/worklenz/license-expired');
|
||||
}
|
||||
}, [currentSession, navigate]);
|
||||
|
||||
|
||||
return (
|
||||
<div style={{ marginBlock: 96, minHeight: '90vh' }}>
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import { Flex, Typography } from 'antd';
|
||||
import React, { useEffect } from 'react';
|
||||
import React from 'react';
|
||||
import { Outlet } from 'react-router-dom';
|
||||
import { useMediaQuery } from 'react-responsive';
|
||||
import AdminCenterSidebar from '@/pages/admin-center/sidebar/sidebar';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { verifyAuthentication } from '@/features/auth/authSlice';
|
||||
import { useAppDispatch } from '@/hooks/useAppDispatch';
|
||||
|
||||
const AdminCenterLayout: React.FC = () => {
|
||||
@@ -13,9 +12,7 @@ const AdminCenterLayout: React.FC = () => {
|
||||
const isMarginAvailable = useMediaQuery({ query: '(min-width: 1000px)' });
|
||||
const { t } = useTranslation('admin-center/sidebar');
|
||||
|
||||
useEffect(() => {
|
||||
void dispatch(verifyAuthentication());
|
||||
}, [dispatch]);
|
||||
|
||||
|
||||
return (
|
||||
<div
|
||||
|
||||
Reference in New Issue
Block a user