feat: get statuses / priorities from their respective tables

- adds schema.sql
- format entire codebase
This commit is contained in:
Abhinav Raut
2024-08-25 18:29:04 +05:30
parent d20469dab8
commit d647d88502
340 changed files with 7251 additions and 6583 deletions

View File

@@ -1,68 +1,75 @@
<template>
<div ref="threadEl" class="overflow-y-scroll">
<div class="text-center mt-3" v-if="conversationStore.messages.hasMore && !conversationStore.messages.loading">
<Button variant="ghost" @click="conversationStore.fetchNextMessages">
<RefreshCw size="17" class="mr-2" />
Load more
</Button>
</div>
<div v-for="message in conversationStore.sortedMessages" :key="message.uuid"
:class="message.type === 'activity' ? 'm-4' : 'm-6'">
<div v-if="!message.private">
<ContactMessageBubble :message="message" v-if="message.type === 'incoming'" />
<AgentMessageBubble :message="message" v-if="message.type === 'outgoing'" />
</div>
<div v-else-if="isPrivateNote(message)">
<AgentMessageBubble :message="message" v-if="message.type === 'outgoing'" />
</div>
<div v-else-if="message.type === 'activity'">
<ActivityMessageBubble :message="message" />
</div>
</div>
<div ref="threadEl" class="overflow-y-scroll">
<div
class="text-center mt-3"
v-if="conversationStore.messages.hasMore && !conversationStore.messages.loading"
>
<Button variant="ghost" @click="conversationStore.fetchNextMessages">
<RefreshCw size="17" class="mr-2" />
Load more
</Button>
</div>
<div
v-for="message in conversationStore.sortedMessages"
:key="message.uuid"
:class="message.type === 'activity' ? 'm-4' : 'm-6'"
>
<div v-if="!message.private">
<ContactMessageBubble :message="message" v-if="message.type === 'incoming'" />
<AgentMessageBubble :message="message" v-if="message.type === 'outgoing'" />
</div>
<div v-else-if="isPrivateNote(message)">
<AgentMessageBubble :message="message" v-if="message.type === 'outgoing'" />
</div>
<div v-else-if="message.type === 'activity'">
<ActivityMessageBubble :message="message" />
</div>
</div>
</div>
</template>
<script setup>
import { ref, onMounted, watch } from 'vue';
import ContactMessageBubble from "./ContactMessageBubble.vue";
import ActivityMessageBubble from "./ActivityMessageBubble.vue";
import AgentMessageBubble from "./AgentMessageBubble.vue";
import { ref, onMounted, watch } from 'vue'
import ContactMessageBubble from './ContactMessageBubble.vue'
import ActivityMessageBubble from './ActivityMessageBubble.vue'
import AgentMessageBubble from './AgentMessageBubble.vue'
import { useConversationStore } from '@/stores/conversation'
import { Button } from '@/components/ui/button';
import { RefreshCw } from 'lucide-vue-next';
import { useEmitter } from '@/composables/useEmitter';
import { Button } from '@/components/ui/button'
import { RefreshCw } from 'lucide-vue-next'
import { useEmitter } from '@/composables/useEmitter'
const conversationStore = useConversationStore()
const threadEl = ref(null)
const emitter = useEmitter()
const scrollToBottom = () => {
setTimeout(() => {
const thread = threadEl.value
if (thread) {
thread.scrollTop = thread.scrollHeight
}
}, 0)
};
setTimeout(() => {
const thread = threadEl.value
if (thread) {
thread.scrollTop = thread.scrollHeight
}
}, 0)
}
onMounted(() => {
scrollToBottom()
// On new outgoing message to the current conversation, scroll to the bottom.
emitter.on('new-outgoing-message', (data) => {
if (data.conversation_uuid === conversationStore.conversation.data.uuid) {
scrollToBottom()
}
});
});
scrollToBottom()
// On new outgoing message to the current conversation, scroll to the bottom.
emitter.on('new-outgoing-message', (data) => {
if (data.conversation_uuid === conversationStore.conversation.data.uuid) {
scrollToBottom()
}
})
})
// On conversation change scroll to the bottom
watch(() => conversationStore.conversation.data, () => {
watch(
() => conversationStore.conversation.data,
() => {
scrollToBottom()
});
}
)
const isPrivateNote = (message) => {
return message.type === "outgoing" && message.private
};
return message.type === 'outgoing' && message.private
}
</script>