update: webhooks

This commit is contained in:
anik-ghosh-au7 2022-07-16 09:53:29 +05:30
parent 913c5c94fb
commit 301bde4da2
2 changed files with 18 additions and 6 deletions

View File

@ -103,8 +103,8 @@ export const EmailVerificationQuery = `
`; `;
export const WebhooksDataQuery = ` export const WebhooksDataQuery = `
query getWebhooksData { query getWebhooksData($params: PaginatedInput!) {
_webhooks{ _webhooks(params: $params){
webhooks{ webhooks{
id id
event_name event_name

View File

@ -77,7 +77,16 @@ const Webhooks = () => {
}; };
const fetchWebookData = async () => { const fetchWebookData = async () => {
setLoading(true); setLoading(true);
const res = await client.query(WebhooksDataQuery).toPromise(); const res = await client
.query(WebhooksDataQuery, {
params: {
pagination: {
limit: paginationProps.limit,
page: paginationProps.page,
},
},
})
.toPromise();
if (res.data?._webhooks) { if (res.data?._webhooks) {
const { pagination, webhooks } = res.data?._webhooks; const { pagination, webhooks } = res.data?._webhooks;
const maxPages = getMaxPages(pagination); const maxPages = getMaxPages(pagination);
@ -97,12 +106,15 @@ const Webhooks = () => {
} }
setLoading(false); setLoading(false);
}; };
useEffect(() => {
fetchWebookData();
}, []);
const paginationHandler = (value: Record<string, number>) => { const paginationHandler = (value: Record<string, number>) => {
setPaginationProps({ ...paginationProps, ...value }); setPaginationProps({ ...paginationProps, ...value });
}; };
useEffect(() => {
fetchWebookData();
}, []);
React.useEffect(() => {
fetchWebookData();
}, [paginationProps.page, paginationProps.limit]);
console.log('webhookData ==>> ', webhookData); console.log('webhookData ==>> ', webhookData);
return ( return (
<Box m="5" py="5" px="10" bg="white" rounded="md"> <Box m="5" py="5" px="10" bg="white" rounded="md">