feat: scope articles by brand
This commit is contained in:
@@ -42,10 +42,12 @@ import {
|
||||
getTemplateMeta,
|
||||
} from '@/lib/display'
|
||||
import { formatError } from '@/lib/errors'
|
||||
import { useCompanyStore } from '@/stores/company'
|
||||
|
||||
const queryClient = useQueryClient()
|
||||
const router = useRouter()
|
||||
const { t } = useI18n()
|
||||
const companyStore = useCompanyStore()
|
||||
|
||||
const pickerOpen = ref(false)
|
||||
const pickerMode = ref<'general' | 'refined' | null>(null)
|
||||
@@ -90,7 +92,8 @@ const kolCardsQuery = useQuery({
|
||||
})
|
||||
|
||||
const recentArticlesQuery = useQuery({
|
||||
queryKey: ['workspace', 'recent-articles', 'templates'],
|
||||
queryKey: computed(() => ['workspace', 'recent-articles', 'templates', companyStore.currentBrandId]),
|
||||
enabled: computed(() => Boolean(companyStore.currentBrandId)),
|
||||
queryFn: () => workspaceApi.recentArticles(),
|
||||
})
|
||||
|
||||
@@ -131,7 +134,8 @@ const articleParams = computed<ArticleListParams>(() => {
|
||||
})
|
||||
|
||||
const articleListQuery = useQuery({
|
||||
queryKey: computed(() => ['articles', 'list', articleParams.value]),
|
||||
queryKey: computed(() => ['articles', 'list', companyStore.currentBrandId, articleParams.value]),
|
||||
enabled: computed(() => Boolean(companyStore.currentBrandId)),
|
||||
queryFn: () => articlesApi.list(articleParams.value),
|
||||
})
|
||||
|
||||
@@ -330,6 +334,10 @@ function resetFilters(): void {
|
||||
}
|
||||
|
||||
function openTemplatePicker(): void {
|
||||
if (!companyStore.currentBrandId) {
|
||||
message.warning(t('templates.wizard.messages.selectBrandBeforeQuestion'))
|
||||
return
|
||||
}
|
||||
pickerOpen.value = true
|
||||
pickerMode.value = 'general'
|
||||
}
|
||||
@@ -339,12 +347,20 @@ function choosePickerMode(mode: 'general' | 'refined'): void {
|
||||
}
|
||||
|
||||
function startTemplate(template: TemplateListItem): void {
|
||||
if (!companyStore.currentBrandId) {
|
||||
message.warning(t('templates.wizard.messages.selectBrandBeforeQuestion'))
|
||||
return
|
||||
}
|
||||
pickerOpen.value = false
|
||||
pickerMode.value = null
|
||||
void router.push({ path: '/articles/wizard', query: { template_id: String(template.id) } })
|
||||
}
|
||||
|
||||
function openRefinedTemplate(card: KolWorkspaceCard): void {
|
||||
if (!companyStore.currentBrandId) {
|
||||
message.warning(t('templates.wizard.messages.selectBrandBeforeQuestion'))
|
||||
return
|
||||
}
|
||||
pickerOpen.value = false
|
||||
pickerMode.value = null
|
||||
void router.push({
|
||||
@@ -471,7 +487,12 @@ function refreshRecords(): void {
|
||||
<p>{{ t('route.templates.description') }}</p>
|
||||
</div>
|
||||
<div class="templates-view__header-actions">
|
||||
<a-button type="primary" class="templates-view__create-btn" @click="openTemplatePicker">
|
||||
<a-button
|
||||
type="primary"
|
||||
class="templates-view__create-btn"
|
||||
:disabled="!companyStore.currentBrandId"
|
||||
@click="openTemplatePicker"
|
||||
>
|
||||
<template #icon><PlusOutlined /></template>
|
||||
{{ t('templates.actions.chooseTemplate') }}
|
||||
</a-button>
|
||||
|
||||
Reference in New Issue
Block a user