diff --git a/src/lib/components/common/Pagination.svelte b/src/lib/components/common/Pagination.svelte new file mode 100644 index 000000000..9658e0d12 --- /dev/null +++ b/src/lib/components/common/Pagination.svelte @@ -0,0 +1,42 @@ + + +
+ +
+ + + +
+ {#each pages as page (page.key)} + {#if page.type === 'ellipsis'} +
...
+ {:else} + + {page.value} + + {/if} + {/each} +
+ + + +
+
+
diff --git a/src/lib/components/common/Paginator.svelte b/src/lib/components/common/Paginator.svelte deleted file mode 100644 index dd5c5296e..000000000 --- a/src/lib/components/common/Paginator.svelte +++ /dev/null @@ -1,254 +0,0 @@ - - -
- - {#if settings.amounts.length} - - {/if} - -
- - {#if showFirstLastButtons} - - {/if} - - {#if showPreviousNextButtons} - - {/if} - - {#if showNumerals === false} - - - {:else} - - {#each controlPages as page} - - {/each} - {/if} - - {#if showPreviousNextButtons} - - {/if} - - {#if showFirstLastButtons} - - {/if} -
-
diff --git a/src/lib/components/icons/ChevronLeft.svelte b/src/lib/components/icons/ChevronLeft.svelte new file mode 100644 index 000000000..78ee64d24 --- /dev/null +++ b/src/lib/components/icons/ChevronLeft.svelte @@ -0,0 +1,15 @@ + + + + + diff --git a/src/lib/components/icons/ChevronRight.svelte b/src/lib/components/icons/ChevronRight.svelte new file mode 100644 index 000000000..7daf4a14a --- /dev/null +++ b/src/lib/components/icons/ChevronRight.svelte @@ -0,0 +1,15 @@ + + + + + diff --git a/src/routes/(app)/admin/+page.svelte b/src/routes/(app)/admin/+page.svelte index 6d153d8a8..a3493cb66 100644 --- a/src/routes/(app)/admin/+page.svelte +++ b/src/routes/(app)/admin/+page.svelte @@ -12,7 +12,7 @@ import { getSignUpEnabledStatus, toggleSignUpEnabledStatus } from '$lib/apis/auths'; import EditUserModal from '$lib/components/admin/EditUserModal.svelte'; import SettingsModal from '$lib/components/admin/SettingsModal.svelte'; - import Paginator from '$lib/components/common/Paginator.svelte'; + import Pagination from '$lib/components/common/Pagination.svelte'; const i18n = getContext('i18n'); @@ -22,16 +22,11 @@ let search = ''; let selectedUser = null; + let page = 1; + let showSettingsModal = false; let showEditUserModal = false; - let paginatorSettings = { - page: 0, - limit: 5, - size: users.length, - amounts: [5, 10, 15, 20] - }; - const updateRoleHandler = async (id, role) => { const res = await updateUserRole(localStorage.token, id, role).catch((error) => { toast.error(error); @@ -72,23 +67,6 @@ } loaded = true; }); - - $: paginatedSource = users - .filter((user) => { - if (search === '') { - return true; - } else { - let name = user.name.toLowerCase(); - const query = search.toLowerCase(); - return name.includes(query); - } - }) - .slice( - paginatorSettings.page * paginatorSettings.limit, - paginatorSettings.page * paginatorSettings.limit + paginatorSettings.limit - ); - - $: paginatorSettings.size = users.length; @@ -184,7 +162,17 @@ - {#each paginatedSource as user} + {#each users + .filter((user) => { + if (search === '') { + return true; + } else { + let name = user.name.toLowerCase(); + const query = search.toLowerCase(); + return name.includes(query); + } + }) + .slice((page - 1) * 20, page * 20) as user}