From 5203b26b418338a2034c5bd16ae08749ad2b12b1 Mon Sep 17 00:00:00 2001 From: Defelo Date: Tue, 15 Oct 2024 21:40:16 +0200 Subject: [PATCH 1/3] chore(devenv): update packages --- .envrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.envrc b/.envrc index e3508ee..17aa1cd 100644 --- a/.envrc +++ b/.envrc @@ -1,5 +1,5 @@ on_git_branch latest && exit if has nix; then - use nix -p nodejs_18 nodePackages.volar nodePackages.typescript-language-server + use nix -p nodejs_18 vue-language-server typescript-language-server fi layout node From 426e2c1fa4a1a9d4e44668f20442faaff52ebeae Mon Sep 17 00:00:00 2001 From: Defelo Date: Tue, 15 Oct 2024 21:42:07 +0200 Subject: [PATCH 2/3] fix(users): remove duplicates in query string --- composables/appUsers.ts | 23 ++--------------------- pages/dashboard/users/index.vue | 2 -- 2 files changed, 2 insertions(+), 23 deletions(-) diff --git a/composables/appUsers.ts b/composables/appUsers.ts index de49537..f87520d 100644 --- a/composables/appUsers.ts +++ b/composables/appUsers.ts @@ -1,6 +1,6 @@ import { useState } from '#app'; import type { Ref } from 'vue'; -import { GET, PATCH, DELETE, PUT } from './fetch'; +import { GET, PATCH, DELETE } from './fetch'; import { UserFilter, UserSearchRequestBody, @@ -11,9 +11,6 @@ import { export const useAppUsers = () => useState('appUsers', () => []); export const useTotalAppUsers = () => useState('totalAppUsers', () => 0); export const useAppUser = () => useState('appUser', () => null); -export const useOffset = () => useState('offset', () => 0); -export const useLimit = () => useState('limit', () => 10); -export const useQuery = () => useState('query', () => ''); export const useBanUsers = () => useState('banUsers', () => []); export async function getUserTest(query: UserSearchRequestBody) { @@ -54,17 +51,7 @@ export async function getAppUsers(filters: UserFilter) { newQuery = newQuery.slice(0, -1); } - const query = useQuery(); - const offset = useOffset(); - const limit = useLimit(); - - if (newQuery != query.value) { - offset.value = 0; - } - - const response = await GET( - `/auth/users?offset=${offset.value}&limit=${limit.value}&${newQuery}` - ); + const response = await GET(`/auth/users?${newQuery}`); const appUsers: Ref = useAppUsers(); const totalAppUsers = useTotalAppUsers(); @@ -101,12 +88,6 @@ export async function getAppUsers(filters: UserFilter) { } totalAppUsers.value = response?.total ?? 0; - query.value = newQuery; - - console.log('offset', offset.value); - console.log('current', appUsers.value.length); - console.log('total', totalAppUsers.value); - console.log('------------------------------------------------'); return [response, null]; } catch (error: any) { diff --git a/pages/dashboard/users/index.vue b/pages/dashboard/users/index.vue index fe8f8c3..76f9e04 100644 --- a/pages/dashboard/users/index.vue +++ b/pages/dashboard/users/index.vue @@ -153,7 +153,6 @@ export default { const emailSearch = ref(true); const loading = ref(appUsers.value.length <= 0); - const offset = useOffset(); const modalOpen = ref(false); const getUserRequestBody = reactive(new UserSearchRequestBody()); @@ -336,7 +335,6 @@ export default { onSelectedOption, options, scrollRef, - offset, totalAppUsers, emailSearch, getUserRequestBody, From 4053bf5ebb7f4d4b26739b5836b1bdaa7b5d1280 Mon Sep 17 00:00:00 2001 From: Defelo Date: Tue, 15 Oct 2024 21:43:42 +0200 Subject: [PATCH 3/3] fix(users): handle false in query correctly --- composables/appUsers.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composables/appUsers.ts b/composables/appUsers.ts index f87520d..117385c 100644 --- a/composables/appUsers.ts +++ b/composables/appUsers.ts @@ -34,7 +34,7 @@ export async function getAppUsers(filters: UserFilter) { (value as string[]).forEach((item: string) => { newQuery = newQuery + `${key}=${item}&`; }); - } else if (typeof value === 'boolean' && value === true) { + } else if (typeof value === 'boolean') { newQuery = newQuery + `${key}=${value}&`; } else if ( typeof value === 'string' &&