add / edit / delete user warrens
This commit is contained in:
@@ -1,23 +1,22 @@
|
||||
import { toast } from 'vue-sonner';
|
||||
import type { DirectoryEntry } from '#shared/types';
|
||||
import type { ApiResponse } from '#shared/types/api';
|
||||
import type { Warren } from '#shared/types/warrens';
|
||||
import type { WarrenData } from '#shared/types/warrens';
|
||||
import { getApiHeaders, getAuthHeader } from '.';
|
||||
|
||||
export async function getWarrens(): Promise<Record<string, Warren>> {
|
||||
const { data, error } = await useFetch<ApiResponse<{ warrens: Warren[] }>>(
|
||||
getApiUrl('warrens'),
|
||||
{
|
||||
method: 'GET',
|
||||
headers: getApiHeaders(),
|
||||
}
|
||||
);
|
||||
export async function getWarrens(): Promise<Record<string, WarrenData>> {
|
||||
const { data, error } = await useFetch<
|
||||
ApiResponse<{ warrens: WarrenData[] }>
|
||||
>(getApiUrl('warrens'), {
|
||||
method: 'GET',
|
||||
headers: getApiHeaders(),
|
||||
});
|
||||
|
||||
if (data.value == null) {
|
||||
throw error.value?.name;
|
||||
}
|
||||
|
||||
const warrens: Record<string, Warren> = {};
|
||||
const warrens: Record<string, WarrenData> = {};
|
||||
|
||||
for (const warren of data.value.data.warrens) {
|
||||
warrens[warren.id] = warren;
|
||||
|
||||
Reference in New Issue
Block a user