Improves the brandingStore usages

This commit is contained in:
2024-09-22 03:03:44 -04:00
parent 79785846c6
commit d290d56cb8
3 changed files with 23 additions and 77 deletions

View File

@@ -1,41 +1,21 @@
<template>
<h1>Content Browser</h1>
<div class="px-4" :style="{ color: brandingStore.value.colors.onBackground}">
<h1>Content Browser</h1>
<p>Get me the content i need the money!</p>
</div>
</template>
<script async setup>
import {watch, ref, onBeforeMount} from 'vue';
import {useRoute} from 'vue-router';
import {useClient} from "@/plugins/api.js";
import { ref} from 'vue';
import {useBrandingStore} from "@/stores/brandingStore.js";
const brandingStore = useBrandingStore()
const creator = ref(null)
const loading = ref(true)
const contents = ref([])
const client = useClient()
const route = useRoute()
function contentPosted(content) {
contents.value.unshift(content)
}
onBeforeMount(async () => await fetchCreatorData(route.params.creator))
watch(
() => route.params.creator,
async () => await fetchCreatorData(route.params.creator)
)
const fetchCreatorData = async (creatorAlias) => {
try {
loading.value = true
const response = await client.get(`/api/creators/@${creatorAlias}`)
creator.value = response.data
} catch (error) {
console.error(`Error fetching content: ${error}`)
} finally {
loading.value = false
}
}
</script>