35 lines
847 B
TypeScript
35 lines
847 B
TypeScript
import type { UpdateEmailPreferencesDto, UserDto } from '~~/.api-client'
|
|
import { useUserApi } from '~/composables'
|
|
|
|
export function useUser() {
|
|
const userApi = useUserApi()
|
|
|
|
async function getUserById(userId: string): Promise<UserDto> {
|
|
return await userApi.getUserById(userId)
|
|
}
|
|
|
|
async function updateEmailPreferences(
|
|
userId: string,
|
|
email: string | null,
|
|
emailOnFormCreated: boolean,
|
|
emailOnFormSubmitted: boolean,
|
|
emailOnFormUpdated: boolean,
|
|
emailOnCommentAdded: boolean
|
|
): Promise<UserDto> {
|
|
const updateDto: UpdateEmailPreferencesDto = {
|
|
email,
|
|
emailOnFormCreated,
|
|
emailOnFormSubmitted,
|
|
emailOnFormUpdated,
|
|
emailOnCommentAdded
|
|
}
|
|
|
|
return await userApi.updateEmailPreferences(userId, updateDto)
|
|
}
|
|
|
|
return {
|
|
getUserById,
|
|
updateEmailPreferences
|
|
}
|
|
}
|