Add auth for chat

This commit is contained in:
marzban-dev
2025-01-16 16:00:35 +03:30
parent 389edd9317
commit 5cb831e848
@@ -7,6 +7,7 @@ import ChatInput from "~/components/product/ChatBox/ChatInput.vue";
import { useIsMutating } from "@tanstack/vue-query";
import { MUTATION_KEYS } from "~/constants";
import CloseButton from "~/components/product/ChatBox/CloseButton.vue";
import { useAuth } from "~/composables/api/auth/useAuth";
// provide-inject
@@ -14,6 +15,8 @@ const { isOpen } = inject("isOpen") as any;
// state
const { isLoggedIn } = useAuth();
const route = useRoute();
const id = route.params.id as string | number;
@@ -126,7 +129,9 @@ whenever(
>
<CloseButton :disabled="!!isCreateMessagePending" />
<template v-if="isLoggedIn">
<Transition name="zoom" mode="out-in">
<div
v-if="!isChatPending"
class="p-4.5 h-full flex flex-col justify-between gap-4"
@@ -168,6 +173,7 @@ whenever(
<ChatInput />
</div>
<div
v-else
class="w-full h-full flex items-center justify-center absolute inset-0"
@@ -175,6 +181,10 @@ whenever(
<AiLoading />
</div>
</Transition>
</template>
<div class="text-black p-4.5 size-full flex justify-center items-center" v-else>
Please sign in first
</div>
</div>
</Transition>
</template>