68 lines
1.6 KiB
TypeScript
68 lines
1.6 KiB
TypeScript
import { readItems } from '@directus/sdk';
|
|
|
|
export const useDocumentList = () => {
|
|
const { $directus } = useNuxtApp();
|
|
const { getDirectusLocale } = useLocalizations();
|
|
const locale = getDirectusLocale();
|
|
|
|
return useAsyncData(`document-list-${locale}`, async () => {
|
|
return await $directus.request(
|
|
readItems('product_documents', {
|
|
fields: [
|
|
'id',
|
|
{
|
|
file: ['id', 'filesize', 'filename_download'],
|
|
},
|
|
{
|
|
translations: ['id', 'title'],
|
|
},
|
|
{
|
|
products: [
|
|
'id',
|
|
{
|
|
products_id: [
|
|
'id',
|
|
{
|
|
translations: ['id', 'name'],
|
|
},
|
|
{
|
|
product_type: [
|
|
'id',
|
|
{
|
|
translations: ['id', 'name'],
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
],
|
|
deep: {
|
|
translations: {
|
|
_filter: {
|
|
languages_code: { _eq: locale },
|
|
},
|
|
},
|
|
products: {
|
|
products_id: {
|
|
translations: {
|
|
_filter: {
|
|
languages_code: { _eq: locale },
|
|
},
|
|
},
|
|
product_type: {
|
|
translations: {
|
|
_filter: {
|
|
languages_code: { _eq: locale },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
})
|
|
);
|
|
});
|
|
};
|