138 lines
4.5 KiB
Vue
138 lines
4.5 KiB
Vue
<script setup lang="ts">
|
|
// imports
|
|
|
|
import useGetAccount from "~/composables/api/account/useGetAccount";
|
|
|
|
// state
|
|
|
|
const route = useRoute();
|
|
|
|
const profileLinks = ref([
|
|
{
|
|
icon: "bi:person-vcard",
|
|
title: "پروفایل",
|
|
path: { name: "profile" },
|
|
},
|
|
{
|
|
icon: "bi:map",
|
|
title: "آدرس ها",
|
|
path: { name: "profile-addresses" },
|
|
},
|
|
{
|
|
icon: "bi:cart",
|
|
title: "خرید ها و سفارش ها",
|
|
path: { name: "profile-purchases-and-orders" },
|
|
matchPattern: /^profile-purchases-and-orders/,
|
|
},
|
|
{
|
|
icon: "bi:ticket",
|
|
title: "تیکت ها",
|
|
path: { name: "profile-tickets" },
|
|
matchPattern: /^profile-ticket/,
|
|
},
|
|
{
|
|
icon: "bi:bell",
|
|
title: "اعلانات",
|
|
path: { name: "profile-notifications" },
|
|
},
|
|
]);
|
|
|
|
const isLinkActive = (link: any) => {
|
|
if (link.matchPattern) {
|
|
return link.matchPattern.test(route.name);
|
|
} else {
|
|
return route.name === link.path.name;
|
|
}
|
|
};
|
|
|
|
// queries
|
|
|
|
const { data: account, suspense } = useGetAccount();
|
|
|
|
await suspense();
|
|
</script>
|
|
|
|
<template>
|
|
<div class="w-3/12 flex flex-col gap-4">
|
|
<div class="w-full rounded-xl bg-slate-50 border border-slate-200 p-4">
|
|
<div class="flex items-center justify-between w-full">
|
|
<div class="flex flex-col items-start gap-1">
|
|
<span class="flex font-semibold text-dynamic-primary">
|
|
<p v-if="account?.first_name">
|
|
{{ `${account?.first_name} ${account?.last_name}` }}
|
|
</p>
|
|
<p v-else>بدون نام کاربری</p>
|
|
</span>
|
|
<NuxtLink
|
|
:to="{ name: 'profile' }"
|
|
class="text-xs font-semibold text-cyan-500"
|
|
>
|
|
ویرایش اطلاعات
|
|
</NuxtLink>
|
|
</div>
|
|
<Avatar
|
|
class="!size-[3rem]"
|
|
:src="account!.profile_photo"
|
|
:alt="
|
|
account?.first_name && account?.last_name
|
|
? `${account?.first_name.charAt(
|
|
0
|
|
)} ${account?.last_name.charAt(0)}`
|
|
: 'بدون نام کاربری'
|
|
"
|
|
/>
|
|
</div>
|
|
</div>
|
|
|
|
<div
|
|
class="w-full flex flex-col gap-2 rounded-xl bg-slate-50 border border-slate-200 p-4"
|
|
>
|
|
<NuxtLink
|
|
v-for="(link, index) in profileLinks"
|
|
:key="index"
|
|
:to="{ ...link.path }"
|
|
:class="
|
|
isLinkActive(link)
|
|
? 'bg-black text-slate-100 **:fill-slate-100'
|
|
: '**:fill-black hover:bg-gray-200'
|
|
"
|
|
class="flex items-center justify-between transition-all rounded-lg py-4 px-3"
|
|
>
|
|
<span class="flex-center gap-3">
|
|
<div class="size-5 flex-center">
|
|
<Icon :name="link.icon" />
|
|
</div>
|
|
<span class="text-sm">{{ link.title }}</span>
|
|
</span>
|
|
|
|
<Icon name="bi:chevron-left" class="transition-all" />
|
|
</NuxtLink>
|
|
|
|
<LogoutModal>
|
|
<template #trigger>
|
|
<button
|
|
class="w-full flex items-center cursor-pointer justify-between transition-all rounded-lg py-4 px-3 hover:bg-danger-100 text-danger-500 **:fill-danger-100"
|
|
>
|
|
<span class="flex-center gap-3">
|
|
<div class="size-5 flex-center">
|
|
<Icon
|
|
name="bi:arrow-bar-right"
|
|
class="**:fill-danger-500"
|
|
/>
|
|
</div>
|
|
<span class="text-sm"> خروج از حساب </span>
|
|
</span>
|
|
|
|
<Icon
|
|
name="bi:chevron-left"
|
|
class="transition-all **:fill-danger-500"
|
|
/>
|
|
</button>
|
|
</template>
|
|
</LogoutModal>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<style scoped></style>
|