From 6845e1ce503a194e12af510d568fb1450887af3d Mon Sep 17 00:00:00 2001 From: William Petit Date: Thu, 10 Sep 2020 19:25:52 +0200 Subject: [PATCH 1/5] =?UTF-8?q?Ajout=20types=20g=C3=A9n=C3=A9riques=20pour?= =?UTF-8?q?=20autocompl=C3=A9tion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/gql/queries/authorization.tsx | 6 +++--- client/src/gql/queries/dsf.tsx | 6 +++--- client/src/gql/queries/helper.ts | 4 ++-- client/src/gql/queries/profile.tsx | 10 +++++----- client/src/gql/queries/workgroups.tsx | 6 +++--- 5 files changed, 16 insertions(+), 16 deletions(-) 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 From 596108b4f4775aa945764c1dcf11440f0f2ae491 Mon Sep 17 00:00:00 2001 From: William Petit Date: Thu, 10 Sep 2020 19:26:41 +0200 Subject: [PATCH 2/5] =?UTF-8?q?Panel=20DADs:=20ajout=20onglets=20'=C3=A0?= =?UTF-8?q?=20voter'=20et=20'vot=C3=A9s'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/DashboardPage/DecisionSupportFilePanel.tsx | 8 ++++++++ 1 file changed, 8 insertions(+) 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 From 978cc65c41be37ebfca46073e29080651de8d563 Mon Sep 17 00:00:00 2001 From: William Petit Date: Thu, 10 Sep 2020 19:27:17 +0200 Subject: [PATCH 3/5] Dissimulation du bouton enregistrer en mode lecture seule --- .../DecisionSupportFilePage.tsx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) 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 + }
From 772b09381c83ef3569ac16d46deae562982d717b Mon Sep 17 00:00:00 2001 From: William Petit Date: Thu, 10 Sep 2020 19:27:43 +0200 Subject: [PATCH 4/5] =?UTF-8?q?Ajout=20label=20'D=C3=A9connexion'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/components/Navbar.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 :
From 11f54ab66e4119d8effa60ba941a914d421e885d Mon Sep 17 00:00:00 2001 From: William Petit Date: Thu, 10 Sep 2020 19:28:08 +0200 Subject: [PATCH 5/5] =?UTF-8?q?Utilisation=20de=20la=20strat=C3=A9gie=20de?= =?UTF-8?q?=20cache=20'cache=20puis=20r=C3=A9seau'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/util/apollo.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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', + }, + } }); }