Files
hossein-por-shop/frontend/components/profile/global/LogoutModal.vue
T
2025-03-18 17:33:24 +03:30

93 lines
2.9 KiB
Vue
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<script setup lang="ts">
// imports
import { useAuth } from "~/composables/api/auth/useAuth";
import useSignOut from "~/composables/api/auth/useSignOut";
import { useToast } from "~/composables/global/useToast";
// state
const { refreshToken, logout } = useAuth();
const { addToast } = useToast();
const isShow = ref(false);
// queries
const { mutateAsync: signout, isPending: signoutIsPending } = useSignOut();
// methods
const handleSubmit = () => {
signout(
{ refresh_token: refreshToken.value! },
{
onSuccess: () => {
addToast({
message: "با موفقیت از حساب خارج شدید",
});
logout(true);
},
onError: () => {
addToast({
message: "خطایی در خروج از حساب رخ داد",
});
isShow.value = false;
},
}
);
};
</script>
<template>
<Modal
v-model="isShow"
title="خروج از حساب"
icon="bi:arrow-bar-right"
contectClass="!w-[90vw] lg:!w-[35vw]"
@close="isShow = false"
>
<template #trigger>
<slot name="trigger" />
</template>
<template #content>
<div class="w-full flex flex-col text-start gap-3 py-5" dir="rtl">
<p>
با خارج شدن از حساب کاربری، دسترسی شما به برخی از امکانات
محدود خواهد شد. اگر قصد دارید دوباره وارد شوید، میتوانید از
همان اطلاعات حساب خود استفاده کنید. در صورت نیاز به کمک یا
بروزرسانی اطلاعات حساب، تیم پشتیبانی ما آماده پاسخگویی به
شماست.
</p>
<p>ما همیشه منتظر بازگشت شما هستیم! 😊</p>
</div>
<div class="py-6 border-t border-slate-200 flex gap-3">
<Button
@click="handleSubmit"
class="rounded-full px-10"
size="md"
>
<Icon
v-if="signoutIsPending"
name="svg-spinners:3-dots-bounce"
/>
<span v-else>آره دارم میرم</span>
</Button>
<DialogClose aria-label="Close">
<Button
variant="outlined"
class="rounded-full px-10"
size="md"
>
نه فعلا هستم
</Button>
</DialogClose>
</div>
</template>
</Modal>
</template>
<style scoped></style>