diff --git a/client/src/components/DashboardPage/DecisionSupportFilePanel.tsx b/client/src/components/DashboardPage/DecisionSupportFilePanel.tsx index ba8929d..208c7d7 100644 --- a/client/src/components/DashboardPage/DecisionSupportFilePanel.tsx +++ b/client/src/components/DashboardPage/DecisionSupportFilePanel.tsx @@ -21,6 +21,14 @@ export function DecisionSupportFilePanel() { label: 'Brouillons', itemFilter: (item: Item) => (item as DecisionSupportFile).status === DecisionSupportFileStatus.Draft }, + { + label: 'À voter', + itemFilter: (item: Item) => (item as DecisionSupportFile).status === DecisionSupportFileStatus.Ready + }, + { + label: 'Votés', + itemFilter: (item: Item) => (item as DecisionSupportFile).status === DecisionSupportFileStatus.Voted + }, { label: 'Clos', itemFilter: (item: Item) => (item as DecisionSupportFile).status === DecisionSupportFileStatus.Closed diff --git a/client/src/components/DecisionSupportFilePage/DecisionSupportFilePage.tsx b/client/src/components/DecisionSupportFilePage/DecisionSupportFilePage.tsx index 0459dd3..daf112a 100644 --- a/client/src/components/DecisionSupportFilePage/DecisionSupportFilePage.tsx +++ b/client/src/components/DecisionSupportFilePage/DecisionSupportFilePage.tsx @@ -22,7 +22,7 @@ export const DecisionSupportFilePage: FunctionComponent
- + { + isAuthorized ? + : + null + }
diff --git a/client/src/components/Navbar.tsx b/client/src/components/Navbar.tsx index 036e8e4..a323f4e 100644 --- a/client/src/components/Navbar.tsx +++ b/client/src/components/Navbar.tsx @@ -44,10 +44,11 @@ export function Navbar() { Mon profil - + + Déconnexion : diff --git a/client/src/gql/queries/authorization.tsx b/client/src/gql/queries/authorization.tsx index d78a813..31293ee 100644 --- a/client/src/gql/queries/authorization.tsx +++ b/client/src/gql/queries/authorization.tsx @@ -1,4 +1,4 @@ -import { gql, useQuery } from '@apollo/client'; +import { gql, useQuery, QueryHookOptions } from '@apollo/client'; import { useGraphQLData } from './helper'; export const QUERY_IS_AUTHORIZED = gql` @@ -7,11 +7,11 @@ export const QUERY_IS_AUTHORIZED = gql` } `; -export function useIsAuthorizedQuery(options = {}) { +export function useIsAuthorizedQuery>(options: QueryHookOptions = {}) { return useQuery(QUERY_IS_AUTHORIZED, options); } -export function useIsAuthorized(options = {}, defaultValue = false) { +export function useIsAuthorized>(options: QueryHookOptions = {}, defaultValue = false) { const { data, loading, error } = useGraphQLData( QUERY_IS_AUTHORIZED, 'isAuthorized', defaultValue, options ); diff --git a/client/src/gql/queries/dsf.tsx b/client/src/gql/queries/dsf.tsx index 0afbdcb..7eab481 100644 --- a/client/src/gql/queries/dsf.tsx +++ b/client/src/gql/queries/dsf.tsx @@ -1,4 +1,4 @@ -import { gql, useQuery } from '@apollo/client'; +import { gql, useQuery, QueryHookOptions } from '@apollo/client'; import { DecisionSupportFile } from '../../types/decision'; import { useGraphQLData } from './helper'; @@ -25,11 +25,11 @@ export const QUERY_DECISION_SUPPORT_FILES = gql` } `; -export function useDecisionSupportFilesQuery(options = {}) { +export function useDecisionSupportFilesQuery>(options: QueryHookOptions = {}) { return useQuery(QUERY_DECISION_SUPPORT_FILES, options); } -export function useDecisionSupportFiles(options = {}) { +export function useDecisionSupportFiles>(options: QueryHookOptions = {}) { const { data, loading, error } = useGraphQLData( QUERY_DECISION_SUPPORT_FILES, 'decisionSupportFiles', [], options ); diff --git a/client/src/gql/queries/helper.ts b/client/src/gql/queries/helper.ts index 586791a..0a42fb4 100644 --- a/client/src/gql/queries/helper.ts +++ b/client/src/gql/queries/helper.ts @@ -1,7 +1,7 @@ -import { useQuery, DocumentNode } from "@apollo/client"; +import { useQuery, DocumentNode, QueryHookOptions } from "@apollo/client"; import { useState, useEffect } from "react"; -export function useGraphQLData(q: DocumentNode, key: string, defaultValue: T, options = {}) { +export function useGraphQLData>(q: DocumentNode, key: string, defaultValue: T, options: QueryHookOptions = {}) { const query = useQuery(q, options); const [ data, setData ] = useState(defaultValue); useEffect(() => { diff --git a/client/src/gql/queries/profile.tsx b/client/src/gql/queries/profile.tsx index 3b79d41..c00b970 100644 --- a/client/src/gql/queries/profile.tsx +++ b/client/src/gql/queries/profile.tsx @@ -1,4 +1,4 @@ -import { gql, useQuery } from '@apollo/client'; +import { gql, useQuery, QueryHookOptions } from '@apollo/client'; import { User } from '../../types/user'; import { useState, useEffect } from 'react'; import { useGraphQLData } from './helper'; @@ -14,13 +14,13 @@ query userProfile { } }`; -export function useUserProfileQuery() { - return useQuery(QUERY_USER_PROFILE); +export function useUserProfileQuery>(options: QueryHookOptions = {}) { + return useQuery(QUERY_USER_PROFILE, options); } -export function useUserProfile() { +export function useUserProfile>(options: QueryHookOptions = {}) { const { data, loading, error } = useGraphQLData( - QUERY_USER_PROFILE, 'userProfile', {id: '', email: ''} + QUERY_USER_PROFILE, 'userProfile', {id: '', email: ''}, options ); return { user: data, loading, error }; } \ No newline at end of file diff --git a/client/src/gql/queries/workgroups.tsx b/client/src/gql/queries/workgroups.tsx index 00efc69..ce4b9ba 100644 --- a/client/src/gql/queries/workgroups.tsx +++ b/client/src/gql/queries/workgroups.tsx @@ -1,4 +1,4 @@ -import { gql, useQuery } from '@apollo/client'; +import { gql, useQuery, QueryHookOptions } from '@apollo/client'; import { Workgroup } from '../../types/workgroup'; import { useGraphQLData } from './helper'; @@ -18,11 +18,11 @@ export const QUERY_WORKGROUP = gql` } `; -export function useWorkgroupsQuery(options = {}) { +export function useWorkgroupsQuery>(options: QueryHookOptions = {}) { return useQuery(QUERY_WORKGROUP, options); } -export function useWorkgroups(options = {}) { +export function useWorkgroups>(options: QueryHookOptions = {}) { const { data, loading, error } = useGraphQLData( QUERY_WORKGROUP, 'workgroups', [], options diff --git a/client/src/util/apollo.ts b/client/src/util/apollo.ts index 519dee5..5cf0150 100644 --- a/client/src/util/apollo.ts +++ b/client/src/util/apollo.ts @@ -44,6 +44,19 @@ export function createClient(setLoggedIn: (boolean) => void) { errorLink, retryLink ]), + defaultOptions: { + watchQuery: { + fetchPolicy: 'cache-and-network', + errorPolicy: 'ignore', + }, + query: { + fetchPolicy: 'network-only', + errorPolicy: 'all', + }, + mutate: { + errorPolicy: 'all', + }, + } }); }