add / edit / delete user warrens
This commit is contained in:
30
frontend/lib/api/admin/editUserWarren.ts
Normal file
30
frontend/lib/api/admin/editUserWarren.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import type { UserWarren } from '~/shared/types/warrens';
|
||||
import { getApiHeaders } from '..';
|
||||
import type { ApiResponse } from '~/shared/types/api';
|
||||
|
||||
export async function editUserWarren(
|
||||
userWarren: UserWarren
|
||||
): Promise<{ success: true; data: UserWarren } | { success: false }> {
|
||||
const { data } = await useFetch<ApiResponse<UserWarren>>(
|
||||
getApiUrl('admin/user-warrens'),
|
||||
{
|
||||
method: 'PATCH',
|
||||
headers: getApiHeaders(),
|
||||
body: JSON.stringify(userWarren),
|
||||
responseType: 'json',
|
||||
}
|
||||
);
|
||||
|
||||
if (data.value == null) {
|
||||
return {
|
||||
success: false,
|
||||
};
|
||||
}
|
||||
|
||||
await refreshNuxtData('admin-resources');
|
||||
|
||||
return {
|
||||
success: true,
|
||||
data: data.value.data,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user