Enregistrement et affichage d'un flux d'évènements
- Ajout d'une nouvelle entité "Event" - Affichage d'une "timeline" sur le tableau de bord - Création semi-automatique des évènements lors des modifications par les utilisateurs
This commit is contained in:
31
client/src/gql/queries/event.ts
Normal file
31
client/src/gql/queries/event.ts
Normal file
@ -0,0 +1,31 @@
|
||||
import { gql, useQuery, QueryHookOptions } from '@apollo/client';
|
||||
import { useGraphQLData } from './helper';
|
||||
import { Event } from '../../types/event';
|
||||
|
||||
export const QUERY_EVENTS = gql`
|
||||
query events($filter: EventFilter) {
|
||||
events(filter: $filter) {
|
||||
id
|
||||
user {
|
||||
id
|
||||
name
|
||||
email
|
||||
}
|
||||
type
|
||||
objectType
|
||||
objectId
|
||||
createdAt
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export function useEventsQuery<A = any, R = Record<string, any>>(options: QueryHookOptions<A, R> = {}) {
|
||||
return useQuery(QUERY_EVENTS, options);
|
||||
}
|
||||
|
||||
export function useEvents<A = any, R = Record<string, any>>(options: QueryHookOptions<A, R> = {}) {
|
||||
const { data, loading, error } = useGraphQLData<Event[]>(
|
||||
QUERY_EVENTS, 'events', [], options
|
||||
);
|
||||
return { events: data, loading, error };
|
||||
}
|
Reference in New Issue
Block a user