From aec6d8b6ab108c8077a56941496f9378a22edf0d Mon Sep 17 00:00:00 2001 From: lwih Date: Tue, 2 Jan 2024 17:12:43 +0100 Subject: [PATCH] Frontend - show loader and errors on missions page --- frontend/src/pam/missions/missions.tsx | 122 +++++++++++++++---------- 1 file changed, 74 insertions(+), 48 deletions(-) diff --git a/frontend/src/pam/missions/missions.tsx b/frontend/src/pam/missions/missions.tsx index 7e6efd5f6..f30be5097 100644 --- a/frontend/src/pam/missions/missions.tsx +++ b/frontend/src/pam/missions/missions.tsx @@ -1,67 +1,93 @@ import React from 'react' import { Mission } from '../../types/env-mission-types' import { Col, FlexboxGrid, Loader, Stack } from 'rsuite' -import { Accent, Button, Icon, Size } from '@mtes-mct/monitor-ui' +import { Accent, Button, Icon, Size, THEME } from '@mtes-mct/monitor-ui' import MissionsList from './missions-list' import { Link } from 'react-router-dom' import { useQuery } from '@apollo/client/react' import { GET_MISSIONS } from './queries' import { GET_MISSION_BY_ID } from '../mission/queries' +import Text from "../../ui/text.tsx"; const Missions: React.FC = () => { - const {loading, data, client} = useQuery(GET_MISSIONS) + const {loading, data, error, client} = useQuery(GET_MISSIONS) - const prefetchMission = async (missionId: string) => { - await client.query({ - query: GET_MISSION_BY_ID, - variables: {missionId} - }) - } + const prefetchMission = async (missionId: string) => { + await client.query({ + query: GET_MISSION_BY_ID, + variables: {missionId} + }) + } - if (data) { - const missions: Mission[] = data.missions as Mission[] - return ( - - - - -

Missions

-
+ if (loading) { + return ( + Missions en cours de chargement}/> + ) + } - -

Mes rapports de mission

-
+ if (error) { + return ( + + + + + Une erreur s'est produite lors du chargement de vos missions. Si le problème persiste, + veuillez contacter l'équipe RapportNav. + + + Erreur: {error?.message} + + + + + ) + } - - - - - + if (data) { + const missions: Mission[] = data.missions as Mission[] + return ( + + + + +

Missions

+
- - {loading ? ( - - - - - - ) : ( - - )} - -
-
-
- ) - } + +

Mes rapports de mission

+
- return null + + + + + + + + {loading ? ( + + + + + + ) : ( + + )} + +
+
+
+ ) + } + + return null } export default Missions