Improves the brandingStore usages
This commit is contained in:
@@ -26,7 +26,7 @@ export const useBrandingStore = defineStore(
|
|||||||
async () => {
|
async () => {
|
||||||
console.log(`creator: ${route.params.creator}`)
|
console.log(`creator: ${route.params.creator}`)
|
||||||
console.log(`currentBrand: ${currentBrand.value}`)
|
console.log(`currentBrand: ${currentBrand.value}`)
|
||||||
if (route.params.creator != currentBrand.value) {
|
if (route.params.creator !== currentBrand.value) {
|
||||||
await fetchCreatorData(route.params.creator);
|
await fetchCreatorData(route.params.creator);
|
||||||
currentBrand.value = route.params.creator
|
currentBrand.value = route.params.creator
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,41 +1,21 @@
|
|||||||
<template>
|
<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>
|
</template>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<script async setup>
|
<script async setup>
|
||||||
import {watch, ref, onBeforeMount} from 'vue';
|
import { ref} from 'vue';
|
||||||
import {useRoute} from 'vue-router';
|
import {useBrandingStore} from "@/stores/brandingStore.js";
|
||||||
import {useClient} from "@/plugins/api.js";
|
|
||||||
|
const brandingStore = useBrandingStore()
|
||||||
|
|
||||||
const creator = ref(null)
|
|
||||||
const loading = ref(true)
|
|
||||||
const contents = ref([])
|
const contents = ref([])
|
||||||
|
|
||||||
const client = useClient()
|
|
||||||
const route = useRoute()
|
|
||||||
|
|
||||||
function contentPosted(content) {
|
function contentPosted(content) {
|
||||||
contents.value.unshift(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>
|
</script>
|
||||||
|
|||||||
@@ -1,63 +1,29 @@
|
|||||||
<template>
|
<template>
|
||||||
|
|
||||||
<div v-if="creator && creator.id">
|
<div v-if="brandingStore.value.loading">
|
||||||
<div class="w-full h-full pr-4">
|
<v-progress-linear indeterminate></v-progress-linear>
|
||||||
<content-list :creator-id="creator.id"
|
|
||||||
:contents="contents"
|
|
||||||
></content-list>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-else>
|
<div v-else>
|
||||||
<div v-if="loading">
|
<div class="w-full h-full pr-4">
|
||||||
<v-progress-linear indeterminate></v-progress-linear>
|
<content-list :creator-id="brandingStore.value.id"
|
||||||
</div>
|
:contents="news"
|
||||||
<div v-else>
|
></content-list>
|
||||||
<v-card>
|
|
||||||
<v-card-text style="text-align: center;">
|
|
||||||
Aucun créateur au nom de {{ route.params.creator }}
|
|
||||||
</v-card-text>
|
|
||||||
</v-card>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script async setup>
|
<script async setup>
|
||||||
import {watch, ref, onBeforeMount} from 'vue';
|
import {ref} from 'vue';
|
||||||
import {useRoute} from 'vue-router';
|
|
||||||
import {useClient} from "@/plugins/api.js";
|
|
||||||
import CreatorBanner from "@/views/creators/CreatorBanner.vue";
|
|
||||||
import ContentList from "@/views/contents/ContentList.vue";
|
import ContentList from "@/views/contents/ContentList.vue";
|
||||||
|
import {useBrandingStore} from "@/stores/brandingStore.js";
|
||||||
|
|
||||||
const creator = ref(null)
|
const brandingStore = useBrandingStore()
|
||||||
const loading = ref(true)
|
|
||||||
const contents = ref([])
|
|
||||||
|
|
||||||
const client = useClient()
|
|
||||||
const route = useRoute()
|
|
||||||
|
|
||||||
|
const news = ref([])
|
||||||
function contentPosted(content) {
|
function contentPosted(content) {
|
||||||
contents.value.unshift(content)
|
news.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>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user