Fix Articles front before table pagination impl.

This commit is contained in:
Florian Sylvain
2023-01-19 00:54:16 +01:00
parent 0c390be215
commit 587301b119
3 changed files with 16 additions and 3 deletions
+14 -1
View File
@@ -11,7 +11,20 @@ export interface Article {
online: boolean online: boolean
} }
export async function getArticles(id: string): Promise<Array<Article>> { export interface GetArticle {
content: Article[],
total: number
pagination: {
skip: number,
take: number
links: {
next: string,
previous: string
}
}
}
export async function getArticles(id: string): Promise<GetArticle> {
return await fetch(`${baseApiUrl}/articles/${id}`, { return await fetch(`${baseApiUrl}/articles/${id}`, {
credentials: 'include', credentials: 'include',
method: 'GET', method: 'GET',
+1 -1
View File
@@ -10,7 +10,7 @@ const table = ref<HTMLInputElement | string>('')
const tabulator: Ref<Tabulator | undefined> = ref(undefined) const tabulator: Ref<Tabulator | undefined> = ref(undefined)
onMounted(async () => { onMounted(async () => {
articles.value = await getArticles('') articles.value = await (await getArticles('')).content
tabulator.value = new Tabulator(table.value, { tabulator.value = new Tabulator(table.value, {
data: articles.value, data: articles.value,
reactiveData: true, reactiveData: true,
+1 -1
View File
@@ -16,7 +16,7 @@ const errorModalDescription: Ref<string> = ref("Quelque chose s'est mal passé..
onMounted(async () => { onMounted(async () => {
await getArticles(useRoute().params.articleID as string) await getArticles(useRoute().params.articleID as string)
.then(articleFetch => { .then(articleFetch => {
article.value = articleFetch[0] article.value = articleFetch.content[0]
editorData.value = article.value.content.html editorData.value = article.value.content.html
}) })
.catch(error => { .catch(error => {