31 lines
780 B
TypeScript
31 lines
780 B
TypeScript
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,
|
|
};
|
|
}
|