Merge branch 'develop' into dist/ubuntu/bionic/develop
This commit is contained in:
commit
aed0048d95
|
@ -21,6 +21,14 @@ export function DecisionSupportFilePanel() {
|
||||||
label: 'Brouillons',
|
label: 'Brouillons',
|
||||||
itemFilter: (item: Item) => (item as DecisionSupportFile).status === DecisionSupportFileStatus.Draft
|
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',
|
label: 'Clos',
|
||||||
itemFilter: (item: Item) => (item as DecisionSupportFile).status === DecisionSupportFileStatus.Closed
|
itemFilter: (item: Item) => (item as DecisionSupportFile).status === DecisionSupportFileStatus.Closed
|
||||||
|
|
|
@ -22,7 +22,7 @@ export const DecisionSupportFilePage: FunctionComponent<DecisionSupportFilePageP
|
||||||
filter: {
|
filter: {
|
||||||
ids: id !== 'new' ? [id] : undefined,
|
ids: id !== 'new' ? [id] : undefined,
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const [ state, setState ] = useState({
|
const [ state, setState ] = useState({
|
||||||
|
@ -114,10 +114,14 @@ export const DecisionSupportFilePage: FunctionComponent<DecisionSupportFilePageP
|
||||||
</div>
|
</div>
|
||||||
<div className="level-right">
|
<div className="level-right">
|
||||||
<div className="level-item buttons">
|
<div className="level-item buttons">
|
||||||
<button className="button is-medium is-success" disabled={!canSave} onClick={saveDSF}>
|
{
|
||||||
<span className="icon"><i className="fa fa-save"></i></span>
|
isAuthorized ?
|
||||||
<span>Enregistrer</span>
|
<button className="button is-medium is-success" disabled={!canSave} onClick={saveDSF}>
|
||||||
</button>
|
<span className="icon"><i className="fa fa-save"></i></span>
|
||||||
|
<span>Enregistrer</span>
|
||||||
|
</button> :
|
||||||
|
null
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -44,10 +44,11 @@ export function Navbar() {
|
||||||
</span>
|
</span>
|
||||||
<span>Mon profil</span>
|
<span>Mon profil</span>
|
||||||
</Link>
|
</Link>
|
||||||
<Link className="button is-warning" to="/logout">
|
<Link className="button is-warning is-small" to="/logout">
|
||||||
<span className="icon">
|
<span className="icon">
|
||||||
<i className="fas fa-sign-out-alt"></i>
|
<i className="fas fa-sign-out-alt"></i>
|
||||||
</span>
|
</span>
|
||||||
|
<span>Déconnexion</span>
|
||||||
</Link>
|
</Link>
|
||||||
</Fragment> :
|
</Fragment> :
|
||||||
<a className="button is-primary" href={Config.loginURL}>
|
<a className="button is-primary" href={Config.loginURL}>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { gql, useQuery } from '@apollo/client';
|
import { gql, useQuery, QueryHookOptions } from '@apollo/client';
|
||||||
import { useGraphQLData } from './helper';
|
import { useGraphQLData } from './helper';
|
||||||
|
|
||||||
export const QUERY_IS_AUTHORIZED = gql`
|
export const QUERY_IS_AUTHORIZED = gql`
|
||||||
|
@ -7,11 +7,11 @@ export const QUERY_IS_AUTHORIZED = gql`
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export function useIsAuthorizedQuery(options = {}) {
|
export function useIsAuthorizedQuery<A = any, R = Record<string, any>>(options: QueryHookOptions<A, R> = {}) {
|
||||||
return useQuery(QUERY_IS_AUTHORIZED, options);
|
return useQuery(QUERY_IS_AUTHORIZED, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useIsAuthorized(options = {}, defaultValue = false) {
|
export function useIsAuthorized<A = any, R = Record<string, any>>(options: QueryHookOptions<A, R> = {}, defaultValue = false) {
|
||||||
const { data, loading, error } = useGraphQLData<boolean>(
|
const { data, loading, error } = useGraphQLData<boolean>(
|
||||||
QUERY_IS_AUTHORIZED, 'isAuthorized', defaultValue, options
|
QUERY_IS_AUTHORIZED, 'isAuthorized', defaultValue, options
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { gql, useQuery } from '@apollo/client';
|
import { gql, useQuery, QueryHookOptions } from '@apollo/client';
|
||||||
import { DecisionSupportFile } from '../../types/decision';
|
import { DecisionSupportFile } from '../../types/decision';
|
||||||
import { useGraphQLData } from './helper';
|
import { useGraphQLData } from './helper';
|
||||||
|
|
||||||
|
@ -25,11 +25,11 @@ export const QUERY_DECISION_SUPPORT_FILES = gql`
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export function useDecisionSupportFilesQuery(options = {}) {
|
export function useDecisionSupportFilesQuery<A = any, R = Record<string, any>>(options: QueryHookOptions<A, R> = {}) {
|
||||||
return useQuery(QUERY_DECISION_SUPPORT_FILES, options);
|
return useQuery(QUERY_DECISION_SUPPORT_FILES, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useDecisionSupportFiles(options = {}) {
|
export function useDecisionSupportFiles<A = any, R = Record<string, any>>(options: QueryHookOptions<A, R> = {}) {
|
||||||
const { data, loading, error } = useGraphQLData<DecisionSupportFile[]>(
|
const { data, loading, error } = useGraphQLData<DecisionSupportFile[]>(
|
||||||
QUERY_DECISION_SUPPORT_FILES, 'decisionSupportFiles', [], options
|
QUERY_DECISION_SUPPORT_FILES, 'decisionSupportFiles', [], options
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { useQuery, DocumentNode } from "@apollo/client";
|
import { useQuery, DocumentNode, QueryHookOptions } from "@apollo/client";
|
||||||
import { useState, useEffect } from "react";
|
import { useState, useEffect } from "react";
|
||||||
|
|
||||||
export function useGraphQLData<T>(q: DocumentNode, key: string, defaultValue: T, options = {}) {
|
export function useGraphQLData<T, A = any, R = Record<string, any>>(q: DocumentNode, key: string, defaultValue: T, options: QueryHookOptions<A, R> = {}) {
|
||||||
const query = useQuery(q, options);
|
const query = useQuery(q, options);
|
||||||
const [ data, setData ] = useState<T>(defaultValue);
|
const [ data, setData ] = useState<T>(defaultValue);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { gql, useQuery } from '@apollo/client';
|
import { gql, useQuery, QueryHookOptions } from '@apollo/client';
|
||||||
import { User } from '../../types/user';
|
import { User } from '../../types/user';
|
||||||
import { useState, useEffect } from 'react';
|
import { useState, useEffect } from 'react';
|
||||||
import { useGraphQLData } from './helper';
|
import { useGraphQLData } from './helper';
|
||||||
|
@ -14,13 +14,13 @@ query userProfile {
|
||||||
}
|
}
|
||||||
}`;
|
}`;
|
||||||
|
|
||||||
export function useUserProfileQuery() {
|
export function useUserProfileQuery<A = any, R = Record<string, any>>(options: QueryHookOptions<A, R> = {}) {
|
||||||
return useQuery(QUERY_USER_PROFILE);
|
return useQuery(QUERY_USER_PROFILE, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useUserProfile() {
|
export function useUserProfile<A = any, R = Record<string, any>>(options: QueryHookOptions<A, R> = {}) {
|
||||||
const { data, loading, error } = useGraphQLData<User>(
|
const { data, loading, error } = useGraphQLData<User>(
|
||||||
QUERY_USER_PROFILE, 'userProfile', {id: '', email: ''}
|
QUERY_USER_PROFILE, 'userProfile', {id: '', email: ''}, options
|
||||||
);
|
);
|
||||||
return { user: data, loading, error };
|
return { user: data, loading, error };
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
import { gql, useQuery } from '@apollo/client';
|
import { gql, useQuery, QueryHookOptions } from '@apollo/client';
|
||||||
import { Workgroup } from '../../types/workgroup';
|
import { Workgroup } from '../../types/workgroup';
|
||||||
import { useGraphQLData } from './helper';
|
import { useGraphQLData } from './helper';
|
||||||
|
|
||||||
|
@ -18,11 +18,11 @@ export const QUERY_WORKGROUP = gql`
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export function useWorkgroupsQuery(options = {}) {
|
export function useWorkgroupsQuery<A = any, R = Record<string, any>>(options: QueryHookOptions<A, R> = {}) {
|
||||||
return useQuery(QUERY_WORKGROUP, options);
|
return useQuery(QUERY_WORKGROUP, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useWorkgroups(options = {}) {
|
export function useWorkgroups<A = any, R = Record<string, any>>(options: QueryHookOptions<A, R> = {}) {
|
||||||
const { data, loading, error } = useGraphQLData<Workgroup[]>(
|
const { data, loading, error } = useGraphQLData<Workgroup[]>(
|
||||||
QUERY_WORKGROUP, 'workgroups', [],
|
QUERY_WORKGROUP, 'workgroups', [],
|
||||||
options
|
options
|
||||||
|
|
|
@ -44,6 +44,19 @@ export function createClient(setLoggedIn: (boolean) => void) {
|
||||||
errorLink,
|
errorLink,
|
||||||
retryLink
|
retryLink
|
||||||
]),
|
]),
|
||||||
|
defaultOptions: {
|
||||||
|
watchQuery: {
|
||||||
|
fetchPolicy: 'cache-and-network',
|
||||||
|
errorPolicy: 'ignore',
|
||||||
|
},
|
||||||
|
query: {
|
||||||
|
fetchPolicy: 'network-only',
|
||||||
|
errorPolicy: 'all',
|
||||||
|
},
|
||||||
|
mutate: {
|
||||||
|
errorPolicy: 'all',
|
||||||
|
},
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue