karinebrandelli
karinebrandelli
NNovu
Created by Pawan Jain on 9/20/2023 in #💬│support
issue in fetching notifications using graphql
Hi Pawan! Thanks, I'll check later bongocat
17 replies
NNovu
Created by Pawan Jain on 9/20/2023 in #💬│support
issue in fetching notifications using graphql
I don't see the example in the link you sent
17 replies
NNovu
Created by Pawan Jain on 9/20/2023 in #💬│support
issue in fetching notifications using graphql
how can I do that with useNotifications ?
17 replies
NNovu
Created by Pawan Jain on 9/20/2023 in #💬│support
issue in fetching notifications using graphql
these all will be refactor using Novu standarts
17 replies
NNovu
Created by Pawan Jain on 9/20/2023 in #💬│support
issue in fetching notifications using graphql
that's what I want to know
17 replies
NNovu
Created by Pawan Jain on 9/20/2023 in #💬│support
issue in fetching notifications using graphql
I just don't know exactly how to trigger that with novu
17 replies
NNovu
Created by Pawan Jain on 9/20/2023 in #💬│support
issue in fetching notifications using graphql
we use a graphql query to render de notifications
17 replies
NNovu
Created by Pawan Jain on 9/20/2023 in #💬│support
issue in fetching notifications using graphql
simplifying of course haha
17 replies
NNovu
Created by Pawan Jain on 9/20/2023 in #💬│support
issue in fetching notifications using graphql
export const MANDATES = gql`
query mandates(
$pagination: Pagination
$query: PaginationDefaultQueryInput!
) {
mandates(pagination: $pagination, query: $query) {
items {
id
description
dateStart
dateEnd
maxDays
}
hasMore
}
}
`

export const useMandates = (
identifier: string = '',
ref?: RefObject<HTMLElement | null>
) => {
const [mandates, loading, refetch] = usePagination<TMandate>({
query: MANDATES,
element: ref,
variables: { identifier }
})

return { mandates, loading, refetch }
}

const { mandates } = useMandates()

const notifications: INotification[] =
mandates.length > MIN_LENGTH
? getNotificationsByMandateEvents(mandateEvents)
: getNotificationCreateFirstMandate()

<NotificationBody>
{notifications.length == MIN_LENGTH ? (
<NotificationEmpty>
Não há notificações
</NotificationEmpty>
) : (
''
)}
{notifications.map((notification, key) => (
<NotificationItem
notification={notification}
key={key}
/>
))}
</NotificationBody>
export const MANDATES = gql`
query mandates(
$pagination: Pagination
$query: PaginationDefaultQueryInput!
) {
mandates(pagination: $pagination, query: $query) {
items {
id
description
dateStart
dateEnd
maxDays
}
hasMore
}
}
`

export const useMandates = (
identifier: string = '',
ref?: RefObject<HTMLElement | null>
) => {
const [mandates, loading, refetch] = usePagination<TMandate>({
query: MANDATES,
element: ref,
variables: { identifier }
})

return { mandates, loading, refetch }
}

const { mandates } = useMandates()

const notifications: INotification[] =
mandates.length > MIN_LENGTH
? getNotificationsByMandateEvents(mandateEvents)
: getNotificationCreateFirstMandate()

<NotificationBody>
{notifications.length == MIN_LENGTH ? (
<NotificationEmpty>
Não há notificações
</NotificationEmpty>
) : (
''
)}
{notifications.map((notification, key) => (
<NotificationItem
notification={notification}
key={key}
/>
))}
</NotificationBody>
17 replies
NNovu
Created by Pawan Jain on 9/20/2023 in #💬│support
issue in fetching notifications using graphql
hey Pawan! currently we use this structure
17 replies