Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions app/components/UserMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,28 +42,29 @@ await loadAuthUser()

user.value.avatar = {
src: `https://api.dicebear.com/8.x/initials/svg?seed=${
user.value.name || user.value.email
user.value.user_metadata.name || user.value.email
}`,
alt: user.value.name || user.value.email
alt: user.value.user_metadata.name || user.value.email
}

const items = computed<DropdownMenuItem[][]>(() => [
[
{
type: 'label',
label: user.value.email,
label: user.value.user_metadata.name || user.value.email,
avatar: user.value.avatar
}
],
[
{
label: 'Perfil',
icon: 'i-lucide-user'
icon: 'i-lucide-user',
to: '/settings'
},
{
label: 'Ajustes',
icon: 'i-lucide-settings',
to: '/settings'
to: '/settings/security'
}
],
[
Expand Down Expand Up @@ -174,7 +175,7 @@ const items = computed<DropdownMenuItem[][]>(() => [
<UButton
v-bind="{
...user,
label: collapsed ? undefined : user?.email,
label: collapsed ? undefined : user?.user_metadata.name || user?.email,
trailingIcon: collapsed ? undefined : 'i-lucide-chevrons-up-down'
}"
color="neutral"
Expand Down
4 changes: 1 addition & 3 deletions app/composables/useAuth.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const useAuth = () => {
const supabase = useSupabaseClient()
const user = ref<any>(null)
const user = useState<any>('auth-user', () => null)

const loadAuthUser = async () => {
const { data } = await supabase.auth.getUser()
Expand Down Expand Up @@ -32,8 +32,6 @@ export const useAuth = () => {
user.value = null
}

loadAuthUser()

return {
user,
loadAuthUser,
Expand Down
4 changes: 2 additions & 2 deletions app/layouts/default.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ const links = [
}
},
{
label: 'Anúncios App',
icon: 'i-lucide-megaphone',
label: 'Anúncios (App)',
icon: 'i-lucide-smartphone',
to: '/anuncios',
onSelect: () => {
open.value = false
Expand Down
13 changes: 7 additions & 6 deletions app/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,16 @@ const items = [
</UDashboardNavbar>
</template>

<UDashboardPanelContent>
<template #body>
<UPageBody>
<div class="flex flex-col gap-4">
<div class="flex flex-col gap-4 px-4">
<h2 class="text-lg font-semibold">Bem-vindo ao Painel</h2>
<p class="text-gray-500">
Selecione uma opção no menu lateral para começar.
</p>
<small class="text-gray-500">Dashboard em construção...</small>
<small>
Enquanto isso, selecione uma opção no menu lateral para começar.
</small>
</div>
</UPageBody>
</UDashboardPanelContent>
</template>
</UDashboardPanel>
</template>
37 changes: 28 additions & 9 deletions app/pages/settings/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,38 @@ type ProfileSchema = z.output<typeof profileSchema>
await loadAuthUser()

const profile = reactive<Partial<ProfileSchema>>({
name: user.value.user_metadata.name,
email: user.value.email
name: user.value?.user_metadata?.name || '',
email: user.value?.email || ''
})

const { updateUser } = useUsers()
const toast = useToast()

async function onSubmit(event: FormSubmitEvent<ProfileSchema>) {
toast.add({
title: 'Success',
description: 'Your settings have been updated.',
icon: 'i-lucide-check',
color: 'success'
})
console.log(event.data)
try {
if (!user.value?.id) return

await updateUser({
id: user.value.id,
name: event.data.name
})

await loadAuthUser()

toast.add({
title: 'Sucesso',
description: 'Suas configurações foram atualizadas.',
icon: 'i-lucide-check',
color: 'success'
})
} catch (error: any) {
toast.add({
title: 'Erro',
description: error.data?.statusMessage || error.message || 'Falha ao atualizar configurações.',
icon: 'i-lucide-circle-x',
color: 'error'
})
}
}

// function onFileChange(e: Event) {
Expand Down