import type { ApiResponse } from '~/shared/types/api'; import type { AdminWarrenData } from '~/shared/types/warrens'; import { getApiHeaders } from '..'; import { toast } from 'vue-sonner'; export async function deleteWarren( warrenId: string ): Promise<{ success: true; warren: AdminWarrenData } | { success: false }> { const { data, error } = await useFetch>( getApiUrl('admin/warrens'), { method: 'DELETE', headers: getApiHeaders(), body: JSON.stringify({ id: warrenId, }), responseType: 'json', } ); if (data.value == null) { toast.error('Delete warren', { description: error.value?.data ?? 'Failed to delete warren', }); return { success: false, }; } await refreshNuxtData(['warrens', 'admin-resources']); toast.success('Delete warren', { description: 'Successfully deleted warren', }); return { success: true, warren: data.value.data, }; }