diff --git a/resources/js/components/rainfall/RainfallGraph.tsx b/resources/js/components/rainfall/RainfallGraph.tsx index afbb10d..17ea405 100644 --- a/resources/js/components/rainfall/RainfallGraph.tsx +++ b/resources/js/components/rainfall/RainfallGraph.tsx @@ -47,6 +47,7 @@ const RainfallGraph: FC = ({width, height, data, start_date, svg.append("g") .attr("transform", "translate(0," + gHeight + ")") .call(d3.axisBottom(x) + .ticks(8) .tickFormat( // @ts-ignore d3.timeFormat("%d/%m/%Y") diff --git a/resources/js/hooks/AuthUser.tsx b/resources/js/hooks/AuthUser.tsx index acb8513..54f7ca0 100644 --- a/resources/js/hooks/AuthUser.tsx +++ b/resources/js/hooks/AuthUser.tsx @@ -31,6 +31,9 @@ export const AuthUserProvider = ({children}: PropsWithChildren) => { // @ts-ignore if (e.response.status === 401) { console.info('no user login') + if (window.location.pathname !== '/connexion') { + window.location.href = '/connexion' + } } } finally { setLoadingAuthUser(false) diff --git a/resources/js/pages/Rainfall.tsx b/resources/js/pages/Rainfall.tsx index f2978f4..41a9e7a 100644 --- a/resources/js/pages/Rainfall.tsx +++ b/resources/js/pages/Rainfall.tsx @@ -41,7 +41,7 @@ const Rainfall = () => { {errorLabel()} -
+ - - - - + + + + {{ config('app.name', 'Laravel') }} diff --git a/vite.config.js b/vite.config.js index d34b909..3267d46 100644 --- a/vite.config.js +++ b/vite.config.js @@ -4,47 +4,92 @@ import react from '@vitejs/plugin-react'; import copy from "rollup-plugin-copy"; import { VitePWA } from 'vite-plugin-pwa' +export default () => { + const manifestIcons = [ + { + src: '/pwa-64x64.png', + sizes: '64x64', + type: 'image/png' + }, + { + src: '/pwa-192x192.png', + sizes: '192x192', + type: 'image/png' + }, + { + src: '/pwa-512x512.png', + sizes: '512x512', + type: 'image/png', + purpose: 'any' + }, + { + src: '/maskable-icon-512x512.png', + sizes: '512x512', + type: 'image/png', + purpose: 'maskable' + }, + ] + const publicIcons = [ + { src: '/favicon.ico' }, + { src: '/favicon.svg' }, + { src: '/apple-touch-icon-180x180.png' } + ] + const additionalImages = [] -export default defineConfig({ - plugins: [ - laravel({ - input: 'resources/js/app.tsx', - refresh: true, - }), - react(), - copy({ - targets: [ - { src: 'resources/images/*', dest: 'public/images' }, - ] - }), - VitePWA({ - registerType: 'autoUpdate', - includeAssets: ['favicon.ico', 'apple-touch-icon.png', 'mask-icon.svg'], - manifest: { - name: 'Bermite', - short_name: 'Bermite', - lang: "fr", - description: 'Application de suivi météo', - theme_color: '#ffffff', - display: "standalone", - icons: [ - { - src: '/pwa-64x64.png', - sizes: '64x64', - type: 'image/png' - }, - { - src: '/pwa-192x192.png', - sizes: '192x192', - type: 'image/png' - }, - { - src: '/pwa-512x512.png', - sizes: '512x512', - type: 'image/png' - } + return defineConfig({ + plugins: [ + laravel({ + input: 'resources/js/app.tsx', + refresh: true, + }), + react(), + copy({ + targets: [ + { src: 'resources/images/*', dest: 'public/images' }, ] - } - }) - ], -}); + }), + VitePWA({ + buildBase: '/build/', + scope: '/', + base: '/', + registerType: 'prompt', + devOptions: { + enabled: false + }, + includeAssets: [], + workbox: { + globPatterns: ['**/*.{js,css,html,ico,jpg,png,svg,woff,woff2,ttf,eot}'], + navigateFallback: '/', + navigateFallbackDenylist: [/^\/horizon/], + additionalManifestEntries: [ + { url: '/', revision: `${Date.now()}` }, + ...manifestIcons.map((i) => { + return { url: i.src, revision: `${Date.now()}` } + }), + ...publicIcons.map((i) => { + return { url: i.src, revision: `${Date.now()}` } + }), + ...additionalImages.map((i) => { + return { url: i.src, revision: `${Date.now()}` } + }) + ], + maximumFileSizeToCacheInBytes: 3000000 + }, + manifest: { + name: 'Bermite', + short_name: 'Bermite', + lang: "fr", + description: 'Application de suivi météo', + theme_color: '#ffffff', + display: "standalone", + scope: '/', + start_url: '/', + id: '/', + + // These icons are used when installing the PWA onto a home screen + icons: [...manifestIcons], + } + }) + ], + }) +}