Skip to content

Commit

Permalink
Merge branch 'develop' into modify-reported-quizzes
Browse files Browse the repository at this point in the history
  • Loading branch information
Lauritz-Tieste authored Oct 28, 2024
2 parents 8c47d93 + c6d4998 commit ef0c529
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .envrc
Original file line number Diff line number Diff line change
@@ -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
25 changes: 3 additions & 22 deletions composables/appUsers.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -11,9 +11,6 @@ import {
export const useAppUsers = () => useState<User[]>('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) {
Expand All @@ -37,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' &&
Expand All @@ -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<any[]> = useAppUsers();
const totalAppUsers = useTotalAppUsers();
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 0 additions & 2 deletions pages/dashboard/users/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down Expand Up @@ -336,7 +335,6 @@ export default {
onSelectedOption,
options,
scrollRef,
offset,
totalAppUsers,
emailSearch,
getUserRequestBody,
Expand Down

0 comments on commit ef0c529

Please sign in to comment.