list users
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { toast } from 'vue-sonner';
|
||||
import type { ApiResponse } from '~/types/api';
|
||||
import type { AuthUser, AuthUserFields } from '~/types/auth';
|
||||
import type { ApiResponse } from '#shared/types/api';
|
||||
import type { AuthUser, AuthUserFields } from '#shared/types/auth';
|
||||
import { getApiHeaders } from '..';
|
||||
|
||||
/** Admin function to create a new user */
|
||||
@@ -32,6 +32,8 @@ export async function createUser(
|
||||
};
|
||||
}
|
||||
|
||||
await refreshNuxtData('users');
|
||||
|
||||
toast.success('Create user', {
|
||||
description: 'Successfully created user',
|
||||
});
|
||||
|
||||
27
frontend/lib/api/admin/listUsers.ts
Normal file
27
frontend/lib/api/admin/listUsers.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import type { ApiResponse } from '~/shared/types/api';
|
||||
import type { AuthUser } from '~/shared/types/auth';
|
||||
import { getApiHeaders } from '..';
|
||||
|
||||
export async function listUsers(): Promise<
|
||||
{ success: true; users: AuthUser[] } | { success: false }
|
||||
> {
|
||||
const { data } = await useFetch<ApiResponse<AuthUser[]>>(
|
||||
getApiUrl('admin/users'),
|
||||
{
|
||||
method: 'GET',
|
||||
headers: getApiHeaders(),
|
||||
responseType: 'json',
|
||||
}
|
||||
);
|
||||
|
||||
if (data.value == null) {
|
||||
return {
|
||||
success: false,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
users: data.value.data,
|
||||
};
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { AuthSessionType, AuthUser } from '~/types/auth';
|
||||
import type { ApiResponse } from '~/types/api';
|
||||
import type { AuthSessionType, AuthUser } from '#shared/types/auth';
|
||||
import type { ApiResponse } from '#shared/types/api';
|
||||
|
||||
export async function getAuthSessionData(params: {
|
||||
sessionType: AuthSessionType;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { toast } from 'vue-sonner';
|
||||
import type { ApiResponse } from '~/types/api';
|
||||
import type { AuthUser } from '~/types/auth';
|
||||
import type { ApiResponse } from '#shared/types/api';
|
||||
import type { AuthUser } from '#shared/types/auth';
|
||||
import { getApiHeaders } from '..';
|
||||
|
||||
export async function loginUser(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { toast } from 'vue-sonner';
|
||||
import type { ApiResponse } from '~/types/api';
|
||||
import type { ApiResponse } from '#shared/types/api';
|
||||
|
||||
export async function registerUser(
|
||||
username: string,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { toast } from 'vue-sonner';
|
||||
import type { DirectoryEntry } from '~/types';
|
||||
import type { ApiResponse } from '~/types/api';
|
||||
import type { Warren } from '~/types/warrens';
|
||||
import type { DirectoryEntry } from '#shared/types';
|
||||
import type { ApiResponse } from '#shared/types/api';
|
||||
import type { Warren } from '#shared/types/warrens';
|
||||
import { getApiHeaders } from '.';
|
||||
|
||||
export async function getWarrens(): Promise<Record<string, Warren>> {
|
||||
|
||||
Reference in New Issue
Block a user