feat(sh-admin): introducing data analytics and newsletter configurations (#3845)

Co-authored-by: jamesgeorge007 <jamesgeorge998001@gmail.com>
Co-authored-by: nivedin <nivedinp@gmail.com>
This commit is contained in:
Joel Jacob Stephen
2024-03-06 20:06:48 +05:30
committed by GitHub
parent 4798d7bbbd
commit 919579b1da
18 changed files with 575 additions and 156 deletions

View File

@@ -1,4 +1,4 @@
import { onMounted, ref } from 'vue';
import { Ref, onMounted, ref } from 'vue';
import { DocumentNode } from 'graphql';
import { TypedDocumentNode, useClientHandle } from '@urql/vue';
@@ -16,38 +16,41 @@ export function usePagedQuery<
const { client } = useClientHandle();
const fetching = ref(true);
const error = ref(false);
const list = ref<ListItem[]>([]);
const list: Ref<ListItem[]> = ref([]);
const currentPage = ref(0);
const hasNextPage = ref(true);
const fetchNextPage = async () => {
fetching.value = true;
try {
const cursor =
list.value.length > 0 ? getCursor(list.value.at(-1)) : undefined;
const variablesForPagination = {
...variables,
take: itemsPerPage,
cursor,
};
const cursor =
list.value.length > 0 ? getCursor(list.value.at(-1)!) : undefined;
const variablesForPagination = {
...variables,
take: itemsPerPage,
cursor,
};
const result = await client
.query(query, variablesForPagination)
.toPromise();
const resultList = getList(result.data!);
const result = await client
.query(query, variablesForPagination)
.toPromise();
if (resultList.length < itemsPerPage) {
hasNextPage.value = false;
}
list.value.push(...resultList);
currentPage.value++;
} catch (e) {
if (result.error) {
error.value = true;
} finally {
fetching.value = false;
return;
}
const resultList = getList(result.data!);
if (resultList.length < itemsPerPage) {
hasNextPage.value = false;
}
list.value.push(...resultList);
currentPage.value++;
fetching.value = false;
};
onMounted(async () => {