Files
nuxt-frontend/app/pages/(protected)/dados-conta/index.vue

116 lines
3.9 KiB
Vue

<template>
<div
class="relative min-h-[calc(100vh-66px)] overflow-x-hidden bg-[#f5f5f5] px-3 py-8 font-sans text-[#0c0a09] sm:px-4 sm:py-12 md:px-6 md:py-16 xl:px-8">
<div
class="pointer-events-none absolute left-1/2 top-6 h-[360px] w-[min(94vw,760px)] -translate-x-1/2 rounded-[40px] bg-[radial-gradient(circle_at_20%_30%,rgba(167,229,211,0.62),transparent_28%),radial-gradient(circle_at_72%_24%,rgba(168,200,232,0.56),transparent_30%),radial-gradient(circle_at_52%_78%,rgba(232,184,196,0.5),transparent_34%)] blur-2xl sm:top-8 sm:h-[420px] sm:rounded-[48px]"
aria-hidden="true"></div>
<main class="relative mx-auto grid w-full min-w-0 max-w-[960px] gap-6 sm:gap-8" aria-labelledby="account-title">
<header class="min-w-0">
<p
class="m-0 inline-flex rounded-full bg-[rgba(168,200,232,0.56)] px-3 py-1 text-xs font-semibold uppercase leading-[1.4] tracking-[0.96px] text-[#0c0a09]">
Conta
</p>
<h1 id="account-title"
class="my-4 max-w-[680px] break-words font-serif text-[34px] font-light leading-[1.08] tracking-[-0.96px] text-[#0c0a09] sm:my-5 sm:text-[40px] md:text-[48px]">
Dados da conta
</h1>
<p
class="m-0 max-w-[540px] text-[15px] font-normal leading-[1.47] tracking-[0.15px] text-[#4e4e4e] sm:text-base sm:leading-6 sm:tracking-[0.16px]">
Estes são os dados retornados pelo perfil da sua sessão atual.
</p>
</header>
<section
class="grid min-w-0 gap-5 rounded-xl border border-[#e7e5e4] bg-white p-4 shadow-[0_4px_16px_rgba(0,0,0,0.04)] sm:rounded-2xl sm:p-6 md:p-8"
aria-label="Dados do perfil autenticado">
<div>
<span
class="inline-flex min-h-6 items-center rounded-full bg-[rgba(167,229,211,0.62)] px-2.5 py-1 text-xs font-semibold uppercase leading-none tracking-[0.96px] text-[#0c0a09]">
Perfil
</span>
<h2
class="mt-4 font-serif text-[26px] font-light leading-[1.13] tracking-[-0.32px] text-[#0c0a09] sm:text-3xl">
Dados da conta
</h2>
</div>
<dl class="grid min-w-0 gap-3 sm:gap-4">
<div v-for="item in profileRows" :key="item.label"
class="grid min-w-0 gap-1 border-t border-[#e7e5e4] pt-3 lg:grid-cols-[140px_minmax(0,1fr)] lg:gap-5 lg:pt-4 xl:grid-cols-[160px_minmax(0,1fr)]">
<dt class="text-xs font-semibold uppercase leading-[1.4] tracking-[0.96px] text-[#777169]">
{{ item.label }}
</dt>
<dd
class="m-0 min-w-0 text-[15px] leading-[1.47] tracking-[0.15px] text-[#0c0a09] sm:text-base sm:leading-6 sm:tracking-[0.16px]"
:class="item.isLong ? 'break-all' : 'break-words'">
{{ item.value }}
</dd>
</div>
</dl>
</section>
</main>
</div>
</template>
<script setup>
definePageMeta({
middleware: 'auth',
layout: 'protected'
})
const { $toast } = useNuxtApp()
const token = useCookie('token', {
secure: true,
sameSite: 'lax',
maxAge: 900
})
const clearToken = () => {
token.value = null
}
const { data: profile, error } = await useAsyncData('profile-me-account', () =>
$fetch('/profile/me', {
headers: {
Authorization: `Bearer ${token.value}`
}
})
)
if (error.value) {
clearToken()
if (import.meta.client) {
$toast.error('Sua sessão expirou. Faça login novamente.', { duration: 8000 })
}
await navigateTo('/login')
}
const profileRows = computed(() => [
{
label: 'user_id',
value: profile.value?.user_id ?? profile.value?.id ?? '-'
},
{
label: 'email',
value: profile.value?.email ?? '-'
},
{
label: 'created_at',
value: profile.value?.created_at ?? '-'
},
{
label: 'updated_at',
value: profile.value?.updated_at ?? '-'
},
{
label: 'jwt_token',
value: token.value ?? '-',
isLong: true
}
])
</script>