Many Changes

This commit is contained in:
2024-01-04 12:27:46 +01:00
parent 57e856c71c
commit 991cac18f2
31 changed files with 1504 additions and 297 deletions

View File

@@ -10,36 +10,22 @@ const props = defineProps({
type: String
}
})
const dataStore = useDataStore()
const user = useSupabaseUser()
const supabase = useSupabaseClient()
const toast = useToast()
const {type, elementId} = props
const showAddHistoryItemModal = ref(false)
const colorMode = useColorMode()
/*const historyItems = ref([
{
user: "86e67794-0ea8-41b0-985a-1072e84f56e9",
text: "<a class='text-primary-500'>@marielesindern</a> magst du die einmal anschauen",
},
{
user: "3b795486-6b71-4ed8-a1f6-dbc52360d826",
text: "<a class='text-primary-500'>@florianfederspiel</a> Jo alles bestens",
},
{
user: "Spaces Bot",
text: "Erstellt",
}
])*/
const {profiles} = storeToRefs(useDataStore())
const {getHistoryItemsByCustomer, fetchHistoryItems} = useDataStore()
const historyItems = computed(() => {
let items = []
if(type === "customer") {
items = getHistoryItemsByCustomer(elementId)
items = dataStore.getHistoryItemsByCustomer(elementId)
} else if(type === "vendor") {
items = dataStore.getHistoryItemsByVendor(elementId)
}
return items.reverse()
@@ -68,7 +54,7 @@ const addHistoryItem = async () => {
} else {
toast.add({title: "Eintrag erfolgreich erstellt"})
showAddHistoryItemModal.value = false
await fetchHistoryItems()
await dataStore.fetchHistoryItems()
}
}
@@ -130,11 +116,11 @@ const renderText = (text) => {
:src="colorMode.value === 'light' ? '/spaces_hell.svg' : '/spaces.svg' "
/>
<UAvatar
:alt="profiles.find(profile => profile.id === item.user).fullName"
:alt="dataStore.profiles.find(profile => profile.id === item.user).fullName"
v-else
/>
<div>
<h3 v-if="item.user">{{profiles.find(profile => profile.id === item.user) ? profiles.find(profile => profile.id === item.user).fullName : ""}}</h3>
<h3 v-if="item.user">{{dataStore.profiles.find(profile => profile.id === item.user) ? dataStore.profiles.find(profile => profile.id === item.user).fullName : ""}}</h3>
<h3 v-else>Spaces Bot</h3>
<span v-html="renderText(item.text)"/><br>
<span class="text-gray-500">{{dayjs(item.created_at).format("DD:MM:YY HH:mm")}}</span>