import { ref } from 'vue'; import { apiClient } from '@/api/client'; import type { CreateProfileDto, UpdateProfileDto } from '@/api/api'; import type { UserProfile } from './useAuth'; const currentProfile = ref(null); const loading = ref(false); async function fetchProfile(profileId: string) { loading.value = true; try { const res = await apiClient.api.profilesControllerFindOne(profileId) as unknown as UserProfile; currentProfile.value = res; return res; } finally { loading.value = false; } } async function createProfile(dto: CreateProfileDto) { const res = await apiClient.api.profilesControllerCreate(dto) as unknown as UserProfile; currentProfile.value = res; return res; } async function updateProfile(profileId: string, dto: UpdateProfileDto) { const res = await apiClient.api.profilesControllerUpdate(profileId, dto) as unknown as UserProfile; currentProfile.value = res; return res; } async function deleteProfile(profileId: string) { await apiClient.api.profilesControllerDelete(profileId); currentProfile.value = null; } export function useProfile() { return { currentProfile, loading, fetchProfile, createProfile, updateProfile, deleteProfile }; }